Mercurial > emacs
annotate lisp/calc/calc-macs.el @ 68596:18f95be962c1
No need to mention Makefile.unix, it is no longer created.
author | Eli Zaretskii <eliz@gnu.org> |
---|---|
date | Fri, 03 Feb 2006 19:31:55 +0000 |
parents | 1db49616ce05 |
children | 6bf177f8065b 187d6a1f84f7 |
rev | line source |
---|---|
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
1 ;;; calc-macs.el --- important macros for Calc |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
2 |
64325
1db49616ce05
Update copyright information.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
62442
diff
changeset
|
3 ;; Copyright (C) 1990, 1991, 1992, 1993, 2001, 2002, 2003, 2004, |
1db49616ce05
Update copyright information.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
62442
diff
changeset
|
4 ;; 2005 Free Software Foundation, Inc. |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
5 |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
6 ;; Author: David Gillespie <daveg@synaptics.com> |
58612
d48ee50961f3
Move provide to end of file.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
52401
diff
changeset
|
7 ;; Maintainer: Jay Belanger <belanger@truman.edu> |
40785 | 8 |
9 ;; This file is part of GNU Emacs. | |
10 | |
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. | |
17 | |
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. | |
25 | |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
26 ;;; Commentary: |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
27 |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
28 ;;; Code: |
40785 | 29 |
30 (defmacro calc-wrapper (&rest body) | |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
31 `(calc-do (function (lambda () |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
32 ,@body)))) |
40785 | 33 |
34 (defmacro calc-slow-wrapper (&rest body) | |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
35 `(calc-do |
41341
6ab668229754
(calc-slow-wrapper): Move (point) call outside of (function ...)
Colin Walters <walters@gnu.org>
parents:
41266
diff
changeset
|
36 (function (lambda () ,@body)) (point))) |
40785 | 37 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
38 (defmacro math-showing-full-precision (form) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
39 `(let ((calc-float-format calc-full-float-format)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
40 ,form)) |
40785 | 41 |
42 (defmacro math-with-extra-prec (delta &rest body) | |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
43 `(math-normalize |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
44 (let ((calc-internal-prec (+ calc-internal-prec ,delta))) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
45 ,@body))) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
46 |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
47 (defmacro math-working (msg arg) ; [Public] |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
48 `(if (eq calc-display-working-message 'lots) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
49 (math-do-working ,msg ,arg))) |
40785 | 50 |
43402
b7527fba7b15
(calc-with-default-simplification): Use &rest for body.
Colin Walters <walters@gnu.org>
parents:
41385
diff
changeset
|
51 (defmacro calc-with-default-simplification (&rest body) |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
52 `(let ((calc-simplify-mode (and (not (memq calc-simplify-mode '(none num))) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
53 calc-simplify-mode))) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
54 ,@body)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
55 |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
56 (defmacro calc-with-trail-buffer (&rest body) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
57 `(let ((save-buf (current-buffer)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
58 (calc-command-flags nil)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
59 (with-current-buffer (calc-trail-display t) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
60 (progn |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
61 (goto-char calc-trail-pointer) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
62 ,@body)))) |
40785 | 63 |
64 ;;; Faster in-line version zerop, normalized values only. | |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
65 (defsubst Math-zerop (a) ; [P N] |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
66 (if (consp a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
67 (and (not (memq (car a) '(bigpos bigneg))) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
68 (if (eq (car a) 'float) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
69 (eq (nth 1 a) 0) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
70 (math-zerop a))) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
71 (eq a 0))) |
40785 | 72 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
73 (defsubst Math-integer-negp (a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
74 (if (consp a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
75 (eq (car a) 'bigneg) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
76 (< a 0))) |
40785 | 77 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
78 (defsubst Math-integer-posp (a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
79 (if (consp a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
80 (eq (car a) 'bigpos) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
81 (> a 0))) |
40785 | 82 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
83 (defsubst Math-negp (a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
84 (if (consp a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
85 (or (eq (car a) 'bigneg) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
86 (and (not (eq (car a) 'bigpos)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
87 (if (memq (car a) '(frac float)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
88 (Math-integer-negp (nth 1 a)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
89 (math-negp a)))) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
90 (< a 0))) |
40785 | 91 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
92 (defsubst Math-looks-negp (a) ; [P x] [Public] |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
93 (or (Math-negp a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
94 (and (consp a) (or (eq (car a) 'neg) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
95 (and (memq (car a) '(* /)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
96 (or (math-looks-negp (nth 1 a)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
97 (math-looks-negp (nth 2 a)))))))) |
40785 | 98 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
99 (defsubst Math-posp (a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
100 (if (consp a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
101 (or (eq (car a) 'bigpos) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
102 (and (not (eq (car a) 'bigneg)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
103 (if (memq (car a) '(frac float)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
104 (Math-integer-posp (nth 1 a)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
105 (math-posp a)))) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
106 (> a 0))) |
40785 | 107 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
108 (defsubst Math-integerp (a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
109 (or (not (consp a)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
110 (memq (car a) '(bigpos bigneg)))) |
40785 | 111 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
112 (defsubst Math-natnump (a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
113 (if (consp a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
114 (eq (car a) 'bigpos) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
115 (>= a 0))) |
40785 | 116 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
117 (defsubst Math-ratp (a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
118 (or (not (consp a)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
119 (memq (car a) '(bigpos bigneg frac)))) |
40785 | 120 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
121 (defsubst Math-realp (a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
122 (or (not (consp a)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
123 (memq (car a) '(bigpos bigneg frac float)))) |
40785 | 124 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
125 (defsubst Math-anglep (a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
126 (or (not (consp a)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
127 (memq (car a) '(bigpos bigneg frac float hms)))) |
40785 | 128 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
129 (defsubst Math-numberp (a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
130 (or (not (consp a)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
131 (memq (car a) '(bigpos bigneg frac float cplx polar)))) |
40785 | 132 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
133 (defsubst Math-scalarp (a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
134 (or (not (consp a)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
135 (memq (car a) '(bigpos bigneg frac float cplx polar hms)))) |
40785 | 136 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
137 (defsubst Math-vectorp (a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
138 (and (consp a) (eq (car a) 'vec))) |
40785 | 139 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
140 (defsubst Math-messy-integerp (a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
141 (and (consp a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
142 (eq (car a) 'float) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
143 (>= (nth 2 a) 0))) |
40785 | 144 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
145 (defsubst Math-objectp (a) ; [Public] |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
146 (or (not (consp a)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
147 (memq (car a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
148 '(bigpos bigneg frac float cplx polar hms date sdev intv mod)))) |
40785 | 149 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
150 (defsubst Math-objvecp (a) ; [Public] |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
151 (or (not (consp a)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
152 (memq (car a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
153 '(bigpos bigneg frac float cplx polar hms date |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
154 sdev intv mod vec)))) |
40785 | 155 |
156 ;;; Compute the negative of A. [O O; o o] [Public] | |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
157 (defsubst Math-integer-neg (a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
158 (if (consp a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
159 (if (eq (car a) 'bigpos) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
160 (cons 'bigneg (cdr a)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
161 (cons 'bigpos (cdr a))) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
162 (- a))) |
40785 | 163 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
164 (defsubst Math-equal (a b) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
165 (= (math-compare a b) 0)) |
40785 | 166 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
167 (defsubst Math-lessp (a b) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
168 (= (math-compare a b) -1)) |
40785 | 169 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
170 (defsubst Math-primp (a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
171 (or (not (consp a)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
172 (memq (car a) '(bigpos bigneg frac float cplx polar |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
173 hms date mod var)))) |
40785 | 174 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
175 (defsubst Math-num-integerp (a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
176 (or (not (consp a)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
177 (memq (car a) '(bigpos bigneg)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
178 (and (eq (car a) 'float) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
179 (>= (nth 2 a) 0)))) |
40785 | 180 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
181 (defsubst Math-bignum-test (a) ; [B N; B s; b b] |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
182 (if (consp a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
183 a |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
184 (math-bignum a))) |
40785 | 185 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
186 (defsubst Math-equal-int (a b) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
187 (or (eq a b) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
188 (and (consp a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
189 (eq (car a) 'float) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
190 (eq (nth 1 a) b) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
191 (= (nth 2 a) 0)))) |
40785 | 192 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
193 (defsubst Math-natnum-lessp (a b) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
194 (if (consp a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
195 (and (consp b) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
196 (= (math-compare-bignum (cdr a) (cdr b)) -1)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
197 (or (consp b) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
198 (< a b)))) |
40785 | 199 |
58612
d48ee50961f3
Move provide to end of file.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
52401
diff
changeset
|
200 (provide 'calc-macs) |
d48ee50961f3
Move provide to end of file.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
52401
diff
changeset
|
201 |
52401 | 202 ;;; arch-tag: 08ba8ec2-fcff-4b80-a079-ec661bdb057e |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40910
diff
changeset
|
203 ;;; calc-macs.el ends here |