R
Rex_chaos
Hi all,
I have a question about datatype converting. Consider the following
types
std::complex<double>
and
struct MyComplex
{
double re, im;
}
I have a larger array of std::complex being converted to that of
MyComplex
I have tried std::transform plus a self-defined converting function.
It works but the efficiency is very low.
I also tried the following method.
std::complex<double> *a;
MyComplex *b;
//initialize a, b
b = reinterpret_cast<MyComplex*>(a);
Yes. Now it's so fast!!! However, I found that the address of a and b
are the same after casting. That is, one of the allocated memory will
be lost!!! That's too bad. Please help!
I have a question about datatype converting. Consider the following
types
std::complex<double>
and
struct MyComplex
{
double re, im;
}
I have a larger array of std::complex being converted to that of
MyComplex
I have tried std::transform plus a self-defined converting function.
It works but the efficiency is very low.
I also tried the following method.
std::complex<double> *a;
MyComplex *b;
//initialize a, b
b = reinterpret_cast<MyComplex*>(a);
Yes. Now it's so fast!!! However, I found that the address of a and b
are the same after casting. That is, one of the allocated memory will
be lost!!! That's too bad. Please help!