To summarize and expand slightly on the comments:
- The CUDA math library offers no direct support of an
arg()
function for complex values.
cuComplex.h
is very rudimentary. As @njuffa notes: It only has what's required by CUBLAS and CUFFT.
- You can, and should, use
atan2(y, x)
(or std::atan2(y, x)
), where y
is the imaginary component and x
is the real one.
Now, what about Thrust? thrust::complex<T>
does have an arg()
method, after all?
Well, this is how it's implemented:
template <typename T>
__host__ __device__
T arg(const complex<T>& z)
{
// Find `atan2` by ADL.
using std::atan2;
return atan2(z.imag(), z.real());
}
(see also on GitHub.) ... so, atan2()
there as well.