OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
FixedFFTLowPass.cpp
Go to the documentation of this file.
2#include "Physics/Physics.h"
3#include "Utilities/GSLFFT.h"
4
5FixedFFTLowPassFilter::FixedFFTLowPassFilter(const int& N) : number_frequencies_m(N) {}
6
7void FixedFFTLowPassFilter::apply(std::vector<double>& LineDensity) {
8 const int M = LineDensity.size();
12 double* LD = new double[M];
13 for (int i = 0; i < M; ++i) {
14 LD[i] = LineDensity[i];
15 }
16 gsl_fft_real_transform(LD, 1, M, real, work);
17
18 for (int i = 2 * number_frequencies_m + 1; i < M; ++i) {
19 LD[i] = 0.0;
20 }
21
24
25 gsl_fft_halfcomplex_inverse(LD, 1, M, hc, work);
26
29
30 for (int i = 0; i < M; ++i) {
31 LineDensity[i] = LD[i];
32 }
33 delete[] LD;
34}
35
36void FixedFFTLowPassFilter::calc_derivative(std::vector<double>& LineDensity, const double& h) {
37 const int M = LineDensity.size();
38 const double gff = 2. * Physics::pi / (h * (M - 1));
39
43 double* LD = new double[M];
44
45 for (int i = 0; i < M; ++i) {
46 LD[i] = LineDensity[i];
47 }
48 gsl_fft_real_transform(LD, 1, M, real, work);
49
51
52 LD[0] = 0.0;
53 for (int i = 1; i < 2 * number_frequencies_m + 1; i += 2) {
54 double temp = LD[i];
55 LD[i] = -LD[i + 1] * gff * (i + 1) / 2;
56 LD[i + 1] = temp * gff * (i + 1) / 2;
57 }
58
59 for (int i = 2 * number_frequencies_m + 1; i < M; ++i) {
60 LD[i] = 0.0;
61 }
62
64
65 gsl_fft_halfcomplex_inverse(LD, 1, M, hc, work);
66
69
70 for (int i = 0; i < M; ++i) {
71 LineDensity[i] = LD[i];
72 }
73
74 delete[] LD;
75}
gsl_fft_halfcomplex_wavetable * gsl_fft_halfcomplex_wavetable_alloc(size_t n)
Allocate a halfcomplex FFT wavetable of size .
Definition GSLFFT.h:181
void gsl_fft_real_wavetable_free(gsl_fft_real_wavetable *w)
Free a real FFT wavetable.
Definition GSLFFT.h:159
gsl_fft_real_workspace * gsl_fft_real_workspace_alloc(size_t n)
Allocate a real FFT workspace of size .
Definition GSLFFT.h:138
void gsl_fft_halfcomplex_inverse(double *data, size_t stride, size_t n, gsl_fft_halfcomplex_wavetable *wavetable, gsl_fft_halfcomplex_workspace *workspace)
Alias for halfcomplex inverse transform.
Definition GSLFFT.h:245
void gsl_fft_real_workspace_free(gsl_fft_real_workspace *w)
Free a real FFT workspace.
Definition GSLFFT.h:163
void gsl_fft_real_transform(double *data, size_t stride, size_t n, gsl_fft_real_wavetable *, gsl_fft_real_workspace *)
Forward real FFT with GSL-compatible packed output.
Definition GSLFFT.h:151
gsl_fft_real_wavetable * gsl_fft_real_wavetable_alloc(size_t n)
Allocate a real FFT wavetable of size .
Definition GSLFFT.h:129
void gsl_fft_halfcomplex_wavetable_free(gsl_fft_halfcomplex_wavetable *w)
Free a halfcomplex FFT wavetable.
Definition GSLFFT.h:233
Halfcomplex FFT types for inverse transforms.
Definition GSLFFT.h:167
GSL-compatible interface for FFT routines.
Definition GSLFFT.h:115
Workspace for real FFT routines.
Definition GSLFFT.h:121
void apply(std::vector< double > &LineDensity)
FixedFFTLowPassFilter(const int &N)
void calc_derivative(std::vector< double > &histogram, const double &h)
constexpr double pi
The value of.
Definition Physics.h:36