diff options
author | Jay Belanger <jay.p.belanger@gmail.com> | 2005-10-28 03:51:36 +0000 |
---|---|---|
committer | Jay Belanger <jay.p.belanger@gmail.com> | 2005-10-28 03:51:36 +0000 |
commit | 7199ddd28ea6c24170119687f24dc7bc5653af29 (patch) | |
tree | 25581ae09895b80256ffd799f099c228ddd9f915 /lisp/calc/calc-arith.el | |
parent | cbd4e89beaf480605fc6b690a150c5382499e4f6 (diff) | |
download | emacs-7199ddd28ea6c24170119687f24dc7bc5653af29.tar.gz |
(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/calc/calc-arith.el')
-rw-r--r-- | lisp/calc/calc-arith.el | 29 |
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 @@ (and (eq (car-safe b) '^) (Math-looks-negp (nth 2 b)) (not (and (eq (car-safe a) '^) (Math-looks-negp (nth 2 a)))) + (not (math-known-matrixp (nth 1 b))) (math-div a (math-normalize (list '^ (nth 1 b) (math-neg (nth 2 b)))))) (and (eq (car-safe a) '/) @@ -1427,6 +1428,30 @@ (list 'calcFunc-idn (math-mul a (nth 1 b)))) (and (math-known-matrixp a) (math-mul a (nth 1 b))))) + (and (math-identity-matrix-p a t) + (or (and (eq (car-safe b) 'calcFunc-idn) + (= (length b) 2) + (list 'calcFunc-idn (math-mul + (nth 1 (nth 1 a)) + (nth 1 b)) + (1- (length a)))) + (and (math-known-scalarp b) + (list 'calcFunc-idn (math-mul + (nth 1 (nth 1 a)) b) + (1- (length a)))) + (and (math-known-matrixp b) + (math-mul (nth 1 (nth 1 a)) b)))) + (and (math-identity-matrix-p b t) + (or (and (eq (car-safe a) 'calcFunc-idn) + (= (length a) 2) + (list 'calcFunc-idn (math-mul (nth 1 a) + (nth 1 (nth 1 b))) + (1- (length b)))) + (and (math-known-scalarp a) + (list 'calcFunc-idn (math-mul a (nth 1 (nth 1 b))) + (1- (length b)))) + (and (math-known-matrixp a) + (math-mul a (nth 1 (nth 1 b)))))) (and (math-looks-negp b) (math-mul (math-neg a) (math-neg b))) (and (eq (car-safe b) '-) @@ -1706,7 +1731,9 @@ (math-div-new-non-trig term)))) (defun math-div-symb-fancy (a b) - (or (and math-simplify-only + (or (and (math-known-matrixp b) + (math-mul a (math-pow b -1))) + (and math-simplify-only (not (equal a math-simplify-only)) (list '/ a b)) (and (Math-equal-int b 1) a) |