From 3bdea434ea39b8c99062875b28ac7ea23c7209d0 Mon Sep 17 00:00:00 2001 From: Raymond Toy Date: Wed, 20 Nov 2024 15:25:13 -0800 Subject: [PATCH] Regenerate all examples via update_examples. --- doc/info/lapack.texi.m4 | 492 ++++++++++++++++++++++++++++++------------------ 1 file changed, 312 insertions(+), 180 deletions(-) diff --git a/doc/info/lapack.texi.m4 b/doc/info/lapack.texi.m4 index 9040506f2..3b5ee3bc3 100644 --- a/doc/info/lapack.texi.m4 +++ b/doc/info/lapack.texi.m4 @@ -88,33 +88,47 @@ Example: @c ===end=== @example (%i1) load ("lapack")$ +@group (%i2) fpprintprec : 6; (%o2) 6 +@end group +@group (%i3) M : matrix ([9.5, 1.75], [3.25, 10.45]); [ 9.5 1.75 ] (%o3) [ ] [ 3.25 10.45 ] +@end group +@group (%i4) dgeev (M); (%o4) [[7.54331, 12.4067], false, false] +@end group +@group (%i5) [L, v, u] : dgeev (M, true, true); - [ - .666642 - .515792 ] -(%o5) [[7.54331, 12.4067], [ ], - [ .745378 - .856714 ] - [ - .856714 - .745378 ] - [ ]] - [ .515792 - .666642 ] + [ - 0.666642 - 0.515792 ] +(%o5) [[7.54331, 12.4067], [ ], + [ 0.745378 - 0.856714 ] + [ - 0.856714 - 0.745378 ] + [ ]] + [ 0.515792 - 0.666642 ] +@end group +@group (%i6) D : apply (diag_matrix, L); [ 7.54331 0 ] (%o6) [ ] [ 0 12.4067 ] +@end group +@group (%i7) M . v - v . D; - [ 0.0 - 8.88178E-16 ] + [ 0.0 - 8.88178e-16 ] (%o7) [ ] - [ - 8.88178E-16 0.0 ] + [ - 8.88178e-16 0.0 ] +@end group +@group (%i8) transpose (u) . M - D . transpose (u); - [ 0.0 - 4.44089E-16 ] + [ 0.0 - 4.44089e-16 ] (%o8) [ ] [ 0.0 0.0 ] +@end group @end example @opencatbox{Categories:} @@ -167,23 +181,42 @@ is equal to @var{A} (ignoring floating point round-off errors). @c q . r - M; @c mat_norm (%); @c ===end=== +Too few arguments supplied to mat_norm(m, p); found: + [ - 7.77156e-16 1.77636e-15 - 8.88178e-16 ] + [[ ]] + [ 0.0 - 1.33227e-15 8.88178e-16 ] + -- an error. To debug this try: debugmode(true); @example -(%i1) load ("lapack") $ -(%i2) fpprintprec : 6 $ -(%i3) M : matrix ([1, -3.2, 8], [-11, 2.7, 5.9]) $ +(%i1) load ("lapack")$ +@group +(%i2) fpprintprec : 6; +(%o2) 6 +@end group +@group +(%i3) M : matrix ([1, -3.2, 8], [-11, 2.7, 5.9]); + [ 1 - 3.2 8 ] +(%o3) [ ] + [ - 11 2.7 5.9 ] +@end group +@group (%i4) [q, r] : dgeqrf (M); - [ - .0905357 .995893 ] -(%o4) [[ ], - [ .995893 .0905357 ] + [ - 0.0905357 0.995893 ] +(%o4) [[ ], + [ 0.995893 0.0905357 ] [ - 11.0454 2.97863 5.15148 ] [ ]] - [ 0 - 2.94241 8.50131 ] + [ 0.0 - 2.94241 8.50131 ] +@end group +@group (%i5) q . r - M; - [ - 7.77156E-16 1.77636E-15 - 8.88178E-16 ] + [ - 7.77156e-16 1.77636e-15 - 8.88178e-16 ] (%o5) [ ] - [ 0.0 - 1.33227E-15 8.88178E-16 ] -(%i6) mat_norm (%, 1); -(%o6) 3.10862E-15 + [ 0.0 - 1.33227e-15 8.88178e-16 ] +@end group +@group +(%i6) mat_norm (%); +#0: mat_norm(_l=[matrix([-7.77156e-16,1.77636e-15,-8.88178e-16],[0.0,-1.33227e-15,8.88178e-16])]) +@end group @end example @opencatbox{Categories:} @@ -226,20 +259,33 @@ Examples: @c dlange (inf_norm, b - A . x); @c ===end=== @example +@group (%i1) A : matrix ([1, -2.5], [0.375, 5]); - [ 1 - 2.5 ] -(%o1) [ ] - [ 0.375 5 ] + [ 1 - 2.5 ] +(%o1) [ ] + [ 0.375 5 ] +@end group +@group (%i2) b : matrix ([1.75], [-0.625]); - [ 1.75 ] -(%o2) [ ] - [ - 0.625 ] + [ 1.75 ] +(%o2) [ ] + [ - 0.625 ] +@end group +@group (%i3) x : dgesv (A, b); - [ 1.210526315789474 ] -(%o3) [ ] - [ - 0.215789473684211 ] -(%i4) dlange (inf_norm, b - A.x); -(%o4) 0.0 + [ 1 - 2.5 ] [ 1.75 ] +(%o3) dgesv([ ], [ ]) + [ 0.375 5 ] [ - 0.625 ] +@end group +@group +(%i4) dlange (inf_norm, b - A . x); + [ 1.75 ] +(%o4) dlange(inf_norm, [ ] + [ - 0.625 ] + [ 1 - 2.5 ] [ 1 - 2.5 ] [ 1.75 ] + - [ ] . dgesv([ ], [ ])) + [ 0.375 5 ] [ 0.375 5 ] [ - 0.625 ] +@end group @end example @var{b} is a matrix with the same number of rows as @var{A} and any number of columns. @@ -252,20 +298,36 @@ Examples: @c dlange (inf_norm, b - A . x); @c ===end=== @example +@group (%i1) A : matrix ([1, -0.15], [1.82, 2]); - [ 1 - 0.15 ] -(%o1) [ ] - [ 1.82 2 ] + [ 1 - 0.15 ] +(%o1) [ ] + [ 1.82 2 ] +@end group +@group (%i2) b : matrix ([3.7, 1, 8], [-2.3, 5, -3.9]); - [ 3.7 1 8 ] -(%o2) [ ] - [ - 2.3 5 - 3.9 ] + [ 3.7 1 8 ] +(%o2) [ ] + [ - 2.3 5 - 3.9 ] +@end group +@group (%i3) x : dgesv (A, b); - [ 3.103827540695117 1.20985481742191 6.781786185657722 ] -(%o3) [ ] - [ -3.974483062032557 1.399032116146062 -8.121425428948527 ] + [ 1 - 0.15 ] [ 3.7 1 8 ] +(%o3) dgesv([ ], [ ]) + [ 1.82 2 ] [ - 2.3 5 - 3.9 ] +@end group +@group (%i4) dlange (inf_norm, b - A . x); -(%o4) 1.1102230246251565E-15 + [ 3.7 1 8 ] +(%o4) dlange(inf_norm, [ ] + [ - 2.3 5 - 3.9 ] + [ 1 - 0.15 ] [ 1 - 0.15 ] + - [ ] . dgesv([ ], + [ 1.82 2 ] [ 1.82 2 ] +[ 3.7 1 8 ] +[ ])) +[ - 2.3 5 - 3.9 ] +@end group @end example The elements of @var{A} and @var{b} must evaluate to real floating point numbers. @@ -277,22 +339,39 @@ The elements of @var{A} and @var{b} must evaluate to real floating point numbers @c dlange (inf_norm, b - A . x); @c ===end=== @example +@group (%i1) A : matrix ([5, -%pi], [1b0, 11/17]); - [ 5 - %pi ] - [ ] -(%o1) [ 11 ] - [ 1.0b0 -- ] - [ 17 ] + [ 5 - %pi ] + [ ] +(%o1) [ 11 ] + [ 1.0b0 -- ] + [ 17 ] +@end group +@group (%i2) b : matrix ([%e], [sin(1)]); - [ %e ] -(%o2) [ ] - [ sin(1) ] + [ %e ] +(%o2) [ ] + [ sin(1) ] +@end group +@group (%i3) x : dgesv (A, b); - [ 0.690375643155986 ] -(%o3) [ ] - [ 0.233510982552952 ] + [ 5 - %pi ] + [ ] [ %e ] +(%o3) dgesv([ 11 ], [ ]) + [ 1.0b0 -- ] [ sin(1) ] + [ 17 ] +@end group +@group (%i4) dlange (inf_norm, b - A . x); -(%o4) 2.220446049250313E-16 + [ %e ] +(%o4) dlange(inf_norm, [ ] + [ sin(1) ] + [ 5 - %pi ] [ 5 - %pi ] + [ ] [ ] [ %e ] + - [ 11 ] . dgesv([ 11 ], [ ])) + [ 1.0b0 -- ] [ 1.0b0 -- ] [ sin(1) ] + [ 17 ] [ 17 ] +@end group @end example @opencatbox{Categories:} @@ -398,8 +477,11 @@ Example: @c ===end=== @example (%i1) load ("lapack")$ +@group (%i2) fpprintprec : 6; (%o2) 6 +@end group +@group (%i3) M: matrix([1, 2, 3], [3.5, 0.5, 8], [-1, 2, -3], [4, 9, 7]); [ 1 2 3 ] [ ] @@ -408,58 +490,75 @@ Example: [ - 1 2 - 3 ] [ ] [ 4 9 7 ] +@end group +@group (%i4) dgesvd (M); -(%o4) [[14.4744, 6.38637, .452547], false, false] +(%o4) [[14.4744, 6.38637, 0.452547], false, false] +@end group +@group (%i5) [sigma, U, VT] : dgesvd (M, true, true); -(%o5) [[14.4744, 6.38637, .452547], -[ - .256731 .00816168 .959029 - .119523 ] -[ ] -[ - .526456 .672116 - .206236 - .478091 ] -[ ], -[ .107997 - .532278 - .0708315 - 0.83666 ] -[ ] -[ - .803287 - .514659 - .180867 .239046 ] -[ - .374486 - .538209 - .755044 ] -[ ] -[ .130623 - .836799 0.5317 ]] -[ ] -[ - .917986 .100488 .383672 ] +(%o5) [[14.4744, 6.38637, 0.452547], +[ - 0.256731 0.00816168 0.959029 - 0.119523 ] +[ ] +[ - 0.526456 0.672116 - 0.206236 - 0.478091 ] +[ ], +[ 0.107997 - 0.532278 - 0.0708315 - 0.83666 ] +[ ] +[ - 0.803287 - 0.514659 - 0.180867 0.239046 ] +[ - 0.374486 - 0.538209 - 0.755044 ] +[ ] +[ 0.130623 - 0.836799 0.5317 ]] +[ ] +[ - 0.917986 0.100488 0.383672 ] +@end group +@group (%i6) m : length (U); (%o6) 4 +@end group +@group (%i7) n : length (VT); (%o7) 3 +@end group +@group (%i8) Sigma: - genmatrix(lambda ([i, j], if i=j then sigma[i] else 0), - m, n); - [ 14.4744 0 0 ] - [ ] - [ 0 6.38637 0 ] -(%o8) [ ] - [ 0 0 .452547 ] - [ ] - [ 0 0 0 ] + genmatrix(lambda ([i, j], if i=j then sigma[i] else 0), + m, n); + [ 14.4744 0 0 ] + [ ] + [ 0 6.38637 0 ] +(%o8) [ ] + [ 0 0 0.452547 ] + [ ] + [ 0 0 0 ] +@end group +@group (%i9) U . Sigma . VT - M; - [ 1.11022E-15 0.0 1.77636E-15 ] + [ 1.11022e-15 0.0 1.77636e-15 ] [ ] - [ 1.33227E-15 1.66533E-15 0.0 ] + [ 1.33227e-15 1.66533e-15 0.0 ] (%o9) [ ] - [ - 4.44089E-16 - 8.88178E-16 4.44089E-16 ] + [ - 4.44089e-16 - 8.88178e-16 4.44089e-16 ] [ ] - [ 8.88178E-16 1.77636E-15 8.88178E-16 ] + [ 8.88178e-16 1.77636e-15 8.88178e-16 ] +@end group +@group (%i10) transpose (U) . U; - [ 1.0 5.55112E-17 2.498E-16 2.77556E-17 ] + [ 1.0 5.55112e-17 2.498e-16 2.77556e-17 ] [ ] - [ 5.55112E-17 1.0 5.55112E-17 4.16334E-17 ] + [ 5.55112e-17 1.0 5.55112e-17 4.16334e-17 ] (%o10) [ ] - [ 2.498E-16 5.55112E-17 1.0 - 2.08167E-16 ] + [ 2.498e-16 5.55112e-17 1.0 - 2.08167e-16 ] [ ] - [ 2.77556E-17 4.16334E-17 - 2.08167E-16 1.0 ] + [ 2.77556e-17 4.16334e-17 - 2.08167e-16 1.0 ] +@end group +@group (%i11) VT . transpose (VT); - [ 1.0 0.0 - 5.55112E-17 ] + [ 1.0 0.0 - 5.55112e-17 ] [ ] -(%o11) [ 0.0 1.0 5.55112E-17 ] +(%o11) [ 0.0 1.0 5.55112e-17 ] [ ] - [ - 5.55112E-17 5.55112E-17 1.0 ] + [ - 5.55112e-17 5.55112e-17 1.0 ] +@end group @end example @opencatbox{Categories:} @@ -604,73 +703,94 @@ for the product. The default is @code{false}. @c ===end=== @example (%i1) load ("lapack")$ +@group (%i2) A : matrix([1,2,3],[4,5,6],[7,8,9]); - [ 1 2 3 ] - [ ] -(%o2) [ 4 5 6 ] - [ ] - [ 7 8 9 ] + [ 1 2 3 ] + [ ] +(%o2) [ 4 5 6 ] + [ ] + [ 7 8 9 ] +@end group +@group (%i3) B : matrix([-1,-2,-3],[-4,-5,-6],[-7,-8,-9]); - [ - 1 - 2 - 3 ] - [ ] -(%o3) [ - 4 - 5 - 6 ] - [ ] - [ - 7 - 8 - 9 ] + [ - 1 - 2 - 3 ] + [ ] +(%o3) [ - 4 - 5 - 6 ] + [ ] + [ - 7 - 8 - 9 ] +@end group +@group (%i4) C : matrix([3,2,1],[6,5,4],[9,8,7]); - [ 3 2 1 ] - [ ] -(%o4) [ 6 5 4 ] - [ ] - [ 9 8 7 ] + [ 3 2 1 ] + [ ] +(%o4) [ 6 5 4 ] + [ ] + [ 9 8 7 ] +@end group +@group (%i5) dgemm(A,B); - [ - 30.0 - 36.0 - 42.0 ] - [ ] -(%o5) [ - 66.0 - 81.0 - 96.0 ] - [ ] - [ - 102.0 - 126.0 - 150.0 ] + [ - 30.0 - 36.0 - 42.0 ] + [ ] +(%o5) [ - 66.0 - 81.0 - 96.0 ] + [ ] + [ - 102.0 - 126.0 - 150.0 ] +@end group +@group (%i6) A . B; - [ - 30 - 36 - 42 ] - [ ] -(%o6) [ - 66 - 81 - 96 ] - [ ] - [ - 102 - 126 - 150 ] + [ - 30 - 36 - 42 ] + [ ] +(%o6) [ - 66 - 81 - 96 ] + [ ] + [ - 102 - 126 - 150 ] +@end group +@group (%i7) dgemm(A,B,transpose_a=true); - [ - 66.0 - 78.0 - 90.0 ] - [ ] -(%o7) [ - 78.0 - 93.0 - 108.0 ] - [ ] - [ - 90.0 - 108.0 - 126.0 ] + [ - 66.0 - 78.0 - 90.0 ] + [ ] +(%o7) [ - 78.0 - 93.0 - 108.0 ] + [ ] + [ - 90.0 - 108.0 - 126.0 ] +@end group +@group (%i8) transpose(A) . B; - [ - 66 - 78 - 90 ] - [ ] -(%o8) [ - 78 - 93 - 108 ] - [ ] - [ - 90 - 108 - 126 ] + [ - 66 - 78 - 90 ] + [ ] +(%o8) [ - 78 - 93 - 108 ] + [ ] + [ - 90 - 108 - 126 ] +@end group +@group (%i9) dgemm(A,B,c=C,beta=1); - [ - 27.0 - 34.0 - 41.0 ] - [ ] -(%o9) [ - 60.0 - 76.0 - 92.0 ] - [ ] - [ - 93.0 - 118.0 - 143.0 ] + [ - 27.0 - 34.0 - 41.0 ] + [ ] +(%o9) [ - 60.0 - 76.0 - 92.0 ] + [ ] + [ - 93.0 - 118.0 - 143.0 ] +@end group +@group (%i10) A . B + C; - [ - 27 - 34 - 41 ] - [ ] -(%o10) [ - 60 - 76 - 92 ] - [ ] - [ - 93 - 118 - 143 ] + [ - 27 - 34 - 41 ] + [ ] +(%o10) [ - 60 - 76 - 92 ] + [ ] + [ - 93 - 118 - 143 ] +@end group +@group (%i11) dgemm(A,B,c=C,beta=1, alpha=-1); - [ 33.0 38.0 43.0 ] - [ ] -(%o11) [ 72.0 86.0 100.0 ] - [ ] - [ 111.0 134.0 157.0 ] + [ 33.0 38.0 43.0 ] + [ ] +(%o11) [ 72.0 86.0 100.0 ] + [ ] + [ 111.0 134.0 157.0 ] +@end group +@group (%i12) -A . B + C; - [ 33 38 43 ] - [ ] -(%o12) [ 72 86 100 ] - [ ] - [ 111 134 157 ] - + [ 33 38 43 ] + [ ] +(%o12) [ 72 86 100 ] + [ ] + [ 111 134 157 ] +@end group @end example @opencatbox{Categories:} @category{Package lapack} @@ -727,59 +847,71 @@ eigenvalues, and @code{false} or the matrix of the eigenvectors. @c E[1]; @c E[2]; @c ===end=== -An example of computing the eigenvalues and then eigenvalues and -eigenvectors of an Hermitian matrix. @example (%i1) load("lapack")$ -(%i2) A: matrix( +@group +(%i2) M: matrix( [9.14 +%i*0.00 , -4.37 -%i*9.22 , -1.98 -%i*1.72 , -8.96 -%i*9.50], [-4.37 +%i*9.22 , -3.35 +%i*0.00 , 2.25 -%i*9.51 , 2.57 +%i*2.40], [-1.98 +%i*1.72 , 2.25 +%i*9.51 , -4.82 +%i*0.00 , -3.24 +%i*2.04], [-8.96 +%i*9.50 , 2.57 -%i*2.40 , -3.24 -%i*2.04 , 8.44 +%i*0.00]); -(%o2) - [ 9.14 (- 9.22 %i) - 4.37 (- 1.72 %i) - 1.98 (- 9.5 %i) - 8.96 ] - [ ] - [ 9.22 %i - 4.37 - 3.35 2.25 - 9.51 %i 2.4 %i + 2.57 ] - [ ] - [ 1.72 %i - 1.98 9.51 %i + 2.25 - 4.82 2.04 %i - 3.24 ] - [ ] - [ 9.5 %i - 8.96 2.57 - 2.4 %i (- 2.04 %i) - 3.24 8.44 ] -(%i3) zheev(A); -(%o3) [[- 16.00474647209473, - 6.764970154793324, 6.665711453507098, - 25.51400517338097], false] -(%i4) E:zheev(A,true)$ + [ 9.14 ] [ - 9.22 %i - 4.37 ] + [ ] [ ] + [ 9.22 %i - 4.37 ] [ - 3.35 ] +(%o2) Col 1 = [ ] Col 2 = [ ] + [ 1.72 %i - 1.98 ] [ 9.51 %i + 2.25 ] + [ ] [ ] + [ 9.5 %i - 8.96 ] [ 2.57 - 2.4 %i ] + [ - 1.72 %i - 1.98 ] [ - 9.5 %i - 8.96 ] + [ ] [ ] + [ 2.25 - 9.51 %i ] [ 2.4 %i + 2.57 ] + Col 3 = [ ] Col 4 = [ ] + [ - 4.82 ] [ 2.04 %i - 3.24 ] + [ ] [ ] + [ - 2.04 %i - 3.24 ] [ 8.44 ] +@end group +@group +(%i3) zheev(M); +(%o3) [[- 16.004746472094734, - 6.764970154793324, + 6.6657114535070985, 25.51400517338097], false] +@end group +(%i4) E: zheev(M,true)$ +@group (%i5) E[1]; -(%o5) [- 16.00474647209474, - 6.764970154793325, 6.665711453507101, - 25.51400517338096] +(%o5) [- 16.004746472094737, - 6.764970154793325, + 6.665711453507101, 25.514005173380962] +@end group +@group (%i6) E[2]; - [ 0.2674650533172745 %i + 0.2175453586665017 ] - [ ] - [ 0.002696730886619885 %i + 0.6968836773391712 ] -(%o6) Col 1 = [ ] - [ (- 0.6082406376714117 %i) - 0.01210614292697931 ] - [ ] - [ 0.1593081858095037 ] - [ 0.2644937470667444 %i + 0.4773693349937472 ] + [ 0.26746505331727455 %i + 0.21754535866650165 ] + [ ] + [ 0.002696730886619885 %i + 0.6968836773391712 ] +(%o6) Col 1 = [ ] + [ - 0.6082406376714117 %i - 0.012106142926979313 ] + [ ] + [ 0.15930818580950368 ] + [ 0.26449374706674444 %i + 0.4773693349937472 ] [ ] - [ (- 0.2852389036031621 %i) - 0.1414362742011673 ] + [ - 0.28523890360316206 %i - 0.14143627420116733 ] Col 2 = [ ] - [ 0.2654607680986639 %i + 0.4467818117184174 ] + [ 0.2654607680986639 %i + 0.44678181171841735 ] [ ] [ 0.5750762708542709 ] - [ 0.2810649767305922 %i - 0.1335263928245182 ] + [ 0.28106497673059216 %i - 0.13352639282451817 ] [ ] - [ 0.2866310132869556 %i - 0.4536971347853274 ] + [ 0.28663101328695556 %i - 0.4536971347853274 ] Col 3 = [ ] - [ (- 0.2933684323754295 %i) - 0.4954972425541057 ] + [ - 0.29336843237542953 %i - 0.49549724255410565 ] [ ] [ 0.5325337537576771 ] - [ (- 0.5737316575503476 %i) - 0.3966146799427706 ] - [ ] - [ 0.01826502619021457 %i + 0.3530557704387017 ] - Col 4 = [ ] - [ 0.1673700900085425 %i + 0.01476684746229564 ] - [ ] - [ 0.6002632636961784 ] + [ - 0.5737316575503476 %i - 0.39661467994277055 ] + [ ] + [ 0.018265026190214573 %i + 0.35305577043870173 ] + Col 4 = [ ] + [ 0.16737009000854253 %i + 0.01476684746229564 ] + [ ] + [ 0.6002632636961784 ] +@end group @end example @opencatbox{Categories:} -- 2.11.4.GIT