Bruce and Gilles,

Thanks for thinking through the problem so well. Your suggestions sound like a good way to do.

For method names, I agree that accessor names are not right. I propose sticking with the convention I see currently in ComplexUtils e.g. polar2Complex. That's a fairly typical convention and nicely compact. Then the methods under discussion would be

Complex[] interleaved2Complex(double[] interleaved, int from, int to)
Complex[] interleaved2Complex(double[] interleaved, Iterable<Integer> range)
Complex[] interleaved2Complex(double[] interleaved) // with one argument, would convert all

double[] complex2Interleaved(Complex[] complex, int from, int to)
double[] complex2Interleaved(Complex[] complex, Iterable<Integer> range)
double[] complex2Interleaved(Complex[] complex) // op. cit.

I would also want to make float methods as the result could be called from the constructor of an OpenCL buffer:

Complex[] interleaved2Complex(float[] interleaved, int from, int to)
Complex[] interleaved2Complex(float[] interleaved, Iterable<Integer> range)
Complex[] interleaved2Complex(float[] interleaved)

float[] complex2InterleavedFloat(Complex[] complex, int from, int to)
float[] complex2InterleavedFloat(Complex[] complex, Iterable<Integer> range)
float[] complex2InterleavedFloat(Complex[] complex)

and the internal building blocks would be four helper methods

double[] extractInterleavedAtIndex(Complex[] complex, int index)
float[] extractInterleavedFloatAtIndex(Complex[] complex, int index)
Complex extractComplexAtIndex(double[] interleaved, int index)
Complex extractComplexAtIndex(float[] interleaved, int index)

I can iterate through the Complex[] but for the double[] I think I will just have to write a loop, as I see is already true in the ComplexUtils().convertToComplex() method.

Please pass along any further suggestions and I'll get started.

Thanks,
Eric

On 09/10/15 11:31, Gilles wrote:


Also, the reverse method could perhaps use additional parameters in
order to try and signal wrong usage or to extract only some part of
the input array data.

Maybe something along the lines:

Complex[] convertInterleavedToComplex(double[] interleaved, int from, int to)





where "from" and "to" would be the range of complex elements to
create. Thus, to convert the whole of "interleaved":
  from = 1,
  to = interleaved.length / 2

We could also make it more general and use the new "range" method
defined in "o.a.c.m.util.IntegerSequence".

Perhaps the basic building block should be a method:

  Complex extractInterleavedAtIndex(double[] interleaved, int index)

where the real and imaginary parts to be extracted are the array
elements located at "index" and "index + 1", respectively.

What do you think?


Gilles

where there already is:

Complex[] convertToComplex(double[] real)

Bruce


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to