> On Oct 8, 2015, at 12:45 PM, Eric Barnhill <ericbarnh...@gmail.com> wrote: > > Dear commons-math.complex maintainers, > > I would like to add a static method to the Complex class that would work as > follows: > > double[] d = Complex.getInterleaved(Complex[] c); > > It would export the data from a Complex[] as a double[] twice the size of > the Complex[] array with real and imaginary components alternating. > > Historically, methods sometimes have used interleaved data because it can > be returned from methods in a single 1D primitive array which can be > computationally advantageous. The JTransforms library is an example. > However, interleaved is still a popular format for data especially with the > advent of CUDA and OpenCL. > > OpenCL in particular makes use of a float2() class to handle complex > numbers, and when Complex[] data is exported into an interleaved float[] > array it can be passed directly to an OpenCL buffer without further > manipulation. > > A related static method, say Complex[] c = > Complex.interleavedToComplex(double[] d) would make a good complement to > the above method and remove some extraneous boilerplate for people > converting between these two (like me). > > There may be a better class for these static methods than the Complex class > itself. Here I am thinking of methods like Integer.toString() . > > Would those involved with commons-math be happy if I checked out the code > and submitted a pull request with this changes? > > Thanks, > Eric
I’d use this. Perhaps they should be in ComplexUtil, where there already is: Complex[] convertToComplex(double[] real) Bruce --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org For additional commands, e-mail: dev-h...@commons.apache.org