aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorJay Belanger2005-10-28 03:51:36 +0000
committerJay Belanger2005-10-28 03:51:36 +0000
commit7199ddd28ea6c24170119687f24dc7bc5653af29 (patch)
tree25581ae09895b80256ffd799f099c228ddd9f915 /lisp
parentcbd4e89beaf480605fc6b690a150c5382499e4f6 (diff)
downloademacs-7199ddd28ea6c24170119687f24dc7bc5653af29.tar.gz
emacs-7199ddd28ea6c24170119687f24dc7bc5653af29.zip
(calc-mul-symb-fancy): Add checks for multiplication by an identity
matrix, don't turn multiplication by an inverse matrix into division. (math-div-symbol-fancy): Replace division by matrices with multiplication by inverse.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/calc/calc-arith.el29
1 files changed, 28 insertions, 1 deletions
diff --git a/lisp/calc/calc-arith.el b/lisp/calc/calc-arith.el
index feb3c9d25a8..f8057c5f1b9 100644
--- a/lisp/calc/calc-arith.el
+++ b/lisp/calc/calc-arith.el
@@ -1386,6 +1386,7 @@
1386 (and (eq (car-safe b) '^) 1386 (and (eq (car-safe b) '^)
1387 (Math-looks-negp (nth 2 b)) 1387 (Math-looks-negp (nth 2 b))
1388 (not (and (eq (car-safe a) '^) (Math-looks-negp (nth 2 a)))) 1388 (not (and (eq (car-safe a) '^) (Math-looks-negp (nth 2 a))))
1389 (not (math-known-matrixp (nth 1 b)))
1389 (math-div a (math-normalize 1390 (math-div a (math-normalize
1390 (list '^ (nth 1 b) (math-neg (nth 2 b)))))) 1391 (list '^ (nth 1 b) (math-neg (nth 2 b))))))
1391 (and (eq (car-safe a) '/) 1392 (and (eq (car-safe a) '/)
@@ -1427,6 +1428,30 @@
1427 (list 'calcFunc-idn (math-mul a (nth 1 b)))) 1428 (list 'calcFunc-idn (math-mul a (nth 1 b))))
1428 (and (math-known-matrixp a) 1429 (and (math-known-matrixp a)
1429 (math-mul a (nth 1 b))))) 1430 (math-mul a (nth 1 b)))))
1431 (and (math-identity-matrix-p a t)
1432 (or (and (eq (car-safe b) 'calcFunc-idn)
1433 (= (length b) 2)
1434 (list 'calcFunc-idn (math-mul
1435 (nth 1 (nth 1 a))
1436 (nth 1 b))
1437 (1- (length a))))
1438 (and (math-known-scalarp b)
1439 (list 'calcFunc-idn (math-mul
1440 (nth 1 (nth 1 a)) b)
1441 (1- (length a))))
1442 (and (math-known-matrixp b)
1443 (math-mul (nth 1 (nth 1 a)) b))))
1444 (and (math-identity-matrix-p b t)
1445 (or (and (eq (car-safe a) 'calcFunc-idn)
1446 (= (length a) 2)
1447 (list 'calcFunc-idn (math-mul (nth 1 a)
1448 (nth 1 (nth 1 b)))
1449 (1- (length b))))
1450 (and (math-known-scalarp a)
1451 (list 'calcFunc-idn (math-mul a (nth 1 (nth 1 b)))
1452 (1- (length b))))
1453 (and (math-known-matrixp a)
1454 (math-mul a (nth 1 (nth 1 b))))))
1430 (and (math-looks-negp b) 1455 (and (math-looks-negp b)
1431 (math-mul (math-neg a) (math-neg b))) 1456 (math-mul (math-neg a) (math-neg b)))
1432 (and (eq (car-safe b) '-) 1457 (and (eq (car-safe b) '-)
@@ -1706,7 +1731,9 @@
1706 (math-div-new-non-trig term)))) 1731 (math-div-new-non-trig term))))
1707 1732
1708(defun math-div-symb-fancy (a b) 1733(defun math-div-symb-fancy (a b)
1709 (or (and math-simplify-only 1734 (or (and (math-known-matrixp b)
1735 (math-mul a (math-pow b -1)))
1736 (and math-simplify-only
1710 (not (equal a math-simplify-only)) 1737 (not (equal a math-simplify-only))
1711 (list '/ a b)) 1738 (list '/ a b))
1712 (and (Math-equal-int b 1) a) 1739 (and (Math-equal-int b 1) a)