Commit 7199ddd2 authored by Jay Belanger's avatar Jay Belanger
Browse files

(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.
parent cbd4e89b
......@@ -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)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment