cudacomplex

This header is in the RTS, and contains useful CUDA operators. All credit to the original author, R. G. Edgar. I’ve added in double definitions, as well as my cuUserComplex def, which allows float or double to be selected during compilation using the flag --DDOUBLE_PRECISION (so even though in the below it says typedef cuFloatComplex cuUserComplex, this depends on compilation).

CUDA operators for complex numbers. For some reason, these aren’t defined in the CUDA headers form NVIDIA

Author

R. G. Edgar

Typedefs

typedef cuFloatComplex cuUserComplex

If -DDOUBLE_PRECISION flag is NOT added at compilation, then cuUserComplex is set to cuFloatComplex

Functions

__device__ inline cuFloatComplex operator-(cuFloatComplex a)

Unary negative.

__device__ inline void operator+=(cuFloatComplex &a, const cuFloatComplex b)

Self addition.

__device__ inline cuFloatComplex operator+(const cuFloatComplex a, const cuFloatComplex b)

Addition of two complex numbers.

__device__ inline cuFloatComplex operator+(const cuFloatComplex a, const float r)

Addition of float to complex.

__device__ inline cuFloatComplex operator+(const float r, const cuFloatComplex z)

Addition of complex to float.

__device__ inline void operator-=(cuFloatComplex &a, const cuFloatComplex b)

Self subtraction.

__device__ inline cuFloatComplex operator-(const cuFloatComplex a, const cuFloatComplex b)

Subtraction.

__device__ inline void operator*=(cuFloatComplex &a, const cuFloatComplex b)

Self multiplication.

__device__ inline cuFloatComplex operator*(const cuFloatComplex a, const cuFloatComplex b)

Multiplication of two complex numbers.

__device__ inline void operator*=(cuFloatComplex &z, const float r)

Self multiplication by real number.

__device__ inline cuFloatComplex operator*(const cuFloatComplex z, const float r)

Multiplication by a real number.

__device__ inline cuFloatComplex operator*(const float r, const cuFloatComplex z)

Multiplication of a real number.

__device__ inline cuFloatComplex operator/(const cuFloatComplex a, const cuFloatComplex b)

Division of two complex numbers.

__device__ inline cuFloatComplex operator/(const float r, const cuFloatComplex b)

Division of a real number.

__device__ inline cuFloatComplex operator/(const cuFloatComplex a, const float r)

Division by a real number.

__device__ inline cuFloatComplex cuComplexExp(const cuFloatComplex z)

Exponentiation Computes e^z == e^x ( cos y + i sin y )

__device__ inline cuFloatComplex U1polar(const float theta)

Calculate real and imaginary parts of U(1) variable e^(i*theta)

__device__ inline cuDoubleComplex operator-(cuDoubleComplex a)

Unary negative.

__device__ inline void operator+=(cuDoubleComplex &a, const cuDoubleComplex b)

Self addition.

__device__ inline cuDoubleComplex operator+(const cuDoubleComplex a, const cuDoubleComplex b)

Addition of two complex numbers.

__device__ inline cuDoubleComplex operator+(const cuDoubleComplex a, const double r)

Addition of double to complex.

__device__ inline cuDoubleComplex operator+(const double r, const cuDoubleComplex z)

Addition of complex to double.

__device__ inline void operator-=(cuDoubleComplex &a, const cuDoubleComplex b)

Self subtraction.

__device__ inline cuDoubleComplex operator-(const cuDoubleComplex a, const cuDoubleComplex b)

Subtraction.

__device__ inline void operator*=(cuDoubleComplex &a, const cuDoubleComplex b)

Self multiplication.

__device__ inline cuDoubleComplex operator*(const cuDoubleComplex a, const cuDoubleComplex b)

Multiplication of two complex numbers.

__device__ inline void operator*=(cuDoubleComplex &z, const double r)

Self multiplication by real number.

__device__ inline cuDoubleComplex operator*(const cuDoubleComplex z, const double r)

Multiplication by a real number.

__device__ inline cuDoubleComplex operator*(const double r, const cuDoubleComplex z)

Multiplication of a real number.

__device__ inline cuDoubleComplex operator/(const cuDoubleComplex a, const cuDoubleComplex b)

Division of two complex numbers.

__device__ inline cuDoubleComplex operator/(const double r, const cuDoubleComplex b)

Division of a real number.

__device__ inline cuDoubleComplex operator/(const cuDoubleComplex a, const double r)

Division by a real number.

__device__ inline cuDoubleComplex cuComplexExp(const cuDoubleComplex z)

Exponentiation Computes e^z == e^x ( cos y + i sin y )

__device__ inline cuDoubleComplex U1polar(const double theta)

Calculate real and imaginary parts of U(1) variable e^(i*theta)

__device__ inline cuUserComplex make_cuUserComplex(user_precision_t real, user_precision_t imag)

Make a CUDA complex to the precision set during compilation.