diff --git a/Core/Computation/RoughMultiLayerComputation.cpp b/Core/Computation/RoughMultiLayerComputation.cpp index d763d8b4191ddabb58a4f3422edddbdfee29b493..8a80a95493055cafbee93baa6a6db35f6f557a2f 100644 --- a/Core/Computation/RoughMultiLayerComputation.cpp +++ b/Core/Computation/RoughMultiLayerComputation.cpp @@ -29,12 +29,9 @@ #else #include "cerfwrap.h" std::complex<double> cerfcx(std::complex<double> z) { - const double zx = z.real(); - const double zy = z.imag(); - double vx; - double vy; - wrap_cerfcx(zx, zy, &vx, &vy); - return {vx, vy}; + std::complex<double> ret; + wrap_cerfcx((void*)&z, (void*)&ret); + return ret; } #endif diff --git a/Core/Computation/cerfwrap.c b/Core/Computation/cerfwrap.c index 1f2fdfa67aed707482ace07ded50156d3d66f47e..7b591f6bfe8721cf32cc07bc505d0e8ee2acc495 100644 --- a/Core/Computation/cerfwrap.c +++ b/Core/Computation/cerfwrap.c @@ -1,21 +1,9 @@ #include "cerfwrap.h" #include <cerf.h> +#include <string.h> -# if !defined(CMPLX) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7\ -)) && !(defined(__ICC) || defined(__INTEL_COMPILER)) -# define CMPLX(a,b) __builtin_complex((double) (a), (double) (b)) -# endif - -# ifdef CMPLX // C11 -# define C(a,b) CMPLX(a,b) -# else -# define C(a,b) ((a) + I*(b)) -# endif - -void wrap_cerfcx(double zx, double zy, double* vx, double* vy) +void wrap_cerfcx(void* z, void* ret) { - const double _Complex arg = C(zx,zy); - const double _Complex val = cerfcx(arg); - *vx = creal(val); - *vy = cimag(val); + double _Complex val = cerfcx(*(double _Complex*)(z)); + memcpy(ret, &val, 2*sizeof(double)); } diff --git a/Core/Computation/cerfwrap.h b/Core/Computation/cerfwrap.h index 1b07e1c4cf2e2ecb03be071f9ab8a8eca3b01f3e..50714051821cb5907bd4f600f6d16d74ed668eb8 100644 --- a/Core/Computation/cerfwrap.h +++ b/Core/Computation/cerfwrap.h @@ -2,7 +2,7 @@ extern "C" { #endif -void wrap_cerfcx(double zx, double zy, double* vx, double* vy); + void wrap_cerfcx(void* z, void* ret); #ifdef __cplusplus }