1 ;; dgesv.lisp -- Maxima interface to lapack::dgesv
2 ;; copyright 2010 by Robert Dodier
3 ;; I release this work under terms of the GNU General Public License.
6 ;; dgesv(a, b) returns solution x of linear equations a . x = b
7 ;; as computed by the LU decomposition.
8 ;; a is a n-by-n Maxima matrix, b is a n-by-m Maxima matrix,
9 ;; where m maybe be greater than or equal to 1.
10 ;; a and b are not modified.
14 (multiple-value-bind (a-nrow a-ncol
) (maxima-matrix-dims a
)
15 (multiple-value-bind (b-nrow b-ncol
) (maxima-matrix-dims b
)
18 ((a-mat (lapack-lispify-matrix a a-nrow a-ncol
))
19 (b-mat (lapack-lispify-matrix b b-nrow b-ncol
))
20 (ipiv (make-array a-nrow
:element-type
'f2cl-lib
:integer4
)))
22 (multiple-value-bind (z-n z-nrhs z-a z-lda z-ipiv z-b z-ldb$ z-info
)
23 (lapack::dgesv a-nrow b-ncol a-mat a-nrow ipiv b-mat b-nrow
0)
25 (declare (ignore z-n z-nrhs z-a z-lda z-ipiv z-b z-ldb$
))
28 (merror "dgesv: ~M-th argument has an illegal value." (- z-info
)))
30 (merror "dgesv: U(~M, ~M) is exactly zero; cannot compute a solution." z-info z-info
))
32 (lapack-maxify-matrix b-nrow b-ncol b-mat
))))))))