annotate lisp/calc/calc-macs.el @ 52787:785941182067

Char-tables are sequences. Add string-bytes.
author Dave Love <fx@gnu.org>
date Mon, 06 Oct 2003 16:52:24 +0000
parents 695cf19ef79e
children d48ee50961f3 375f2633d815
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40910
diff changeset
3 ;; Copyright (C) 1990, 1991, 1992, 1993, 2001 Free Software Foundation, Inc.
41266
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
4
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
5 ;; Author: David Gillespie <daveg@synaptics.com>
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49263
diff changeset
6 ;; Maintainers: D. Goel <deego@gnufans.org>
49263
f4d68f97221e Add new maintainer (deego).
Deepak Goel <deego@gnufans.org>
parents: 43402
diff changeset
7 ;; Colin Walters <walters@debian.org>
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
8
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
9 ;; This file is part of GNU Emacs.
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
10
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
11 ;; GNU Emacs is distributed in the hope that it will be useful,
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
12 ;; but WITHOUT ANY WARRANTY. No author or distributor
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
13 ;; accepts responsibility to anyone for the consequences of using it
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
14 ;; or for whether it serves any particular purpose or works at all,
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
15 ;; unless he says so in writing. Refer to the GNU Emacs General Public
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
16 ;; License for full details.
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
17
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
18 ;; Everyone is granted permission to copy, modify and redistribute
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
19 ;; GNU Emacs, but only under the conditions described in the
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
20 ;; GNU Emacs General Public License. A copy of this license is
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
21 ;; supposed to have been given to you along with GNU Emacs so you
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
22 ;; can know your rights and responsibilities. It should be in a
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
23 ;; file named COPYING. Among other things, the copyright notice
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
24 ;; and this notice must be preserved on all copies.
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
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
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
29
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
30 (provide 'calc-macs)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
31
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
32 (defun calc-need-macros () nil)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
33
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
34 (defmacro calc-wrapper (&rest body)
41266
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
35 `(calc-do (function (lambda ()
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
36 ,@body))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
37
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
38 (defmacro calc-slow-wrapper (&rest body)
41266
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
39 `(calc-do
41341
6ab668229754 (calc-slow-wrapper): Move (point) call outside of (function ...)
Colin Walters <walters@gnu.org>
parents: 41266
diff changeset
40 (function (lambda () ,@body)) (point)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
41
41266
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
42 (defmacro math-showing-full-precision (form)
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
43 `(let ((calc-float-format calc-full-float-format))
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
44 ,form))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
45
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
46 (defmacro math-with-extra-prec (delta &rest body)
41266
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
47 `(math-normalize
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
48 (let ((calc-internal-prec (+ calc-internal-prec ,delta)))
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
49 ,@body)))
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
50
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
51 (defmacro math-working (msg arg) ; [Public]
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
52 `(if (eq calc-display-working-message 'lots)
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
53 (math-do-working ,msg ,arg)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
54
43402
b7527fba7b15 (calc-with-default-simplification): Use &rest for body.
Colin Walters <walters@gnu.org>
parents: 41385
diff changeset
55 (defmacro calc-with-default-simplification (&rest body)
41266
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
56 `(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
57 calc-simplify-mode)))
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
58 ,@body))
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
59
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
60 (defmacro calc-with-trail-buffer (&rest body)
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
61 `(let ((save-buf (current-buffer))
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
62 (calc-command-flags nil))
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
63 (with-current-buffer (calc-trail-display t)
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
64 (progn
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
65 (goto-char calc-trail-pointer)
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
66 ,@body))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
67
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
68 ;;; Faster in-line version zerop, normalized values only.
41266
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
69 (defsubst Math-zerop (a) ; [P N]
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
70 (if (consp a)
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
71 (and (not (memq (car a) '(bigpos bigneg)))
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
72 (if (eq (car a) 'float)
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
73 (eq (nth 1 a) 0)
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
74 (math-zerop a)))
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
75 (eq a 0)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
76
41266
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
77 (defsubst Math-integer-negp (a)
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
78 (if (consp a)
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
79 (eq (car a) 'bigneg)
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
80 (< a 0)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
81
41266
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
82 (defsubst Math-integer-posp (a)
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
83 (if (consp a)
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
84 (eq (car a) 'bigpos)
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
85 (> a 0)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
86
41266
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
87 (defsubst Math-negp (a)
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
88 (if (consp a)
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
89 (or (eq (car a) 'bigneg)
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
90 (and (not (eq (car a) 'bigpos))
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
91 (if (memq (car a) '(frac float))
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
92 (Math-integer-negp (nth 1 a))
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
93 (math-negp a))))
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
94 (< a 0)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
95
41266
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
96 (defsubst Math-looks-negp (a) ; [P x] [Public]
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
97 (or (Math-negp a)
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
98 (and (consp a) (or (eq (car a) 'neg)
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
99 (and (memq (car a) '(* /))
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
100 (or (math-looks-negp (nth 1 a))
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
101 (math-looks-negp (nth 2 a))))))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
102
41266
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
103 (defsubst Math-posp (a)
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
104 (if (consp a)
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
105 (or (eq (car a) 'bigpos)
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
106 (and (not (eq (car a) 'bigneg))
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
107 (if (memq (car a) '(frac float))
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
108 (Math-integer-posp (nth 1 a))
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
109 (math-posp a))))
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
110 (> a 0)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
111
41266
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
112 (defsubst Math-integerp (a)
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
113 (or (not (consp a))
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
114 (memq (car a) '(bigpos bigneg))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
115
41266
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
116 (defsubst Math-natnump (a)
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
117 (if (consp a)
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
118 (eq (car a) 'bigpos)
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
119 (>= a 0)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
120
41266
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
121 (defsubst Math-ratp (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))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
124
41266
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
125 (defsubst Math-realp (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))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
128
41266
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
129 (defsubst Math-anglep (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 hms))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
132
41266
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
133 (defsubst Math-numberp (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))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
136
41266
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
137 (defsubst Math-scalarp (a)
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
138 (or (not (consp a))
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
139 (memq (car a) '(bigpos bigneg frac float cplx polar hms))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
140
41266
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
141 (defsubst Math-vectorp (a)
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
142 (and (consp a) (eq (car a) 'vec)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
143
41266
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
144 (defsubst Math-messy-integerp (a)
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
145 (and (consp a)
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
146 (eq (car a) 'float)
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
147 (>= (nth 2 a) 0)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
148
41266
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
149 (defsubst Math-objectp (a) ; [Public]
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
150 (or (not (consp a))
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
151 (memq (car a)
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
152 '(bigpos bigneg frac float cplx polar hms date sdev intv mod))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
153
41266
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
154 (defsubst Math-objvecp (a) ; [Public]
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
155 (or (not (consp a))
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
156 (memq (car a)
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
157 '(bigpos bigneg frac float cplx polar hms date
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
158 sdev intv mod vec))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
159
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
160 ;;; 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
161 (defsubst Math-integer-neg (a)
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
162 (if (consp a)
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
163 (if (eq (car a) 'bigpos)
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
164 (cons 'bigneg (cdr a))
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
165 (cons 'bigpos (cdr a)))
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
166 (- a)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
167
41266
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
168 (defsubst Math-equal (a b)
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
169 (= (math-compare a b) 0))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
170
41266
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
171 (defsubst Math-lessp (a b)
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
172 (= (math-compare a b) -1))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
173
41266
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
174 (defsubst Math-primp (a)
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
175 (or (not (consp a))
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
176 (memq (car a) '(bigpos bigneg frac float cplx polar
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
177 hms date mod var))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
178
41266
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
179 (defsubst Math-num-integerp (a)
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
180 (or (not (consp a))
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
181 (memq (car a) '(bigpos bigneg))
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
182 (and (eq (car a) 'float)
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
183 (>= (nth 2 a) 0))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
184
41266
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
185 (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
186 (if (consp a)
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
187 a
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
188 (math-bignum a)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
189
41266
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
190 (defsubst Math-equal-int (a b)
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
191 (or (eq a b)
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
192 (and (consp a)
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
193 (eq (car a) 'float)
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
194 (eq (nth 1 a) b)
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
195 (= (nth 2 a) 0))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
196
41266
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
197 (defsubst Math-natnum-lessp (a b)
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
198 (if (consp a)
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
199 (and (consp b)
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
200 (= (math-compare-bignum (cdr a) (cdr b)) -1))
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
201 (or (consp b)
c08a55ae8e5d (calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
202 (< a b))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
203
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 49598
diff changeset
204 ;;; 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
205 ;;; calc-macs.el ends here