Robert Dodier writes:
> Stavros Macrakis wrote:
> > Having the same generator on every platform would be ideal.
>
> Richard Fateman wrote:
> > Only if it is as fast as possible on every platform.
>
> I'm inclined to think that we can have both portability and
> acceptable performance across platforms.
>
> I found a Lisp implementation of the Mersenne twister.
> This implementation loads into CMUCL, Clisp, and GCL out
> of the box. As you know, CMUCL's RANDOM is a MT
> implementation also, but it doesn't drop into Clisp or GCL.
>
> In a simple test (a Monte Carlo integration) calling MT-RANDOM
> from Maxima random (instead of RANDOM) to fill an array with
> random numbers takes about 1.5 times as long (Clisp) or five times
> as long (CMUCL). But since that's only part of the work, the
> overall time to finish the computation is about 1.2 times as
> long (Clisp) or twice as long (CMUCL).
I just glanced at the code. It's essentially unoptimized lisp.
Appropriate type declarations, a top level (optimize ...) statement
and a little inlining should speed it up substantially.
Alternatively, with some read-time conditionalization, you could
presumably port the CMUCL implementation (which is probably already
heavily optimized) to the other lisps. I wouldn't be surprised if
it's just a couple of optimization declarations that aren't available
in the other lisps that are causing the problem.
--
Harvey Stein
Bloomberg LP
hjstein@bloomberg.com