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 ;; Maintainers: D. Goel <deego@gnufans.org>
7 ;; Colin Walters <walters@debian.org>
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is distributed in the hope that it will be useful,
12 ;; but WITHOUT ANY WARRANTY. No author or distributor
13 ;; accepts responsibility to anyone for the consequences of using it
14 ;; or for whether it serves any particular purpose or works at all,
15 ;; unless he says so in writing. Refer to the GNU Emacs General Public
16 ;; License for full details.
18 ;; Everyone is granted permission to copy, modify and redistribute
19 ;; GNU Emacs, but only under the conditions described in the
20 ;; GNU Emacs General Public License. A copy of this license is
21 ;; supposed to have been given to you along with GNU Emacs so you
22 ;; can know your rights and responsibilities. It should be in a
23 ;; file named COPYING. Among other things, the copyright notice
24 ;; and this notice must be preserved on all copies.
32 (defun calc-need-macros () nil)
34 (defmacro calc-wrapper (&rest body)
35 `(calc-do (function (lambda ()
38 (defmacro calc-slow-wrapper (&rest body)
40 (function (lambda () ,@body)) (point)))
42 (defmacro math-showing-full-precision (form)
43 `(let ((calc-float-format calc-full-float-format))
46 (defmacro math-with-extra-prec (delta &rest body)
48 (let ((calc-internal-prec (+ calc-internal-prec ,delta)))
51 (defmacro math-working (msg arg) ; [Public]
52 `(if (eq calc-display-working-message 'lots)
53 (math-do-working ,msg ,arg)))
55 (defmacro calc-with-default-simplification (&rest body)
56 `(let ((calc-simplify-mode (and (not (memq calc-simplify-mode '(none num)))
60 (defmacro calc-with-trail-buffer (&rest body)
61 `(let ((save-buf (current-buffer))
62 (calc-command-flags nil))
63 (with-current-buffer (calc-trail-display t)
65 (goto-char calc-trail-pointer)
68 ;;; Faster in-line version zerop, normalized values only.
69 (defsubst Math-zerop (a) ; [P N]
71 (and (not (memq (car a) '(bigpos bigneg)))
72 (if (eq (car a) 'float)
77 (defsubst Math-integer-negp (a)
82 (defsubst Math-integer-posp (a)
87 (defsubst Math-negp (a)
89 (or (eq (car a) 'bigneg)
90 (and (not (eq (car a) 'bigpos))
91 (if (memq (car a) '(frac float))
92 (Math-integer-negp (nth 1 a))
96 (defsubst Math-looks-negp (a) ; [P x] [Public]
98 (and (consp a) (or (eq (car a) 'neg)
99 (and (memq (car a) '(* /))
100 (or (math-looks-negp (nth 1 a))
101 (math-looks-negp (nth 2 a))))))))
103 (defsubst Math-posp (a)
105 (or (eq (car a) 'bigpos)
106 (and (not (eq (car a) 'bigneg))
107 (if (memq (car a) '(frac float))
108 (Math-integer-posp (nth 1 a))
112 (defsubst Math-integerp (a)
114 (memq (car a) '(bigpos bigneg))))
116 (defsubst Math-natnump (a)
121 (defsubst Math-ratp (a)
123 (memq (car a) '(bigpos bigneg frac))))
125 (defsubst Math-realp (a)
127 (memq (car a) '(bigpos bigneg frac float))))
129 (defsubst Math-anglep (a)
131 (memq (car a) '(bigpos bigneg frac float hms))))
133 (defsubst Math-numberp (a)
135 (memq (car a) '(bigpos bigneg frac float cplx polar))))
137 (defsubst Math-scalarp (a)
139 (memq (car a) '(bigpos bigneg frac float cplx polar hms))))
141 (defsubst Math-vectorp (a)
142 (and (consp a) (eq (car a) 'vec)))
144 (defsubst Math-messy-integerp (a)
149 (defsubst Math-objectp (a) ; [Public]
152 '(bigpos bigneg frac float cplx polar hms date sdev intv mod))))
154 (defsubst Math-objvecp (a) ; [Public]
157 '(bigpos bigneg frac float cplx polar hms date
158 sdev intv mod vec))))
160 ;;; Compute the negative of A. [O O; o o] [Public]
161 (defsubst Math-integer-neg (a)
163 (if (eq (car a) 'bigpos)
164 (cons 'bigneg (cdr a))
165 (cons 'bigpos (cdr a)))
168 (defsubst Math-equal (a b)
169 (= (math-compare a b) 0))
171 (defsubst Math-lessp (a b)
172 (= (math-compare a b) -1))
174 (defsubst Math-primp (a)
176 (memq (car a) '(bigpos bigneg frac float cplx polar
179 (defsubst Math-num-integerp (a)
181 (memq (car a) '(bigpos bigneg))
182 (and (eq (car a) 'float)
185 (defsubst Math-bignum-test (a) ; [B N; B s; b b]
190 (defsubst Math-equal-int (a b)
197 (defsubst Math-natnum-lessp (a b)
200 (= (math-compare-bignum (cdr a) (cdr b)) -1))
204 ;;; arch-tag: 08ba8ec2-fcff-4b80-a079-ec661bdb057e
205 ;;; calc-macs.el ends here