1 @c -----------------------------------------------------------------------------
2 @c File : linearalgebra.de.texi
3 @c License : GNU General Public License (GPL)
5 @c Original : linearalgebra.texi revision 1.17
7 @c Revision : 19.02.2011
9 @c This file is part of Maxima -- GPL CAS based on DOE-MACSYMA
10 @c -----------------------------------------------------------------------------
13 * Introduction to linearalgebra::
14 * Functions and Variables for linearalgebra::
17 @c -----------------------------------------------------------------------------
18 @node Introduction to linearalgebra, Functions and Variables for linearalgebra, linearalgebra, linearalgebra
19 @section Introduction to linearalgebra
20 @c -----------------------------------------------------------------------------
22 @code{linearalgebra} is a collection of functions for linear algebra.
27 (%i1) M : matrix ([1, 2], [1, 2]);
37 (%i3) columnspace (M);
41 (%i4) ptriangularize (M - z*ident(2), z);
46 (%i5) M : matrix ([1, 2, 3], [4, 5, 6], [7, 8, 9]) - z*ident(3);
52 (%i6) MM : ptriangularize (M, z);
57 [ 0 -- - -- + ----- + --- ]
62 [ 0 0 ----- - ------ - ----- ]
64 (%i7) algebraic : true;
66 (%i8) tellrat (MM [3, 3]);
68 (%o8) [z - 15 z - 18 z]
69 (%i9) MM : ratsimp (MM);
73 (%o9) [ 66 7 z - 102 z - 132 ]
74 [ 0 -- - ------------------ ]
78 (%i10) nullspace (MM);
90 (%i11) M : matrix ([1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12],
99 (%i12) columnspace (M);
103 (%o12) span([ ], [ ])
107 (%i13) apply ('orthogonal_complement, args (nullspace (transpose (M))));
111 (%o13) span([ ], [ ])
117 @c -----------------------------------------------------------------------------
118 @node Functions and Variables for linearalgebra, , Introduction to linearalgebra, linearalgebra
119 @section Functions and Variables for linearalgebra
120 @c -----------------------------------------------------------------------------
122 @c -----------------------------------------------------------------------------
123 @deffn {Function} addmatrices (@var{f}, @var{M_1}, ..., @var{M_n})
125 @c REWORD -- THE RESULT IS NOT GENERALLY THE SUM OF M_1, ..., M_N
126 Using the function @var{f} as the addition function, return the sum of
127 the matrices @var{M_1}, ..., @var{M_n}. The function @var{f} must accept any
128 number of arguments (a Maxima nary function).
133 (%i1) m1 : matrix([1,2],[3,4])$
134 (%i2) m2 : matrix([7,8],[9,10])$
135 (%i3) addmatrices('max,m1,m2);
136 (%o3) matrix([7,8],[9,10])
137 (%i4) addmatrices('max,m1,m2,5*m1);
138 (%o4) matrix([7,10],[15,20])
142 @c -----------------------------------------------------------------------------
143 @deffn {Function} blockmatrixp (@var{M})
145 Return true if and only if @var{M} is a matrix and every entry of
149 @c -----------------------------------------------------------------------------
150 @deffn {Function} columnop (@var{M}, @var{i}, @var{j}, @var{theta})
152 If @var{M} is a matrix, return the matrix that results from doing the
153 column operation @code{C_i <- C_i - @var{theta} * C_j}. If @var{M} doesn't
154 have a row @var{i} or @var{j}, signal an error.
157 @c -----------------------------------------------------------------------------
158 @deffn {Function} columnswap (@var{M}, @var{i}, @var{j})
160 If @var{M} is a matrix, swap columns @var{i} and @var{j}. If @var{M} doesn't
161 have a column @var{i} or @var{j}, signal an error.
164 @c -----------------------------------------------------------------------------
165 @deffn {Function} columnspace (@var{M})
167 If @var{M} is a matrix, return @code{span (v_1, ..., v_n)}, where the set
168 @code{@{v_1, ..., v_n@}} is a basis for the column space of @var{M}. The span
169 of the empty set is @code{@{0@}}. Thus, when the column space has only
170 one member, return @code{span ()}.
173 @c -----------------------------------------------------------------------------
174 @deffn {Function} copy (@var{e})
176 Return a copy of the Maxima expression @var{e}. Although @var{e} can be any
177 Maxima expression, the copy function is the most useful when @var{e} is either
178 a list or a matrix; consider:
190 Let's try the same experiment, but this time let @var{mm} be a copy of @var{m}
201 This time, the assignment to @var{mm} does not change the value of @var{m}.
204 @c -----------------------------------------------------------------------------
205 @deffn {Function} cholesky (@var{M})
206 @deffnx {Function} cholesky (@var{M}, @var{field})
208 Return the Cholesky factorization of the matrix selfadjoint (or hermitian)
209 matrix @var{M}. The second argument defaults to 'generalring.' For a description
210 of the possible values for @var{field}, see @code{lu_factor}.
213 @c -----------------------------------------------------------------------------
214 @deffn {Function} ctranspose (@var{M})
216 Return the complex conjugate transpose of the matrix @var{M}. The function
217 @code{ctranspose} uses @code{matrix_element_transpose} to transpose each matrix
221 @c -----------------------------------------------------------------------------
222 @deffn {Function} diag_matrix (@var{d_1}, @var{d_2},...,@var{d_n})
224 Return a diagonal matrix with diagonal entries @var{d_1}, @var{d_2}, ...,
225 @var{d_n}. When the diagonal entries are matrices, the zero entries of the
226 returned matrix are zero matrices of the appropriate size; for example:
229 (%i1) diag_matrix(diag_matrix(1,2),diag_matrix(3,4));
238 (%i2) diag_matrix(p,q);
246 @c -----------------------------------------------------------------------------
247 @deffn {Function} dotproduct (@var{u}, @var{v})
249 Return the dotproduct of vectors @var{u} and @var{v}. This is the same
250 as @code{conjugate (transpose (@var{u})) . @var{v}}. The arguments @var{u} and
251 @var{v} must be column vectors.
254 @c -----------------------------------------------------------------------------
255 @deffn {Function} eigens_by_jacobi (@var{A})
256 @deffnx {Function} eigens_by_jacobi (@var{A}, @var{field_type})
258 Computes the eigenvalues and eigenvectors of @var{A} by the method of Jacobi
259 rotations. @var{A} must be a symmetric matrix (but it need not be positive
260 definite nor positive semidefinite). @var{field_type} indicates the
261 computational field, either @code{floatfield} or @code{bigfloatfield}. If
262 @var{field_type} is not specified, it defaults to @code{floatfield}.
264 The elements of @var{A} must be numbers or expressions which evaluate to numbers
265 via @code{float} or @code{bfloat} (depending on @var{field_type}).
270 (%i1) S: matrix([1/sqrt(2), 1/sqrt(2)],[-1/sqrt(2), 1/sqrt(2)]);
276 [ - ------- ------- ]
278 (%i2) L : matrix ([sqrt(3), 0], [0, sqrt(5)]);
282 (%i3) M : S . L . transpose (S);
283 [ sqrt(5) sqrt(3) sqrt(5) sqrt(3) ]
284 [ ------- + ------- ------- - ------- ]
287 [ sqrt(5) sqrt(3) sqrt(5) sqrt(3) ]
288 [ ------- - ------- ------- + ------- ]
290 (%i4) eigens_by_jacobi (M);
291 The largest percent change was 0.1454972243679
292 The largest percent change was 0.0
294 number of rotations: 1
295 (%o4) [[1.732050807568877, 2.23606797749979],
296 [ 0.70710678118655 0.70710678118655 ]
298 [ - 0.70710678118655 0.70710678118655 ]
299 (%i5) float ([[sqrt(3), sqrt(5)], S]);
300 (%o5) [[1.732050807568877, 2.23606797749979],
301 [ 0.70710678118655 0.70710678118655 ]
303 [ - 0.70710678118655 0.70710678118655 ]
304 (%i6) eigens_by_jacobi (M, bigfloatfield);
305 The largest percent change was 1.454972243679028b-1
306 The largest percent change was 0.0b0
308 number of rotations: 1
309 (%o6) [[1.732050807568877b0, 2.23606797749979b0],
310 [ 7.071067811865475b-1 7.071067811865475b-1 ]
312 [ - 7.071067811865475b-1 7.071067811865475b-1 ]
316 @c -----------------------------------------------------------------------------
317 @deffn {Function} get_lu_factors (@var{x})
319 When @code{@var{x} = lu_factor (@var{A})}, then @code{get_lu_factors} returns
320 a list of the form @code{[P, L, U]}, where @var{P} is a permutation matrix,
321 @var{L} is lower triangular with ones on the diagonal, and @var{U} is upper
322 triangular, and @code{@var{A} = @var{P} @var{L} @var{U}}.
325 @c -----------------------------------------------------------------------------
326 @deffn {Function} hankel (@var{col})
327 @deffnx {Function} hankel (@var{col}, @var{row})
329 Return a Hankel matrix @var{H}. The first column of @var{H} is @var{col};
330 except for the first entry, the last row of @var{H} is @var{row}. The
331 default for @var{row} is the zero vector with the same length as @var{col}.
334 @c -----------------------------------------------------------------------------
335 @deffn {Function} hessian (@var{f}, @var{x})
337 Returns the Hessian matrix of @var{f} with respect to the list of variables
338 @var{x}. The @code{(i, j)}-th element of the Hessian matrix is
339 @code{diff(@var{f}, @var{x}[i], 1, @var{x}[j], 1)}.
344 (%i1) hessian (x * sin (y), [x, y]);
347 [ cos(y) - x sin(y) ]
348 (%i2) depends (F, [a, b]);
350 (%i3) hessian (F, [a, b]);
365 @c -----------------------------------------------------------------------------
366 @deffn {Function} hilbert_matrix (@var{n})
368 Return the @var{n} by @var{n} Hilbert matrix. When @var{n} isn't a positive
369 integer, signal an error.
372 @c -----------------------------------------------------------------------------
373 @deffn {Function} identfor (@var{M})
374 @deffnx {Function} identfor (@var{M}, @var{fld})
376 Return an identity matrix that has the same shape as the matrix
377 @var{M}. The diagonal entries of the identity matrix are the
378 multiplicative identity of the field @var{fld}; the default for
379 @var{fld} is @var{generalring}.
381 The first argument @var{M} should be a square matrix or a
382 non-matrix. When @var{M} is a matrix, each entry of @var{M} can be a
383 square matrix -- thus @var{M} can be a blocked Maxima matrix. The
384 matrix can be blocked to any (finite) depth.
386 See also @code{zerofor}
389 @c -----------------------------------------------------------------------------
390 @deffn {Function} invert_by_lu (@var{M}, @var{(rng generalring)})
392 Invert a matrix @var{M} by using the LU factorization. The LU factorization
393 is done using the ring @var{rng}.
396 @c -----------------------------------------------------------------------------
397 @deffn {Function} jacobian (@var{f}, @var{x})
399 Returns the Jacobian matrix of the list of functions @var{f} with respect to
400 the list of variables @var{x}. The @code{(i, j)}-th element of the Jacobian
401 matrix is @code{diff(@var{f}[i], @var{x}[j])}.
406 (%i1) jacobian ([sin (u - v), sin (u * v)], [u, v]);
407 [ cos(v - u) - cos(v - u) ]
409 [ v cos(u v) u cos(u v) ]
410 (%i2) depends ([F, G], [y, z]);
411 (%o2) [F(y, z), G(y, z)]
412 (%i3) jacobian ([F, G], [y, z]);
423 @c -----------------------------------------------------------------------------
424 @deffn {Function} kronecker_product (@var{A}, @var{B})
426 Return the Kronecker product of the matrices @var{A} and @var{B}.
429 @c -----------------------------------------------------------------------------
430 @deffn {Function} listp (@var{e}, @var{p})
431 @deffnx {Function} listp (@var{e})
433 Given an optional argument @var{p}, return @code{true} if @var{e} is
434 a Maxima list and @var{p} evaluates to @code{true} for every list element.
435 When @code{listp} is not given the optional argument, return @code{true} if @var{e} is
436 a Maxima list. In all other cases, return @code{false}.
439 @c -----------------------------------------------------------------------------
440 @deffn {Function} locate_matrix_entry (@var{M}, @var{r_1}, @var{c_1}, @var{r_2}, @var{c_2}, @var{f}, @var{rel})
442 The first argument must be a matrix; the arguments
443 @var{r_1} through @var{c_2} determine a sub-matrix of @var{M} that consists of
444 rows @var{r_1} through @var{r_2} and columns @var{c_1} through @var{c_2}.
446 Find an entry in the sub-matrix @var{M} that satisfies some property.
449 (1) @code{@var{rel} = 'bool} and @var{f} a predicate:
451 Scan the sub-matrix from left to right then top to bottom,
452 and return the index of the first entry that satisfies the
453 predicate @var{f}. If no matrix entry satisfies @var{f}, return @code{false}.
455 (2) @code{@var{rel} = 'max} and @var{f} real-valued:
457 Scan the sub-matrix looking for an entry that maximizes @var{f}.
458 Return the index of a maximizing entry.
460 (3) @code{@var{rel} = 'min} and @var{f} real-valued:
462 Scan the sub-matrix looking for an entry that minimizes @var{f}.
463 Return the index of a minimizing entry.
466 @c -----------------------------------------------------------------------------
467 @deffn {Function} lu_backsub (@var{M}, @var{b})
469 When @code{@var{M} = lu_factor (@var{A}, @var{field})},
470 then @code{lu_backsub (@var{M}, @var{b})} solves the linear
471 system @code{@var{A} @var{x} = @var{b}}.
474 @c -----------------------------------------------------------------------------
475 @deffn {Function} lu_factor (@var{M}, @var{field})
477 Return a list of the form @code{[@var{LU}, @var{perm}, @var{fld}]}, or
478 @code{[@var{LU}, @var{perm}, @var{fld}, @var{lower-cnd} @var{upper-cnd}]}, where
480 (1) The matrix @var{LU} contains the factorization of @var{M} in a packed
481 form. Packed form means three things: First, the rows of @var{LU} are
482 permuted according to the list @var{perm}. If, for example, @var{perm}
483 is the list @code{[3,2,1]}, the actual first row
484 of the @var{LU} factorization is the third row of the matrix @var{LU}.
485 Second, the lower triangular factor of m is the lower triangular part of
486 @var{LU} with the diagonal entries replaced by all ones. Third, the upper
487 triangular factor of @var{M} is the upper triangular part of @var{LU}.
489 (2) When the field is either @code{floatfield} or @code{complexfield},
490 the numbers @var{lower-cnd} and @var{upper-cnd} are lower and upper bounds
491 for the infinity norm condition number of @var{M}. For all fields, the
492 condition number might not be estimated; for such fields, @code{lu_factor}
493 returns a two item list. Both the lower and upper bounds can differ from
494 their true values by arbitrarily large factors.
495 (See also @code{mat_cond}.)
497 The argument @var{M} must be a square matrix.
499 The optional argument @var{fld} must be a symbol that determines a ring or
500 field. The pre-defined fields and rings are:
502 (a) @code{generalring} -- the ring of Maxima expressions,
503 (b) @code{floatfield} -- the field of floating point numbers of the type double,
504 (c) @code{complexfield} -- the field of complex floating point numbers of the
506 (d) @code{crering} -- the ring of Maxima CRE expressions,
507 (e) @code{rationalfield} -- the field of rational numbers,
508 (f) @code{runningerror} -- track the all floating point rounding errors,
509 (g) @code{noncommutingring} -- the ring of Maxima expressions where multiplication is the
510 non-commutative dot operator.
512 When the field is @code{floatfield}, @code{complexfield}, or
513 @code{runningerror}, the algorithm uses partial pivoting; for all
514 other fields, rows are switched only when needed to avoid a zero
517 Floating point addition arithmetic isn't associative, so the meaning
518 of 'field' differs from the mathematical definition.
520 A member of the field @code{runningerror} is a two member Maxima list
521 of the form @code{[x,n]},where @var{x} is a floating point number and
522 @code{n} is an integer. The relative difference between the 'true'
523 value of @code{x} and @code{x} is approximately bounded by the machine
524 epsilon times @code{n}. The running error bound drops some terms that
525 of the order the square of the machine epsilon.
527 There is no user-interface for defining a new field. A user that is
528 familiar with Common Lisp should be able to define a new field. To do
529 this, a user must define functions for the arithmetic operations and
530 functions for converting from the field representation to Maxima and
531 back. Additionally, for ordered fields (where partial pivoting will be
532 used), a user must define functions for the magnitude and for
533 comparing field members. After that all that remains is to define a
534 Common Lisp structure @code{mring}. The file @code{mring} has many
537 To compute the factorization, the first task is to convert each matrix
538 entry to a member of the indicated field. When conversion isn't
539 possible, the factorization halts with an error message. Members of
540 the field needn't be Maxima expressions. Members of the
541 @code{complexfield}, for example, are Common Lisp complex numbers. Thus
542 after computing the factorization, the matrix entries must be
543 converted to Maxima expressions.
545 See also @code{get_lu_factors}.
550 (%i1) w[i,j] := random (1.0) + %i * random (1.0);
551 (%o1) w := random(1.) + %i random(1.)
553 (%i2) showtime : true$
554 Evaluation took 0.00 seconds (0.00 elapsed)
555 (%i3) M : genmatrix (w, 100, 100)$
556 Evaluation took 7.40 seconds (8.23 elapsed)
557 (%i4) lu_factor (M, complexfield)$
558 Evaluation took 28.71 seconds (35.00 elapsed)
559 (%i5) lu_factor (M, generalring)$
560 Evaluation took 109.24 seconds (152.10 elapsed)
561 (%i6) showtime : false$
563 (%i7) M : matrix ([1 - z, 3], [3, 8 - z]);
567 (%i8) lu_factor (M, generalring);
570 (%o8) [[ 3 9 ], [1, 2], generalring]
571 [ ----- - z - ----- + 8 ]
573 (%i9) get_lu_factors (%);
576 (%o9) [[ ], [ 3 ], [ 9 ]]
577 [ 0 1 ] [ ----- 1 ] [ 0 - z - ----- + 8 ]
579 (%i10) %[1] . %[2] . %[3];
586 @c -----------------------------------------------------------------------------
587 @deffn {Function} mat_cond (@var{M}, 1)
588 @deffnx {Function} mat_cond (@var{M}, inf)
590 Return the @var{p}-norm matrix condition number of the matrix
591 @var{m}. The allowed values for @var{p} are 1 and @var{inf}. This
592 function uses the LU factorization to invert the matrix @var{m}. Thus
593 the running time for @code{mat_cond} is proportional to the cube of
594 the matrix size; @code{lu_factor} determines lower and upper bounds
595 for the infinity norm condition number in time proportional to the
596 square of the matrix size.
599 @c -----------------------------------------------------------------------------
600 @deffn {Function} mat_norm (@var{M}, 1)
601 @deffnx {Function} mat_norm (@var{M}, inf)
602 @deffnx {Function} mat_norm (@var{M}, frobenius)
604 Return the matrix @var{p}-norm of the matrix @var{M}. The allowed values for
605 @var{p} are 1, @code{inf}, and @code{frobenius} (the Frobenius matrix norm).
606 The matrix @var{M} should be an unblocked matrix.
609 @c -----------------------------------------------------------------------------
610 @deffn {Function} matrixp (@var{e}, @var{p})
611 @deffnx {Function} matrixp (@var{e})
613 Given an optional argument @var{p}, return @code{true} if @var{e} is
614 a matrix and @var{p} evaluates to @code{true} for every matrix element.
615 When @code{matrixp} is not given an optional argument, return @code{true}
616 if @code{e} is a matrix. In all other cases, return @code{false}.
618 See also @code{blockmatrixp}
621 @c -----------------------------------------------------------------------------
622 @deffn {Function} matrix_size (@var{M})
624 Return a two member list that gives the number of rows and columns, respectively
625 of the matrix @var{M}.
628 @c -----------------------------------------------------------------------------
629 @deffn {Function} mat_fullunblocker (@var{M})
631 If @var{M} is a block matrix, unblock the matrix to all levels. If @var{M} is
632 a matrix, return @var{M}; otherwise, signal an error.
635 @c -----------------------------------------------------------------------------
636 @deffn {Function} mat_trace (@var{M})
638 Return the trace of the matrix @var{M}. If @var{M} isn't a matrix, return a
639 noun form. When @var{M} is a block matrix, @code{mat_trace(M)} returns
640 the same value as does @code{mat_trace(mat_unblocker(m))}.
643 @c -----------------------------------------------------------------------------
644 @deffn {Function} mat_unblocker (@var{M})
646 If @var{M} is a block matrix, unblock @var{M} one level. If @var{M} is a matrix,
647 @code{mat_unblocker (M)} returns @var{M}; otherwise, signal an error.
649 Thus if each entry of @var{M} is matrix, @code{mat_unblocker (M)} returns an
650 unblocked matrix, but if each entry of @var{M} is a block matrix,
651 @code{mat_unblocker (M)} returns a block matrix with one less level of blocking.
653 If you use block matrices, most likely you'll want to set
654 @code{matrix_element_mult} to @code{"."} and @code{matrix_element_transpose}
655 to @code{'transpose}. See also @code{mat_fullunblocker}.
660 (%i1) A : matrix ([1, 2], [3, 4]);
664 (%i2) B : matrix ([7, 8], [9, 10]);
668 (%i3) matrix ([A, B]);
672 (%i4) mat_unblocker (%);
679 @c -----------------------------------------------------------------------------
680 @deffn {Function} nullspace (@var{M})
682 If @var{M} is a matrix, return @code{span (v_1, ..., v_n)}, where the set
683 @code{@{v_1, ..., v_n@}} is a basis for the nullspace of @var{M}. The span of
684 the empty set is @code{@{0@}}. Thus, when the nullspace has only one member,
685 return @code{span ()}.
688 @c -----------------------------------------------------------------------------
689 @deffn {Function} nullity (@var{M})
691 If @var{M} is a matrix, return the dimension of the nullspace of @var{M}.
694 @c -----------------------------------------------------------------------------
695 @deffn {Function} orthogonal_complement (@var{v_1}, ..., @var{v_n})
697 Return @code{span (u_1, ..., u_m)}, where the set @code{@{u_1, ..., u_m@}} is a
698 basis for the orthogonal complement of the set @code{(v_1, ..., v_n)}.
700 Each vector @var{v_1} through @var{v_n} must be a column vector.
703 @c -----------------------------------------------------------------------------
704 @deffn {Function} polynomialp (@var{p}, @var{L}, @var{coeffp}, @var{exponp})
705 @deffnx {Function} polynomialp (@var{p}, @var{L}, @var{coeffp})
706 @deffnx {Function} polynomialp (@var{p}, @var{L})
708 Return @code{true} if @var{p} is a polynomial in the variables in the list
709 @var{L}. The predicate @var{coeffp} must evaluate to @code{true} for each
710 coefficient, and the predicate @var{exponp} must evaluate to @code{true} for all
711 exponents of the variables in @var{L}. If you want to use a non-default
712 value for @var{exponp}, you must supply @var{coeffp} with a value even if you
713 want to use the default for @var{coeffp}.
715 @c WORK THE FOLLOWING INTO THE PRECEDING
716 The command @code{polynomialp (@var{p}, @var{L}, @var{coeffp})} is equivalent to
717 @code{polynomialp (@var{p}, @var{L}, @var{coeffp}, 'nonnegintegerp)} and
718 @code{polynomialp (@var{p}, @var{L})} is equivalent to
719 @code{polynomialp (@var{p}, L@var{,} 'constantp, 'nonnegintegerp)}.
721 The polynomial needn't be expanded:
724 (%i1) polynomialp ((x + 1)*(x + 2), [x]);
726 (%i2) polynomialp ((x + 1)*(x + 2)^a, [x]);
730 An example using non-default values for coeffp and exponp:
733 (%i1) polynomialp ((x + 1)*(x + 2)^(3/2), [x], numberp, numberp);
735 (%i2) polynomialp ((x^(1/2) + 1)*(x + 2)^(3/2), [x], numberp,
740 Polynomials with two variables:
743 (%i1) polynomialp (x^2 + 5*x*y + y^2, [x]);
745 (%i2) polynomialp (x^2 + 5*x*y + y^2, [x, y]);
750 @c -----------------------------------------------------------------------------
751 @deffn {Function} polytocompanion (@var{p}, @var{x})
753 If @var{p} is a polynomial in @var{x}, return the companion matrix of @var{p}.
754 For a monic polynomial @var{p} of degree @var{n}, we have
755 @code{@var{p} = (-1)^@var{n} charpoly (polytocompanion (@var{p}, @var{x}))}.
757 When @var{p} isn't a polynomial in @var{x}, signal an error.
760 @c -----------------------------------------------------------------------------
761 @deffn {Function} ptriangularize (@var{M}, @var{v})
763 If @var{M} is a matrix with each entry a polynomial in @var{v}, return
764 a matrix @var{M2} such that
766 (1) @var{M2} is upper triangular,
768 (2) @code{@var{M2} = @var{E_n} ... @var{E_1} @var{M}},
769 where @var{E_1} through @var{E_n} are elementary matrices
770 whose entries are polynomials in @var{v},
772 (3) @code{|det (@var{M})| = |det (@var{M2})|},
774 Note: This function doesn't check that every entry is a polynomial in @var{v}.
777 @c -----------------------------------------------------------------------------
778 @deffn {Function} rowop (@var{M}, @var{i}, @var{j}, @var{theta})
780 If @var{M} is a matrix, return the matrix that results from doing the
781 row operation @code{R_i <- R_i - theta * R_j}. If @var{M} doesn't have a row
782 @var{i} or @var{j}, signal an error.
785 @c -----------------------------------------------------------------------------
786 @deffn {Function} rank (@var{M})
788 Return the rank of that matrix @var{M}. The rank is the dimension of the
794 (%i1) rank(matrix([1,2],[2,4]));
796 (%i2) rank(matrix([1,b],[c,d]));
797 Proviso: @{d - b c # 0@}
802 @c -----------------------------------------------------------------------------
803 @deffn {Function} rowswap (@var{M}, @var{i}, @var{j})
805 If @var{M} is a matrix, swap rows @var{i} and @var{j}. If @var{M} doesn't have
806 a row @var{i} or @var{j}, signal an error.
809 @c -----------------------------------------------------------------------------
810 @deffn {Function} toeplitz (@var{col})
811 @deffnx {Function} toeplitz (@var{col}, @var{row})
813 Return a Toeplitz matrix @var{T}. The first first column of @var{T} is
814 @var{col}; except for the first entry, the first row of @var{T} is @var{row}.
815 The default for @var{row} is complex conjugate of @var{col}.
820 (%i1) toeplitz([1,2,3],[x,y,z]);
827 (%i2) toeplitz([1,1+%i]);
835 @c -----------------------------------------------------------------------------
836 @deffn {Function} vandermonde_matrix ([@var{x_1}, ..., @var{x_n}])
838 Return a @var{n} by @var{n} matrix whose @var{i}-th row is
839 @code{[1, @var{x_i}, @var{x_i}^2, ... @var{x_i}^(@var{n}-1)]}.
842 @c -----------------------------------------------------------------------------
843 @deffn {Function} zerofor (@var{M})
844 @deffnx {Function} zerofor (@var{M}, @var{fld})
846 Return a zero matrix that has the same shape as the matrix
847 @var{M}. Every entry of the zero matrix is the
848 additive identity of the field @var{fld}; the default for
849 @var{fld} is @var{generalring}.
851 The first argument @var{M} should be a square matrix or a
852 non-matrix. When @var{M} is a matrix, each entry of @var{M} can be a
853 square matrix -- thus @var{M} can be a blocked Maxima matrix. The
854 matrix can be blocked to any (finite) depth.
856 See also @code{identfor}
859 @c -----------------------------------------------------------------------------
860 @deffn {Function} zeromatrixp (@var{M})
862 If @var{M} is not a block matrix, return @code{true} if
863 @code{is (equal (@var{e}, 0))} is true for each element @var{e} of the matrix
864 @var{M}. If @var{M} is a block matrix, return @code{true} if @code{zeromatrixp}
865 evaluates to @code{true} for each element of @var{e}.
868 @c --- End of file linearalgebra.de.texi ---------------------------------------