1#ifndef PRDC_CPU_COMPLEX_H
2#define PRDC_CPU_COMPLEX_H
11#include <pscf/math/complex.h>
59 {
return sqrt(a[0] * a[0] + a[1] * a[1]); }
70 {
return (a[0] * a[0] + a[1] * a[1]); }
83 void conj(fftw_complex& z, fftw_complex
const& a)
115 void assign(fftw_complex& z,
double const& a,
double const& b)
130 void assign(fftw_complex& z,
double const& a)
145 void assign(fftw_complex& z, fftw_complex
const& a)
160 void assign(fftw_complex & z, std::complex<double>
const& a)
175 void assign(std::complex<double> & z, fftw_complex
const& a)
176 { z = std::complex<double>(a[0], a[1]); }
190 void add(fftw_complex& z, fftw_complex
const& a, fftw_complex
const& b)
206 void add(fftw_complex& z, fftw_complex
const& a,
double const& b)
221 void addEq(fftw_complex& a, fftw_complex
const& b)
236 void addEq(fftw_complex& a,
double const& b)
253 void sub(fftw_complex& z, fftw_complex
const& a, fftw_complex
const& b)
269 void sub(fftw_complex& z, fftw_complex
const& a,
double const& b)
284 void subEq(fftw_complex & a, fftw_complex
const& b)
299 void subEq(fftw_complex & a,
double const& b)
315 double absSqDiff(fftw_complex
const& a, fftw_complex
const& b)
334 void mul(fftw_complex& z, fftw_complex
const& a, fftw_complex
const& b)
336 z[0] = a[0] * b[0] - a[1] * b[1];
337 z[1] = a[1] * b[0] + a[0] * b[1];
350 void mul(fftw_complex& z, fftw_complex
const& a,
double const& b)
365 void mulEq(fftw_complex & a, fftw_complex
const& b)
368 a0 = a[0] * b[0] - a[1] * b[1];
369 a[1] = a[1] * b[0] + a[0] * b[1];
382 void mulEq(fftw_complex & a,
double const& b)
397 void square(fftw_complex& z, fftw_complex
const& a)
399 z[0] = a[0] * a[0] - a[1] * a[1];
400 z[1] = 2.0 * a[1] * a[0];
415 void div(fftw_complex& z, fftw_complex
const& a, fftw_complex
const& b)
417 double bSq = b[0] * b[0] + b[1] * b[1];
418 z[0] = (a[0] * b[0] + a[1] * b[1])/bSq;
419 z[1] = (a[1] * b[0] - a[0] * b[1])/bSq;
432 void div(fftw_complex& z, fftw_complex
const& a,
double const& b)
447 void divEq(fftw_complex & a, fftw_complex
const & b)
449 double bSq = b[0] * b[0] + b[1] * b[1];
450 double a0 = (a[0] * b[0] + a[1] * b[1])/bSq;
451 a[1] = (a[1] * b[0] - a[0] * b[1])/bSq;
464 void divEq(fftw_complex & a,
double const& b)
485 std::ostream&
operator << (std::ostream& os, fftw_complex
const & z);
497 template <
typename Archive>
498 void serialize(Archive& ar,
double z[2],
const unsigned int version = 0)
500 serialize(ar, z[0], version);
501 serialize(ar, z[1], version);
double imag< fftw_complex, double >(fftw_complex const &a)
Return the imaginary part of a complex number.
double absSq< fftw_complex, double >(fftw_complex const &a)
Return square of absolute magnitude of a complex number.
double real< fftw_complex, double >(fftw_complex const &a)
Return the real part of a complex number.
double abs< fftw_complex, double >(fftw_complex const &a)
Return absolute magnitude of a complex number.
void div(CT &z, CT const &a, CT const &b)
Division of two complex numbers, z = a / b .
void square(CT &z, CT const &a)
Compute complex square of a complex number, z = a * a.
void conj(CT &z, CT const &a)
Compute complex conjugate, z = a^*.
void divEq(CT &a, CT const &b)
In place division of two complex number, a /= b.
void subEq(CT &a, CT const &b)
In place subtraction of two complex numbers, a -= b.
void mulEq(CT &a, CT const &b)
In place multiplication of two complex number, a *= b.
void assign(CT &z, RT const &a, RT const &b)
Create a complex number from real and imaginary parts, z = a + ib.
void addEq(CT &a, CT const &b)
In place addition of complex numbers, a += b.
RT absSqDiff(CT const &a, CT const &b)
Return square of the absolute magnitude of a complex difference.
void add(CT &z, CT const &a, CT const &b)
Addition of two complex numbers, z = a + b.
void sub(CT &z, CT const &a, CT const &b)
Subtraction of two complex numbers, z = a - b.
void mul(CT &z, CT const &a, CT const &b)
Multiplication of two complex numbers, z = a * b.
PSCF package top-level namespace.
std::istream & operator>>(std::istream &in, Pair< Data > &pair)
Input a Pair from an istream.
std::ostream & operator<<(std::ostream &out, const Pair< Data > &pair)
Output a Pair to an ostream, without line breaks.