22 #include "pism/util/fftw_utilities.hh"
24 #include "pism/util/petscwrappers/Vec.hh"
31 : m_My(My), m_i_offset(i_offset), m_j_offset(j_offset),
32 m_array(reinterpret_cast<std::complex<double>*>(a)) {
38 : m_My(My), m_i_offset(0), m_j_offset(0),
39 m_array(reinterpret_cast<std::complex<double>*>(a)) {
47 std::vector<double>
fftfreq(
int M,
double normalization) {
48 std::vector<double> result(M);
50 int N = (M % 2) != 0 ? M / 2 : M / 2 - 1;
52 for (
int i = 0; i <= N; i++) {
56 for (
int i = N + 1; i < M; i++) {
61 for (
int i = 0; i < M; i++) {
62 result[i] /= (M * normalization);
71 for (
int i = 0; i < Nx; ++i) {
72 for (
int j = 0; j < Ny; ++j) {
79 void copy_fftw_array(fftw_complex *source, fftw_complex *destination,
int Nx,
int Ny) {
80 memcpy(destination, source, Nx * Ny *
sizeof(fftw_complex));
94 fftw_complex *output) {
98 for (
int j = 0; j < My; ++j) {
99 for (
int i = 0; i < Mx; ++i) {
100 out(i, j) = in(i, j) * normalization;
111 double normalization,
118 for (
int j = 0; j < My; ++j) {
119 for (
int i = 0; i < Mx; ++i) {
120 out(i, j) = in(i, j).real() * normalization;
FFTWArray(fftw_complex *a, int Mx, int My, int i_offset, int j_offset)
Wrapper around VecGetArray2d and VecRestoreArray2d.
void clear_fftw_array(fftw_complex *input, int Nx, int Ny)
Fill input with zeros.
void copy_fftw_array(fftw_complex *source, fftw_complex *destination, int Nx, int Ny)
Copy source to destination.
void get_real_part(fftw_complex *input, double normalization, int Mx, int My, int Nx, int Ny, int i0, int j0, petsc::Vec &output)
Get the real part of input and put it in output.
void set_real_part(petsc::Vec &input, double normalization, int Mx, int My, int Nx, int Ny, int i0, int j0, fftw_complex *output)
std::vector< double > fftfreq(int M, double normalization)