File: dgesv.lisp

package info (click to toggle)
maxima 5.44.0-2
  • links: PTS
  • area: main
  • in suites: bullseye, sid
  • size: 108,368 kB
  • sloc: lisp: 383,860; fortran: 14,665; perl: 14,369; tcl: 11,147; sh: 4,517; makefile: 2,580; ansic: 447; python: 262; xml: 59; awk: 37; sed: 17
file content (32 lines) | stat: -rw-r--r-- 1,311 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
;; dgesv.lisp -- Maxima interface to lapack::dgesv
;; copyright 2010 by Robert Dodier
;; I release this work under terms of the GNU General Public License.
(in-package :maxima)

;; dgesv(a, b) returns solution x of linear equations a . x = b
;; as computed by the LU decomposition.
;; a is a n-by-n Maxima matrix, b is a n-by-m Maxima matrix,
;; where m maybe be greater than or equal to 1.
;; a and b are not modified.

(defun $dgesv (a b)

  (multiple-value-bind (a-nrow a-ncol) (maxima-matrix-dims a)
    (multiple-value-bind (b-nrow b-ncol) (maxima-matrix-dims b)

      (let
        ((a-mat (lapack-lispify-matrix a a-nrow a-ncol))
         (b-mat (lapack-lispify-matrix b b-nrow b-ncol))
         (ipiv (make-array a-nrow :element-type 'f2cl-lib:integer4)))

        (multiple-value-bind (z-n z-nrhs z-a z-lda z-ipiv z-b z-ldb$ z-info)
          (lapack::dgesv a-nrow b-ncol a-mat a-nrow ipiv b-mat b-nrow 0)

          (declare (ignore z-n z-nrhs z-a z-lda z-ipiv z-b z-ldb$))
          (cond
            ((< z-info 0)
             (merror "dgesv: ~M-th argument has an illegal value." (- z-info)))
            ((> z-info 0)
             (merror "dgesv: U(~M, ~M) is exactly zero; cannot compute a solution." z-info z-info))
            (t
              (lapack-maxify-matrix b-nrow b-ncol b-mat))))))))