1 ;;; calc-macs.el --- important macros for Calc
3 ;; Copyright (C) 1990, 1991, 1992, 1993, 2001, 2002, 2003, 2004,
4 ;; 2005, 2006, 2007 Free Software Foundation, Inc.
6 ;; Author: David Gillespie <daveg@synaptics.com>
7 ;; Maintainer: Jay Belanger <belanger@truman.edu>
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 ;; Boston, MA 02110-1301, USA.
30 (defmacro calc-wrapper (&rest body)
31 `(calc-do (function (lambda ()
34 (defmacro calc-slow-wrapper (&rest body)
36 (function (lambda () ,@body)) (point)))
38 (defmacro math-showing-full-precision (form)
39 `(let ((calc-float-format calc-full-float-format))
42 (defmacro math-with-extra-prec (delta &rest body)
44 (let ((calc-internal-prec (+ calc-internal-prec ,delta)))
47 (defmacro math-working (msg arg) ; [Public]
48 `(if (eq calc-display-working-message 'lots)
49 (math-do-working ,msg ,arg)))
51 (defmacro calc-with-default-simplification (&rest body)
52 `(let ((calc-simplify-mode (and (not (memq calc-simplify-mode '(none num)))
56 (defmacro calc-with-trail-buffer (&rest body)
57 `(let ((save-buf (current-buffer))
58 (calc-command-flags nil))
59 (with-current-buffer (calc-trail-display t)
61 (goto-char calc-trail-pointer)
64 ;;; Faster in-line version zerop, normalized values only.
65 (defsubst Math-zerop (a) ; [P N]
67 (and (not (memq (car a) '(bigpos bigneg)))
68 (if (eq (car a) 'float)
73 (defsubst Math-integer-negp (a)
78 (defsubst Math-integer-posp (a)
83 (defsubst Math-negp (a)
85 (or (eq (car a) 'bigneg)
86 (and (not (eq (car a) 'bigpos))
87 (if (memq (car a) '(frac float))
88 (Math-integer-negp (nth 1 a))
92 (defsubst Math-looks-negp (a) ; [P x] [Public]
94 (and (consp a) (or (eq (car a) 'neg)
95 (and (memq (car a) '(* /))
96 (or (math-looks-negp (nth 1 a))
97 (math-looks-negp (nth 2 a))))))))
99 (defsubst Math-posp (a)
101 (or (eq (car a) 'bigpos)
102 (and (not (eq (car a) 'bigneg))
103 (if (memq (car a) '(frac float))
104 (Math-integer-posp (nth 1 a))
108 (defsubst Math-integerp (a)
110 (memq (car a) '(bigpos bigneg))))
112 (defsubst Math-natnump (a)
117 (defsubst Math-ratp (a)
119 (memq (car a) '(bigpos bigneg frac))))
121 (defsubst Math-realp (a)
123 (memq (car a) '(bigpos bigneg frac float))))
125 (defsubst Math-anglep (a)
127 (memq (car a) '(bigpos bigneg frac float hms))))
129 (defsubst Math-numberp (a)
131 (memq (car a) '(bigpos bigneg frac float cplx polar))))
133 (defsubst Math-scalarp (a)
135 (memq (car a) '(bigpos bigneg frac float cplx polar hms))))
137 (defsubst Math-vectorp (a)
138 (and (consp a) (eq (car a) 'vec)))
140 (defsubst Math-messy-integerp (a)
145 (defsubst Math-objectp (a) ; [Public]
148 '(bigpos bigneg frac float cplx polar hms date sdev intv mod))))
150 (defsubst Math-objvecp (a) ; [Public]
153 '(bigpos bigneg frac float cplx polar hms date
154 sdev intv mod vec))))
156 ;;; Compute the negative of A. [O O; o o] [Public]
157 (defsubst Math-integer-neg (a)
159 (if (eq (car a) 'bigpos)
160 (cons 'bigneg (cdr a))
161 (cons 'bigpos (cdr a)))
164 (defsubst Math-equal (a b)
165 (= (math-compare a b) 0))
167 (defsubst Math-lessp (a b)
168 (= (math-compare a b) -1))
170 (defsubst Math-primp (a)
172 (memq (car a) '(bigpos bigneg frac float cplx polar
175 (defsubst Math-num-integerp (a)
177 (memq (car a) '(bigpos bigneg))
178 (and (eq (car a) 'float)
181 (defsubst Math-bignum-test (a) ; [B N; B s; b b]
186 (defsubst Math-equal-int (a b)
193 (defsubst Math-natnum-lessp (a b)
196 (= (math-compare-bignum (cdr a) (cdr b)) -1))
202 ;;; arch-tag: 08ba8ec2-fcff-4b80-a079-ec661bdb057e
203 ;;; calc-macs.el ends here