cudacomplex

This header is in the RTS, and contains useful CUDA operators. All credit to the original author, R. G. Edgar.

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

Author

R. G. Edgar

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)