[Gsll-devel] patch for calculus/monte-carlo.lisp

Liam Healy lhealy at common-lisp.net
Sun Aug 8 01:54:46 UTC 2010


OK, I've fixed this by defining 'dpi as the double-float version of pi.
There were quite a number of places where pi was assumed to be
double-float, so this should work better overall for CLISP.

As for coercing, there has been a request for general coercing
to double float (or whatever GSL requires for a particular function).
I somewhat agree with this and somewhat disagree, but it is a
low priority.  In the meantime, things have actually got a bit worse
as far as arrays are concerned; with foreign arrays built-in to GSLL,
there was an auto-coerce on defining initial values; since they
are now in GSD (foreign-array), that has for the time being gone away.

Liam

On Wed, Jul 28, 2010 at 4:58 PM, Sam Steingold <sds at gnu.org> wrote:
> PI has type long-float, not double-float, so the following patch is necessary:
> =========================================================
> diff --git a/calculus/monte-carlo.lisp b/calculus/monte-carlo.lisp
> index cb18bb1..32bae65 100644
> --- a/calculus/monte-carlo.lisp
> +++ b/calculus/monte-carlo.lisp
> @@ -211,7 +211,8 @@
>  (defparameter *mc-lower* #m(0.0d0 0.0d0 0.0d0))
>
>  (defparameter *mc-upper*
> -  (grid:make-foreign-array 'double-float :initial-contents (list pi pi pi)))
> +  (grid:make-foreign-array 'double-float :initial-contents
> +                           (list #1=#.(float pi 0d0) #1# #1#)))
>
>  (defun random-walk-plain-example (&optional (nsamples 500000))
>   (monte-carlo-integrate-plain 'mcrw *mc-lower* *mc-upper* nsamples))
> =========================================================
> alternatively, you may need to call COERCE in grid:make-foreign-array
> or something.
>
> --
> Sam Steingold <http://sds.podval.org>




More information about the gsll-devel mailing list