emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/lisp/calc/calc-arith.el [lexbind]


From: Miles Bader
Subject: [Emacs-diffs] Changes to emacs/lisp/calc/calc-arith.el [lexbind]
Date: Wed, 08 Dec 2004 19:40:43 -0500

Index: emacs/lisp/calc/calc-arith.el
diff -c emacs/lisp/calc/calc-arith.el:1.3.4.2 
emacs/lisp/calc/calc-arith.el:1.3.4.3
*** emacs/lisp/calc/calc-arith.el:1.3.4.2       Tue Oct 14 23:35:48 2003
--- emacs/lisp/calc/calc-arith.el       Wed Dec  8 23:36:21 2004
***************
*** 3,10 ****
  ;; Copyright (C) 1990, 1991, 1992, 1993, 2001 Free Software Foundation, Inc.
  
  ;; Author: David Gillespie <address@hidden>
! ;; Maintainers: D. Goel <address@hidden>
! ;;              Colin Walters <address@hidden>
  
  ;; This file is part of GNU Emacs.
  
--- 3,9 ----
  ;; Copyright (C) 1990, 1991, 1992, 1993, 2001 Free Software Foundation, Inc.
  
  ;; Author: David Gillespie <address@hidden>
! ;; Maintainer: Jay Belanger <address@hidden>
  
  ;; This file is part of GNU Emacs.
  
***************
*** 28,38 ****
  ;;; Code:
  
  ;; This file is autoloaded from calc-ext.el.
- (require 'calc-ext)
  
  (require 'calc-macs)
  
! (defun calc-Need-calc-arith () nil)
  
  
  ;;; Arithmetic.
--- 27,99 ----
  ;;; Code:
  
  ;; This file is autoloaded from calc-ext.el.
  
+ (require 'calc-ext)
  (require 'calc-macs)
  
! ;;; The following lists are not exhaustive.
! (defvar math-scalar-functions '(calcFunc-det
!                               calcFunc-cnorm calcFunc-rnorm
!                               calcFunc-vlen calcFunc-vcount
!                               calcFunc-vsum calcFunc-vprod
!                               calcFunc-vmin calcFunc-vmax))
! 
! (defvar math-nonscalar-functions '(vec calcFunc-idn calcFunc-diag
!                                      calcFunc-cvec calcFunc-index
!                                      calcFunc-trn
!                                      | calcFunc-append
!                                      calcFunc-cons calcFunc-rcons
!                                      calcFunc-tail calcFunc-rhead))
! 
! (defvar math-scalar-if-args-functions '(+ - * / neg))
! 
! (defvar math-real-functions '(calcFunc-arg
!                             calcFunc-re calcFunc-im
!                             calcFunc-floor calcFunc-ceil
!                             calcFunc-trunc calcFunc-round
!                             calcFunc-rounde calcFunc-roundu
!                             calcFunc-ffloor calcFunc-fceil
!                             calcFunc-ftrunc calcFunc-fround
!                             calcFunc-frounde calcFunc-froundu))
! 
! (defvar math-positive-functions '())
! 
! (defvar math-nonnegative-functions '(calcFunc-cnorm calcFunc-rnorm
!                                    calcFunc-vlen calcFunc-vcount))
! 
! (defvar math-real-scalar-functions '(% calcFunc-idiv calcFunc-abs
!                                      calcFunc-choose calcFunc-perm
!                                      calcFunc-eq calcFunc-neq
!                                      calcFunc-lt calcFunc-gt
!                                      calcFunc-leq calcFunc-geq
!                                      calcFunc-lnot
!                                      calcFunc-max calcFunc-min))
! 
! (defvar math-real-if-arg-functions '(calcFunc-sin calcFunc-cos
!                                    calcFunc-tan calcFunc-arctan
!                                    calcFunc-sinh calcFunc-cosh
!                                    calcFunc-tanh calcFunc-exp
!                                    calcFunc-gamma calcFunc-fact))
! 
! (defvar math-integer-functions '(calcFunc-idiv
!                                calcFunc-isqrt calcFunc-ilog
!                                calcFunc-vlen calcFunc-vcount))
! 
! (defvar math-num-integer-functions '())
! 
! (defvar math-rounding-functions '(calcFunc-floor
!                                 calcFunc-ceil
!                                 calcFunc-round calcFunc-trunc
!                                 calcFunc-rounde calcFunc-roundu))
! 
! (defvar math-float-rounding-functions '(calcFunc-ffloor
!                                       calcFunc-fceil
!                                       calcFunc-fround calcFunc-ftrunc
!                                       calcFunc-frounde calcFunc-froundu))
! 
! (defvar math-integer-if-args-functions '(+ - * % neg calcFunc-abs
!                                          calcFunc-min calcFunc-max
!                                          calcFunc-choose calcFunc-perm))
  
  
  ;;; Arithmetic.
