[common-math-cvs] r3 - trunk/common-math/numerics/linear-algebra

mantoniotti at common-lisp.net mantoniotti at common-lisp.net
Fri Aug 18 15:54:07 UTC 2006


Author: mantoniotti
Date: Fri Aug 18 11:54:06 2006
New Revision: 3

Added:
   trunk/common-math/numerics/linear-algebra/determinants.lisp
   trunk/common-math/numerics/linear-algebra/inversion.lisp
Modified:
   trunk/common-math/numerics/linear-algebra/linear-algebra-pkg.lisp
   trunk/common-math/numerics/linear-algebra/linear-algebra.system
   trunk/common-math/numerics/linear-algebra/lu-decomposition.lisp
   trunk/common-math/numerics/linear-algebra/matrix.lisp
Log:
Rearranged a few files, added two more and fixed a small number of issues here and there.


Added: trunk/common-math/numerics/linear-algebra/determinants.lisp
==============================================================================
--- (empty file)
+++ trunk/common-math/numerics/linear-algebra/determinants.lisp	Fri Aug 18 11:54:06 2006
@@ -0,0 +1,44 @@
+;;;; -*- Mode: Lisp -*-
+
+;;;; determinants.lisp --
+
+
+(in-package "CL.MATH.LINEAR-ALGEBRA")
+
+;;;===========================================================================
+;;; Determinants
+
+;;; det
+
+(defgeneric det (m))
+
+(defgeneric det/double-float (m))
+
+
+(defmethod det ((a array))
+  (assert (square-matrix-p a))
+  (multiple-value-bind (lu permutations parity)
+      (lu-decompose a)
+    (declare (ignore permutations))
+    (dotimes (i (array-dimension lu 0) parity)
+      (setf parity (* parity (aref lu i i))))))
+
+(defmethod det ((a matrix))
+  (det (matrix-data a)))
+
+
+(defmethod det/double-float ((a array))
+  (assert (square-matrix-p a))
+  (multiple-value-bind (lu permutations parity)
+      (lu-decompose a)
+    (declare (type (array double-float (cl:* cl:*)) lu)
+             (ignore permutations)
+             (type double-float parity))
+    (dotimes (i (array-dimension lu 0) parity)
+      (setf parity (* parity (aref lu i i))))))
+
+(defmethod det/double-float ((a matrix))
+  (det/double-float (matrix-data a)))
+
+
+;;; end of file -- determinant.lisp --

Added: trunk/common-math/numerics/linear-algebra/inversion.lisp
==============================================================================
--- (empty file)
+++ trunk/common-math/numerics/linear-algebra/inversion.lisp	Fri Aug 18 11:54:06 2006
@@ -0,0 +1,29 @@
+;;;; -*- Mode: Lisp -*-
+
+;;;; inversion.lisp --
+
+
+(in-package "CL.MATH.LINEAR-ALGEBRA")
+
+;;;===========================================================================
+;;; Inversion
+
+;;; inverse
+
+(defgeneric inverse (m))
+
+(defgeneric inverse/double-float (m))
+
+
+
+(defmethod inverse ((a matrix))
+  (inverse (matrix-data a)))
+
+
+
+
+(defmethod inverse/double-float ((a matrix))
+  (inverse/double-float (matrix-data a)))
+
+
+;;; end of file -- inversion.lisp --

Modified: trunk/common-math/numerics/linear-algebra/linear-algebra-pkg.lisp
==============================================================================
--- trunk/common-math/numerics/linear-algebra/linear-algebra-pkg.lisp	(original)
+++ trunk/common-math/numerics/linear-algebra/linear-algebra-pkg.lisp	Fri Aug 18 11:54:06 2006
@@ -13,6 +13,8 @@
   (:export ".*" "./" "EXPT*")
 
   (:export ".*%2" ".*%1" "./%2" "./%1")
+
+  (:export "DET" "SOLVE")
   
   )
 

Modified: trunk/common-math/numerics/linear-algebra/linear-algebra.system
==============================================================================
--- trunk/common-math/numerics/linear-algebra/linear-algebra.system	(original)
+++ trunk/common-math/numerics/linear-algebra/linear-algebra.system	Fri Aug 18 11:54:06 2006
@@ -8,6 +8,9 @@
                "common-math-extra"
                "vector"
                "matrix"
-               "lu-decomposition"))
+               (:file "lu-decomposition" :depends-on ("matrix"))
+               (:file "determinants" :depends-on ("lu-decomposition"))
+               (:file "inversion" :depends-on ("lu-decomposition"))
+               ))
 
 ;;;; end of file -- linear-algebra.system --

Modified: trunk/common-math/numerics/linear-algebra/lu-decomposition.lisp
==============================================================================
--- trunk/common-math/numerics/linear-algebra/lu-decomposition.lisp	(original)
+++ trunk/common-math/numerics/linear-algebra/lu-decomposition.lisp	Fri Aug 18 11:54:06 2006
@@ -14,13 +14,6 @@
 (defparameter *epsilon* 1.0e-20) ; Change this to CL constant.
 
 
-(defgeneric square-matrix-p (m)
-  (:method ((m array))
-   (and (matrix-array-p m)
-        (cl:= (array-dimension m 0) (array-dimension m 1))))
-  (:method ((m matrix))
-   (cl:= (matrix-row-number m) (matrix-column-number m))))
-
 
 
 ;;; Different base type.
@@ -283,33 +276,11 @@
   (solve/double-float (matrix-data a) b result))
 
 
-;;;---------------------------------------------------------------------------
-;;; det
-
-(defmethod det ((a array))
-  (assert (square-matrix-p a))
-  (multiple-value-bind (lu permutations parity)
-      (lu-decompose a)
-    (declare (ignore permutations))
-    (dotimes (i (array-dimension lu 0) parity)
-      (setf parity (* parity (aref lu i i))))))
-
-(defmethod det ((a matrix))
-  (det (matrix-data a)))
-
-
-(defmethod det/double-float ((a array))
-  (assert (square-matrix-p a))
-  (multiple-value-bind (lu permutations parity)
-      (lu-decompose a)
-    (declare (type (array double-float (cl:* cl:*)) lu)
-             (ignore permutations)
-             (type double-float parity))
-    (dotimes (i (array-dimension lu 0) parity)
-      (setf parity (* parity (aref lu i i))))))
+;;;===========================================================================
+;;; Determinants
 
-(defmethod det/double-float ((a matrix))
-  (det/double-float (matrix-data a)))
+;;;===========================================================================
+;;; Inverse
 
 
 ;;;===========================================================================

Modified: trunk/common-math/numerics/linear-algebra/matrix.lisp
==============================================================================
--- trunk/common-math/numerics/linear-algebra/matrix.lisp	(original)
+++ trunk/common-math/numerics/linear-algebra/matrix.lisp	Fri Aug 18 11:54:06 2006
@@ -146,6 +146,14 @@
   (shape-equal-p m1 m2))
 
 
+
+(defgeneric square-matrix-p (m)
+  (:method ((m array))
+   (cl:= (matrix-row-number m) (matrix-column-number m)))
+  (:method ((m matrix))
+   (cl:= (matrix-row-number m) (matrix-column-number m))))
+
+
 ;;;---------------------------------------------------------------------------
 ;;; Creation.
 



More information about the Common-math-cvs mailing list