What CUDA headers should I include in my programme if I want to work with complex numbers and do simple maths operations (addition and multiplication) to these complex double nu
The header to include is:
#include
On a standard linux CUDA install, it is located in:
/usr/local/cuda/include
You will need to inspect that header file and use the functions defined in it to manipulate complex numbers on the device.
To multiply a (double) complex number by a real number, I would:
#include
...
double cr = 1;
double ci = 2;
double r = 3;
cuDoubleComplex c = make_cuDoubleComplex(cr, ci);
cuDoubleComplex result = cuCmul(c, make_cuDoubleComplex(r, 0));
EDIT: With the recently released Thrust v1.8 in CUDA 7 RC, it is possible to use thrust::complex in either thrust code or CUDA device code. This makes it possible to write more natural-looking operations such as:
#include
...
thrust::complex c = thrust::complex(2.0f, 5.0f);
thrust::complex c2 = c*c;
float r = c2.real();