diff --git a/changelog b/changelog index 3013e26..9714410 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,5 @@ +20090802 tpd src/axiom-website/patches.html 20090802.01.tpd.patch +20090802 tpd src/interp/vmlisp.lisp rewrite to remove chunks 20090726 tpd books/ps/v71releasenotes.eps updated for july 2009 20090726 tpd books/ps/v71july2009.eps added 20090726 tpd books/bookvol7.1 add july2009 what's new page diff --git a/src/axiom-website/patches.html b/src/axiom-website/patches.html index 6e66bad..b9de071 100644 --- a/src/axiom-website/patches.html +++ b/src/axiom-website/patches.html @@ -1734,6 +1734,8 @@ books/bookvol10.4 add SOLVTRA regress, help, examples
In process, not yet released


+
20090802.01.tpd.patch +src/interp/vmlisp.lisp rewrite to remove chunks
diff --git a/src/interp/vmlisp.lisp.pamphlet b/src/interp/vmlisp.lisp.pamphlet index ccd83f2..58e3913 100644 --- a/src/interp/vmlisp.lisp.pamphlet +++ b/src/interp/vmlisp.lisp.pamphlet @@ -1,181 +1,15 @@ \documentclass{article} \usepackage{axiom} \begin{document} -\title{\$SPAD/src/interp vmlisp.lisp} +\title{\$SPAD/src/interp depsys.lisp} \author{Lars Ericson, Barry Trager, Martial Schor, Timothy Daly} \maketitle \begin{abstract} \end{abstract} \eject \tableofcontents -\section{Missing DFLOAT Transcendental functions} -These functions should be defined for DoubleFloat inputs but are not. -These are cheap and easy definitions that work but should be rewritten. -<>= -(defun sec (x) (/ 1 (cos x))) -(defun csc (x) (/ 1 (sin x))) -(defun acsc (x) (asin (/ 1 x))) -(defun asec (x) (acos (/ 1 x))) -(defun csch (x) (/ 1 (sinh x))) -(defun coth (x) (* (cosh x) (csch x))) -(defun sech (x) (/ 1 (cosh x))) -(defun acsch (x) (asinh (/ 1 x))) -(defun acoth (x) (atanh (/ 1 x))) -(defun asech (x) (acosh (/ 1 x))) -@ - -\section{The StringImage Fix} -In GCL 2.5 there is a bug in the write-to-string function. -It should respect *print-escape* but it does not. That is, -\begin{verbatim} - -In GCL 2.4.1: -(setq *print-escape* nil) -(write-to-string '|a|) ==> "a" - -In GCL 2.5: -(setq *print-escape* nil) -(write-to-string '|a|) ==> "|a|" - -\end{verbatim} -The form2LispString function uses stringimage and fails. -The princ-to-string function assumes *print-escape* is nil -and works properly. - -<>= -;(define-function 'prin2cvec #'write-to-string) -(define-function 'prin2cvec #'princ-to-string) -;(define-function 'stringimage #'write-to-string) -(define-function 'stringimage #'princ-to-string) - -@ -\section{The manexp fix} -Contributed by Juergen Weiss from a suggestion by Arthur Norman. -This is a Mantissa and Exponent function. -<>= -#+(or :cmu :akcl :gcl) -(defun manexp (u) - (multiple-value-bind (f e s) - (decode-float u) - (cons (* s f) e))) - -@ -\section{The arc cotangent function} -Contributed by Juergen Weiss from Arthur Norman's CCL. -<>= -#+:(or :cmu :akcl :gcl) -(defun acot (a) - (if (> a 0.0) - (if (> a 1.0) - (atan (/ 1.0 a)) - (- (/ pi 2.0) (atan a))) - (if (< a -1.0) - (- pi (atan (/ -1.0 a))) - (+ (/ pi 2.0) (atan (- a)))))) - -@ -\section{The arc cotangent function} -Contributed by Juergen Weiss from Arthur Norman's CCL. -<>= -#+:(or :cmu :akcl :gcl) -(defun cot (a) - (if (or (> a 1000.0) (< a -1000.0)) - (/ (cos a) (sin a)) - (/ 1.0 (tan a)))) - -@ -\section{The digits-by-radix function} -The purpose of the following function is to calculate the number of -digits in the radix $B$ expansion of an arbitrary Lisp integer $n$. -The width of an integer can be determined rapidly when the radix is a -power of two, otherwise an approach based on successive divisions is -used. - -<>= -(defun digits-by-radix (n &optional (radix 10)) - (flet (<> - <>) - (assert (>= radix 2) (radix) - "Bad radix ~D < 2 given to DIGITS-BY-RADIX." radix) - (setq n (abs n)) - (cond - ((zerop n) (values 1)) - ((zerop (logand radix (1- radix))) (power-of-two-width n radix)) - (t (iterative-width n radix))))) - -@ When the radix $B$ is of the form $2^b$, $b$ bits are needed to -represent one radix $B$ digit. The radix $B$ width of $n$ is obtained -by dividing the width of the binary representation of $n$ by $b$, and -incrementing the result when the remainder is non-zero. - -<>= - (power-of-two-width (n radix) - (let ((bits (integer-length n)) - (radix-bits (1- (integer-length radix)))) - (multiple-value-bind (quo rem) (floor bits radix-bits) - (if (zerop rem) quo (1+ quo))))) - -@ When the radix is not a power of two, we choose a power $p$ of the -radix $B$ and use $B^p$ as a divisor. Each division counts as $p$ -digits in the radix $B$ expansion. The power, bound to the variable -[[digits]] below, is chosen so that $B^p <$ -\texttt{most-positive-long-float}. This allows use of [[log]] to -compute $p$ without concern for floating point overflow. Once a -quotient is produced which is smaller than the divisor, we complete -the calculation by repeated divisions using the radix itself. - -<>= - (iterative-width (n radix) - (multiple-value-bind (q width) - (let* ((target (if (< n most-positive-long-float) - (values n) - (values most-positive-long-float))) - (digits (let ((d (floor (log target radix)))) - (if (zerop d) 1 d))) - (div (expt radix digits))) - (loop for q = n then (floor q div) - until (< q div) sum digits into width - finally (return (values q width)))) - (+ width (loop for r = q then (floor r radix) - until (zerop r) count t)))) -@ -\section{License} -<>= -;; Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -;; All rights reserved. -;; -;; Redistribution and use in source and binary forms, with or without -;; modification, are permitted provided that the following conditions are -;; met: -;; -;; - Redistributions of source code must retain the above copyright -;; notice, this list of conditions and the following disclaimer. -;; -;; - Redistributions in binary form must reproduce the above copyright -;; notice, this list of conditions and the following disclaimer in -;; the documentation and/or other materials provided with the -;; distribution. -;; -;; - Neither the name of The Numerical ALgorithms Group Ltd. nor the -;; names of its contributors may be used to endorse or promote products -;; derived from this software without specific prior written permission. -;; -;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -;; IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -;; TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -;; PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -;; OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -;; EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -;; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -;; PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -;; LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -@ <<*>>= -<> ; VM LISP EMULATION PACKAGE @@ -975,7 +809,61 @@ the calculation by repeated divisions using the radix itself. ; 12.0 Operations on Numbers -<> +@ +\section{The digits-by-radix function} +The purpose of the following function is to calculate the number of +digits in the radix $B$ expansion of an arbitrary Lisp integer $n$. +The width of an integer can be determined rapidly when the radix is a +power of two, otherwise an approach based on successive divisions is +used. + +We have a subfunction called ``power-of-two-width''. +When the radix $B$ is of the form $2^b$, $b$ bits are needed to +represent one radix $B$ digit. The radix $B$ width of $n$ is obtained +by dividing the width of the binary representation of $n$ by $b$, and +incrementing the result when the remainder is non-zero. + +We have a subfunction called ``digits-by-radix''. +When the radix is not a power of two, we choose a power $p$ of the +radix $B$ and use $B^p$ as a divisor. Each division counts as $p$ +digits in the radix $B$ expansion. The power, bound to the variable +[[digits]] below, is chosen so that $B^p <$ +\texttt{most-positive-long-float}. This allows use of [[log]] to +compute $p$ without concern for floating point overflow. Once a +quotient is produced which is smaller than the divisor, we complete +the calculation by repeated divisions using the radix itself. + +@ +<<*>>= +(defun digits-by-radix (n &optional (radix 10)) + (flet ( + (power-of-two-width (n radix) + (let ((bits (integer-length n)) + (radix-bits (1- (integer-length radix)))) + (multiple-value-bind (quo rem) (floor bits radix-bits) + (if (zerop rem) quo (1+ quo))))) + (iterative-width (n radix) + (multiple-value-bind (q width) + (let* ((target (if (< n most-positive-long-float) + (values n) + (values most-positive-long-float))) + (digits (let ((d (floor (log target radix)))) + (if (zerop d) 1 d))) + (div (expt radix digits))) + (loop for q = n then (floor q div) + until (< q div) sum digits into width + finally (return (values q width)))) + (+ width (loop for r = q then (floor r radix) + until (zerop r) count t)))) + ) + (assert (>= radix 2) (radix) + "Bad radix ~D < 2 given to DIGITS-BY-RADIX." radix) + (setq n (abs n)) + (cond + ((zerop n) (values 1)) + ((zerop (logand radix (1- radix))) (power-of-two-width n radix)) + (t (iterative-width n radix))))) + ; 12.1 Conversion @@ -1623,7 +1511,30 @@ can be restored. ; 24.0 Printing -<> +@ +\section{The StringImage Fix} +In GCL 2.5 there is a bug in the write-to-string function. +It should respect *print-escape* but it does not. That is, +\begin{verbatim} + +In GCL 2.4.1: +(setq *print-escape* nil) +(write-to-string '|a|) ==> "a" + +In GCL 2.5: +(setq *print-escape* nil) +(write-to-string '|a|) ==> "|a|" + +\end{verbatim} +The form2LispString function uses stringimage and fails. +The princ-to-string function assumes *print-escape* is nil +and works properly. + +<<*>>= +;(define-function 'prin2cvec #'write-to-string) +(define-function 'prin2cvec #'princ-to-string) +;(define-function 'stringimage #'write-to-string) +(define-function 'stringimage #'princ-to-string) (define-function 'printexp #'princ) (define-function 'prin0 #'prin1) @@ -1973,10 +1884,38 @@ can be restored. (in-package 'boot) -<> -<> -<> -<> +#+(or :cmu :akcl :gcl) +(defun manexp (u) + (multiple-value-bind (f e s) + (decode-float u) + (cons (* s f) e))) + +#+:(or :cmu :akcl :gcl) +(defun acot (a) + (if (> a 0.0) + (if (> a 1.0) + (atan (/ 1.0 a)) + (- (/ pi 2.0) (atan a))) + (if (< a -1.0) + (- pi (atan (/ -1.0 a))) + (+ (/ pi 2.0) (atan (- a)))))) + +#+:(or :cmu :akcl :gcl) +(defun cot (a) + (if (or (> a 1000.0) (< a -1000.0)) + (/ (cos a) (sin a)) + (/ 1.0 (tan a)))) + +(defun sec (x) (/ 1 (cos x))) +(defun csc (x) (/ 1 (sin x))) +(defun acsc (x) (asin (/ 1 x))) +(defun asec (x) (acos (/ 1 x))) +(defun csch (x) (/ 1 (sinh x))) +(defun coth (x) (* (cosh x) (csch x))) +(defun sech (x) (/ 1 (cosh x))) +(defun acsch (x) (asinh (/ 1 x))) +(defun acoth (x) (atanh (/ 1 x))) +(defun asech (x) (acosh (/ 1 x))) ;;--------------------> NEW DEFINITION (see unlisp.lisp.pamphlet)