[lisplab-cvs] r135 - trunk/src/linalg

Jørn Inge Vestgården jivestgarden at common-lisp.net
Wed Mar 10 19:53:17 UTC 2010


Author: jivestgarden
Date: Wed Mar 10 14:53:17 2010
New Revision: 135

Log:
fixed lu factor and determinant

Modified:
   trunk/src/linalg/level3-linalg-generic.lisp
   trunk/src/linalg/level3-linalg-interface.lisp

Modified: trunk/src/linalg/level3-linalg-generic.lisp
==============================================================================
--- trunk/src/linalg/level3-linalg-generic.lisp	(original)
+++ trunk/src/linalg/level3-linalg-generic.lisp	Wed Mar 10 14:53:17 2010
@@ -136,7 +136,7 @@
       (w/mat L (x i j) (cond ((> i j) x) ((= i j) 1) (t 0)))
       (w/mat U (x i j) (cond ((<= i j) x) (t 0)))
       (dotimes (i (rows P))
-	(setf (mref Pmat i (vref p i) ) 1))
+	(setf (mref Pmat (vref p i) i) 1))
       (list L U Pmat))))
 
 (defun L-solve! (L x)
@@ -175,7 +175,8 @@
       (LU-solve! LU b2))))
   
 (defmethod mdet ((A matrix-base))
-  (destructuring-bind (LU pvec det) (LU-factor A)    
+  (destructuring-bind (LU pvec det) 
+      (LU-factor! (copy A) (make-permutation-vector (rows A)))    
     (dotimes (i (rows A))
       (setf det (.* det (mref LU i i))))
     det))

Modified: trunk/src/linalg/level3-linalg-interface.lisp
==============================================================================
--- trunk/src/linalg/level3-linalg-interface.lisp	(original)
+++ trunk/src/linalg/level3-linalg-interface.lisp	Wed Mar 10 14:53:17 2010
@@ -62,11 +62,14 @@
   (:documentation "Short for (m*! a (minv b)). Destructive."))
 
 (defgeneric LU-factor! (matrix pivotes)
-  (:documentation "LU-factorization with pivoting. Destructive."))
+  (:documentation "LU-factorization with pivoting. Destructive. 
+Ouputs a combined LU matrix where the diagonals belong to U and a
+permutation vector."))
 
 (defgeneric LU-factor (matrix)
-  (:documentation "LU-factorization with pivoting. Outputs (m p) where 
-m is the LU-matrix and p is the pivot permutations."))
+  (:documentation "LU-factorization with pivoting. Outputs (L U P) where 
+L is low diagonal with unity at diagnoals, U is upper diagnoal and 
+P is an permutation matrix, so that A = P L U."))
 
 (defgeneric lin-solve (A b)
   (:documentation  "Solves the linear system of equations Ax=b."))




More information about the lisplab-cvs mailing list