Eigen::internal::kiss_cpx_fft< Scalar_ > Struct Template Reference

#include <ei_kissfft_impl.h>

Public Types

typedef Scalar_ Scalar
 
typedef std::complex< ScalarComplex
 

Public Member Functions

void make_twiddles (int nfft, bool inverse)
 
void factorize (int nfft)
 
template<typename Src_ >
void work (int stage, Complex *xout, const Src_ *xin, size_t fstride, size_t in_stride)
 
void bfly2 (Complex *Fout, const size_t fstride, int m)
 
void bfly4 (Complex *Fout, const size_t fstride, const size_t m)
 
void bfly3 (Complex *Fout, const size_t fstride, const size_t m)
 
void bfly5 (Complex *Fout, const size_t fstride, const size_t m)
 
void bfly_generic (Complex *Fout, const size_t fstride, int m, int p)
 

Public Attributes

std::vector< Complexm_twiddles
 
std::vector< intm_stageRadix
 
std::vector< intm_stageRemainder
 
std::vector< Complexm_scratchBuf
 
bool m_inverse
 

Static Public Attributes

static const Scalar m_pi4
 

Member Typedef Documentation

◆ Complex

template<typename Scalar_ >
typedef std::complex<Scalar> Eigen::internal::kiss_cpx_fft< Scalar_ >::Complex

◆ Scalar

template<typename Scalar_ >
typedef Scalar_ Eigen::internal::kiss_cpx_fft< Scalar_ >::Scalar

Member Function Documentation

◆ bfly2()

template<typename Scalar_ >
void Eigen::internal::kiss_cpx_fft< Scalar_ >::bfly2 ( Complex Fout,
const size_t  fstride,
int  m 
)
inline
138  {
139  for (int k = 0; k < m; ++k) {
140  Complex t = Fout[m + k] * m_twiddles[k * fstride];
141  Fout[m + k] = Fout[k] - t;
142  Fout[k] += t;
143  }
144  }
std::complex< RealScalar > Complex
Definition: common.h:71
int * m
Definition: level2_cplx_impl.h:294
char char char int int * k
Definition: level2_impl.h:374
t
Definition: plotPSD.py:36
std::vector< Complex > m_twiddles
Definition: ei_kissfft_impl.h:24

References k, m, Eigen::internal::kiss_cpx_fft< Scalar_ >::m_twiddles, and plotPSD::t.

Referenced by Eigen::internal::kiss_cpx_fft< Scalar_ >::work().

◆ bfly3()

template<typename Scalar_ >
void Eigen::internal::kiss_cpx_fft< Scalar_ >::bfly3 ( Complex Fout,
const size_t  fstride,
const size_t  m 
)
inline
167  {
168  size_t k = m;
169  const size_t m2 = 2 * m;
170  Complex *tw1, *tw2;
171  Complex scratch[5];
172  Complex epi3;
173  epi3 = m_twiddles[fstride * m];
174 
175  tw1 = tw2 = &m_twiddles[0];
176 
177  do {
178  scratch[1] = Fout[m] * *tw1;
179  scratch[2] = Fout[m2] * *tw2;
180 
181  scratch[3] = scratch[1] + scratch[2];
182  scratch[0] = scratch[1] - scratch[2];
183  tw1 += fstride;
184  tw2 += fstride * 2;
185  Fout[m] = Complex(Fout->real() - Scalar(.5) * scratch[3].real(), Fout->imag() - Scalar(.5) * scratch[3].imag());
186  scratch[0] *= epi3.imag();
187  *Fout += scratch[3];
188  Fout[m2] = Complex(Fout[m].real() + scratch[0].imag(), Fout[m].imag() - scratch[0].real());
189  Fout[m] += Complex(-scratch[0].imag(), scratch[0].real());
190  ++Fout;
191  } while (--k);
192  }
MatrixType m2(n_dims)
SCALAR Scalar
Definition: bench_gemm.cpp:45
const AutoDiffScalar< DerType > & real(const AutoDiffScalar< DerType > &x)
Definition: AutoDiffScalar.h:486
DerType::Scalar imag(const AutoDiffScalar< DerType > &)
Definition: AutoDiffScalar.h:490
std::complex< Scalar > Complex
Definition: ei_kissfft_impl.h:23

