I am an EE, not a code expert, so please carry me here.
I am using Embarcadero C ++ Builder (XE3).
I have an FFT algorithm that performs many operations on complex numbers. I found out that if I go around the complex Embarcadero math library and do all the calculations in my own code, my FFT will work about 4.5 times faster. All 4 operations shown here require an excessive amount of time.
#include <dinkumware\complex> #define ComplexD std::complex<double> ComplexD X, Y, Z, FFTInput[1024]; double x, y; Z = X * Y; x = X.real(); y = X.imag(); Z = ComplexD(x,y);
Replacing multiplication with my own cross doubles the execution time. However, my concern is with the way I access the real and imaginary parts of the input array. I'm doing it:
double *Input; Input = reinterpret_cast<double *>(FFTInput);
Doing this reduction in execution time in half again, but I don't know if this reinterpret_cast is reasonable. I can change the input array to two doubles instead of a complex one, but I use this FFT in numerous programs and do not want to rewrite everything.
Is it reinterpret_cast OK, or will I have memory problems? Also, is there a way to make Embarcadero's math functions work faster? And finally, although this is not very important to me, is it portable reinterpret_cast?
source share