![]() |
Blitz Support : |
From: Julian Cummings (cummings_at_[hidden])
Date: 2004-05-07 12:34:28
Hello Ed,
Edward Grace wrote:
>The concept of storage orders seems to be almost what is needed, but at the
>same time I doubt it will work. I have started using MATLAB for the
>convenience of prototyping, data analysis etc. Unfortunately the part of the
>MATLAB API I am using deals with complex numbers using seperate arrays for
>the real and imaginary parts, rather than one array of (say) complex<double>.
>
>The library requires:
>
> double* realPart;
> double* imagPart;
>
>Whereas a typical array (even in Blitz++) would be
>
> Array<complex<double>,2> A(2,2);
>
>A pointer to which is given by:
> complex<double>* complexArray=A.data();
>
>Is there any way (no matter how contrived), that pointers to the real and
>imaginary parts can be returned such that
>
> realPart++; imagPart++;
>
>point to the next real and imaginary double?
>
>
>
You can use the blitz functions real() and imag() to get the real and
imaginary components of a complex Array. However, these functions
produce Array "views" of the data, which would still be strided in
memory. You can get Array iterators from these component Arrays and
step through the data that way. If you truly need raw pointers, you
could do something nasty like reinterpret_cast<> your complex<double>*
into a double* and step through the memory yourself. If you really need
the components to be in separate contiguous memory blocks, you would
need to copy the Array views into new Arrays of double.
Regards, Julian C.
-- Dr. Julian C. Cummings E-mail: cummings_at_[hidden] California Institute of Technology Phone: 626-395-2543 1200 E. California Blvd., Mail Code 158-79 Fax: 626-584-5917 Pasadena, CA 91125