]> git.eshelyaron.com Git - emacs.git/commitdiff
(math-expand-term): Multiply out the powers when in matrix mode.
authorJay Belanger <jay.p.belanger@gmail.com>
Wed, 7 Sep 2005 19:29:38 +0000 (19:29 +0000)
committerJay Belanger <jay.p.belanger@gmail.com>
Wed, 7 Sep 2005 19:29:38 +0000 (19:29 +0000)
lisp/ChangeLog
lisp/calc/calc-poly.el

index bd0c2e87e7072a7326c99fea1207dabe0d283acf..89dc0c3a3df75078ca70c68d56a65ce58184ee30 100644 (file)
@@ -1,3 +1,8 @@
+2005-09-07  Jay Belanger  <belanger@truman.edu>
+
+       * calc/calc-poly.el (math-expand-term): Multiply out any powers
+       when in matrix mode.
+
 2005-09-08  Chong Yidong  <cyd@stupidchicken.com>
 
        * buff-menu.el (Buffer-menu-sort-by-column): New function.
index 3dd19b6f67a2cf0783a907d20965411211c319eb..e27705de98aec679acc838a38ab4f190c8665d00 100644 (file)
         (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)