aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJay Belanger2011-01-31 20:15:52 -0600
committerJay Belanger2011-01-31 20:15:52 -0600
commit4fdfcddf73d5e7ab67defcff9ef3f01fd9b492a4 (patch)
tree1c1e0f2e734ae6c9a5da373943116b7be8f6e29c
parent14beddf4711854b01d400f36166dc71eb39435bb (diff)
downloademacs-4fdfcddf73d5e7ab67defcff9ef3f01fd9b492a4.tar.gz
emacs-4fdfcddf73d5e7ab67defcff9ef3f01fd9b492a4.zip
* calc/calc-mtx.el (math-lud-pivot-check): New function.
(math-do-matrix-lud): Use `math-lud-pivot-check' to check the size of potential pivots.
-rw-r--r--lisp/ChangeLog6
-rw-r--r--lisp/calc/calc-mtx.el16
2 files changed, 21 insertions, 1 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index b2e5e98016e..7e5d94f9703 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
12011-02-01 Jay Belanger <jay.p.belanger@gmail.com>
2
3 * calc/calc-mtx.el (math-lud-pivot-check): New function.
4 (math-do-matrix-lud): Use `math-lud-pivot-check' to check the size
5 of potential pivots.
6
12011-01-31 Alan Mackenzie <acm@muc.de> 72011-01-31 Alan Mackenzie <acm@muc.de>
2 8
3 * progmodes/cc-cmds.el (c-forward-over-illiterals): Continue 9 * progmodes/cc-cmds.el (c-forward-over-illiterals): Continue
diff --git a/lisp/calc/calc-mtx.el b/lisp/calc/calc-mtx.el
index 9941c11ff14..5ec15005b48 100644
--- a/lisp/calc/calc-mtx.el
+++ b/lisp/calc/calc-mtx.el
@@ -232,6 +232,20 @@
232 (setq math-lud-cache (cons (cons m entry) math-lud-cache))) 232 (setq math-lud-cache (cons (cons m entry) math-lud-cache)))
233 lud)))) 233 lud))))
234 234
235
236(defun math-lud-pivot-check (a)
237 "Determine a useful value for checking the size of potential pivots
238in LUD decomposition."
239 (cond ((eq (car-safe a) 'mod)
240 (if (and (math-integerp (nth 1 a))
241 (math-integerp (nth 2 a))
242 (eq (math-gcd (nth 1 a) (nth 2 a)) 1))
243 1
244 0))
245 (t
246 (math-abs-approx a))))
247
248
235;;; Numerical Recipes section 2.3; implicit pivoting omitted. 249;;; Numerical Recipes section 2.3; implicit pivoting omitted.
236(defun math-do-matrix-lud (m) 250(defun math-do-matrix-lud (m)
237 (let* ((lu (math-copy-matrix m)) 251 (let* ((lu (math-copy-matrix m))
@@ -261,7 +275,7 @@
261 (nth j (nth k lu)))) 275 (nth j (nth k lu))))
262 k (1+ k))) 276 k (1+ k)))
263 (setcar (nthcdr j (nth i lu)) sum) 277 (setcar (nthcdr j (nth i lu)) sum)
264 (let ((dum (math-abs-approx sum))) 278 (let ((dum (math-lud-pivot-check sum)))
265 (if (Math-lessp big dum) 279 (if (Math-lessp big dum)
266 (setq big dum 280 (setq big dum
267 imax i))) 281 imax i)))