TRIQS/TRIQS 4.0.0
Researching Interacting Quantum Systems
Loading...
Searching...
No Matches
fourier_common.cpp
Go to the documentation of this file.
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-2020 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: Michel Ferrero, Nils Wentzell
19
24
25#include "./fourier_common.hpp"
26
27namespace triqs::gfs {
28
29 void _fourier_base(array_const_view<dcomplex, 2> in, array_view<dcomplex, 2> out, int rank, int *dims, int fftw_count, int fftw_backward_forward) {
30
31 // FFTW takes a non-const fftw_complex* even though FFTW_ESTIMATE does not modify the input buffer; the binary
32 // layout of dcomplex and fftw_complex is identical, so the casts are safe.
33 // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast,cppcoreguidelines-pro-type-reinterpret-cast): required for FFTW C interop
34 auto in_fft = reinterpret_cast<fftw_complex *>(const_cast<dcomplex *>(in.data()));
35 // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast): required for FFTW C interop
36 auto out_fft = reinterpret_cast<fftw_complex *>(out.data());
37
38 auto p = fftw_plan_many_dft(rank, // rank
39 dims, // the dimension
40 fftw_count, // how many FFT : here 1
41 in_fft, // in data
42 nullptr, // embed : unused. Doc unclear ?
43 static_cast<int>(in.indexmap().strides()[0]), // stride of the in data
44 1, // in : shift for multi fft.
45 out_fft, // out data
46 nullptr, // embed : unused. Doc unclear ?
47 static_cast<int>(out.indexmap().strides()[0]), // stride of the out data
48 1, // out : shift for multi fft.
49 fftw_backward_forward, FFTW_ESTIMATE);
50
51 fftw_execute(p);
52 fftw_destroy_plan(p);
53 }
54
55 //void _fourier_base(array_const_view<double, 2> in, array_view<dcomplex, 2> out, int rank, int *dims, int fftw_count) {
56
57 //auto in_fft = reinterpret_cast<fftw_real *>(in.data());
58 //auto out_fft = reinterpret_cast<fftw_complex *>(out.data());
59
60 //auto p = fftw_plan_many_dft(rank, // rank
61 //dims, // the dimension
62 //fftw_count, // how many FFT : here 1
63 //in_fft, // in data
64 //NULL, // embed : unused. Doc unclear ?
65 //in.indexmap().strides()[0], // stride of the in data
66 //1, // in : shift for multi fft.
67 //out_fft, // out data
68 //NULL, // embed : unused. Doc unclear ?
69 //out.indexmap().strides()[0], // stride of the out data
70 //1, // out : shift for multi fft.
71 //FFTW_ESTIMATE);
72
73 //fftw_execute(p);
74 //fftw_destroy_plan(p);
75 //}
76
77} // namespace triqs::gfs
Declares the low-level FFTW wrapper shared by the Fourier transform implementations.