TRIQS/triqs_tprf 4.0.0
A TRIQS application
Loading...
Searching...
No Matches
fourier_common.cpp
1// Copyright (c) 2018 Commissariat à l'énergie atomique et aux énergies alternatives (CEA)
2// Copyright (c) 2018 Centre national de la recherche scientifique (CNRS)
3// Copyright (c) 2018 Simons Foundation
4//
5// This program is free software: you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You may obtain a copy of the License at
16// https://www.gnu.org/licenses/gpl-3.0.txt
17//
18// Authors: Hugo Strand, Michel Ferrero, Nils Wentzell
19
20#include "./fourier_common.hpp"
21
22#include <fftw3.h>
23
24namespace triqs_tprf::fourier {
25
26 fourier_plan _fourier_base_plan(array_const_view<dcomplex, 2> in, array_const_view<dcomplex, 2> out, int rank, int *dims, int fftw_count,
27 int fftw_backward_forward) {
28
29 auto in_fft = reinterpret_cast<fftw_complex *>(const_cast<dcomplex *>(in.data()));
30 auto out_fft = reinterpret_cast<fftw_complex *>(const_cast<dcomplex *>(out.data()));
31
32 auto p = fftw_plan_many_dft(rank, // rank
33 dims, // the dimension
34 fftw_count, // how many FFT : here 1
35 in_fft, // in data
36 NULL, // embed : unused. Doc unclear ?
37 in.indexmap().strides()[0], // stride of the in data
38 1, // in : shift for multi fft.
39 out_fft, // out data
40 NULL, // embed : unused. Doc unclear ?
41 out.indexmap().strides()[0], // stride of the out data
42 1, // out : shift for multi fft.
43 fftw_backward_forward, FFTW_ESTIMATE);
44
45 return {(void *)p, [](void *p) { fftw_destroy_plan((fftw_plan)p); }};
46 }
47
48 void _fourier_base(array_const_view<dcomplex, 2> in, array_view<dcomplex, 2> out, fourier_plan &plan) {
49
50 auto in_fft = reinterpret_cast<fftw_complex *>(const_cast<dcomplex *>(in.data()));
51 auto out_fft = reinterpret_cast<fftw_complex *>(out.data());
52
53 fftw_execute_dft((fftw_plan)plan.get(), in_fft, out_fft);
54 }
55
56} // namespace triqs_tprf::fourier