In C++, to use complex numbers, I have the struct-type "creal" be defined as
typedef struct {
double re;
double im; } creal;
Now let "length" be the number of elements of the struct array "complex_vector" that is initilized as
creal complex_vector[length];
and is later filled with data.
I would like to extract the two arrays "real_vector" and "imag_vector" from "complex_vector". Until now I have used a for-loop:
double real_vector[length];
double imag_vector[length];
for (int n = 0; n < length; n++)
{
real_vector[n] = complex_vector[n].re;
imag_vector[n] = complex_vector[n].im;
}
I wonder if there is a way to avoid the for loop and extract the values of the struct array "complex_vector" directly to create the arrays "real_vector" and "imag_vector".
Thank you for your help.
#include <complex>
std::transform
.