## [Maxima-commits] CVS: maxima/share/linearalgebra linalg-utilities.lisp,1.8,1.9 linalgcholesky.lisp,1.7,1.8 lu.lisp,1.7,1.8

 [Maxima-commits] CVS: maxima/share/linearalgebra linalg-utilities.lisp,1.8,1.9 linalgcholesky.lisp,1.7,1.8 lu.lisp,1.7,1.8 From: Barton Willis - 2006-01-25 02:59:18 ```Update of /cvsroot/maxima/maxima/share/linearalgebra In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21971/share/linearalgebra Modified Files: linalg-utilities.lisp linalgcholesky.lisp lu.lisp Log Message: Better full-matrix-map function Index: linalg-utilities.lisp =================================================================== RCS file: /cvsroot/maxima/maxima/share/linearalgebra/linalg-utilities.lisp,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- linalg-utilities.lisp 24 Jan 2006 11:58:39 -0000 1.8 +++ linalg-utilities.lisp 25 Jan 2006 02:59:09 -0000 1.9 @@ -62,11 +62,16 @@ (if (not (and (integerp i) (> i 0))) (merror "The ~:M argument of the function ~:M must be a positive integer" pos fun))) -(defun \$ctranspose (m) - (let ((mc (copy-tree m))) - (full-matrix-map mc #'(lambda (s) (simplifya `((\$conjugate) ,s) nil))) - (mfuncall '\$transpose mc))) +;; Map the lisp function fn over the matrix m. This function is block matrix friendly. + +(defun full-matrix-map (m fn) + (if (or (\$listp m) (\$matrixp m)) + (cons (car m) (mapcar #'(lambda (s) (full-matrix-map s fn)) (cdr m))) + (setf m (funcall fn m)))) +(defun \$ctranspose (m) + (mfuncall '\$transpose (full-matrix-map m #'(lambda (s) (simplifya `((\$conjugate) ,s) nil))))) + (defun \$zeromatrixp (m) (let ((r) (c) (ok t)) (cond ((\$matrixp m) @@ -82,4 +87,5 @@ (eval-when (eval compile load) (mfuncall '\$alias '\$copylist '\$copy '\$copymatrix '\$copy)) -(defun \$copy (e) (copy-tree e)) \ No newline at end of file +(defun \$copy (e) (copy-tree e)) + Index: linalgcholesky.lisp =================================================================== RCS file: /cvsroot/maxima/maxima/share/linearalgebra/linalgcholesky.lisp,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- linalgcholesky.lisp 11 Jan 2006 13:00:31 -0000 1.7 +++ linalgcholesky.lisp 25 Jan 2006 02:59:09 -0000 1.8 @@ -33,7 +33,7 @@ (setq l (\$zerofor m)) - (full-matrix-map l fconvert) + (setq l (full-matrix-map l fconvert)) (loop for k from 1 to n do (push k perm)) @@ -59,7 +59,7 @@ (m-elem l perm j k) (funcall fadjoint (m-elem l perm i k)))))) (setmatelem l (funcall fmult acc lii-inv) j i))) - (full-matrix-map l (mring-mring-to-maxima fld)) - l)) + (full-matrix-map l (mring-mring-to-maxima fld)))) + Index: lu.lisp =================================================================== RCS file: /cvsroot/maxima/maxima/share/linearalgebra/lu.lisp,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- lu.lisp 10 Jan 2006 13:42:21 -0000 1.7 +++ lu.lisp 25 Jan 2006 02:59:09 -0000 1.8 @@ -31,19 +31,6 @@ (loop for j from 1 to c do (setmatelem m (funcall fn (nth j (nth i m))) i j)))) -;; Map the lisp function fn over the r by c Maxima matrix m. This function is -;; block matrix friendly. - -(defun full-matrix-map (m fn) - (let ((r) (c)) - (setq r (\$matrix_size m)) - (setq c (\$second r)) - (setq r (\$first r)) - (loop for i from 1 to r do - (loop for j from 1 to c do - (if (\$matrixp (nth j (nth i m))) (full-matrix-map (nth j (nth i m)) fn) - (setmatelem m (funcall fn (nth j (nth i m))) i j)))))) - ;; Return the i,j entry of the Maxima matrix m. The rows of m have been permuted according ;; to the Maxima list p. ```

 [Maxima-commits] CVS: maxima/share/linearalgebra linalg-utilities.lisp,1.8,1.9 linalgcholesky.lisp,1.7,1.8 lu.lisp,1.7,1.8 From: Barton Willis - 2006-01-25 02:59:18 ```Update of /cvsroot/maxima/maxima/share/linearalgebra In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21971/share/linearalgebra Modified Files: linalg-utilities.lisp linalgcholesky.lisp lu.lisp Log Message: Better full-matrix-map function Index: linalg-utilities.lisp =================================================================== RCS file: /cvsroot/maxima/maxima/share/linearalgebra/linalg-utilities.lisp,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- linalg-utilities.lisp 24 Jan 2006 11:58:39 -0000 1.8 +++ linalg-utilities.lisp 25 Jan 2006 02:59:09 -0000 1.9 @@ -62,11 +62,16 @@ (if (not (and (integerp i) (> i 0))) (merror "The ~:M argument of the function ~:M must be a positive integer" pos fun))) -(defun \$ctranspose (m) - (let ((mc (copy-tree m))) - (full-matrix-map mc #'(lambda (s) (simplifya `((\$conjugate) ,s) nil))) - (mfuncall '\$transpose mc))) +;; Map the lisp function fn over the matrix m. This function is block matrix friendly. + +(defun full-matrix-map (m fn) + (if (or (\$listp m) (\$matrixp m)) + (cons (car m) (mapcar #'(lambda (s) (full-matrix-map s fn)) (cdr m))) + (setf m (funcall fn m)))) +(defun \$ctranspose (m) + (mfuncall '\$transpose (full-matrix-map m #'(lambda (s) (simplifya `((\$conjugate) ,s) nil))))) + (defun \$zeromatrixp (m) (let ((r) (c) (ok t)) (cond ((\$matrixp m) @@ -82,4 +87,5 @@ (eval-when (eval compile load) (mfuncall '\$alias '\$copylist '\$copy '\$copymatrix '\$copy)) -(defun \$copy (e) (copy-tree e)) \ No newline at end of file +(defun \$copy (e) (copy-tree e)) + Index: linalgcholesky.lisp =================================================================== RCS file: /cvsroot/maxima/maxima/share/linearalgebra/linalgcholesky.lisp,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- linalgcholesky.lisp 11 Jan 2006 13:00:31 -0000 1.7 +++ linalgcholesky.lisp 25 Jan 2006 02:59:09 -0000 1.8 @@ -33,7 +33,7 @@ (setq l (\$zerofor m)) - (full-matrix-map l fconvert) + (setq l (full-matrix-map l fconvert)) (loop for k from 1 to n do (push k perm)) @@ -59,7 +59,7 @@ (m-elem l perm j k) (funcall fadjoint (m-elem l perm i k)))))) (setmatelem l (funcall fmult acc lii-inv) j i))) - (full-matrix-map l (mring-mring-to-maxima fld)) - l)) + (full-matrix-map l (mring-mring-to-maxima fld)))) + Index: lu.lisp =================================================================== RCS file: /cvsroot/maxima/maxima/share/linearalgebra/lu.lisp,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- lu.lisp 10 Jan 2006 13:42:21 -0000 1.7 +++ lu.lisp 25 Jan 2006 02:59:09 -0000 1.8 @@ -31,19 +31,6 @@ (loop for j from 1 to c do (setmatelem m (funcall fn (nth j (nth i m))) i j)))) -;; Map the lisp function fn over the r by c Maxima matrix m. This function is -;; block matrix friendly. - -(defun full-matrix-map (m fn) - (let ((r) (c)) - (setq r (\$matrix_size m)) - (setq c (\$second r)) - (setq r (\$first r)) - (loop for i from 1 to r do - (loop for j from 1 to c do - (if (\$matrixp (nth j (nth i m))) (full-matrix-map (nth j (nth i m)) fn) - (setmatelem m (funcall fn (nth j (nth i m))) i j)))))) - ;; Return the i,j entry of the Maxima matrix m. The rows of m have been permuted according ;; to the Maxima list p. ```