References Eigen::imag(), k, m, m2(), Eigen::internal::kiss_cpx_fft< Scalar_ >::m_twiddles, and Eigen::real().

Referenced by Eigen::internal::kiss_cpx_fft< Scalar_ >::work().

◆ bfly4()

template<typename Scalar_ >
void Eigen::internal::kiss_cpx_fft< Scalar_ >::bfly4 ( Complex Fout,
const size_t  fstride,
const size_t  m 
)
inline
146  {
147  Complex scratch[6];
148  int negative_if_inverse = m_inverse * -2 + 1;
149  for (size_t k = 0; k < m; ++k) {
150  scratch[0] = Fout[k + m] * m_twiddles[k * fstride];
151  scratch[1] = Fout[k + 2 * m] * m_twiddles[k * fstride * 2];
152  scratch[2] = Fout[k + 3 * m] * m_twiddles[k * fstride * 3];
153  scratch[5] = Fout[k] - scratch[1];
154 
155  Fout[k] += scratch[1];
156  scratch[3] = scratch[0] + scratch[2];
157  scratch[4] = scratch[0] - scratch[2];
158  scratch[4] = Complex(scratch[4].imag() * negative_if_inverse, -scratch[4].real() * negative_if_inverse);
159 
160  Fout[k + 2 * m] = Fout[k] - scratch[3];
161  Fout[k] += scratch[3];
162  Fout[k + m] = scratch[5] + scratch[4];
163  Fout[k + 3 * m] = scratch[5] - scratch[4];
164  }
165  }
bool m_inverse
Definition: ei_kissfft_impl.h:28

References Eigen::imag(), k, m, Eigen::internal::kiss_cpx_fft< Scalar_ >::m_inverse, Eigen::internal::kiss_cpx_fft< Scalar_ >::m_twiddles, and Eigen::real().

Referenced by Eigen::internal::kiss_cpx_fft< Scalar_ >::work().

◆ bfly5()

template<typename Scalar_ >
void Eigen::internal::kiss_cpx_fft< Scalar_ >::bfly5 ( Complex Fout,
const size_t  fstride,
const size_t  m 
)
inline
194  {
195  Complex *Fout0, *Fout1, *Fout2, *Fout3, *Fout4;
196  size_t u;
197  Complex scratch[13];
198  Complex *twiddles = &m_twiddles[0];
199  Complex *tw;
200  Complex ya, yb;
201  ya = twiddles[fstride * m];
202  yb = twiddles[fstride * 2 * m];
203 
204  Fout0 = Fout;
205  Fout1 = Fout0 + m;
206  Fout2 = Fout0 + 2 * m;
207  Fout3 = Fout0 + 3 * m;
208  Fout4 = Fout0 + 4 * m;
209 
210  tw = twiddles;
211  for (u = 0; u < m; ++u) {
212  scratch[0] = *Fout0;
213 
214  scratch[1] = *Fout1 * tw[u * fstride];
215  scratch[2] = *Fout2 * tw[2 * u * fstride];
216  scratch[3] = *Fout3 * tw[3 * u * fstride];
217  scratch[4] = *Fout4 * tw[4 * u * fstride];
218 
219  scratch[7] = scratch[1] + scratch[4];
220  scratch[10] = scratch[1] - scratch[4];
221  scratch[8] = scratch[2] + scratch[3];
222  scratch[9] = scratch[2] - scratch[3];
223 
224  *Fout0 += scratch[7];
225  *Fout0 += scratch[8];
226 
227  scratch[5] = scratch[0] + Complex((scratch[7].real() * ya.real()) + (scratch[8].real() * yb.real()),
228  (scratch[7].imag() * ya.real()) + (scratch[8].imag() * yb.real()));
229 
230  scratch[6] = Complex((scratch[10].imag() * ya.imag()) + (scratch[9].imag() * yb.imag()),
231  -(scratch[10].real() * ya.imag()) - (scratch[9].real() * yb.imag()));
232 
233  *Fout1 = scratch[5] - scratch[6];
234  *Fout4 = scratch[5] + scratch[6];
235 
236  scratch[11] = scratch[0] + Complex((scratch[7].real() * yb.real()) + (scratch[8].real() * ya.real()),
237  (scratch[7].imag() * yb.real()) + (scratch[8].imag() * ya.real()));
238 
239  scratch[12] = Complex(-(scratch[10].imag() * yb.imag()) + (scratch[9].imag() * ya.imag()),
240  (scratch[10].real() * yb.imag()) - (scratch[9].real() * ya.imag()));
241 
242  *Fout2 = scratch[11] + scratch[12];
243  *Fout3 = scratch[11] - scratch[12];
244 
245  ++Fout0;
246  ++Fout1;
247  ++Fout2;
248  ++Fout3;
249  ++Fout4;
250  }
251  }

