7#ifndef HEFFTE_STOCK_COMPLEX_H
8#define HEFFTE_STOCK_COMPLEX_H
13#include "heffte_stock_vec_types.h"
28template<
typename F,
int L>
46 explicit Complex(std::complex<F>
const *
c): var(mm_complex_load<
F,
L>(
c)) {}
48 explicit Complex(std::complex<F>
const *
c,
int stride): var(mm_complex_load<
F,
L>(
c, stride)) {}
70 return Complex(mm_complex_mul(var,
o.var));
75 return Complex(mm_complex_div(var,
o.var));
80 var = mm_add(var,
o.var);
86 var = mm_sub(var,
o.var);
92 var = mm_complex_mul(var,
o.var);
98 var = mm_complex_div(var,
o.var);
156 return Complex(mm_complex_fmadd(var,
y.var,
z.var));
161 return Complex(mm_complex_fmsub(var,
y.var,
z.var));
172 for(
int i = 0;
i <
L/2;
i++) {
179 return mm_complex_mod(var);
184 return Complex(mm_complex_conj(var));
189 return Complex(mm_complex_mul_i(var));
194 return Complex(mm_complex_mul_neg_i(var));
204 return std::complex<F>(
reinterpret_cast<F*
>(&var)[2*
idx],
reinterpret_cast<F*
>(&var)[2*
idx + 1]);
221template<
typename F,
int L>
223 typename pack<F, L>::type var =
dt.get();
225 for(
int i = 0;
i <
L;
i+=2) {
227 if(var[
i+1] < 0)
os <<
" - " << -var[
i+1] <<
"i";
228 else os <<
" + " << var[
i+1] <<
"i";
229 if(
i+2 <
L)
os <<
", ";
Custom complex type taking advantage of vectorization A Complex Type intrinsic to HeFFTe that takes a...
Definition heffte_stock_complex.h:29
Complex< F, L > operator*(Complex< F, L > const &o)
Multiply by another pack of complex number.
Definition heffte_stock_complex.h:69
Complex(std::initializer_list< std::complex< F > > il)
Load from initializer list of existing std::complex numbers.
Definition heffte_stock_complex.h:50
Complex< F, L > fmadd(Complex< F, L > const &y, Complex< F, L > const &z)
Fused multiply add.
Definition heffte_stock_complex.h:155
Complex(F x, F y)
Load from real and imaginary parts (repeating for all numbers in pack)
Definition heffte_stock_complex.h:44
Complex(std::complex< F > const *c)
Load from pointer to existing std::complex numbers.
Definition heffte_stock_complex.h:46
Complex< F, L > conjugate()
Conjugate the current complex number.
Definition heffte_stock_complex.h:183
pack< F, L >::type get() const
Return a vector pack representation of this number.
Definition heffte_stock_complex.h:208
Complex< F, L > operator-=(F o)
Subtract and assign a floating point number.
Definition heffte_stock_complex.h:133
Complex< F, L > __mul_neg_i()
Multiply the complex number by i.
Definition heffte_stock_complex.h:193
Complex< F, L > operator/=(Complex< F, L > const &o)
Divide by and assign another complex number.
Definition heffte_stock_complex.h:97
Complex< F, L > operator-(F o)
Subtract a floating point number.
Definition heffte_stock_complex.h:112
Complex< F, L > operator/(F o)
Divide by a floating point number.
Definition heffte_stock_complex.h:122
Complex(F *const f)
Load from an array of primitives.
Definition heffte_stock_complex.h:38
Complex()
Default constructor of zeros.
Definition heffte_stock_complex.h:52
Complex< F, L > __mul_i()
Multiply the complex number by i.
Definition heffte_stock_complex.h:188
void modulus(F *dest)
Store the modulus of the complex number in an array of size L/2.
Definition heffte_stock_complex.h:170
Complex< F, L > operator*=(F o)
Multiply by and assign a floating point number.
Definition heffte_stock_complex.h:139
Complex< F, L > operator*=(Complex< F, L > const &o)
Multiply by and assign another complex number.
Definition heffte_stock_complex.h:91
Complex(std::complex< F > const *c, int stride)
Load from strided pointer to existing std::complex numbers.
Definition heffte_stock_complex.h:48
Complex< F, L > operator+=(Complex< F, L > const &o)
Add with and assign another complex number.
Definition heffte_stock_complex.h:79
Complex< F, L > operator*(F o)
Multiply by a floating point number.
Definition heffte_stock_complex.h:117
Complex< F, L > operator/(Complex< F, L > const &o)
Divide by another pack of complex number.
Definition heffte_stock_complex.h:74
Complex< F, L > operator+=(F o)
Add with and assign a floating point number.
Definition heffte_stock_complex.h:127
pack< F, L >::type modulus()
Return the modulus of the complex number in a vector pack.
Definition heffte_stock_complex.h:178
Complex< F, L > fmsub(Complex< F, L > const &y, Complex< F, L > const &z)
Fused multiply add.
Definition heffte_stock_complex.h:160
Complex< F, L > operator-()
Negate the complex number.
Definition heffte_stock_complex.h:165
Complex(typename pack< F, L >::type v)
Load from an existing vector pack.
Definition heffte_stock_complex.h:42
void get(F *dest)
Store the Complex number in an array of length L.
Definition heffte_stock_complex.h:198
Complex< F, L > operator+(F o)
Add with a floating point number.
Definition heffte_stock_complex.h:107
Complex< F, L > operator-(Complex< F, L > const &o)
Subtract another pack of complex number.
Definition heffte_stock_complex.h:64
std::complex< F > operator[](std::size_t idx)
Access the ith Complex number as a std::complex.
Definition heffte_stock_complex.h:203
Complex< F, L > operator-=(Complex< F, L > const &o)
Subtract and assign another complex number from this.
Definition heffte_stock_complex.h:85
Complex< F, L > operator+(Complex< F, L > const &o)
Add with another pack of complex number.
Definition heffte_stock_complex.h:59
Complex(std::initializer_list< F > il)
Load from an initializer list of primitives.
Definition heffte_stock_complex.h:40
Namespace containing all HeFFTe methods and classes.
Definition heffte_backend_cuda.h:38
Wrapper around cufftHandle plans, set for float or double complex.
Definition heffte_backend_cuda.h:346
Struct to retrieve the vector type associated with the number of elements stored "per unit".
Definition heffte_stock_vec_types.h:43