diff options
author | Jay Belanger <jay.p.belanger@gmail.com> | 2005-09-07 19:29:38 +0000 |
---|---|---|
committer | Jay Belanger <jay.p.belanger@gmail.com> | 2005-09-07 19:29:38 +0000 |
commit | 2ccc02f2182ab453ef5b056415e16df4454d426e (patch) | |
tree | 8734125e6b623640e73d4dd953de753f9c27d5fb /lisp/calc/calc-poly.el | |
parent | 104fc809f95472cb143388230cdac95052bbefb5 (diff) | |
download | emacs-2ccc02f2182ab453ef5b056415e16df4454d426e.tar.gz |
(math-expand-term): Multiply out the powers when in matrix mode.
Diffstat (limited to 'lisp/calc/calc-poly.el')
-rw-r--r-- | lisp/calc/calc-poly.el | 45 |
1 files changed, 36 insertions, 9 deletions
diff --git a/lisp/calc/calc-poly.el b/lisp/calc/calc-poly.el index 3dd19b6f67a..e27705de98a 100644 --- a/lisp/calc/calc-poly.el +++ b/lisp/calc/calc-poly.el @@ -1069,18 +1069,45 @@ (math-add-or-sub (list '/ (nth 1 (nth 1 expr)) (nth 2 expr)) (list '/ (nth 2 (nth 1 expr)) (nth 2 expr)) nil (eq (car (nth 1 expr)) '-))) + ((and (eq calc-matrix-mode 'matrix) + (eq (car-safe expr) '^) + (natnump (nth 2 expr)) + (> (nth 2 expr) 1) + (memq (car-safe (nth 1 expr)) '(+ -))) + (if (= (nth 2 expr) 2) + (math-add-or-sub (list '* (nth 1 (nth 1 expr)) (nth 1 expr)) + (list '* (nth 2 (nth 1 expr)) (nth 1 expr)) + nil (eq (car (nth 1 expr)) '-)) + (math-add-or-sub (list '* (nth 1 (nth 1 expr)) (list '^ (nth 1 expr) + (1- (nth 2 expr)))) + (list '* (nth 2 (nth 1 expr)) (list '^ (nth 1 expr) + (1- (nth 2 expr)))) + nil (eq (car (nth 1 expr)) '-)))) ((and (eq (car-safe expr) '^) (memq (car-safe (nth 1 expr)) '(+ -)) (integerp (nth 2 expr)) - (if (> (nth 2 expr) 0) - (or (and (or (> math-mt-many 500000) (< math-mt-many -500000)) - (math-expand-power (nth 1 expr) (nth 2 expr) - nil t)) - (list '* - (nth 1 expr) - (list '^ (nth 1 expr) (1- (nth 2 expr))))) - (if (< (nth 2 expr) 0) - (list '/ 1 (list '^ (nth 1 expr) (- (nth 2 expr)))))))) + (if (and (eq calc-matrix-mode 'matrix) + (> (nth 2 expr) 1)) + (if (= (nth 2 expr) 2) + (math-add-or-sub (list '* (nth 1 (nth 1 expr)) (nth 1 expr)) + (list '* (nth 2 (nth 1 expr)) (nth 1 expr)) + nil (eq (car (nth 1 expr)) '-)) + (math-add-or-sub (list '* (nth 1 (nth 1 expr)) + (list '^ (nth 1 expr) + (1- (nth 2 expr)))) + (list '* (nth 2 (nth 1 expr)) + (list '^ (nth 1 expr) + (1- (nth 2 expr)))) + nil (eq (car (nth 1 expr)) '-))) + (if (> (nth 2 expr) 0) + (or (and (or (> math-mt-many 500000) (< math-mt-many -500000)) + (math-expand-power (nth 1 expr) (nth 2 expr) + nil t)) + (list '* + (nth 1 expr) + (list '^ (nth 1 expr) (1- (nth 2 expr))))) + (if (< (nth 2 expr) 0) + (list '/ 1 (list '^ (nth 1 expr) (- (nth 2 expr))))))))) (t expr))) (defun calcFunc-expand (expr &optional many) |