jjjkkkjjj / Matft

Numpy-like library in swift. (Multi-dimensional Array, ndarray, matrix and vector library)
BSD 3-Clause "New" or "Revised" License
134 stars 21 forks source link

Complex support #24

Open jjjkkkjjj opened 2 years ago

jjjkkkjjj commented 2 years ago

To use vdsp, DSPSplitComplex seems to be needed according to documents

To use blas package, DSPComplex will be needed according to this discussion

to achieve to support complex type, using DSPComplex is ideal? I must check the difference between DSPComplex and DSPSplitComplex at first.

DSPComplex is the consecutive float values.

Complex data are stored as ordered pairs of floating-point numbers. Because they are stored as ordered pairs, complex vectors require address strides that are multiples of two.

by document

On the other hand, DSPSplitComplex is stored in different memories

A structure that represents a single-precision complex vector with the real and imaginary parts stored in separate arrays.

by document

So I need to implement the function to connect this difference of memory layout

jjjkkkjjj commented 2 years ago

Basically I store complex data as DSPComplex, and then pass DSPSplitComplex(realptr, imgptr)with 2 times strides to vDSP function

jjjkkkjjj commented 2 years ago

To convert DSPComplex into DSPSplitComplex, use vDSP_ctoz

jjjkkkjjj commented 2 years ago

Hmm, Create another object as MfArrayComplex?

jjjkkkjjj commented 2 years ago

Create MfComplexArray with realdata and imagdata simply!

jjjkkkjjj commented 2 years ago

ToDo

jjjkkkjjj commented 2 years ago

MfComplexArray inherent from MfArray and MfComplexData inherit from MfData?

jjjkkkjjj commented 2 years ago

How about withUnsafeComplexPointer?

jjjkkkjjj commented 2 years ago

Complex addition was implemented by ca948f4. But, this implementation will be hard for other modification... So, should i integrate MfComplexArray into MfArray?

jjjkkkjjj commented 1 year ago

ToDo list