1 ;;; calc-macs.el --- important macros for Calc
3 ;; Copyright (C) 1990, 1991, 1992, 1993, 2001 Free Software Foundation, Inc.
5 ;; Author: David Gillespie <daveg@synaptics.com>
6 ;; Maintainer: Jay Belanger <belanger@truman.edu>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is distributed in the hope that it will be useful,
11 ;; but WITHOUT ANY WARRANTY. No author or distributor
12 ;; accepts responsibility to anyone for the consequences of using it
13 ;; or for whether it serves any particular purpose or works at all,
14 ;; unless he says so in writing. Refer to the GNU Emacs General Public
15 ;; License for full details.
17 ;; Everyone is granted permission to copy, modify and redistribute
18 ;; GNU Emacs, but only under the conditions described in the
19 ;; GNU Emacs General Public License. A copy of this license is
20 ;; supposed to have been given to you along with GNU Emacs so you
21 ;; can know your rights and responsibilities. It should be in a
22 ;; file named COPYING. Among other things, the copyright notice
23 ;; and this notice must be preserved on all copies.
29 (defmacro calc-wrapper
(&rest body
)
30 `(calc-do (function (lambda ()
33 (defmacro calc-slow-wrapper
(&rest body
)
35 (function (lambda () ,@body
)) (point)))
37 (defmacro math-showing-full-precision
(form)
38 `(let ((calc-float-format calc-full-float-format
))
41 (defmacro math-with-extra-prec
(delta &rest body
)
43 (let ((calc-internal-prec (+ calc-internal-prec
,delta
)))
46 (defmacro math-working
(msg arg
) ; [Public]
47 `(if (eq calc-display-working-message
'lots
)
48 (math-do-working ,msg
,arg
)))
50 (defmacro calc-with-default-simplification
(&rest body
)
51 `(let ((calc-simplify-mode (and (not (memq calc-simplify-mode
'(none num
)))
55 (defmacro calc-with-trail-buffer
(&rest body
)
56 `(let ((save-buf (current-buffer))
57 (calc-command-flags nil
))
58 (with-current-buffer (calc-trail-display t
)
60 (goto-char calc-trail-pointer
)
63 ;;; Faster in-line version zerop, normalized values only.
64 (defsubst Math-zerop
(a) ; [P N]
66 (and (not (memq (car a
) '(bigpos bigneg
)))
67 (if (eq (car a
) 'float
)
72 (defsubst Math-integer-negp
(a)
77 (defsubst Math-integer-posp
(a)
82 (defsubst Math-negp
(a)
84 (or (eq (car a
) 'bigneg
)
85 (and (not (eq (car a
) 'bigpos
))
86 (if (memq (car a
) '(frac float
))
87 (Math-integer-negp (nth 1 a
))
91 (defsubst Math-looks-negp
(a) ; [P x] [Public]
93 (and (consp a
) (or (eq (car a
) 'neg
)
94 (and (memq (car a
) '(* /))
95 (or (math-looks-negp (nth 1 a
))
96 (math-looks-negp (nth 2 a
))))))))
98 (defsubst Math-posp
(a)
100 (or (eq (car a
) 'bigpos
)
101 (and (not (eq (car a
) 'bigneg
))
102 (if (memq (car a
) '(frac float
))
103 (Math-integer-posp (nth 1 a
))
107 (defsubst Math-integerp
(a)
109 (memq (car a
) '(bigpos bigneg
))))
111 (defsubst Math-natnump
(a)
116 (defsubst Math-ratp
(a)
118 (memq (car a
) '(bigpos bigneg frac
))))
120 (defsubst Math-realp
(a)
122 (memq (car a
) '(bigpos bigneg frac float
))))
124 (defsubst Math-anglep
(a)
126 (memq (car a
) '(bigpos bigneg frac float hms
))))
128 (defsubst Math-numberp
(a)
130 (memq (car a
) '(bigpos bigneg frac float cplx polar
))))
132 (defsubst Math-scalarp
(a)
134 (memq (car a
) '(bigpos bigneg frac float cplx polar hms
))))
136 (defsubst Math-vectorp
(a)
137 (and (consp a
) (eq (car a
) 'vec
)))
139 (defsubst Math-messy-integerp
(a)
144 (defsubst Math-objectp
(a) ; [Public]
147 '(bigpos bigneg frac float cplx polar hms date sdev intv mod
))))
149 (defsubst Math-objvecp
(a) ; [Public]
152 '(bigpos bigneg frac float cplx polar hms date
153 sdev intv mod vec
))))
155 ;;; Compute the negative of A. [O O; o o] [Public]
156 (defsubst Math-integer-neg
(a)
158 (if (eq (car a
) 'bigpos
)
159 (cons 'bigneg
(cdr a
))
160 (cons 'bigpos
(cdr a
)))
163 (defsubst Math-equal
(a b
)
164 (= (math-compare a b
) 0))
166 (defsubst Math-lessp
(a b
)
167 (= (math-compare a b
) -
1))
169 (defsubst Math-primp
(a)
171 (memq (car a
) '(bigpos bigneg frac float cplx polar
174 (defsubst Math-num-integerp
(a)
176 (memq (car a
) '(bigpos bigneg
))
177 (and (eq (car a
) 'float
)
180 (defsubst Math-bignum-test
(a) ; [B N; B s; b b]
185 (defsubst Math-equal-int
(a b
)
192 (defsubst Math-natnum-lessp
(a b
)
195 (= (math-compare-bignum (cdr a
) (cdr b
)) -
1))
201 ;;; arch-tag: 08ba8ec2-fcff-4b80-a079-ec661bdb057e
202 ;;; calc-macs.el ends here