How to load maxima as a asdf package? (sbcl)



On 12/24/10 9:36 PM, Shaowei Wang (wsw) wrote:
> Hi ,all
>   I found maxima.asd file in maxima/src/. So I want to load maxima as
> a asdf package using sbcl. But I have some issues.
I think the preferred way of building maxima is to use configure/make.

> ; compiling file
> "/home/wsw/Sources/maxima/src/numerical/slatec/derfc.lisp" (written 08
> APR 2009 08:04:22 AM):
> ; compiling (IN-PACKAGE :SLATEC)
> ; compiling (LET (# # ...) ...)
> ; file: /home/wsw/Sources/maxima/src/numerical/slatec/derfc.lisp
> ; in: DEFUN DERFC
> ;     (F2CL-LIB:FSQRT (* 2.0d0 (F2CL-LIB:D1MACH 3)))
> ; --> BLOCK TYPECASE LET COND IF PROGN SQRT COERCE THE
> ; ==>
> ;   (SB-KERNEL:%SINGLE-FLOAT SB-C::X)
> ;
> ; caught STYLE-WARNING:
> ;   Result is a (VALUES (SINGLE-FLOAT 0.0f0) &OPTIONAL), not a DOUBLE-FLOAT.
> ;   See also:
> ;     The SBCL Manual, Node "Handling of Types"
>
> ;     (SETF SLATEC::TXMAX (F2CL-LIB:FSQRT (- (F2CL-LIB:FLOG #))))
> ; --> SETQ
> ; ==>
> ;   (THE #<SB-KERNEL:NUMERIC-TYPE DOUBLE-FLOAT>
> ;        (F2CL-LIB:FSQRT (- (F2CL-LIB:FLOG (* SLATEC::SQRTPI #)))))
> ;
> ; caught WARNING:
> ;   Asserted type DOUBLE-FLOAT conflicts with derived type
> ;   (VALUES (OR (COMPLEX SINGLE-FLOAT) (COMPLEX DOUBLE-FLOAT)

Try the following.  In numerical/f2cl-lib.lisp, change the entry for
fsqrt to be:

(defun fsqrt (x)
  (typecase x
    (single-float
      (sqrt (the (type (or (single-float (0f0)) (member 0f0))) x))
    (double-float
      (sqrt (the (type (or (double-float (0d0)) (member 0d0)))) x))
    (t (sqrt x))))

This is a bug in f2cl-lib.lisp which was neglecting to take into account
floating-point signed zeroes, which, I think is only supported by cmucl
and sbcl.  And cmucl says (sqrt -0d0) is -0d0.  I suspect sbcl says
(sqrt -0d0) produces a complex number.

Ray