1#ifndef PSCF_CUDA_COMPLEX_H
2#define PSCF_CUDA_COMPLEX_H
11#include <pscf/cuda/cudaTypes.h>
12#include <pscf/math/arithmetic.h>
67 {
return sqrt(a.x * a.x + a.y * a.y); }
78 {
return (a.x * a.x + a.y * a.y); }
169 std::complex<cudaReal>
const& a)
186 { z = std::complex<cudaReal>(a.x, a.y); }
352 z.x = a.x * b.x - a.y * b.y;
353 z.y = a.y * b.x + a.x * b.y;
385 a0 = a.x * b.x - a.y * b.y;
386 a.y = a.y * b.x + a.x * b.y;
416 z.x = a.x * a.x - a.y * a.y;
417 z.y = 2.0 * a.y * a.x;
435 cudaReal bSq = b.x * b.x + b.y * b.y;
436 z.x = (a.x * b.x + a.y * b.y) / bSq;
437 z.y = (a.y * b.x - a.x * b.y) / bSq;
468 cudaReal bSq = b.x * b.x + b.y * b.y;
469 cudaReal a0 = (a.x * b.x + a.y * b.y)/bSq;
470 a.y = (a.y * b.x - a.x * b.y)/bSq;
503 cudaReal aSq = a.x * a.x + a.y * a.y;
522 std::complex<cudaReal> arg
523 = std::complex<cudaReal>(a.x, a.y);
524 std::complex<cudaReal> result = std::exp(arg);
541 std::complex<cudaReal> arg
542 = std::complex<cudaReal>(a.x, a.y);
543 std::complex<cudaReal> result = std::log(arg);
558 __host__ __device__
static inline
void mulEq(fftw_complex &a, fftw_complex const &b)
In-place multiplication of two complex number, a *= b.
double absSq(fftw_complex const &a)
Return square of absolute magnitude of an fftw_complex number.
void addEq(fftw_complex &a, fftw_complex const &b)
In-place addition of fftw_complex numbers, a += b.
void square(fftw_complex &z, fftw_complex const &a)
Complex square of an fftw_complex number, z = a * a.
void div(fftw_complex &z, fftw_complex const &a, fftw_complex const &b)
Division of fftw_complex numbers, z = a / b .
void inverse(fftw_complex &z, fftw_complex const &a)
Inversion of an fftw_complex number, z = 1 / a .
double imag(fftw_complex const &a)
Return the imaginary part of an fftw_complex number.
void conj(fftw_complex &z, fftw_complex const &a)
Complex conjugate of an fftw_complex, z = a^*.
void assignExp(fftw_complex &z, fftw_complex const &a)
Exponentation of a ffts_complex variable, z = exp(a).
void add(fftw_complex &z, fftw_complex const &a, fftw_complex const &b)
Addition of fftw_complex numbers, z = a + b.
void sub(fftw_complex &z, fftw_complex const &a, fftw_complex const &b)
Subtraction of fftw_complex numbers, z = a - b.
double absSqDiff(fftw_complex const &a, fftw_complex const &b)
Return square of the absolute magnitude of a complex difference.
void subEq(fftw_complex &a, fftw_complex const &b)
In-place subtraction of fftw_complex numbers, a -= b.
void assign(fftw_complex &z, double const &a, double const &b)
Create an fftw_complex from real and imaginary parts, z = a + ib.
void mul(fftw_complex &z, fftw_complex const &a, fftw_complex const &b)
Multiplication of fftw_complex numbers, z = a * b.
double real(fftw_complex const &a)
Return the real part of an fftw_complex number.
void divEq(fftw_complex &a, fftw_complex const &b)
In-place division of fftw_complex numbers, a /= b.
double abs(fftw_complex const &a)
Return absolute magnitude of an fftw_complex number.
void assignLog(fftw_complex &z, fftw_complex const &a)
Logarithm of an fftw_complex variable, z = log(a).
PSCF package top-level namespace.
cufftDoubleComplex cudaComplex
Complex number type used in CPU code that uses FFTW.
cufftDoubleReal cudaReal
Real number type used in CPU code that uses FFTW.