On Sep 1, 2009, at 11:45 PM, Richard Fateman wrote:
> ?iga Lenarc(ic( wrote:
>> On Sep 1, 2009, at 11:05 PM, Raymond Toy wrote:
>>
>>> Hopefully the compiler is smart enough to know that flonum is the
>>> same
>>> as double-float.
>>>
>>> Ray
>>>
>>>
>>
>> This is the real question. Moreover - do (more or less) all lisps
>> do this? I'll do a test on SBCL.
>>
>> Regards,
>> Ziga
>> _______________________________________________
>> Maxima mailing list
>> Maxima at math.utexas.edu
>> http://www.math.utexas.edu/mailman/listinfo/maxima
>>
> If Ray's view is right (and I think it is),
> I think you need to say (deftype flonum () 'double-float)
>
> and also (declare (optimize (speed 3)(safety 0)) in the fft program.
>
> or maybe (safety 1), which may be almost as fast but safer.
>
> RJF
>
>
From clmacs.lisp:
(deftype flonum (&optional low high)
(cond (high
`(double-float ,low ,high))
(low
`(double-float ,low))
(t
'double-float)))
Or for the double double type
(deftype flonum (&optional low high)
(cond (high
`(kernel:double-double-float ,low ,high))
(low
`(kernel:double-double-float ,low))
(t
'kernel:double-double-float)))
So flonum is always 'deftyped' to some internal floating point type.
In a C program the situation is very clear - deftypes are resolved
before compilation by the macro preprocessor, so optimization is there.
Perhaps we could also support http://common-lisp.net/project/oct/
which should work on all lisps, though it's quite a performance hit
and I don't know if it's doable or even worth it...
On a side note, I've used maxima's $timer function and found out (by
following internal ?forward\-fft and maxima's 'float' functions) that
time taken by conversion of data is 10x bigger than that of internal
numerical fft routine which works on double-float arrays. Each maxima
number (represented by mplus expression if complex) is split into two
double-float numbers with (risplit ($float maxima-number)) - and this
is where most of the time is spent.
Regards,
Ziga