summaryrefslogtreecommitdiff
path: root/lisp/calc/calc-mtx.el
diff options
context:
space:
mode:
authorMattias EngdegÄrd <mattiase@acm.org>2020-05-13 15:17:10 +0200
committerMattias EngdegÄrd <mattiase@acm.org>2020-05-14 10:28:51 +0200
commit1d559581b3bcd91644e44b1e3a3788614d99924f (patch)
tree1d50f80af6168494032043f4191b486dc90f62b0 /lisp/calc/calc-mtx.el
parenta4671733b7b990e83ef6daed4d17ab240a3591b5 (diff)
Calc: fix LU decomposition for non-numeric matrices (bug#41223)
Computing determinant and inverse for on some matrices containing non-numeric elements failed or gave the wrong result. Reported by Mauro Aranda. * lisp/calc/calc-mtx.el (math-do-matrix-lud): Don't use zero as pivot. * test/lisp/calc/calc-tests.el (calc-matrix-determinant): New test.
Diffstat (limited to 'lisp/calc/calc-mtx.el')
-rw-r--r--lisp/calc/calc-mtx.el2
1 files changed, 1 insertions, 1 deletions
diff --git a/lisp/calc/calc-mtx.el b/lisp/calc/calc-mtx.el
index fe241b57c60..2850b33721b 100644
--- a/lisp/calc/calc-mtx.el
+++ b/lisp/calc/calc-mtx.el
@@ -275,7 +275,7 @@ in LUD decomposition."
k (1+ k)))
(setcar (nthcdr j (nth i lu)) sum)
(let ((dum (math-lud-pivot-check sum)))
- (if (Math-lessp big dum)
+ (if (or (math-zerop big) (Math-lessp big dum))
(setq big dum
imax i)))
(setq i (1+ i)))