***************
*** 164,169 ****
--- 225,243 ----
  ;;;       TYPES is a list of type symbols (any, int, frac, ...)
  ;;;     RANGE is a sorted vector of intervals describing the range.
  
+ (defvar math-super-types
+   '((int numint rat real number)
+     (numint real number)
+     (frac rat real number)
+     (rat real number)
+     (float real number)
+     (real number)
+     (number)
+     (scalar)
+     (matrix vector)
+     (vector)
+     (const)))
+ 
  (defun math-setup-declarations ()
    (or (eq math-decls-cache-tag (calc-var-value 'var-Decls))
        (let ((p (calc-var-value 'var-Decls))
***************
*** 214,232 ****
                      (error nil)))))
        (setq math-decls-all (assq 'var-All math-decls-cache)))))
  
- (defvar math-super-types
-   '((int numint rat real number)
-     (numint real number)
-     (frac rat real number)
-     (rat real number)
-     (float real number)
-     (real number)
-     (number)
-     (scalar)
-     (matrix vector)
-     (vector)
-     (const)))
- 
  (defun math-known-scalarp (a &optional assume-scalar)
    (math-setup-declarations)
    (if (if calc-matrix-mode
--- 288,293 ----
***************
*** 326,334 ****
               ((Math-negp a) 1)
               ((Math-zerop a) 2)
               ((eq (car a) 'intv)
!               (cond ((Math-zerop (nth 2 a)) 6)
!                     ((Math-zerop (nth 3 a)) 3)
!                     (t 7)))
               ((eq (car a) 'sdev)
                (if (math-known-realp (nth 1 a)) 7 15))
               (t 8)))
--- 387,398 ----
               ((Math-negp a) 1)
               ((Math-zerop a) 2)
               ((eq (car a) 'intv)
!               (cond 
!                  ((math-known-posp (nth 2 a)) 4)
!                  ((math-known-negp (nth 3 a)) 1)
!                  ((Math-zerop (nth 2 a)) 6)
!                  ((Math-zerop (nth 3 a)) 3)
!                  (t 7)))
               ((eq (car a) 'sdev)
                (if (math-known-realp (nth 1 a)) 7 15))
               (t 8)))
***************
*** 819,889 ****
        (math-reject-arg a 'objectp 'quiet))))
  
  
- ;;; The following lists are not exhaustive.
- (defvar math-scalar-functions '(calcFunc-det
-                               calcFunc-cnorm calcFunc-rnorm
-                               calcFunc-vlen calcFunc-vcount
-                               calcFunc-vsum calcFunc-vprod
-                               calcFunc-vmin calcFunc-vmax))
- 
- (defvar math-nonscalar-functions '(vec calcFunc-idn calcFunc-diag
-                                      calcFunc-cvec calcFunc-index
-                                      calcFunc-trn
-                                      | calcFunc-append
-                                      calcFunc-cons calcFunc-rcons
-                                      calcFunc-tail calcFunc-rhead))
- 
- (defvar math-scalar-if-args-functions '(+ - * / neg))
- 
- (defvar math-real-functions '(calcFunc-arg
-                             calcFunc-re calcFunc-im
-                             calcFunc-floor calcFunc-ceil
-                             calcFunc-trunc calcFunc-round
-                             calcFunc-rounde calcFunc-roundu
-                             calcFunc-ffloor calcFunc-fceil
-                             calcFunc-ftrunc calcFunc-fround
-                             calcFunc-frounde calcFunc-froundu))
- 
- (defvar math-positive-functions '())
- 
- (defvar math-nonnegative-functions '(calcFunc-cnorm calcFunc-rnorm
-                                    calcFunc-vlen calcFunc-vcount))
- 
- (defvar math-real-scalar-functions '(% calcFunc-idiv calcFunc-abs
-                                      calcFunc-choose calcFunc-perm
-                                      calcFunc-eq calcFunc-neq
-                                      calcFunc-lt calcFunc-gt
-                                      calcFunc-leq calcFunc-geq
-                                      calcFunc-lnot
-                                      calcFunc-max calcFunc-min))
- 
- (defvar math-real-if-arg-functions '(calcFunc-sin calcFunc-cos
-                                    calcFunc-tan calcFunc-arctan
-                                    calcFunc-sinh calcFunc-cosh
-                                    calcFunc-tanh calcFunc-exp
-                                    calcFunc-gamma calcFunc-fact))
- 
- (defvar math-integer-functions '(calcFunc-idiv
-                                calcFunc-isqrt calcFunc-ilog
-                                calcFunc-vlen calcFunc-vcount))
- 
- (defvar math-num-integer-functions '())
- 
- (defvar math-rounding-functions '(calcFunc-floor
-                                 calcFunc-ceil
-                                 calcFunc-round calcFunc-trunc
-                                 calcFunc-rounde calcFunc-roundu))
- 
- (defvar math-float-rounding-functions '(calcFunc-ffloor
-                                       calcFunc-fceil
-                                       calcFunc-fround calcFunc-ftrunc
-                                       calcFunc-frounde calcFunc-froundu))
- 
- (defvar math-integer-if-args-functions '(+ - * % neg calcFunc-abs
-                                          calcFunc-min calcFunc-max
-                                          calcFunc-choose calcFunc-perm))
- 
- 
  ;;;; Arithmetic.
  
  (defsubst calcFunc-neg (a)
--- 883,888 ----
***************
*** 1742,1764 ****
    (math-normalize (list '^ a b)))
  
  (defun math-pow-of-zero (a b)
!   (if (Math-zerop b)
!       (if calc-infinite-mode
!         '(var nan var-nan)
!       (math-reject-arg (list '^ a b) "*Indeterminate form"))
!     (if (math-floatp b) (setq a (math-float a)))
!     (if (math-posp b)
!       a
!       (if (math-negp b)
!         (math-div 1 a)
!       (if (math-infinitep b)
!           '(var nan var-nan)
!         (if (and (eq (car b) 'intv) (math-intv-constp b)
!                  calc-infinite-mode)
!             '(intv 3 (neg (var inf var-inf)) (var inf var-inf))
!           (if (math-objectp b)
!               (list '^ a b)
!             a)))))))
  
  (defun math-pow-zero (a b)
    (if (eq (car-safe a) 'mod)
--- 1741,1775 ----
    (math-normalize (list '^ a b)))
  
  (defun math-pow-of-zero (a b)
!   "Raise A to the power of B, where A is a form of zero."
!   (if (math-floatp b) (setq a (math-float a)))
!   (cond
!    ;; 0^0 = 1
!    ((eq b 0)
!     1)
!    ;; 0^0.0, etc., are undetermined
!    ((Math-zerop b)
!     (if calc-infinite-mode
!         '(var nan var-nan)
!       (math-reject-arg (list '^ a b) "*Indeterminate form")))
!    ;; 0^positive = 0
!    ((math-known-posp b)
!     a)
!    ;; 0^negative is undefined (let math-div handle it)
!    ((math-known-negp b)
!     (math-div 1 a))
!    ;; 0^infinity is undefined
!    ((math-infinitep b)
!     '(var nan var-nan))
!    ;; Some intervals
!    ((and (eq (car b) 'intv)
!          calc-infinite-mode
!          (math-negp (nth 2 b))
!          (math-posp (nth 3 b)))
!     '(intv 3 (neg (var inf var-inf)) (var inf var-inf)))
!    ;; If none of the above, leave it alone.
!    (t
!     (list '^ a b))))
  
  (defun math-pow-zero (a b)
    (if (eq (car-safe a) 'mod)
***************
*** 2185,2190 ****
--- 2196,2205 ----
  
  (defalias 'calcFunc-float 'math-float)
  
+ ;; The variable math-trunc-prec is local to math-trunc in calc-misc.el, 
+ ;; but used by math-trunc-fancy which is called by math-trunc.
+ (defvar math-trunc-prec)
+ 
  (defun math-trunc-fancy (a)
    (cond ((eq (car a) 'frac) (math-quotient (nth 1 a) (nth 2 a)))
        ((eq (car a) 'cplx) (math-trunc (nth 1 a)))
***************
*** 2214,2220 ****
                           (math-trunc (nth 3 a)))))
        ((math-provably-integerp a) a)
        ((Math-vectorp a)
!        (math-map-vec (function (lambda (x) (math-trunc x prec))) a))
        ((math-infinitep a)
         (if (or (math-posp a) (math-negp a))
             a
--- 2229,2235 ----
                           (math-trunc (nth 3 a)))))
        ((math-provably-integerp a) a)
        ((Math-vectorp a)
!        (math-map-vec (function (lambda (x) (math-trunc x math-trunc-prec))) 
a))
        ((math-infinitep a)
         (if (or (math-posp a) (math-negp a))
             a
***************
*** 2251,2256 ****
--- 2266,2275 ----
        a
      (math-float (math-trunc a prec))))
  
+ ;; The variable math-floor-prec is local to math-floor in calc-misc.el,
+ ;; but used by math-floor-fancy which is called by math-floor.
+ (defvar math-floor-prec)
+ 
  (defun math-floor-fancy (a)
    (cond ((math-provably-integerp a) a)
        ((eq (car a) 'hms)
***************
*** 2273,2279 ****
                             (math-add (math-floor (nth 3 a)) -1)
                           (math-floor (nth 3 a)))))
        ((Math-vectorp a)
!        (math-map-vec (function (lambda (x) (math-floor x prec))) a))
        ((math-infinitep a)
         (if (or (math-posp a) (math-negp a))
             a
--- 2292,2298 ----
                             (math-add (math-floor (nth 3 a)) -1)
                           (math-floor (nth 3 a)))))
        ((Math-vectorp a)
!        (math-map-vec (function (lambda (x) (math-floor x math-floor-prec))) 
a))
        ((math-infinitep a)
         (if (or (math-posp a) (math-negp a))
             a
***************
*** 2629,2634 ****
--- 2648,2658 ----
  (defvar math-combine-prod-e '(var e var-e))
  
  ;;; The following is expanded out four ways for speed.
+ 
+ ;; math-unit-prefixes is defined in calc-units.el,
+ ;; but used here.
+ (defvar math-unit-prefixes)
+ 
  (defun math-combine-prod (a b inva invb scalar-okay)
    (cond
     ((or (and inva (Math-zerop a))
***************
*** 2761,2783 ****
          (math-div a b)
        (math-mul a b)))))
  
  (defun math-commutative-equal (a b)
    (if (memq (car-safe a) '(+ -))
        (and (memq (car-safe b) '(+ -))
!          (let ((bterms nil) aterms p)
             (math-commutative-collect b nil)
!            (setq aterms bterms bterms nil)
             (math-commutative-collect a nil)
!            (and (= (length aterms) (length bterms))
                  (progn
                    (while (and aterms
                                (progn
!                                 (setq p bterms)
                                  (while (and p (not (equal (car aterms)
                                                            (car p))))
                                    (setq p (cdr p)))
                                  p))
!                     (setq bterms (delq (car p) bterms)
                            aterms (cdr aterms)))
                    (not aterms)))))
      (equal a b)))
--- 2785,2812 ----
          (math-div a b)
        (math-mul a b)))))
  
+ ;; The variable math-com-bterms is local to math-commutative-equal,
+ ;; but is used by math-commutative collect, which is called by
+ ;; math-commutative-equal.
+ (defvar math-com-bterms)
+ 
  (defun math-commutative-equal (a b)
    (if (memq (car-safe a) '(+ -))
        (and (memq (car-safe b) '(+ -))
!          (let ((math-com-bterms nil) aterms p)
             (math-commutative-collect b nil)
!            (setq aterms math-com-bterms math-com-bterms nil)
             (math-commutative-collect a nil)
!            (and (= (length aterms) (length math-com-bterms))
                  (progn
                    (while (and aterms
                                (progn
!                                 (setq p math-com-bterms)
                                  (while (and p (not (equal (car aterms)
                                                            (car p))))
                                    (setq p (cdr p)))
                                  p))
!                     (setq math-com-bterms (delq (car p) math-com-bterms)
                            aterms (cdr aterms)))
                    (not aterms)))))
      (equal a b)))
***************
*** 2791,2797 ****
        (progn
          (math-commutative-collect (nth 1 b) neg)
          (math-commutative-collect (nth 2 b) (not neg)))
!       (setq bterms (cons (if neg (math-neg b) b) bterms)))))
  
  ;;; arch-tag: 6c396b5b-14c6-40ed-bb2a-7cc2e8111465
  ;;; calc-arith.el ends here
--- 2820,2828 ----
        (progn
          (math-commutative-collect (nth 1 b) neg)
          (math-commutative-collect (nth 2 b) (not neg)))
!       (setq math-com-bterms (cons (if neg (math-neg b) b) math-com-bterms)))))
! 
! (provide 'calc-arith)
  
  ;;; arch-tag: 6c396b5b-14c6-40ed-bb2a-7cc2e8111465
  ;;; calc-arith.el ends here




reply via email to

[Prev in Thread] Current Thread [Next in Thread]