comparison lisp/calc/calc-poly.el @ 65356:22640ddbd499

(math-expand-term): Multiply out the powers when in matrix mode.
author Jay Belanger <jay.p.belanger@gmail.com>
date Wed, 07 Sep 2005 19:27:11 +0000
parents 1db49616ce05
children a15a1dd65d9e 10fe5fadaf89
comparison
equal deleted inserted replaced
65355:d96b22b8de33 65356:22640ddbd499
1067 ((and (eq (car-safe expr) '/) 1067 ((and (eq (car-safe expr) '/)
1068 (memq (car-safe (nth 1 expr)) '(+ -))) 1068 (memq (car-safe (nth 1 expr)) '(+ -)))
1069 (math-add-or-sub (list '/ (nth 1 (nth 1 expr)) (nth 2 expr)) 1069 (math-add-or-sub (list '/ (nth 1 (nth 1 expr)) (nth 2 expr))
1070 (list '/ (nth 2 (nth 1 expr)) (nth 2 expr)) 1070 (list '/ (nth 2 (nth 1 expr)) (nth 2 expr))
1071 nil (eq (car (nth 1 expr)) '-))) 1071 nil (eq (car (nth 1 expr)) '-)))
1072 ((and (eq calc-matrix-mode 'matrix)
1073 (eq (car-safe expr) '^)
1074 (natnump (nth 2 expr))
1075 (> (nth 2 expr) 1)
1076 (memq (car-safe (nth 1 expr)) '(+ -)))
1077 (if (= (nth 2 expr) 2)
1078 (math-add-or-sub (list '* (nth 1 (nth 1 expr)) (nth 1 expr))
1079 (list '* (nth 2 (nth 1 expr)) (nth 1 expr))
1080 nil (eq (car (nth 1 expr)) '-))
1081 (math-add-or-sub (list '* (nth 1 (nth 1 expr)) (list '^ (nth 1 expr)
1082 (1- (nth 2 expr))))
1083 (list '* (nth 2 (nth 1 expr)) (list '^ (nth 1 expr)
1084 (1- (nth 2 expr))))
1085 nil (eq (car (nth 1 expr)) '-))))
1072 ((and (eq (car-safe expr) '^) 1086 ((and (eq (car-safe expr) '^)
1073 (memq (car-safe (nth 1 expr)) '(+ -)) 1087 (memq (car-safe (nth 1 expr)) '(+ -))
1074 (integerp (nth 2 expr)) 1088 (integerp (nth 2 expr))
1075 (if (> (nth 2 expr) 0) 1089 (if (and (eq calc-matrix-mode 'matrix)
1076 (or (and (or (> math-mt-many 500000) (< math-mt-many -500000)) 1090 (> (nth 2 expr) 1))
1077 (math-expand-power (nth 1 expr) (nth 2 expr) 1091 (if (= (nth 2 expr) 2)
1078 nil t)) 1092 (math-add-or-sub (list '* (nth 1 (nth 1 expr)) (nth 1 expr))
1079 (list '* 1093 (list '* (nth 2 (nth 1 expr)) (nth 1 expr))
1080 (nth 1 expr) 1094 nil (eq (car (nth 1 expr)) '-))
1081 (list '^ (nth 1 expr) (1- (nth 2 expr))))) 1095 (math-add-or-sub (list '* (nth 1 (nth 1 expr))
1082 (if (< (nth 2 expr) 0) 1096 (list '^ (nth 1 expr)
1083 (list '/ 1 (list '^ (nth 1 expr) (- (nth 2 expr)))))))) 1097 (1- (nth 2 expr))))
1098 (list '* (nth 2 (nth 1 expr))
1099 (list '^ (nth 1 expr)
1100 (1- (nth 2 expr))))
1101 nil (eq (car (nth 1 expr)) '-)))
1102 (if (> (nth 2 expr) 0)
1103 (or (and (or (> math-mt-many 500000) (< math-mt-many -500000))
1104 (math-expand-power (nth 1 expr) (nth 2 expr)
1105 nil t))
1106 (list '*
1107 (nth 1 expr)
1108 (list '^ (nth 1 expr) (1- (nth 2 expr)))))
1109 (if (< (nth 2 expr) 0)
1110 (list '/ 1 (list '^ (nth 1 expr) (- (nth 2 expr)))))))))
1084 (t expr))) 1111 (t expr)))
1085 1112
1086 (defun calcFunc-expand (expr &optional many) 1113 (defun calcFunc-expand (expr &optional many)
1087 (math-normalize (math-map-tree 'math-expand-term expr many))) 1114 (math-normalize (math-map-tree 'math-expand-term expr many)))
1088 1115