blob 301848a0ef60640f55c26f1b1a62d2c180193bba
1 % Copyright (C) 2008, 2009, 2010, 2011, 2012, 2014, 2018
2 % Bert Burgemeister
4 % Permission is granted to copy, distribute and/or modify this
5 % document under the terms of the GNU Free Documentation License,
6 % Version 1.2; with no Invariant Sections, no Front-Cover Texts and
7 % no Back-Cover Texts. For details see file COPYING.
10 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
11 \section{Numbers}
12 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
14 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
15 \subsection{Predicates}
16 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
18 \begin{LIST}{1cm}
20 \IT{\arrGOO{(\FU*{=}\RP{\VAR{
21 number}})\\
22 (\FU*{/=}\RP{\VAR{ number}})}{.}}
24 \retval{\T} if all \VAR{number}s, or
25 none, respectively, are equal in value.
28 \IT{\arrGOO{(\FU{\boldmath$>$}\RP{\VAR{
29 number}})\\(\FU{\boldmath$>$=}\RP{\VAR{
30 number}})\\(\FU{\boldmath$<$}\RP{\VAR{
31 number}})\\(\FU{\boldmath$<$=}\RP{\VAR{ number}})}{.}}
33 \index{>@$>$}%
34 \index{>=@$>$=}%
35 \index{<@$<$}%
36 \index{<=@$<$=}%
37 Return \retval{\T} if \VAR{number}s are
38 monotonically decreasing, monotonically non-increasing,
39 monotonically increasing, or monotonically non-decreasing, respectively.
42 \IT{\arrGOO{(\FU*{MINUSP} \VAR{ a})\\
43 (\FU*{ZEROP} \VAR{ a})\\
44 (\FU*{PLUSP}
45 \VAR{ a})}{.}}
47 \retval{\T} if $a < 0$, $a = 0$, or $a > 0$, respectively.
50 \IT{\arrGOO{(\FU*{EVENP } \VAR{int})\\
51 (\FU*{ODDP } \VAR{int})}{.}}
53 \retval{\T} if \VAR{int} is even or odd, respectively.
56 \IT{\arrGOO{(\FU*{NUMBERP} \VAR{ foo})\\
57 (\FU*{REALP} \VAR{ foo})\\
58 (\FU*{RATIONALP} \VAR{ foo})\\
59 (\FU*{FLOATP} \VAR{ foo})\\
60 (\FU*{INTEGERP} \VAR{ foo})\\
61 (\FU*{COMPLEXP} \VAR{ foo})\\
62 (\FU*{RANDOM-STATE-P} \VAR{ foo})
63 }{.}}
65 \retval{\T} if \VAR{foo} is of
66 indicated type.
69 \end{LIST}
71 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
72 \subsection{Numeric Functions}
73 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
75 \begin{LIST}{1cm}
77 \IT{\arrGOO{(\FU*{+} \OPn{\VAR{ a}\DF{\LIT{0}}})\\
78 (\FU{\A} \OPn{\VAR{ a}\DF{\LIT{1}}})}{.}}
79 {\index{*@\A}
80 Return \retval{$\sum{a}$} or \retval{$\prod{a}$}, respectively.
83 \IT{\arrGOO{(\FU*{--} \VAR{ a}\OPn{\VAR{ b}})\\
84 (\FU*{/} \VAR{ a}
85 \OPn{\VAR{ b}})}{.}}
87 Return \retval{$a-\sum{b}$} or \retval{$a/\prod{b}$}, respectively. Without any
88 \VAR{b}s, return \retval{$-a$} or \retval{$1/a$}, respectively.
91 \IT{\arrGOO{(\FU*{1+} \VAR{ a})\\(\FU*{1--} \VAR{ a})}{.}}
92 {Return \retval{$a+1$} or
93 \retval{$a-1$}, respectively.
96 \IT{(\xorGOO{\MC*{INCF}\\
97 \MC*{DECF}}{\}} \DES{\VAR{place}}
98 \Op{\VAR{delta}\DF{\LIT{1}}})}
100 Increment or decrement the value of \VAR{place} by \VAR{delta}. Return \retval{new value}.
103 \IT{\arrGOO{%
104 (\FU*{EXP } \VAR{p})\\
107 Return \retval{$\mbox{e}^p$} or \retval{$b^p$}, respectively.
110 \IT{(\FU*{LOG} \VAR{a} \Op{\VAR{b}\DF{e}})}
112 Return \retval{$\log_b a$} or,
113 without \VAR{b}, \retval{$\ln a$}.
116 \IT{\arrGOO{(\FU*{SQRT} \VAR{ n})\\
119 \retval{$\sqrt{n}$} in complex numbers/natural numbers.
122 \IT{\arrGOO{(\FU*{LCM} \OPn{\VAR{ integer}}\DF{\LIT{1}})\\
123 (\FU*{GCD} \OPn{\VAR{ integer}})}{.}}
125 \retval{Least common multiple} or \retval{greatest common
126 de\-no\-mi\-na\-tor}, respectively, of \VAR{integer}s. (\kwd{gcd})
127 returns \retval{0}.
132 \kwd{long-float} approximation of $\pi$, Ludolph's number.
135 \IT{\arrGOO{(\FU*{SIN} \VAR{ a})\\
136 (\FU*{COS} \VAR{ a})\\
137 (\FU*{TAN} \VAR{ a})}{.}}
139 \retval{$\sin a$}, \retval{$\cos 140 a$}, or \retval{$\tan a$}, respectively. (\VAR{a} in radians.)
143 \IT{\arrGOO{(\FU*{ASIN} \VAR{ a})\\
144 (\FU*{ACOS} \VAR{ a})}{.}}
146 \retval{$\arcsin a$} or \retval{$\arccos 147 a$}, respectively, in radians.
150 \IT{(\FU*{ATAN} \VAR{a} \Op{\VAR{b}\DF{\LIT{1}}})}
152 \retval{$\arctan \frac{a}{b}$} in radians.
155 \IT{\arrGOO{(\FU*{SINH} \VAR{ a})\\(\FU*{COSH} \VAR{ a})\\(\FU*{TANH}
156 \VAR{ a})}{.}}
158 \retval{$\sinh a$}, \retval{$\cosh 159 a$}, or \retval{$\tanh a$}, respectively.
162 \IT{\arrGOO{(\FU*{ASINH} \VAR{ a})\\
163 (\FU*{ACOSH} \VAR{ a})
164 \\(\FU*{ATANH} \VAR{ a})}{.}}
166 \retval{$\operatorname{asinh} a$}, \retval{$\operatorname{acosh} 167 a$}, or \retval{$\operatorname{atanh} a$}, respectively.
172 Return
173 \retval{$\operatorname{e}^{\operatorname{i} a}$} $=$ \retval{$\cos a + 174 \operatorname{i}\sin a$}.
177 \IT{(\FU*{CONJUGATE} \VAR{a})}
179 Return complex \retval{conjugate of \VAR{a}}.
182 \IT{\arrGOO{(\FU*{MAX } \RP{\VAR{num}})\\
183 (\FU*{MIN } \RP{\VAR{num}})}{.}}
185 \retval{Greatest} or \retval{least}, respectively, of \VAR{num}s.
188 \IT{(\xorGOO{%
189 \Goo{\FU*{ROUND}\XOR\FU*{FROUND}}\\
190 \Goo{\FU*{FLOOR}\XOR\FU*{FFLOOR}}\\
191 \Goo{\FU*{CEILING}\XOR\FU*{FCEILING}}\\
192 \Goo{\FU*{TRUNCATE}\XOR\FU*{FTRUNCATE}}}{\}}
193 \VAR{n} \Op{\VAR{d}\DF{\LIT{1}}})}
195 Return as \kwd{integer} or \kwd{float}, respectively, \retval{$n/d$}
196 rounded, or rounded towards $-\infty$, $+\infty$, or $0$,
197 respectively; and \retvalii{re\-main\-der}.
200 \IT{(\xorGOO{\FU*{MOD}\\
201 \FU*{REM}}{\}} \VAR{n} \VAR{d})}
202 {Same as \FU{floor} or
203 \FU{truncate}, respectively, but return \retval{re\-main\-der} only.
206 \IT{(\FU*{RANDOM} \VAR{limit} \Op{\DES{\VAR{state}}\DF{\V{\A random-state\A}}})}
208 Return non-negative \retval{random number} less than \VAR{limit},
209 and of the same type.
212 \IT{(\FU*{MAKE-RANDOM-STATE} \OP{\Goo{\VAR{state}\XOR\NIL\XOR\T}\DF{\NIL}})}
214 \retval{Copy} of \kwd{random-state} object \VAR{state} or of
215 the current random state; or a randomly initialized fresh \retval{random
216 state}.
220 {\index{*RANDOM-STATE*@\A RANDOM-STATE\A}
221 Current random state.
224 \IT{(\FU*{FLOAT-SIGN} \VAR{num-a} \Op{\VAR{num-b}\DF{\LIT{1}}})}
226 \retval{\VAR{num-b}} with \VAR{num-a}'s sign.
229 \IT{(\FU*{SIGNUM} \VAR{n})}
230 {\retval{Number} of magnitude 1
231 representing sign or phase of \VAR{n}.
234 \IT{\arrGOO{(\FU*{NUMERATOR} \VAR{ rational})\\
235 (\FU*{DENOMINATOR} \VAR{ rational})}{.}}
237 \retval{Numerator} or \retval{denominator}, respectively, of
238 \VAR{rational}'s canonical form.
241 \IT{\arrGOO{(\FU*{REALPART} \VAR{ number})\\
242 (\FU*{IMAGPART} \VAR{ number})}{.}}
244 \retval{Real part} or \retval{imaginary part}, respectively, of \VAR{number}.
247 \IT{(\FU*{COMPLEX} \VAR{real} \Op{\VAR{imag}\DF{\LIT{0}}})}
249 Make a \retval{complex number}.
252 \IT{(\FU*{PHASE} \VAR{num})}
254 \retval{Angle} of \VAR{num}'s polar representation.
259 Return \retval{$|n|$}.
262 \IT{\arrGOO{(\FU*{RATIONAL} \VAR{ real})\\
263 (\FU*{RATIONALIZE} \VAR{ real})}{.}}
265 Convert \VAR{real} to \retval{rational}. Assume complete/limited accuracy for \VAR{real}.
268 \IT{(\FU*{FLOAT} \VAR{real}
269 \Op{\VAR{prototype}\DF{\LIT{0.0F0}}})}
271 Convert \VAR{real} into \retval{float} with type of \VAR{prototype}.
274 \end{LIST}
277 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
278 \subsection{Logic Functions}
279 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
280 \label{section:Logic Functions}
281 Negative integers are used in
282 two's complement representation.
284 \begin{LIST}{1cm}
286 \IT{(\FU*{BOOLE} \VAR{operation} \VAR{int-a} \VAR{int-b})}
288 Return
289 \retval{value} of bitwise logical \VAR{operation}. \VAR{operation}s
293 \begin{LIST}{.5cm}
296 \IT{\CNS*{BOOLE-C1}\qquad\qquad} {\retval{$\lnot\text{\VAR{int-a}}$}.}
297 \IT{\CNS*{BOOLE-C2}\qquad\qquad} {\retval{$\lnot\text{\VAR{int-b}}$}.}
300 \IT{\CNS*{BOOLE-EQV}\qquad\qquad} {\retval{$\text{\VAR{int-a}} \equiv \text{\VAR{int-b}}$}.}
301 \IT{\CNS*{BOOLE-AND}\qquad\qquad} {\retval{$\text{\VAR{int-a}}\land\text{\VAR{int-b}}$}.}
302 \IT{\CNS*{BOOLE-ANDC1}} {\retval{$\lnot \text{\VAR{int-a}} \land \text{\VAR{int-b}}$}.}
303 \IT{\CNS*{BOOLE-ANDC2}} {\retval{$\text{\VAR{int-a}} \land \lnot\text{\VAR{int-b}}$}.}
304 \IT{\CNS*{BOOLE-NAND}} {\retval{$\lnot(\text{\VAR{int-a}} \land \text{\VAR{int-b}})$}.}
305 \IT{\CNS*{BOOLE-IOR}\qquad\qquad} {\retval{$\text{\VAR{int-a}} \lor \text{\VAR{int-b}}$}.}
306 \IT{\CNS*{BOOLE-ORC1}\qquad} {\retval{$\lnot \text{\VAR{int-a}} \lor \text{\VAR{int-b}}$}.}
307 \IT{\CNS*{BOOLE-ORC2}\qquad} {\retval{$\text{\VAR{int-a}} \lor \lnot\text{\VAR{int-b}}$}.}
308 \IT{\CNS*{BOOLE-XOR}\qquad\qquad} {\retval{$\lnot(\text{\VAR{int-a}} \equiv \text{\VAR{int-b}})$}.}
309 \IT{\CNS*{BOOLE-NOR}\qquad\qquad} {\retval{$\lnot(\text{\VAR{int-a}} \lor \text{\VAR{int-b}})$}.}
310 \end{LIST}
314 \retval{$\lnot\text{\VAR{integer}}$}.
317 \IT{\arrGOO{(\FU*{LOGEQV} \OPn{\VAR{ integer}})\\
318 (\FU*{LOGAND} \OPn{\VAR{ integer}})}{.}}
320 Return \retval{value of exclusive-nored or anded \VAR{integer}s},
321 respectively. Without any \VAR{integer}, return \retval{$-1$}.
324 \IT{(\FU*{LOGANDC1} \VAR{int-a} \VAR{int-b})}
326 \retval{$\lnot \text{\VAR{int-a}} \land \text{\VAR{int-b}}$}.
329 \IT{(\FU*{LOGANDC2} \VAR{int-a} \VAR{int-b})}
331 \retval{$\text{\VAR{int-a}} \land \lnot\text{\VAR{int-b}}$}.
336 \retval{$\lnot(\text{\VAR{int-a}} \land \text{\VAR{int-b}})$}.
339 \IT{\arrGOO{(\FU*{LOGXOR} \OPn{\VAR{ integer}})\\
340 (\FU*{LOGIOR} \OPn{\VAR{ integer}})}{.}}
342 Return \retval{value of exclusive-ored or ored \VAR{integer}s},
343 respectively. Without any \VAR{integer}, return \retval{0}.
346 \IT{(\FU*{LOGORC1} \VAR{int-a} \VAR{int-b})}
348 \retval{$\lnot \text{\VAR{int-a}} \lor \text{\VAR{int-b}}$}.
351 \IT{(\FU*{LOGORC2} \VAR{int-a} \VAR{int-b})}
353 \retval{$\text{\VAR{int-a}} \lor \lnot\text{\VAR{int-b}}$}.
356 \IT{(\FU*{LOGNOR} \VAR{int-a} \VAR{int-b})}
358 \retval{$\lnot(\text{\VAR{int-a}} \lor \text{\VAR{int-b}})$}.
361 \IT{(\FU*{LOGBITP} \VAR{i} \VAR{int})}
363 \retval{\T} if zero-indexed \VAR{i}th bit of \VAR{int} is set.
366 \IT{(\FU*{LOGTEST} \VAR{int-a} \VAR{int-b})}
367 {Return \retval{\T} if
368 there is any bit set in \VAR{int-a} which is set in \VAR{int-b} as well.
371 \IT{(\FU*{LOGCOUNT} \VAR{int})}
373 \retval{Number of 1 bits} in $\text{\VAR{int}}\ge 0$,
374 \retval{number of 0 bits} in $\text{\VAR{int}}< 0$.
378 \end{LIST}
380 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
381 \subsection{Integer Functions}
382 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
383 \begin{LIST}{1cm}
385 \IT{(\FU*{INTEGER-LENGTH} \VAR{integer})}
387 \retval{Number of bits} necessary to represent \VAR{integer}.
390 \IT{(\FU*{LDB-TEST} \VAR{byte-spec} \VAR{integer})}
392 Return \retval{\T} if any bit specified by \VAR{byte-spec} in
393 \VAR{integer} is set.
396 \IT{(\FU*{ASH} \VAR{integer} \VAR{count})}
398 Return copy of \retval{\VAR{integer}} arithmetically shifted left by
400 at the right, or, for $\VAR{count}<0$, shifted right discarding
401 bits.
404 \IT{(\FU*{LDB} \VAR{byte-spec} \VAR{integer})}
406 Extract \retval{byte} denoted by \VAR{byte-spec} from
407 \VAR{integer}. \kwd{setf}able.
410 \IT{(\xorGOO{\FU*{DEPOSIT-FIELD}\\
411 \FU*{DPB}}{\}}
412 \VAR{int-a} \VAR{byte-spec} \VAR{int-b})}
414 Return \retval{\VAR{int-b}} with bits denoted by \VAR{byte-spec} replaced
415 by corresponding bits of \VAR{int-a}, or by the low (\FU{byte-size}
416 \VAR{byte-spec}) bits of \VAR{int-a}, respectively.
421 Return copy of \retval{\VAR{integer}} with all bits unset but those denoted by
422 \VAR{byte-spec}. \kwd{setf}able.
425 \IT{(\FU*{BYTE} \VAR{size} \VAR{position})}
427 \retval{Byte specifier} for a byte of \VAR{size} bits starting at a
428 weight of $2^{\VAR{position}}$.
431 \IT{\arrGOO{(\FU*{BYTE-SIZE} \VAR{ byte-spec})\\
432 (\FU*{BYTE-POSITION} \VAR{ byte-spec})}{.}}
434 \retval{Size} or \retval{position}, respectively, of \VAR{byte-spec}.
437 \end{LIST}
440 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
441 \subsection{Implementation-Dependent}
442 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
443 \begin{LIST}{1cm}
445 \IT{\arrGOO{\CNS{SHORT-FLOAT}\\
446 \CNS{SINGLE-FLOAT}\\
447 \CNS{DOUBLE-FLOAT}\\
448 \CNS{LONG-FLOAT}}{\}}\kwd{-}%
449 \xorGOO{\kwd{EPSILON}\\
450 \kwd{NEGATIVE-EPSILON}}{.}}
452 \index{SHORT-FLOAT-EPSILON}%
453 \index{SINGLE-FLOAT-EPSILON}%
454 \index{DOUBLE-FLOAT-EPSILON}%
455 \index{LONG-FLOAT-EPSILON}%
456 \index{SHORT-FLOAT-NEGATIVE-EPSILON}%
457 \index{SINGLE-FLOAT-NEGATIVE-EPSILON}%
458 \index{DOUBLE-FLOAT-NEGATIVE-EPSILON}%
459 \index{LONG-FLOAT-NEGATIVE-EPSILON}%
460 Smallest possible number making a difference when added or subtracted, respectively.
463 \IT{\arrGOO{%
464 \CNS{LEAST-NEGATIVE}\\
465 \CNS{LEAST-NEGATIVE-NORMALIZED}\\
466 \CNS{LEAST-POSITIVE}\\
467 \CNS{LEAST-POSITIVE-NORMALIZED}}{\}}%
468 \kwd{-}%
469 \xorGOO{%
470 \kwd{SHORT-FLOAT}\\
471 \kwd{SINGLE-FLOAT}\\
472 \kwd{DOUBLE-FLOAT}\\
473 \kwd{LONG-FLOAT}}{.}}
475 \index{LEAST-NEGATIVE-SHORT-FLOAT}%
476 \index{LEAST-NEGATIVE-NORMALIZED-SHORT-FLOAT}%
477 \index{LEAST-NEGATIVE-SINGLE-FLOAT}%
478 \index{LEAST-NEGATIVE-NORMALIZED-SINGLE-FLOAT}%
479 \index{LEAST-NEGATIVE-DOUBLE-FLOAT}%
480 \index{LEAST-NEGATIVE-NORMALIZED-DOUBLE-FLOAT}%
481 \index{LEAST-NEGATIVE-LONG-FLOAT}%
482 \index{LEAST-NEGATIVE-NORMALIZED-LONG-FLOAT}%
483 \index{LEAST-POSITIVE-SHORT-FLOAT}%
484 \index{LEAST-POSITIVE-NORMALIZED-SHORT-FLOAT}%
485 \index{LEAST-POSITIVE-SINGLE-FLOAT}%
486 \index{LEAST-POSITIVE-NORMALIZED-SINGLE-FLOAT}%
487 \index{LEAST-POSITIVE-DOUBLE-FLOAT}%
488 \index{LEAST-POSITIVE-NORMALIZED-DOUBLE-FLOAT}%
489 \index{LEAST-POSITIVE-LONG-FLOAT}%
490 \index{LEAST-POSITIVE-NORMALIZED-LONG-FLOAT}%
491 Available numbers closest to $-0$ or $+0$, respectively.
494 \IT{\arrGOO{\CNS{MOST-NEGATIVE}\\
495 \CNS{MOST-POSITIVE}}{\}}%
496 \kwd{-}%
497 \xorGOO{%
498 \kwd{SHORT-FLOAT}\\
499 \kwd{SINGLE-FLOAT}\\
500 \kwd{DOUBLE-FLOAT}\\
501 \kwd{LONG-FLOAT}\\
502 \kwd{FIXNUM}}{.}}
504 \index{MOST-NEGATIVE-DOUBLE-FLOAT}%
505 \index{MOST-NEGATIVE-LONG-FLOAT}%
506 \index{MOST-NEGATIVE-SHORT-FLOAT}%
507 \index{MOST-NEGATIVE-SINGLE-FLOAT}%
508 \index{MOST-NEGATIVE-FIXNUM}%
509 \index{MOST-POSITIVE-DOUBLE-FLOAT}%
510 \index{MOST-POSITIVE-LONG-FLOAT}%
511 \index{MOST-POSITIVE-SHORT-FLOAT}%
512 \index{MOST-POSITIVE-SINGLE-FLOAT}%
513 \index{MOST-POSITIVE-FIXNUM}%
514 Available numbers closest to $-\infty$ or $+\infty$, respectively.
517 \IT{\arrGOO{(\FU*{DECODE-FLOAT} \VAR{ n})\\
518 (\FU*{INTEGER-DECODE-FLOAT} \VAR{ n})}{.}}
520 Return \retval{significand}, \retvalii{exponent}, and
521 \retvaliii{sign} of \kwd{float} \VAR{n}.
524 \IT{(\FU*{SCALE-FLOAT} \VAR{n} \VAR{i})}
526 With \VAR{n}'s radix $b$, return $n b^{i}$.
529 \IT{\arrGOO{