diff --git a/books/bookvol10.3.pamphlet b/books/bookvol10.3.pamphlet index 97d6d81..3756f73 100644 --- a/books/bookvol10.3.pamphlet +++ b/books/bookvol10.3.pamphlet @@ -28096,7 +28096,7 @@ DoubleFloat(): Join(FloatingPointSystem, DifferentialRing, OpenMath, then polygamma(n::Integer::NonNegativeInteger,sfy)$SFSFUN pretend % else error "polygamma: first argument should be a nonnegative integer" - wholePart x == FIX(x)$Lisp + wholePart x == TRUNCATE(x)$Lisp float(ma,ex,b) == ma*(b::%)**ex convert(x:%):DoubleFloat == x pretend DoubleFloat convert(x:%):Float == convert(x pretend DoubleFloat)$Float @@ -28128,10 +28128,9 @@ DoubleFloat(): Join(FloatingPointSystem, DifferentialRing, OpenMath, "failed" sign(x) == retract FLOAT_-SIGN(x,1)$Lisp - abs x == FLOAT_-SIGN(1,x)$Lisp + abs x == FLOAT_-SIGN(1,x)$Lisp - manexp(x) == zero? x => [0,0] s := sign x; x := abs x @@ -145177,7 +145176,7 @@ Note that this code is not included in the generated catdef.spad file. ((EQL (FLOAT-RADIX 0.0) 16) (* 4 (FLOAT-DIGITS 0.0))) ('T (PROG1 (LETT G105705 - (FIX (SPADCALL (FLOAT-DIGITS 0.0) + (truncate (SPADCALL (FLOAT-DIGITS 0.0) (SPADCALL (FLOAT (FLOAT-RADIX 0.0) MOST-POSITIVE-LONG-FLOAT) @@ -145408,9 +145407,9 @@ Note that this code is not included in the generated catdef.spad file. (DEFUN |DFLOAT;Beta;3$;69| (|x| |y| |$|) (SPADCALL |x| |y| (QREFELT |$| 95))) -(PUT (QUOTE |DFLOAT;wholePart;$I;70|) (QUOTE |SPADreplace|) (QUOTE FIX)) +(PUT (QUOTE |DFLOAT;wholePart;$I;70|) (QUOTE |SPADreplace|) (QUOTE truncate)) -(DEFUN |DFLOAT;wholePart;$I;70| (|x| |$|) (FIX |x|)) +(DEFUN |DFLOAT;wholePart;$I;70| (|x| |$|) (truncate |x|)) (DEFUN |DFLOAT;float;2IPi$;71| (|ma| |ex| |b| |$|) (|*| |ma| (EXPT (FLOAT |b| |MOST-POSITIVE-LONG-FLOAT|) |ex|))) @@ -145472,7 +145471,7 @@ Note that this code is not included in the generated catdef.spad file. (PROG (|n|) (RETURN (SEQ - (LETT |n| (FIX |x|) |DFLOAT;retract;$I;78|) + (LETT |n| (truncate |x|) |DFLOAT;retract;$I;78|) (EXIT (COND ((|=| |x| (FLOAT |n| |MOST-POSITIVE-LONG-FLOAT|)) |n|) @@ -145482,7 +145481,7 @@ Note that this code is not included in the generated catdef.spad file. (PROG (|n|) (RETURN (SEQ - (LETT |n| (FIX |x|) |DFLOAT;retractIfCan;$U;79|) + (LETT |n| (truncate |x|) |DFLOAT;retractIfCan;$U;79|) (EXIT (COND ((|=| |x| (FLOAT |n| |MOST-POSITIVE-LONG-FLOAT|)) (CONS 0 |n|)) @@ -145529,7 +145528,7 @@ Note that this code is not included in the generated catdef.spad file. (FLOAT-DIGITS 0.0)) |DFLOAT;manexp|) (EXIT (CONS (* |s| - (FIX (* |two53| (QCAR |me|)))) + (truncate (* |two53| (QCAR |me|)))) (- (QCDR |me|) (FLOAT-DIGITS 0.0)))))))) G105806 (EXIT G105806))))) diff --git a/books/bookvol5.pamphlet b/books/bookvol5.pamphlet index a3dd676..ba3f6ba 100644 --- a/books/bookvol5.pamphlet +++ b/books/bookvol5.pamphlet @@ -37139,6 +37139,16 @@ filetype and filemode. We also UPCASE everything. @ +\defun{pname}{pname} +Note it is important that PNAME returns nil not an error for non-symbols +<>= +(defun pname (x) + (cond ((symbolp x) (symbol-name x)) + ((characterp x) (string x)) + (t nil))) + +@ + \defun{size}{size} <>= (defun size (l) @@ -39666,6 +39676,7 @@ This needs to work off the internal exposure list, not the file. <> <> <> +<> <> <> diff --git a/changelog b/changelog index cc5f075..40e1574 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,10 @@ +20101218 tpd src/axiom-website/patches.html 20101218.01.tpd.patch +20101218 tpd src/interp/vmlisp.lisp cleaning vmlisp +20101218 tpd src/interp/i-output.lisp cleaning vmlisp +20101218 tpd src/interp/g-timer.lisp cleaning vmlisp +20101218 tpd src/interp/br-con.lisp cleaning vmlisp +20101218 tpd books/bookvol5 cleaning vmlisp +20101218 tpd books/bookvol10.3 cleaning vmlisp 20101217 tpd src/axiom-website/patches.html 20101217.01.tpd.patch 20101217 tpd books/bookvol5 cleaning vmlisp 20101217 tpd src/interp/i-coerce.lisp cleaning vmlisp diff --git a/src/axiom-website/patches.html b/src/axiom-website/patches.html index 75f51a6..3cb1fbf 100644 --- a/src/axiom-website/patches.html +++ b/src/axiom-website/patches.html @@ -3321,5 +3321,7 @@ books/bookvol9 treeshake compiler
books/bookvol9 treeshake compiler
20101217.01.tpd.patch src/interp/vmlisp.lisp cleaning vmlisp
+20101218.01.tpd.patch +src/interp/vmlisp.lisp cleaning vmlisp
diff --git a/src/interp/br-con.lisp.pamphlet b/src/interp/br-con.lisp.pamphlet index f2b550c..8846015 100644 --- a/src/interp/br-con.lisp.pamphlet +++ b/src/interp/br-con.lisp.pamphlet @@ -10679,6 +10679,17 @@ ; count := count + 1 ; htEndTable() +;; property lists in vmlisp are alists +(defun PROPLIST (x) + (if (symbolp x) + (plist2alist (symbol-plist x)) + nil)) + +(defun plist2alist (x) + (if (null x) + nil + (cons (cons (first x) (second x)) (plist2alist (cddr x))))) + (DEFUN |dbShowOpParameters| (|htPage| |opAlist| |which| |data|) (declare (ignore |htPage| |opAlist|)) (PROG (|single?| |firstTime| |opform| |exposeFlag| |tail| |op| |args| diff --git a/src/interp/g-timer.lisp.pamphlet b/src/interp/g-timer.lisp.pamphlet index 09bbb5c..8b55510 100644 --- a/src/interp/g-timer.lisp.pamphlet +++ b/src/interp/g-timer.lisp.pamphlet @@ -266,7 +266,7 @@ (DEFUN |roundStat| (|t|) (COND ((NULL (RNUMP |t|)) |t|) - ('T (QUOTIENT (FIX (PLUS 0.5 (TIMES |t| 1000.0))) 1000.0)))) + ('T (QUOTIENT (truncate (PLUS 0.5 (TIMES |t| 1000.0))) 1000.0)))) ;makeStatString(oldstr,time,abb,flag) == ; time = '"" => oldstr diff --git a/src/interp/i-output.lisp.pamphlet b/src/interp/i-output.lisp.pamphlet index c857b15..b15695b 100644 --- a/src/interp/i-output.lisp.pamphlet +++ b/src/interp/i-output.lisp.pamphlet @@ -2606,6 +2606,57 @@ NIL ((ATOM |u|) (|#| (|atom2String| |u|))) ('T (WIDTH (COPY |u|))))) +;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))))) + ;WIDTH u == ; STRINGP u => ; u = $EmptyString => 0 diff --git a/src/interp/vmlisp.lisp.pamphlet b/src/interp/vmlisp.lisp.pamphlet index f9a9093..0bfcbe5 100644 --- a/src/interp/vmlisp.lisp.pamphlet +++ b/src/interp/vmlisp.lisp.pamphlet @@ -425,14 +425,6 @@ documentclass{article} (defun define-function (f v) (setf (symbol-function f) v)) -(defun $TOTAL-ELAPSED-TIME () - (list (get-internal-run-time) (get-internal-real-time))) - -(defun $TOTAL-GC-TIME (&aux (gcruntime (system:gbc-time))) - (if (minusp gcruntime) - (setq gcruntime (system:gbc-time 0))) - (list gcruntime gcruntime)) - ; 7.0 Macros ; 7.2 Creating Macro Expressions @@ -605,101 +597,10 @@ documentclass{article} ; 11.2 Accessing -;; note it is important that PNAME returns nil not an error for non-symbols -(defun pname (x) - (cond ((symbolp x) (symbol-name x)) - ((characterp x) (string x)) - (t nil))) - -;; property lists in vmlisp are alists -(defun PROPLIST (x) - (if (symbolp x) - (plist2alist (symbol-plist x)) - nil)) - -(defun plist2alist (x) - (if (null x) - nil - (cons (cons (first x) (second x)) (plist2alist (cddr x))))) - (defun put (sym ind val) (setf (get sym ind) val)) (define-function 'MAKEPROP #'put) -; 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 - -(define-function 'FIX #'truncate) - -; 12.2 Predicates - -;(define-function 'lessp #'<) - - -; 12.3 Computation - -;(define-function 'sub1 #'1-) -;(define-function 'plus #'+) -;(define-function 'times #'*) -;(define-function 'minus #'-) - (defun QUOTIENT (x y) (cond ((or (floatp x) (floatp y)) (lisp:/ x y)) (t (truncate x y))))