From fd45b9e658b332788f779a709d74b24a93f46793 Mon Sep 17 00:00:00 2001 From: AJ Rossini Date: Thu, 11 Dec 2008 17:45:26 +0100 Subject: [PATCH] more matrix stuff removed. its in lisp-matrix. --- src/numerics/lm-statlinalg.lisp | 69 ----------------------------------------- 1 file changed, 69 deletions(-) diff --git a/src/numerics/lm-statlinalg.lisp b/src/numerics/lm-statlinalg.lisp index fe18449..a75c341 100644 --- a/src/numerics/lm-statlinalg.lisp +++ b/src/numerics/lm-statlinalg.lisp @@ -604,75 +604,6 @@ corresponding element of TOLERANCES." -;;;; -;;;; Linear Algebra Functions -;;;; - -(defun matrix (dim data) -"Args: (dim data) -returns a matrix of dimensions DIM initialized using sequence DATA -in row major order." - (let ((dim (coerce dim 'list)) - (data (coerce data 'list))) - (make-array dim :initial-contents (split-list data (nth 1 dim))))) - -(defun flatsize (x) - (length x)) ;; FIXME: defined badly!! - -(defun print-matrix (a &optional (stream *standard-output*)) -"Args: (matrix &optional stream) -Prints MATRIX to STREAM in a nice form that is still machine readable" - (unless (matrixp a) (error "not a matrix - ~a" a)) - (let ((size (min 15 (max (map-elements #'flatsize a))))) - (format stream "#2a(~%") - (dolist (x (row-list a)) - (format stream " (") - (let ((n (length x))) - (dotimes (i n) - (let ((y (aref x i))) - (cond - ((integerp y) (format stream "~vd" size y)) - ((floatp y) (format stream "~vg" size y)) - (t (format stream "~va" size y)))) - (if (< i (- n 1)) (format stream " ")))) - (format stream ")~%")) - (format stream " )~%") - nil)) - -(defun solve (a b) -"Args: (a b) -Solves A x = B using LU decomposition and backsolving. B can be a sequence -or a matrix." - (let ((lu (lu-decomp a))) - (if (matrixp b) - (apply #'bind-columns - (mapcar #'(lambda (x) (lu-solve lu x)) (column-list b))) - (lu-solve lu b)))) - -(defun backsolve (a b) -"Args: (a b) -Solves A x = B by backsolving, assuming A is upper triangular. B must be a -sequence. For use with qr-decomp." - (let* ((n (length b)) - (sol (make-array n))) - (dotimes (i n) - (let* ((k (- n i 1)) - (val (elt b k))) - (dotimes (j i) - (let ((l (- n j 1))) - (setq val (- val (* (aref sol l) (aref a k l)))))) - (setf (aref sol k) (/ val (aref a k k))))) - (if (listp b) (coerce sol 'list) sol))) - -(defun eigenvalues (a) -"Args: (a) -Returns list of eigenvalues of square, symmetric matrix A" - (first (eigen a))) - -(defun eigenvectors (a) -"Args: (a) -Returns list of eigenvectors of square, symmetric matrix A" - (second (eigen a))) (defun accumulate (f s) "Args: (f s) -- 2.11.4.GIT