Show
Ignore:
Timestamp:
2005年11月02日 00時34分59秒 (3 years ago)
Author:
miyoshi
Message:

Sync up with Emacs CVS HEAD.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lisp/calc/calc-arith.el

    r3801 r3945  
    240240    (number) 
    241241    (scalar) 
     242    (sqmatrix matrix vector) 
    242243    (matrix vector) 
    243244    (vector) 
     
    306307       (not (math-known-scalarp a t)))) 
    307308 
     309(defun math-known-square-matrixp (a) 
     310  (and (math-known-matrixp a) 
     311       (math-check-known-square-matrixp a))) 
     312 
    308313;;; Try to prove that A is a scalar (i.e., a non-vector). 
    309314(defun math-check-known-scalarp (a) 
     
    324329                         (or (assq (nth 2 a) math-decls-cache) 
    325330                             math-decls-all) 
    326                        (assq (car a) math-decls-cache)))) 
    327            (memq 'scalar (nth 1 decl)))))) 
     331                       (assq (car a) math-decls-cache))) 
     332               val) 
     333           (cond 
     334            ((memq 'scalar (nth 1 decl)) 
     335             t) 
     336            ((and (eq (car a) 'var) 
     337                  (boundp (nth 2 a)) 
     338                  (setq val (symbol-value (nth 2 a)))) 
     339             (math-check-known-scalarp val)) 
     340            (t 
     341             nil)))))) 
    328342 
    329343;;; Try to prove that A is *not* a scalar. 
     
    343357                         (or (assq (nth 2 a) math-decls-cache) 
    344358                             math-decls-all) 
    345                        (assq (car a) math-decls-cache)))) 
    346            (memq 'vector (nth 1 decl)))))) 
    347  
     359                       (assq (car a) math-decls-cache))) 
     360               val) 
     361           (cond 
     362            ((memq 'matrix (nth 1 decl)) 
     363             t) 
     364            ((and (eq (car a) 'var) 
     365                  (boundp (nth 2 a)) 
     366                  (setq val (symbol-value (nth 2 a)))) 
     367             (math-check-known-matrixp val)) 
     368            (t 
     369             nil)))))) 
     370 
     371;;; Given that A is a matrix, try to prove that it is a square matrix. 
     372(defun math-check-known-square-matrixp (a) 
     373  (cond ((math-square-matrixp a) 
     374         t) 
     375        ((eq (car-safe a) '^) 
     376         (math-check-known-square-matrixp (nth 1 a))) 
     377        (t 
     378         (let ((decl (if (eq (car a) 'var) 
     379                         (or (assq (nth 2 a) math-decls-cache) 
     380                             math-decls-all) 
     381                       (assq (car a) math-decls-cache))) 
     382               val) 
     383           (cond 
     384            ((memq 'sqmatrix (nth 1 decl)) 
     385             t) 
     386            ((and (eq (car a) 'var) 
     387                  (boundp (nth 2 a)) 
     388                  (setq val (symbol-value (nth 2 a)))) 
     389             (math-check-known-square-matrixp val)) 
     390            ((and (or 
     391                   (integerp calc-matrix-mode) 
     392                   (eq calc-matrix-mode 'sqmatrix)) 
     393                  (eq (car-safe a) 'var)) 
     394             t) 
     395            ((memq 'matrix (nth 1 decl)) 
     396             nil) 
     397            (t 
     398             nil)))))) 
    348399 
    349400;;; Try to prove that A is a real (i.e., not complex). 
     
    13361387           (Math-looks-negp (nth 2 b)) 
    13371388           (not (and (eq (car-safe a) '^) (Math-looks-negp (nth 2 a)))) 
     1389           (not (math-known-matrixp (nth 1 b))) 
    13381390           (math-div a (math-normalize 
    13391391                        (list '^ (nth 1 b) (math-neg (nth 2 b)))))) 
     
    13771429               (and (math-known-matrixp a) 
    13781430                    (math-mul a (nth 1 b))))) 
     1431      (and (math-identity-matrix-p a t) 
     1432           (or (and (eq (car-safe b) 'calcFunc-idn) 
     1433                    (= (length b) 2) 
     1434                    (list 'calcFunc-idn (math-mul  
     1435                                         (nth 1 (nth 1 a)) 
     1436                                         (nth 1 b)) 
     1437                          (1- (length a)))) 
     1438               (and (math-known-scalarp b) 
     1439                    (list 'calcFunc-idn (math-mul  
     1440                                         (nth 1 (nth 1 a)) b) 
     1441                          (1- (length a)))) 
     1442               (and (math-known-matrixp b) 
     1443                    (math-mul (nth 1 (nth 1 a)) b)))) 
     1444      (and (math-identity-matrix-p b t) 
     1445           (or (and (eq (car-safe a) 'calcFunc-idn) 
     1446                    (= (length a) 2) 
     1447                    (list 'calcFunc-idn (math-mul (nth 1 a)  
     1448                                                  (nth 1 (nth 1 b))) 
     1449                          (1- (length b)))) 
     1450               (and (math-known-scalarp a) 
     1451                    (list 'calcFunc-idn (math-mul a (nth 1 (nth 1 b)))  
     1452                          (1- (length b)))) 
     1453               (and (math-known-matrixp a) 
     1454                    (math-mul a (nth 1 (nth 1 b)))))) 
    13791455      (and (math-looks-negp b) 
    13801456           (math-mul (math-neg a) (math-neg b))) 
     
    16561732 
    16571733(defun math-div-symb-fancy (a b) 
    1658   (or (and math-simplify-only 
     1734  (or (and (math-known-matrixp b) 
     1735           (math-mul a (math-pow b -1))) 
     1736      (and math-simplify-only 
    16591737           (not (equal a math-simplify-only)) 
    16601738           (list '/ a b)) 
     
    18701948                       (not (equal a math-simplify-only))) 
    18711949                  (list '^ a b)) 
     1950                 ((and (eq (car-safe a) '*) 
     1951                       (or  
     1952                        (and 
     1953                         (math-known-matrixp (nth 1 a)) 
     1954                         (math-known-matrixp (nth 2 a))) 
     1955                        (and 
     1956                         calc-matrix-mode 
     1957                         (not (eq calc-matrix-mode 'scalar)) 
     1958                         (and (not (math-known-scalarp (nth 1 a))) 
     1959                              (not (math-known-scalarp (nth 2 a))))))) 
     1960                  (if (and (= b -1) 
     1961                           (math-known-square-matrixp (nth 1 a)) 
     1962                           (math-known-square-matrixp (nth 2 a))) 
     1963                      (list '* (list '^ (nth 2 a) -1) (list '^ (nth 1 a) -1)) 
     1964                    (list '^ a b))) 
    18721965                 ((and (eq (car-safe a) '*) 
    18731966                       (or (math-known-num-integerp b)