Does a C ++ function call a solution for you? C ++ STL has a nice complex class, and boost also offers some nice options. Write a function in C ++ and declare it "extern C"
extern "C" void myexp(float*, float*); #include <complex> using std::complex; void myexp (float *real, float *img ) { complex<float> param(*real, *img); complex<float> result = exp (param); *real = result.real(); *img = result.imag(); }
You can then call the function from any C code you rely on (Ansi-C, C99, ...).
#include <stdio.h> void myexp(float*, float*); int main(){ float real = 0.0; float img = -1.0; myexp(&real, &img); printf ("e^-i = %f + i* %f\n", real, img); return 0; }
Lucas source share