[Liboil] complex types?

David Schleef ds at schleef.org
Mon Nov 14 18:54:51 PST 2005


On Mon, Nov 14, 2005 at 09:50:07AM +0100, Stephane Fillod wrote:
> On Sun, Nov 13, 2005 at 04:32:51PM -0800, David Schleef wrote:
> > Is there any reason to have complex integer types?  I can understand
> > the need for complex float/double.
> 
> Some applications do complex fixed-point (integer) computations.
> This is a lot faster on FPU-less systems.

Ah, sure.  But then, liboil doesn't even have fixed-point types
currently.  That would be nice to have.

> I mean 'float *' as in 'float *d_2xn' that has n interleaved real and
> imag float values. Speed can be one reason, existing data model of 
> applications and/or hardware devices is another one.

Ok, good.

> oil_sincos_f64()-like prototype does not fit my need, because "complex" 
> args are not interleaved.

How about:

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);
  }
}

Also,

oil_complexmult_f64 (double *d_2xn, double *s1_2xn, double *s2_2xn, int
n)
{
  int i;
  double a, b, c, d;
  for(i=0;i<n;i++){
    a = s1_2xn[2*i + 0];
    b = s1_2xn[2*i + 1];
    c = s2_2xn[2*i + 0];
    d = s2_2xn[2*i + 1];
    d_2xn[2*i + 0] = a * c - b * d;
    d_2xn[2*i + 1] = a * d + b * c;
  }
}

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.



dave...

-- 
David Schleef
Big Kitten LLC (http://www.bigkitten.com/) -- data acquisition on Linux


More information about the Liboil mailing list