References Eigen::imag(), m, Eigen::internal::kiss_cpx_fft< Scalar_ >::m_twiddles, and Eigen::real().

Referenced by Eigen::internal::kiss_cpx_fft< Scalar_ >::work().

◆ bfly_generic()

template<typename Scalar_ >
void Eigen::internal::kiss_cpx_fft< Scalar_ >::bfly_generic ( Complex Fout,
const size_t  fstride,
int  m,
int  p 
)
inline
254  {
255  int u, k, q1, q;
256  Complex *twiddles = &m_twiddles[0];
257  Complex t;
258  int Norig = static_cast<int>(m_twiddles.size());
259  Complex *scratchbuf = &m_scratchBuf[0];
260 
261  for (u = 0; u < m; ++u) {
262  k = u;
263  for (q1 = 0; q1 < p; ++q1) {
264  scratchbuf[q1] = Fout[k];
265  k += m;
266  }
267 
268  k = u;
269  for (q1 = 0; q1 < p; ++q1) {
270  int twidx = 0;
271  Fout[k] = scratchbuf[0];
272  for (q = 1; q < p; ++q) {
273  twidx += static_cast<int>(fstride) * k;
274  if (twidx >= Norig) twidx -= Norig;
275  t = scratchbuf[q] * twiddles[twidx];
276  Fout[k] += t;
277  }
278  k += m;
279  }
280  }
281  }
float * p
Definition: Tutorial_Map_using.cpp:9
EIGEN_DEVICE_FUNC const Scalar & q
Definition: SpecialFunctionsImpl.h:2019
std::vector< Complex > m_scratchBuf
Definition: ei_kissfft_impl.h:27

References k, m, Eigen::internal::kiss_cpx_fft< Scalar_ >::m_scratchBuf, Eigen::internal::kiss_cpx_fft< Scalar_ >::m_twiddles, p, Eigen::numext::q, and plotPSD::t.

Referenced by Eigen::internal::kiss_cpx_fft< Scalar_ >::work().

◆ factorize()

template<typename Scalar_ >
void Eigen::internal::kiss_cpx_fft< Scalar_ >::factorize ( int  nfft)
inline
68  {
69  // start factoring out 4's, then 2's, then 3,5,7,9,...
70  int n = nfft;
71  int p = 4;
72  do {
73  while (n % p) {
74  switch (p) {
75  case 4:
76  p = 2;
77  break;
78  case 2:
79  p = 3;
80  break;
81  default:
82  p += 2;
83  break;
84  }
85  if (p * p > n) p = n; // impossible to have a factor > sqrt(n)
86  }
87  n /= p;
88  m_stageRadix.push_back(p);
89  m_stageRemainder.push_back(n);
90  if (p > 5) m_scratchBuf.resize(p); // scratchbuf will be needed in bfly_generic
91  } while (n > 1);
92  }
const unsigned n
Definition: CG3DPackingUnitTest.cpp:11
std::vector< int > m_stageRadix
Definition: ei_kissfft_impl.h:25
std::vector< int > m_stageRemainder
Definition: ei_kissfft_impl.h:26

