3 |
;; Copyright (C) 1990, 1991, 1992, 1993, 2001 Free Software Foundation, Inc. |
;; Copyright (C) 1990, 1991, 1992, 1993, 2001 Free Software Foundation, Inc. |
4 |
|
|
5 |
;; Author: David Gillespie <daveg@synaptics.com> |
;; Author: David Gillespie <daveg@synaptics.com> |
6 |
;; Maintainers: D. Goel <deego@gnufans.org> |
;; Maintainer: Jay Belanger <belanger@truman.edu> |
|
;; Colin Walters <walters@debian.org> |
|
7 |
|
|
8 |
;; This file is part of GNU Emacs. |
;; This file is part of GNU Emacs. |
9 |
|
|
175 |
(nth 1 m) |
(nth 1 m) |
176 |
(math-reject-arg m 'square-matrixp)))) |
(math-reject-arg m 'square-matrixp)))) |
177 |
|
|
178 |
|
;; The variable math-det-lu is local to math-det-raw, but is |
179 |
|
;; used by math-det-step, which is called by math-det-raw. |
180 |
|
(defvar math-det-lu) |
181 |
|
|
182 |
(defun math-det-raw (m) |
(defun math-det-raw (m) |
183 |
(let ((n (1- (length m)))) |
(let ((n (1- (length m)))) |
184 |
(cond ((= n 1) |
(cond ((= n 1) |
214 |
(nth 3 (nth 3 m)))))) |
(nth 3 (nth 3 m)))))) |
215 |
(t (let ((lud (math-matrix-lud m))) |
(t (let ((lud (math-matrix-lud m))) |
216 |
(if lud |
(if lud |
217 |
(let ((lu (car lud))) |
(let ((math-det-lu (car lud))) |
218 |
(math-det-step n (nth 2 lud))) |
(math-det-step n (nth 2 lud))) |
219 |
0)))))) |
0)))))) |
220 |
|
|
221 |
(defun math-det-step (n prod) |
(defun math-det-step (n prod) |
222 |
(if (> n 0) |
(if (> n 0) |
223 |
(math-det-step (1- n) (math-mul prod (nth n (nth n lu)))) |
(math-det-step (1- n) (math-mul prod (nth n (nth n math-det-lu)))) |
224 |
prod)) |
prod)) |
225 |
|
|
226 |
;;; This returns a list (LU index d), or nil if not possible. |
;;; This returns a list (LU index d), or nil if not possible. |