Stavros Macrakis wrote:
> On Sat, Aug 22, 2009 at 6:36 PM, ?iga Lenar?i?<ziga.lenarcic at gmail.com> wrote:
>
>> ...Code like
>>
>> (dotimes (i ($length a1))
>> (setf (nth (1+ i) a1) (m+ (nth (1+ i) a1) (m* '$%i (nth (1
>> + i) a2)))))
>>
>> can't be efficient on lists of length perhaps 1024*8. Surely the list
>> should be traversed in some other way....
>>
>
> Indeed! This changes FFT from O(n log n) to O(n^2) -- though with a
> smaller constant.
>
> As for the m+ etc., I suppose this is to allow the use of bfloats as
> well as machine numbers, and in the future perhaps to other numeric
> types (intervals?).
>
> -s
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>
rewriting ...
(dotimes (i ($length a1))
(setf (nth (1+ i) a1)
(m+ (nth (1+ i) a1)
(m* '$%i (nth (1+ i) a2)))))
;; here's my suggestion...
(let ((r2 (coerce (rest a2) 'vector))) ;; do this somewhere outside loop...
(let ((r1 (coerce (rest a1) 'vector))) ;; assuming a1 looks like
((mlist) 1 2 3....)
(dotimes (i (length r) (setf a1 (cons '(mlist) (coerce r1) 'list)))
(setf (aref r1 i)
(m+ (aref r1 i)
(m* '$%i (aref r2)))))))
;; Though there is no reason, internal to the FFT to uses lists EVER.