> Return of double-floats is very costly (the compiler should have
> printed a note informing you of the problem, if not you need to switch
> on notes).

Right now my 500 line program is printing about 800 notes.  I haven't
read them all.

> Try not to let the double-float "escape" to global variables or as
> function returns or as direct function parameters.
> 
> If needed, use an array or a struct to pass it around functions by
> reference.

I'm getting a vague mental picture, but I don't completely understand
(yet).  Let's say I have a vector of double-floats (call it orig), and
I want a new vector (squared) whose i'th element is the square of the
i'th element of the original double-float.  (We can also assume that I
am willing to have my program crash or even produce ill-defined
results if squaring an element of orig results in an overflow.)  

In order to get good performance, will I have to make a single
function that takes the whole vector and does all the operations
internally (i.e., a function called square-vector for instance), or
can I build a higher-order function which takes a procedure like
square and operates on the elements of the vector?  It seems that if
I'm guaranteed to lose as soon as I call a function with a
double-float argument, that it's going to be hard to do this fast.
What're good strategies here?

rif

Reply via email to