diff --git a/doc/reference/c++/gf/fourier.rst b/doc/reference/c++/gf/fourier.rst index 1d60835a..f86da8ac 100644 --- a/doc/reference/c++/gf/fourier.rst +++ b/doc/reference/c++/gf/fourier.rst @@ -22,11 +22,19 @@ Synopsis gf make_gf_from_fourier(gf const&); gf make_gf_from_fourier(gf_view const&); gf make_gf_from_fourier(gf_const_view const&); - + + gf make_gf_from_fourier(gf const&, int n_iw); + gf make_gf_from_fourier(gf_view const&, int n_iw); + gf make_gf_from_fourier(gf_const_view const&, int n_iw); + gf make_gf_from_inverse_fourier(gf const&); gf make_gf_from_inverse_fourier(gf_view const&); gf make_gf_from_inverse_fourier(gf_const_view const&); + gf make_gf_from_inverse_fourier(gf const&, int n_tau); + gf make_gf_from_inverse_fourier(gf_view const&, int n_tau); + gf make_gf_from_inverse_fourier(gf_const_view const&, int n_tau); + **fourier, inverse_fourier** @@ -57,10 +65,7 @@ We therefore use *a view* as LHS:: **make_gf_from_fourier, make_gf_from_inverse_fourier** In the case where we want to create a *new* container from the fourier transform of gt, -we can use the function make_gf_from_fourier, in which choice is explicitly made to generate a new gf with the same number of points in the mesh. -(Cf example below). - -DOC TO BE FINISHED. +we can use the function make_gf_from_fourier. Example ========= diff --git a/doc/reference/c++/gf/fourier_0.cpp b/doc/reference/c++/gf/fourier_0.cpp index defa4549..9f9ba97a 100644 --- a/doc/reference/c++/gf/fourier_0.cpp +++ b/doc/reference/c++/gf/fourier_0.cpp @@ -3,17 +3,16 @@ using namespace triqs::gfs; int main() { double beta = 1, a = 1; int N = 10000; - auto gw = gf{{beta, Fermion, N}, {1, 1}}; + auto gw = gf{{beta, Fermion, N/2}, {1, 1}}; auto gt = gf{{beta, Fermion, N}, {1, 1}}; triqs::clef::placeholder<0> om_; gw(om_) << 1 / (om_ - a); // fills a full *view* of gt with the contents of the FFT - // NB : the mesh of gt *must* have the same size as the mesh of gw. gt() = inverse_fourier(gw); - // make a new fresh gf, with the same size mesh, from the FFT of gt - auto gw2 = make_gf_from_fourier(gt); + // make a new fresh gf from the FFT of gt with a mesh of size N/2 + auto gw2 = make_gf_from_fourier(gt, N/2); } diff --git a/doc/reference/python/green/tail.rst b/doc/reference/python/green/tail.rst index b1fd2a54..21f0d727 100644 --- a/doc/reference/python/green/tail.rst +++ b/doc/reference/python/green/tail.rst @@ -44,17 +44,13 @@ Basic ``TailGf`` object from pytriqs.gf.local import * - t = TailGf(shape=(1,1)) + t = TailGf(N1=1, N2=1) print "t = ",t print "t.data.shape = ",t.data.shape print "t.order_min = ",t.order_min print "t.order_max = ",t.order_max print "t.mask = ",t.mask print "t[1] = ",t[1] - t[1]=[1] - print "t = ",t - t[-1]=.25 - print "t = ",t print "t(100) = ",t(100) @@ -101,6 +97,7 @@ coefficients :math:`(\mathbf{a}_{-1})_{00} = 0`\ , .. runblock:: python from pytriqs.gf.local import * + import numpy g = GfImFreq(indices = [1], beta = 50, n_points = 1000, name = "imp") g <<= inverse( iOmega_n + 0.5 ) g.tail.zero() diff --git a/triqs/gfs/local/fourier_matsubara.hpp b/triqs/gfs/local/fourier_matsubara.hpp index 86943f05..f4880aa1 100644 --- a/triqs/gfs/local/fourier_matsubara.hpp +++ b/triqs/gfs/local/fourier_matsubara.hpp @@ -49,30 +49,32 @@ namespace gfs { void triqs_gf_view_assign_delegation(gf_view g, gf_keeper const& L); - template gf_mesh make_mesh_fourier_compatible(gf_mesh const& m) { - int L = (m.size() - (m.kind() == full_bins ? 1 : 0))/2; - return {m.domain(), L}; - } - - template - gf_mesh make_mesh_fourier_compatible(gf_mesh const& m, mesh_kind mk = full_bins) { - int L = 2*m.size() + (mk == full_bins ? 1 : 0); - return {m.domain(), L}; - } - template - gf make_gf_from_fourier(gf_impl const& gt) { - auto gw = gf{make_mesh_fourier_compatible(gt.mesh()), get_target_shape(gt)}; + gf make_gf_from_fourier(gf_impl const& gt, int n_iw) { + auto m = gf_mesh{gt.mesh().domain(), n_iw}; + auto gw = gf{m, get_target_shape(gt)}; gw() = fourier(gt); return gw; } template - gf make_gf_from_inverse_fourier(gf_impl const& gw, mesh_kind mk = full_bins) { - auto gt = gf{make_mesh_fourier_compatible(gw.mesh(), mk), get_target_shape(gw)}; + gf make_gf_from_fourier(gf_impl const& gt) { + return make_gf_from_fourier(gt, (gt.mesh().size() - (gt.mesh().kind() == full_bins ? 1 : 0)) / 2); + } + + template + gf make_gf_from_inverse_fourier(gf_impl const& gw, int n_tau, + mesh_kind mk = full_bins) { + auto m = gf_mesh{gw.mesh().domain(), n_tau}; + auto gt = gf{m, get_target_shape(gw)}; gt() = inverse_fourier(gw); return gt; } + + template + gf make_gf_from_inverse_fourier(gf_impl const& gw, mesh_kind mk = full_bins) { + return make_gf_from_inverse_fourier(gw, 2 * gw.mesh().size() + (mk == full_bins ? 1 : 0), mk); + } } namespace clef {