A new implementation of C++ std::complex for complex numbers on CUDA

I have written a new implementation of C++ std::complex for use of complex numbers on CUDA devices.
It is is heavily derived from the LLVM libcpp project.

Apart from nvcc, it should also work wih any C++03 compiler.
It is quiet complete. As far as I can tell the only missing features are:

  • long double support (not supported on CUDA)
  • some integral pow functions (due to lack of C++11 support on CUDA)

The code is available on githib:


Please let me know of any improvements/errors you find with it.


what are the minimum requirements regarding the CUDA toolkit version?


I’m not entirely sure. I wrote and tested it with version 4.1. It should also work with 4.0.

BTW you may also be interested in the Cusp library which has an alternative implementation (which I didn’t know about when writing this one):



John, I tried to use your complex number on device

device complex complex_CUDA;

And I got this ‘error: can’t generate code for non empty constructors or destructors on device’

What is wrong?