[AD] sincos

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Hello,
As Eric suggested on [AL], I started to code an al_sincos() function for
Allegro: (btw, does anyone have objections to adding this function?)

void al_sincos(double x, double *s, double *c);
   Calculates sin(x) and cos(x) and stores the results in *s and *c.
   This is faster than calling first sin(x) and then cos(x) because
   there is a single machine instruction that does both at the
   same time.

I first wanted to make it inline, but then I realized a little problem
with this: the C version, which just calls sin() and cos(), would
require either allegro.h or the user to #include <math.h>, which is not
so nice. I have three suggestions:

 (1) Put the C version in a c file while keeping the assembler versions
inlined.
 (2) Don't inline the functions.
 (3) Include math.h.

Any preferences? (I vote for (2), since sincos() is rather slow anyway.
A comparision with djgpp's sincos() indicates that the difference is
within the uncertainty of the measurement, even though djgpp's version
does extra checks on the parameters and is non-inline).

-- 
Sven Sandberg    svsa1977@xxxxxxxxxx    home.student.uu.se/svsa1977



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/