[Liboil] complex types?

Stephane Fillod f8cfe at free.fr
Mon Nov 21 00:36:51 PST 2005

On Mon, Nov 14, 2005 at 06:54:51PM -0800, David Schleef wrote:
[..]> oil_sincos_interleaved_f64(double *d_2xn, double *s1_1, double *s2_1,
> int n)
> {
>   int i;
>   for(i=0;i<n;i++){
>     d_2xn[i*2 + 0] = cos(*s1_1 + *s2_1 * i);
>     d_2xn[i*2 + 1] = sin(*s1_1 + *s2_1 * i);
>   }
> }

I've created a bunch of sincos_interleaved_*, with a scaling factor:

 oil_sincos_interleaved_*(double *d_2xn, double *s1_1, double *s2_1,
 				double *s3_1, int n);

Now, I'd like to create a new one, but I'm not sure about a good name:

 oil_sincos_interleaved_source_*(double *d_2xn, double *s1_n, 
 				double *s3_1, int n);
   int i;
     d_2xn[i*2 + 0] = cos(*s1_n[i]) * *s3_1;
     d_2xn[i*2 + 1] = sin(*s1_n[i]) * *s3_1;

Do you have a better idea?

> Also,
> oil_complexmult_f64 (double *d_2xn, double *s1_2xn, double *s2_2xn, int
> n)

and what should be the name of a dot product of complex with real array?

oil_complexmultsum_f64_f64 (double *d_2, double *s1_2xn, double *s2_n, int n)
   int i;
   double sum0 = 0, sum1 = 0;
     sum0 += s1_2xn[2*i + 0] * s2_n[i];
     sum1 += s1_2xn[2*i + 1] * s2_n[i];
   d_2xn[0] = sum0;
   d_2xn[1] = sum1;
> So in other words, complex would be a convention, not a new type,
> somewhat like ARGB.  BTW, I'm trying to avoid the issue in order to
> take a wait-and-see approach.
> > BTW, I don't understand why offset and interval
> > are passed by address and not by value in oil_sincos_f64.
> Everything is pass-by-address because it's about a million times
> easier on the automatic testing and marshalling code.  And that's
> one of the reasons why liboil exists instead of being prototype
> code in my random hacking directory.

I guess that is for the same reason liboil doesn't use function return
value, but return by address.

I have couple more questions about implementation.
>From the liboil/HACKING file, I see that pure C implementations
should go in liboil/c subdirectory. There's no such directory.
Should I create it? Likewise, in which directory should we put 3DNow!
and MMX intrinsic-based implementations ?

When creating a new API entry like sincos_interleaved_f64, I noticed
I had to add a line "OIL_DECLARE_CLASS(sincos_interleaved_f64);"
in liboil/simdpack/simdpack.h to make it to compile. I'm sure
there's a much proper place where to declare the class. What would 
you recommend?

Is it okay to assume all the math calls in liboil are doing modulo
arithmetics when the integers overflow? What should be the modifier 
name for saturation?


More information about the Liboil mailing list