-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgrid_tw.cpp
More file actions
executable file
·39 lines (30 loc) · 1.04 KB
/
grid_tw.cpp
File metadata and controls
executable file
·39 lines (30 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//
// grid_tw.cpp
//
// Modified by Patrick Anderson on 07/05/2015.
// "grid_tw" is a linear temporal grid. The spectral counterpart of this grid is evaluated and
// made accessible.
//
#include "grid_tw.hpp"
#include "maths_textbook.hpp"
#include <Eigen/Dense>
using namespace Eigen;
//------------------------------------------------------------------------------------------------//
// Class implementation
//------------------------------------------------------------------------------------------------//
// Constructor
grid_tw::grid_tw(int N_t_, double t_min_, double t_max_) {
maths_textbook maths;
// Temporal
N_t = N_t_;
t_min = t_min_;
t_max = t_max_;
t = ArrayXd::Zero(N_t);
t.setLinSpaced(t_min, t_max);
dt = t(1) - t(0);
// Spectral
w = ArrayXd::Zero(N_t);
w.setLinSpaced(-N_t / 2, (N_t / 2) - 1);
w *= 2 * maths.pi / (N_t * (t(1) - t(0)));
w.tail(N_t / 2).swap(w.head(N_t / 2)); // Equivalent to fftshift(kx)
}