I was thinking about how to speed up some code in /share/linearalgebra.
If I could figure out how to make the function 'sumit' (see below)
faster, I could use the same ideas to speed up linearalgebra.
My experiments show that 'sumit' runs no faster when it uses doubles
than when it doesn't.
(The function 'sumit' imitates things that need to be done in
linearalgebra--the function 'sumit' is just a simplified 'toy'
function.)
(%i2) load("sumit.o")$
(%i3) showtime : all$
Evaluation took 0.00 seconds (0.00 elapsed)
(%i4) lst : makelist(1.0/k,k,1,10^4)$
(%i5) sumit('double,lst);
Evaluation took 3.70 seconds (3.70 elapsed)
(%o5) 9.7876060360443446
(%i6) sumit('abc,lst);
Evaluation took 3.77 seconds (3.77 elapsed)
(%o6) 9.7876060360443446
---file sumit.lisp-------
(defun $sumit (typ lst)
(let* ((n ($length lst)) (acc 0)
(a (if (eq typ '$double)
(make-array n :element-type 'double-float :initial-contents (cdr lst))
(make-array n :initial-contents (cdr lst)))))
(flet ((fadd (x y) (if (eq typ '$double) (+ x y) (add x y))))
(decf n)
(loop for i from 0 to n do
(setq acc (fadd acc (aref a i)))))
acc))
------------------------
Barton