Q0:
Is exp() supported by cuComplex.h?
Q1:
How to write A = B * exp(i * C), where A, B, C are same size arrays of real numbers? Is this right?
ma
Thrust also now has support for complex exponentials.
It's not necessary to otherwise be using thrust for this capability. You can include the thrust complex header file, and use these constructs in ordinary CUDA code.
$ cat t1793.cu
#include
#include
#include
__host__ __device__
cuFloatComplex my_complex_exp (cuFloatComplex arg)
{
cuFloatComplex res;
float s, c;
float e = expf(arg.x);
sincosf(arg.y, &s, &c);
res.x = c * e;
res.y = s * e;
return res;
}
__global__ void demo(){
cuFloatComplex a = make_cuFloatComplex(1.0f, 1.0f);
thrust::complex b(1.0f, 1.0f);
printf("thrust: %f,%f, cuComplex: %f,%f\n", exp(b).real(), exp(b).imag(), cuCrealf( my_complex_exp(a)), cuCimagf(my_complex_exp(a)));
}
int main(){
demo<<<1,1>>>();
cudaDeviceSynchronize();
}
$ nvcc -o t1793 t1793.cu
$ cuda-memcheck ./t1793
========= CUDA-MEMCHECK
thrust: 1.468694,2.287355, cuComplex: 1.468694,2.287355
========= ERROR SUMMARY: 0 errors
$