Update copyright year.
[bpt/emacs.git] / lisp / calc / calc-arith.el
index f8057c5..2372b0e 100644 (file)
@@ -1,7 +1,7 @@
 ;;; calc-arith.el --- arithmetic functions for Calc
 
 ;; Copyright (C) 1990, 1991, 1992, 1993, 2001, 2002, 2003, 2004,
-;;   2005 Free Software Foundation, Inc.
+;;   2005, 2006 Free Software Foundation, Inc.
 
 ;; Author: David Gillespie <daveg@synaptics.com>
 ;; Maintainer: Jay Belanger <belanger@truman.edu>
          t)
         ((eq (car-safe a) '^)
          (math-check-known-square-matrixp (nth 1 a)))
+        ((or
+          (eq (car-safe a) '*)
+          (eq (car-safe a) '+)
+          (eq (car-safe a) '-))
+         (and
+          (math-check-known-square-matrixp (nth 1 a))
+          (math-check-known-square-matrixp (nth 2 a))))
         (t
          (let ((decl (if (eq (car a) 'var)
                          (or (assq (nth 2 a) math-decls-cache)
               (and (math-known-scalarp b)
                    (math-add (nth 1 a) b))))
       (and (eq (car-safe b) 'calcFunc-idn)
-          (= (length a) 2)
+          (= (length b) 2)
           (or (and (math-square-matrixp a)
                    (math-add a (math-mimic-ident (nth 1 b) a)))
               (and (math-known-scalarp a)
               (math-mul-zero b a))))
       (list '/ a b)))
 
+;;; Division from the left.
+(defun calcFunc-ldiv (a b)
+  (if (math-known-scalarp a)
+      (math-div b a)
+    (math-mul (math-pow a -1) b)))
 
 (defun calcFunc-mod (a b)
   (math-normalize (list '% a b)))
                   (if (and (= b -1)
                            (math-known-square-matrixp (nth 1 a))
                            (math-known-square-matrixp (nth 2 a)))
-                      (list '* (list '^ (nth 2 a) -1) (list '^ (nth 1 a) -1))
+                      (math-mul (math-pow-fancy (nth 2 a) -1) 
+                                (math-pow-fancy (nth 1 a) -1))
                     (list '^ a b)))
                 ((and (eq (car-safe a) '*)
                       (or (math-known-num-integerp b)