References Eigen::internal::kiss_cpx_fft< Scalar_ >::m_scratchBuf, Eigen::internal::kiss_cpx_fft< Scalar_ >::m_stageRadix, Eigen::internal::kiss_cpx_fft< Scalar_ >::m_stageRemainder, n, and p.

Referenced by Eigen::internal::kissfft_impl< Scalar_ >::get_plan().

◆ make_twiddles()

template<typename Scalar_ >
void Eigen::internal::kiss_cpx_fft< Scalar_ >::make_twiddles ( int  nfft,
bool  inverse 
)
inline
32  {
33  using numext::cos;
34  using numext::sin;
36  m_twiddles.resize(nfft);
37  Scalar phinc = m_pi4 / nfft;
38  Scalar flip = inverse ? Scalar(1) : Scalar(-1);
39  m_twiddles[0] = Complex(Scalar(1), Scalar(0));
40  if ((nfft & 1) == 0) m_twiddles[nfft / 2] = Complex(Scalar(-1), Scalar(0));
41  int i = 1;
42  for (; i * 8 < nfft; ++i) {
43  Scalar c = Scalar(cos(i * 8 * phinc));
44  Scalar s = Scalar(sin(i * 8 * phinc));
45  m_twiddles[i] = Complex(c, s * flip);
46  m_twiddles[nfft - i] = Complex(c, -s * flip);
47  }
48  for (; i * 4 < nfft; ++i) {
49  Scalar c = Scalar(cos((2 * nfft - 8 * i) * phinc));
50  Scalar s = Scalar(sin((2 * nfft - 8 * i) * phinc));
51  m_twiddles[i] = Complex(s, c * flip);
52  m_twiddles[nfft - i] = Complex(s, -c * flip);
53  }
54  for (; i * 8 < 3 * nfft; ++i) {
55  Scalar c = Scalar(cos((8 * i - 2 * nfft) * phinc));
56  Scalar s = Scalar(sin((8 * i - 2 * nfft) * phinc));
57  m_twiddles[i] = Complex(-s, c * flip);
58  m_twiddles[nfft - i] = Complex(-s, -c * flip);
59  }
60  for (; i * 2 < nfft; ++i) {
61  Scalar c = Scalar(cos((4 * nfft - 8 * i) * phinc));
62  Scalar s = Scalar(sin((4 * nfft - 8 * i) * phinc));
63  m_twiddles[i] = Complex(-c, s * flip);
64  m_twiddles[nfft - i] = Complex(-c, -s * flip);
65  }
66  }
AnnoyingScalar cos(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:136
AnnoyingScalar sin(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:137
int i
Definition: BiCGSTAB_step_by_step.cpp:9
void inverse(const MatrixType &m)
Definition: inverse.cpp:64
RealScalar s
Definition: level1_cplx_impl.h:130
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T cos(const T &x)
Definition: MathFunctions.h:1559
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T sin(const T &x)
Definition: MathFunctions.h:1581
int c
Definition: calibrate.py:100
static const Scalar m_pi4
Definition: ei_kissfft_impl.h:30
Scalar_ Scalar
Definition: ei_kissfft_impl.h:22

References calibrate::c, cos(), Eigen::numext::cos(), i, inverse(), Eigen::internal::kiss_cpx_fft< Scalar_ >::m_inverse, Eigen::internal::kiss_cpx_fft< Scalar_ >::m_pi4, Eigen::internal::kiss_cpx_fft< Scalar_ >::m_twiddles, s, sin(), and Eigen::numext::sin().

Referenced by Eigen::internal::kissfft_impl< Scalar_ >::get_plan().

◆ work()

template<typename Scalar_ >
template<typename Src_ >
void Eigen::internal::kiss_cpx_fft< Scalar_ >::work ( int  stage,
Complex xout,
const Src_ *  xin,
size_t  fstride,
size_t  in_stride 
)
inline
95  {
96  int p = m_stageRadix[stage];
97  int m = m_stageRemainder[stage];
98  Complex *Fout_beg = xout;
99  Complex *Fout_end = xout + p * m;
100 
101  if (m > 1) {
102  do {
103  // recursive call:
104  // DFT of size m*p performed by doing
105  // p instances of smaller DFTs of size m,
106  // each one takes a decimated version of the input
107  work(stage + 1, xout, xin, fstride * p, in_stride);
108  xin += fstride * in_stride;
109  } while ((xout += m) != Fout_end);
110  } else {
111  do {
112  *xout = *xin;
113  xin += fstride * in_stride;
114  } while (++xout != Fout_end);
115  }
116  xout = Fout_beg;
117 
118  // recombine the p smaller DFTs
119  switch (p) {
120  case 2:
121  bfly2(xout, fstride, m);
122  break;
123  case 3:
124  bfly3(xout, fstride, m);
125  break;
126  case 4:
127  bfly4(xout, fstride, m);
128  break;
129  case 5:
130  bfly5(xout, fstride, m);
131  break;
132  default:
133  bfly_generic(xout, fstride, m, p);
134  break;
135  }
136  }
void bfly2(Complex *Fout, const size_t fstride, int m)
Definition: ei_kissfft_impl.h:138
void bfly4(Complex *Fout, const size_t fstride, const size_t m)
Definition: ei_kissfft_impl.h:146
void bfly5(Complex *Fout, const size_t fstride, const size_t m)
Definition: ei_kissfft_impl.h:194
void bfly3(Complex *Fout, const size_t fstride, const size_t m)
Definition: ei_kissfft_impl.h:167
void work(int stage, Complex *xout, const Src_ *xin, size_t fstride, size_t in_stride)
Definition: ei_kissfft_impl.h:95
void bfly_generic(Complex *Fout, const size_t fstride, int m, int p)
Definition: ei_kissfft_impl.h:254

References Eigen::internal::kiss_cpx_fft< Scalar_ >::bfly2(), Eigen::internal::kiss_cpx_fft< Scalar_ >::bfly3(), Eigen::internal::kiss_cpx_fft< Scalar_ >::bfly4(), Eigen::internal::kiss_cpx_fft< Scalar_ >::bfly5(), Eigen::internal::kiss_cpx_fft< Scalar_ >::bfly_generic(), m, Eigen::internal::kiss_cpx_fft< Scalar_ >::m_stageRadix, Eigen::internal::kiss_cpx_fft< Scalar_ >::m_stageRemainder, and p.

Referenced by Eigen::internal::kissfft_impl< Scalar_ >::fwd(), and Eigen::internal::kissfft_impl< Scalar_ >::inv().

Member Data Documentation

◆ m_inverse

◆ m_pi4

template<typename _Scalar >
const kiss_cpx_fft< _Scalar >::Scalar Eigen::internal::kiss_cpx_fft< _Scalar >::m_pi4
static
Initial value:
=
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T atan(const T &x)
Definition: MathFunctions.h:1683

Referenced by Eigen::internal::kiss_cpx_fft< Scalar_ >::make_twiddles().

◆ m_scratchBuf

◆ m_stageRadix

template<typename Scalar_ >
std::vector<int> Eigen::internal::kiss_cpx_fft< Scalar_ >::m_stageRadix

◆ m_stageRemainder

template<typename Scalar_ >
std::vector<int> Eigen::internal::kiss_cpx_fft< Scalar_ >::m_stageRemainder

◆ m_twiddles


The documentation for this struct was generated from the following file: