diff --git a/pytriqs/gf/local/imfreq.pxd b/pytriqs/gf/local/imfreq.pxd index caad25c2..33163e29 100644 --- a/pytriqs/gf/local/imfreq.pxd +++ b/pytriqs/gf/local/imfreq.pxd @@ -5,8 +5,7 @@ cdef extern from "triqs/gfs/imfreq.hpp" namespace "triqs::gfs" : statistic_enum statistic imfreq_domain () - #cdef cppclass mesh_imfreq "triqs::gfs::linear_mesh" : - cdef cppclass mesh_imfreq "triqs::gfs::linear_mesh>" : + cdef cppclass mesh_imfreq "triqs::gfs::mesh" : mesh_imfreq () mesh_imfreq (mesh_imfreq &) imfreq_domain & domain() @@ -14,7 +13,7 @@ cdef extern from "triqs/gfs/imfreq.hpp" namespace "triqs::gfs" : long size() bint operator ==( mesh_imfreq &) - cdef mesh_imfreq make_mesh_imfreq "triqs::gfs::make_gf_mesh" (double beta, statistic_enum S, size_t n_max) + cdef mesh_imfreq make_mesh_imfreq "triqs::gfs::mesh" (double beta, statistic_enum S, size_t n_max) #cdef mesh_imfreq make_mesh_imfreq "triqs::gfs::gf_implementation::gf_factories::make_mesh" (double beta, statistic_enum S, size_t n_max) cdef cppclass gf_imfreq "triqs::python_tools::cython_proxy >" : diff --git a/pytriqs/gf/local/imtime.pxd b/pytriqs/gf/local/imtime.pxd index c77ce2e4..cca2c168 100644 --- a/pytriqs/gf/local/imtime.pxd +++ b/pytriqs/gf/local/imtime.pxd @@ -5,8 +5,7 @@ cdef extern from "triqs/gfs/imtime.hpp" namespace "triqs::gfs" : statistic_enum statistic imtime_domain () - #cdef cppclass mesh_imtime "triqs::gfs::linear_mesh" : - cdef cppclass mesh_imtime "triqs::gfs::linear_mesh>" : + cdef cppclass mesh_imtime "triqs::gfs::mesh" : mesh_imtime () mesh_imtime (mesh_imtime &) imtime_domain & domain() @@ -15,7 +14,7 @@ cdef extern from "triqs/gfs/imtime.hpp" namespace "triqs::gfs" : long kind() bint operator ==( mesh_imtime &) - cdef mesh_imtime make_mesh_imtime "triqs::gfs::make_gf_mesh" (double beta, statistic_enum S, size_t n_time_slices, mesh_enum mk) + cdef mesh_imtime make_mesh_imtime "triqs::gfs::mesh" (double beta, statistic_enum S, size_t n_time_slices, mesh_enum mk) #cdef mesh_imtime make_mesh_imtime "triqs::gfs::gf_factories::make_mesh" (double beta, statistic_enum S, size_t n_time_slices, mesh_enum mk) cdef cppclass gf_imtime "triqs::python_tools::cython_proxy>" : diff --git a/pytriqs/gf/local/legendre.pxd b/pytriqs/gf/local/legendre.pxd index ec457d98..ca5307fc 100644 --- a/pytriqs/gf/local/legendre.pxd +++ b/pytriqs/gf/local/legendre.pxd @@ -6,15 +6,14 @@ cdef extern from "triqs/gfs/legendre.hpp" namespace "triqs::gfs" : statistic_enum statistic legendre_domain () - #cdef cppclass mesh_legendre "triqs::gfs::discrete_mesh": - cdef cppclass mesh_legendre "triqs::gfs::discrete_mesh": + cdef cppclass mesh_legendre "triqs::gfs::mesh" : mesh_legendre () mesh_legendre (mesh_legendre &) legendre_domain & domain() long size() bint operator == (mesh_legendre &) - cdef mesh_legendre make_mesh_legendre "triqs::gfs::make_gf_mesh" (double beta, statistic_enum S, size_t n_leg) + cdef mesh_legendre make_mesh_legendre "triqs::gfs::mesh" (double beta, statistic_enum S, size_t n_leg) #cdef mesh_legendre make_mesh_legendre "triqs::gfs::gf_factories::make_mesh" (double beta, statistic_enum S, size_t n_leg) cdef cppclass gf_legendre "triqs::python_tools::cython_proxy>" : diff --git a/pytriqs/gf/local/refreq.pxd b/pytriqs/gf/local/refreq.pxd index d73c0e36..2c9bfc74 100644 --- a/pytriqs/gf/local/refreq.pxd +++ b/pytriqs/gf/local/refreq.pxd @@ -3,8 +3,7 @@ cdef extern from "triqs/gfs/refreq.hpp" namespace "triqs::gfs" : cdef cppclass refreq_domain : refreq_domain() - #cdef cppclass mesh_refreq "triqs::gfs::linear_mesh" : - cdef cppclass mesh_refreq "triqs::gfs::linear_mesh" : + cdef cppclass mesh_refreq "triqs::gfs::mesh" : mesh_refreq () mesh_refreq (mesh_refreq &) refreq_domain & domain() @@ -14,7 +13,7 @@ cdef extern from "triqs/gfs/refreq.hpp" namespace "triqs::gfs" : double kind() bint operator ==( mesh_refreq &) - cdef mesh_refreq make_mesh_refreq "triqs::gfs::make_gf_mesh" (double omega_min, double omega_max, size_t n_freq, mesh_enum mk) + cdef mesh_refreq make_mesh_refreq "triqs::gfs::mesh" (double omega_min, double omega_max, size_t n_freq, mesh_enum mk) #cdef mesh_refreq make_mesh_refreq "triqs::gfs::gf_factories::make_mesh" (double omega_min, double omega_max, size_t n_freq, mesh_enum mk) cdef cppclass gf_refreq "triqs::python_tools::cython_proxy>" : diff --git a/pytriqs/gf/local/retime.pxd b/pytriqs/gf/local/retime.pxd index 09efe701..797c12b8 100644 --- a/pytriqs/gf/local/retime.pxd +++ b/pytriqs/gf/local/retime.pxd @@ -3,8 +3,7 @@ cdef extern from "triqs/gfs/retime.hpp" namespace "triqs::gfs" : cdef cppclass retime_domain : retime_domain() - #cdef cppclass mesh_retime "triqs::gfs::linear_mesh" : - cdef cppclass mesh_retime "triqs::gfs::linear_mesh" : + cdef cppclass mesh_retime "triqs::gfs::mesh" : mesh_retime () mesh_retime (mesh_retime &) retime_domain & domain() @@ -14,7 +13,7 @@ cdef extern from "triqs/gfs/retime.hpp" namespace "triqs::gfs" : double kind() bint operator ==( mesh_retime &) - cdef mesh_retime make_mesh_retime "triqs::gfs::make_gf_mesh" (double t_min, double t_max, size_t n_freq, mesh_enum mk) + cdef mesh_retime make_mesh_retime "triqs::gfs::mesh" (double t_min, double t_max, size_t n_freq, mesh_enum mk) #cdef mesh_retime make_mesh_retime "triqs::gfs::gf_factories::make_mesh" (double t_min, double t_max, size_t n_freq, mesh_enum mk) cdef cppclass gf_retime "triqs::python_tools::cython_proxy>" : diff --git a/pytriqs/gf/local/two_real_times.pxd b/pytriqs/gf/local/two_real_times.pxd index a4ddc70e..61c8f795 100644 --- a/pytriqs/gf/local/two_real_times.pxd +++ b/pytriqs/gf/local/two_real_times.pxd @@ -3,8 +3,7 @@ cdef extern from "triqs/gfs/two_real_times.hpp" namespace "triqs::gfs" : cdef cppclass two_real_times_domain : two_real_times_domain() - #cdef cppclass mesh_retime "triqs::gfs::linear_mesh" : - cdef cppclass mesh_two_real_times "triqs::gfs::mesh_product,triqs::gfs::linear_mesh>" : + cdef cppclass mesh_two_real_times "triqs::gfs::mesh" : mesh_two_real_times () mesh_two_real_times (mesh_two_real_times &) two_real_times_domain & domain() @@ -14,7 +13,7 @@ cdef extern from "triqs/gfs/two_real_times.hpp" namespace "triqs::gfs" : double kind() bint operator ==( mesh_two_real_times &) - cdef mesh_two_real_times make_mesh_two_real_times "triqs::gfs::make_gf_mesh" (double t_max, double n_time_slices) + cdef mesh_two_real_times make_mesh_two_real_times "triqs::gfs::mesh" (double t_max, double n_time_slices) cdef mesh_retime & get_1d_mesh_from_2times_mesh "triqs::gfs::get_1d_mesh_from_2times_mesh" (mesh_two_real_times &) diff --git a/test/triqs/gf/c++11/gf_re_im_freq_time.cpp b/test/triqs/gf/c++11/gf_re_im_freq_time.cpp index d2601806..14f3fd78 100644 --- a/test/triqs/gf/c++11/gf_re_im_freq_time.cpp +++ b/test/triqs/gf/c++11/gf_re_im_freq_time.cpp @@ -34,11 +34,11 @@ try { auto G_w_tau= make_gf(wmin, wmax, n_re_freq, beta, Fermion, n_im_time); auto G_w= make_gf(wmin, wmax, n_re_freq); - auto G_t_tau= make_gf, scalar_valued>( make_gf_mesh(tmin, tmax, n_re_time), make_gf_mesh(beta, Fermion, n_im_time)); + auto G_t_tau= make_gf, scalar_valued>(mesh(tmin, tmax, n_re_time), mesh(beta, Fermion, n_im_time)); //auto G_t_tau_N= make_gf, scalar_valued>( {tmin, tmax, n_re_time}, {beta, Fermion, n_im_time}); - auto G_w_wn2 = make_gf, scalar_valued>( make_gf_mesh(wmin, wmax, n_re_freq), make_gf_mesh(beta, Fermion, n_im_freq)); - auto G_w_tau2 = make_gf, scalar_valued>( make_gf_mesh(wmin, wmax, n_re_freq), make_gf_mesh(beta, Fermion, n_im_time,full_bins)); + auto G_w_wn2 = make_gf, scalar_valued>( mesh(wmin, wmax, n_re_freq), mesh(beta, Fermion, n_im_freq)); + auto G_w_tau2 = make_gf, scalar_valued>( mesh(wmin, wmax, n_re_freq), mesh(beta, Fermion, n_im_time,full_bins)); //auto g_tau = slice_mesh1(G_w_tau(),1); diff --git a/triqs/gfs/block.hpp b/triqs/gfs/block.hpp index c8c20d59..95766ad6 100644 --- a/triqs/gfs/block.hpp +++ b/triqs/gfs/block.hpp @@ -29,9 +29,13 @@ namespace triqs { namespace gfs { struct block_index {}; + template struct mesh : discrete_mesh { + mesh() = default; + mesh(size_t s) : discrete_mesh(s) {} + }; + namespace gfs_implementation { - template struct mesh { typedef discrete_mesh type;}; template struct h5_name { static std::string invoke(){ return "BlockGf";}}; /// --------------------------- h5_rw --------------------------------- @@ -62,7 +66,7 @@ namespace triqs { namespace gfs { template struct factories { - typedef typename mesh::type mesh_t; + typedef mesh mesh_t; typedef gf gf_t; typedef gf_view gf_view_t; @@ -76,11 +80,11 @@ namespace triqs { namespace gfs { return gf_t(mesh_t(block_names), std::move(V), nothing(), nothing() ); } - /* static gf_t make_gf(std::initializer_list const & l) { - auto v = std::vector {l}; - return make_gf(v); - } -*/ + /* static gf_t make_gf(std::initializer_list const & l) { + auto v = std::vector {l}; + return make_gf(v); + } + */ /* template static gf_t make_gf(size_t N, Args&& ...args) { std::vector V; V.reserve(N); @@ -114,7 +118,7 @@ namespace triqs { namespace gfs { static gf_view_t make_gf_view(std::vector && V) { return gf_view_t ( mesh_t(V.size()), std::move(V), nothing(), nothing() ) ; } }; - + } // gfs_implementation // ------------------------------- Free function -------------------------------------------------- @@ -133,7 +137,7 @@ namespace triqs { namespace gfs { // also experimental // an iterator over the block - template + template class block_gf_iterator : public boost::iterator_facade< block_gf_iterator, typename Target::view_type , boost::forward_traversal_tag, typename Target::view_type > { friend class boost::iterator_core_access; @@ -149,11 +153,11 @@ namespace triqs { namespace gfs { void increment() { ++mesh_it; } bool at_end() const { return mesh_it.at_end();} }; - - template + + template block_gf_iterator begin(gf_impl const & bgf) { return {bgf,false};} - - template + + template block_gf_iterator end(gf_impl const & bgf) { return {bgf,true};} diff --git a/triqs/gfs/curry.hpp b/triqs/gfs/curry.hpp index 15864121..0fe1c9c9 100644 --- a/triqs/gfs/curry.hpp +++ b/triqs/gfs/curry.hpp @@ -119,7 +119,7 @@ namespace triqs { namespace gfs { Opt> curry (gf_impl, Target,Opt,B> const & g) { auto comp = pv_,pos...>::m(std::make_tuple(),g.mesh().components()); - typedef typename mesh< typename pv_,pos...>::type,Opt>::type m_t; + typedef mesh< typename pv_,pos...>::type,Opt> m_t; return {triqs::tuple::apply_construct(comp),curry_polymorphic_lambda, Target,Opt>, pos ...>{g}, nothing(), nothing()}; }; diff --git a/triqs/gfs/gf.hpp b/triqs/gfs/gf.hpp index 9c12af9a..27fcc0d5 100644 --- a/triqs/gfs/gf.hpp +++ b/triqs/gfs/gf.hpp @@ -34,13 +34,12 @@ namespace triqs { namespace gfs { using arrays::make_shape; // GENERALISE matrxi TO DEFAULT + template struct mesh; template class gf; // the value class template class gf_view; // the view class // various implementation traits namespace gfs_implementation { // never use using of this... - // what is the mesh - template struct mesh; // evaluator regroup functions to evaluate the function. Cf descriptors template struct evaluator{ static constexpr int arity = 0;}; @@ -80,9 +79,6 @@ namespace triqs { namespace gfs { template gf_view make_gf_view(U && ... x) { return gfs_implementation::factories::make_gf_view(std::forward(x)...);} - template - typename gfs_implementation::mesh::type make_gf_mesh(U && ... x) { return gfs_implementation::mesh::make(std::forward(x)...);} - template struct gf_desc{}; template struct gf_tag{}; @@ -105,7 +101,7 @@ namespace triqs { namespace gfs { typedef Variable variable_t; typedef Opt option_t; - typedef typename gfs_implementation::mesh::type mesh_t; + typedef mesh mesh_t; typedef typename mesh_t::domain_t domain_t; typedef typename mesh_t::mesh_point_t mesh_point_t; typedef typename mesh_t::index_t mesh_index_t; diff --git a/triqs/gfs/imfreq.hpp b/triqs/gfs/imfreq.hpp index bf5a9b3c..7f574483 100644 --- a/triqs/gfs/imfreq.hpp +++ b/triqs/gfs/imfreq.hpp @@ -29,23 +29,20 @@ namespace triqs { namespace gfs { struct imfreq {}; + template struct mesh : linear_mesh> { + typedef linear_mesh> B; + static double m1(double beta) { return std::acos(-1)/beta;} + mesh() = default; + mesh (double beta, statistic_enum S, size_t Nmax = 1025) : + B(typename B::domain_t(beta,S), S==Fermion?m1(beta):0, S==Fermion?(2*Nmax+1)*m1(beta): 2*Nmax*m1(beta), Nmax, without_last){} + }; + namespace gfs_implementation { - // mesh type and its factories - template struct mesh { - typedef linear_mesh> type; - typedef typename type::domain_t domain_t; - - static type make(double beta, statistic_enum S, size_t Nmax = 1025) { - double m1 = std::acos(-1)/beta; - return type( domain_t(beta,S), S==Fermion?m1:0, S==Fermion?(2*Nmax+1)*m1: 2*Nmax*m1, Nmax, without_last); - } - }; - //singularity template struct singularity { typedef local::tail type;}; template struct singularity { typedef local::tail type;}; - + //h5 name template struct h5_name { static std::string invoke(){ return "ImFreq";}}; @@ -68,44 +65,44 @@ namespace triqs { namespace gfs { template struct data_proxy : data_proxy_array,1> {}; // ------------------------------- Factories -------------------------------------------------- - + // matrix_valued template struct factories { - typedef gf gf_t; - - template + typedef gf gf_t; + + template static gf_t make_gf(MeshType && m, tqa::mini_vector shape, local::tail_view const & t) { - typename gf_t::data_regular_t A(shape.front_append(m.size())); A() =0; - return gf_t ( std::forward(m), std::move(A), t, nothing() ) ; - } - static gf_t make_gf(double beta, statistic_enum S, tqa::mini_vector shape) { - return make_gf(mesh::make(beta,S), shape, local::tail(shape)); - } - static gf_t make_gf(double beta, statistic_enum S, tqa::mini_vector shape, size_t Nmax) { - return make_gf(mesh::make(beta,S,Nmax), shape, local::tail(shape)); - } - static gf_t make_gf(double beta, statistic_enum S, tqa::mini_vector shape, size_t Nmax, local::tail_view const & t) { - return make_gf(mesh::make(beta,S,Nmax), shape, t); + typename gf_t::data_regular_t A(shape.front_append(m.size())); A() =0; + return gf_t ( std::forward(m), std::move(A), t, nothing() ) ; } + static gf_t make_gf(double beta, statistic_enum S, tqa::mini_vector shape) { + return make_gf(mesh(beta,S), shape, local::tail(shape)); + } + static gf_t make_gf(double beta, statistic_enum S, tqa::mini_vector shape, size_t Nmax) { + return make_gf(mesh(beta,S,Nmax), shape, local::tail(shape)); + } + static gf_t make_gf(double beta, statistic_enum S, tqa::mini_vector shape, size_t Nmax, local::tail_view const & t) { + return make_gf(mesh(beta,S,Nmax), shape, t); + } }; - + // scalar_valued template struct factories { typedef gf gf_t; template - static gf_t make_gf(MeshType && m, local::tail_view const & t) { - typename gf_t::data_regular_t A(m.size()); A() =0; - return gf_t ( std::forward(m), std::move(A), t, nothing() ) ; - } + static gf_t make_gf(MeshType && m, local::tail_view const & t) { + typename gf_t::data_regular_t A(m.size()); A() =0; + return gf_t ( std::forward(m), std::move(A), t, nothing() ) ; + } static gf_t make_gf(double beta, statistic_enum S) { - return make_gf(mesh::make(beta,S), local::tail(tqa::mini_vector (1,1))); + return make_gf(mesh(beta,S), local::tail(tqa::mini_vector (1,1))); } static gf_t make_gf(double beta, statistic_enum S, size_t Nmax) { - return make_gf(mesh::make(beta,S,Nmax), local::tail(tqa::mini_vector (1,1))); + return make_gf(mesh(beta,S,Nmax), local::tail(tqa::mini_vector (1,1))); } static gf_t make_gf(double beta, statistic_enum S, size_t Nmax, local::tail_view const & t) { - return make_gf(mesh::make(beta,S,Nmax), t); + return make_gf(mesh(beta,S,Nmax), t); } }; } // gfs_implementation diff --git a/triqs/gfs/imtime.hpp b/triqs/gfs/imtime.hpp index 79377453..bc0ff677 100644 --- a/triqs/gfs/imtime.hpp +++ b/triqs/gfs/imtime.hpp @@ -30,21 +30,20 @@ namespace triqs { namespace gfs { struct imtime {}; + // mesh type and its factories + template struct mesh : linear_mesh> { + typedef linear_mesh> B; + mesh() = default; + mesh (double beta, statistic_enum S, size_t n_time_slices, mesh_kind mk=half_bins): + B( typename B::domain_t(beta,S), 0, beta, n_time_slices, mk){} + }; + namespace gfs_implementation { - // mesh type and its factories - template struct mesh { - typedef linear_mesh> type; - typedef typename type::domain_t domain_t; - static type make(double beta, statistic_enum S, size_t n_time_slices, mesh_kind mk=half_bins) { - return type(domain_t(beta,S), 0, beta, n_time_slices, mk); - } - }; - // singularity template struct singularity { typedef local::tail type;}; template struct singularity { typedef local::tail type;}; - + // h5 name template struct h5_name { static std::string invoke(){ return "ImTime";}}; @@ -53,7 +52,7 @@ namespace triqs { namespace gfs { template struct data_proxy : data_proxy_array {}; template struct data_proxy : data_proxy_array {}; - /// --------------------------- closest mesh point on the grid --------------------------------- + /// --------------------------- closest mesh point on the grid --------------------------------- template struct get_closest_point { @@ -123,7 +122,7 @@ namespace triqs { namespace gfs { typename G::singularity_t const & operator()(G const * g,freq_infty const &) const {return g->singularity();} }; - // ------------------------------- Factories -------------------------------------------------- + // ------------------------------- Factories -------------------------------------------------- // matrix_valued template struct factories { @@ -135,10 +134,10 @@ namespace triqs { namespace gfs { return gf_t (std::forward(m), std::move(A), t, nothing(), evaluator(shape[0],shape[1]) ) ; } static gf_t make_gf(double beta, statistic_enum S, tqa::mini_vector shape, size_t Nmax=1025, mesh_kind mk= half_bins) { - return make_gf(mesh::make(beta,S,Nmax,mk), shape, local::tail(shape)); + return make_gf(mesh(beta,S,Nmax,mk), shape, local::tail(shape)); } static gf_t make_gf(double beta, statistic_enum S, tqa::mini_vector shape, size_t Nmax, mesh_kind mk, local::tail_view const & t) { - return make_gf(mesh::make(beta,S,Nmax,mk), shape, t); + return make_gf(mesh(beta,S,Nmax,mk), shape, t); } }; @@ -151,14 +150,14 @@ namespace triqs { namespace gfs { return gf_t (std::forward(m), std::move(A), t, nothing()); } static gf_t make_gf(double beta, statistic_enum S, size_t Nmax=1025, mesh_kind mk= half_bins) { - return make_gf(mesh::make(beta,S,Nmax,mk), local::tail(tqa::mini_vector (1,1))); + return make_gf(mesh(beta,S,Nmax,mk), local::tail(tqa::mini_vector (1,1))); } static gf_t make_gf(double beta, statistic_enum S, size_t Nmax, mesh_kind mk, local::tail_view const & t) { - return make_gf(mesh::make(beta,S,Nmax,mk), t); + return make_gf(mesh(beta,S,Nmax,mk), t); } }; } // gfs_implementation. - + }} #endif diff --git a/triqs/gfs/legendre.hpp b/triqs/gfs/legendre.hpp index 53b6b1d5..10df5fc0 100644 --- a/triqs/gfs/legendre.hpp +++ b/triqs/gfs/legendre.hpp @@ -30,15 +30,15 @@ namespace triqs { namespace gfs { struct legendre {}; + // mesh type and its factories + template struct mesh :discrete_mesh { + typedef discrete_mesh B; + mesh() = default; + mesh(double beta, statistic_enum S, size_t n_leg) : B(typename B::domain_t(beta,S,n_leg)) {} + }; + namespace gfs_implementation { - // mesh type and its factories - template struct mesh { - typedef discrete_mesh type; - typedef typename type::domain_t domain_t; - static type make(double beta, statistic_enum S, size_t n_leg) { return type(domain_t(beta,S,n_leg)); } - }; - // h5 name template struct h5_name { static std::string invoke(){ return "Legendre";}}; @@ -66,7 +66,7 @@ namespace triqs { namespace gfs { static gf_t make_gf(double beta, statistic_enum S, tqa::mini_vector shape, size_t n_leg) { typename gf_t::data_regular_t A(shape.front_append(n_leg)); A() = 0; - return gf_t(mesh::make(beta, S, n_leg), std::move(A), nothing(), nothing()); + return gf_t(mesh(beta, S, n_leg), std::move(A), nothing(), nothing()); } }; diff --git a/triqs/gfs/meshes/linear.hpp b/triqs/gfs/meshes/linear.hpp index 470a979c..1daaf93b 100644 --- a/triqs/gfs/meshes/linear.hpp +++ b/triqs/gfs/meshes/linear.hpp @@ -116,6 +116,7 @@ namespace triqs { namespace gfs { /// Mesh comparison bool operator == (linear_mesh const & M) const { return ((_dom == M._dom) && (size() ==M.size()) && (std::abs(xmin - M.xmin)<1.e-15) && (std::abs(xmax - M.xmax)<1.e-15));} + bool operator != (linear_mesh const & M) const { return !(operator==(M));} /// Write into HDF5 friend void h5_write (h5::group fg, std::string subgroup_name, linear_mesh const & m) { diff --git a/triqs/gfs/product.hpp b/triqs/gfs/product.hpp index 93b1110a..56b8f447 100644 --- a/triqs/gfs/product.hpp +++ b/triqs/gfs/product.hpp @@ -31,13 +31,14 @@ namespace triqs { namespace gfs { static constexpr size_t size = sizeof...(Ms); }; + // the mesh is simply a cartesian product + template struct mesh,Opt> : mesh_product< mesh ... > { + typedef mesh_product< mesh ... > B; + typedef std::tuple mesh_name_t; + mesh (mesh ... ms) : B {std::move(ms)...} {} + }; + namespace gfs_implementation { - // the mesh is simply a cartesian product - template struct mesh,Opt> { - typedef mesh_product< typename mesh::type ... > type; - typedef std::tuple mesh_name_t; - static type make (typename mesh::type ... ms) { return type{std::move(ms)...};} - }; // h5 name : name1_x_name2_..... template struct h5_name,matrix_valued,Opt> { @@ -159,7 +160,7 @@ namespace triqs { namespace gfs { template static gf_t make_gf(Meshes && ... meshes) { - auto m = make_gf_mesh,Opt>(meshes...); + auto m = mesh,Opt>(meshes...); typename gf_t::data_regular_t A(m.size()); A() =0; return gf_t (m, std::move(A), nothing(), nothing()); diff --git a/triqs/gfs/re_im_freq.hpp b/triqs/gfs/re_im_freq.hpp index feb319e1..bb11fc41 100644 --- a/triqs/gfs/re_im_freq.hpp +++ b/triqs/gfs/re_im_freq.hpp @@ -29,61 +29,60 @@ namespace triqs { namespace gfs { struct re_im_freq {}; - + + // the mesh + template struct mesh : mesh_product,mesh> { + typedef mesh m1_t; + typedef mesh m2_t; + typedef mesh_product B; + mesh (double wmin, double wmax, size_t n_freq_re, double beta, statistic_enum S, size_t n_freq_im) : + B { mesh(wmin,wmax,n_freq_re,full_bins), mesh(beta, S, n_freq_im)} {} + }; + namespace gfs_implementation { - - // the mesh - template struct mesh { - typedef typename mesh::type m1_t; - typedef typename mesh::type m2_t; - typedef mesh_product type; - static type make (double wmin, double wmax, size_t n_freq_re, double beta, statistic_enum S, size_t n_freq_im) { - return {gfs::make_gf_mesh(wmin,wmax,n_freq_re,full_bins), make_gf_mesh(beta, S, n_freq_im)}; - } - }; - - // singularity - template struct singularity { typedef gf type;}; - - // h5 name - template struct h5_name { static std::string invoke(){ return "GfReImFreq";}}; - - /// --------------------------- data access --------------------------------- - - template struct data_proxy : data_proxy_array,1> {}; - - /// --------------------------- evaluator --------------------------------- - - template + + // singularity + template struct singularity { typedef gf type;}; + + // h5 name + template struct h5_name { static std::string invoke(){ return "GfReImFreq";}}; + + /// --------------------------- data access --------------------------------- + + template struct data_proxy : data_proxy_array,1> {}; + + /// --------------------------- evaluator --------------------------------- + + template struct evaluator { - static constexpr int arity = 2; - template + static constexpr int arity = 2; + template std::complex operator() (G const * g, double w, long n) const { - auto & data = g->data(); - auto & mesh = g->mesh(); - size_t nr; double wr; bool in; - std::tie(in, nr, wr) = windowing( std::get<0>(g->mesh().components()), w); - if (!in) TRIQS_RUNTIME_ERROR <<" Evaluation out of bounds"; - auto gg = [g,data,mesh]( size_t nr, size_t n) {return data(mesh.index_to_linear(std::tuple{nr,n}));}; - return wr * gg(nr,n) + (1-wr) * gg(nr+1,n) ; + auto & data = g->data(); + auto & mesh = g->mesh(); + size_t nr; double wr; bool in; + std::tie(in, nr, wr) = windowing( std::get<0>(g->mesh().components()), w); + if (!in) TRIQS_RUNTIME_ERROR <<" Evaluation out of bounds"; + auto gg = [g,data,mesh]( size_t nr, size_t n) {return data(mesh.index_to_linear(std::tuple{nr,n}));}; + return wr * gg(nr,n) + (1-wr) * gg(nr+1,n) ; } }; - - // ------------------------------- Factories -------------------------------------------------- - - template struct factories { - typedef gf gf_t; -// typedef typename mesh::type mesh_t; - - static gf_t make_gf(double wmin, double wmax, size_t nw, double beta, statistic_enum S, size_t nwn) { - auto m = make_gf_mesh(wmin, wmax, nw, beta, S, nwn); - typename gf_t::data_regular_t A(m.size()); - A() =0; - return gf_t (m, std::move(A), gfs::make_gf(wmin, wmax, nw), nothing() ) ; - } - }; - -} // gfs_implementation + + // ------------------------------- Factories -------------------------------------------------- + + template struct factories { + typedef gf gf_t; + // typedef typename mesh::type mesh_t; + + static gf_t make_gf(double wmin, double wmax, size_t nw, double beta, statistic_enum S, size_t nwn) { + auto m = mesh(wmin, wmax, nw, beta, S, nwn); + typename gf_t::data_regular_t A(m.size()); + A() =0; + return gf_t (m, std::move(A), gfs::make_gf(wmin, wmax, nw), nothing() ) ; + } + }; + + } // gfs_implementation }} #endif diff --git a/triqs/gfs/re_im_time.hpp b/triqs/gfs/re_im_time.hpp index 031f64ae..198720ac 100644 --- a/triqs/gfs/re_im_time.hpp +++ b/triqs/gfs/re_im_time.hpp @@ -27,20 +27,19 @@ #include "./meshes/product.hpp" namespace triqs { namespace gfs { - + struct re_im_time {}; - namespace gfs_implementation { + // the mesh + template struct mesh : mesh_product,mesh> { + typedef mesh m1_t; + typedef mesh m2_t; + typedef mesh_product B; + mesh (double tmin, double tmax, size_t nt, double beta, statistic_enum S, size_t ntau, mesh_kind mk=full_bins) : + B {mesh(tmin,tmax,nt), mesh(beta,S, ntau, mk)} {} + }; - // the mesh - template struct mesh { - typedef typename mesh::type m1_t; - typedef typename mesh::type m2_t; - typedef mesh_product type; - static type make (double tmin, double tmax, size_t nt, double beta, statistic_enum S, size_t ntau, mesh_kind mk=full_bins) { - return {make_gf_mesh(tmin,tmax,nt), make_gf_mesh(beta,S, ntau, mk)}; - } - }; + namespace gfs_implementation { // singularity //template struct singularity { typedef gf type;}; @@ -78,16 +77,16 @@ namespace triqs { namespace gfs { template struct factories { typedef gf gf_t; - + template - static gf_t make_gf(MeshType && m) { - typename gf_t::data_regular_t A(m.size()); - A() =0; - return gf_t (m, std::move(A), nothing(), nothing() ) ; - } + static gf_t make_gf(MeshType && m) { + typename gf_t::data_regular_t A(m.size()); + A() =0; + return gf_t (m, std::move(A), nothing(), nothing() ) ; + } static gf_t make_gf(double tmin, double tmax, size_t nt, double beta, statistic_enum S, size_t ntau, mesh_kind mk=full_bins) { - auto m = make_gf_mesh(tmin,tmax, nt, beta, S, ntau, mk); + auto m = mesh(tmin,tmax, nt, beta, S, ntau, mk); typename gf_t::data_regular_t A(m.size()); A() =0; return gf_t (m, std::move(A), nothing(), nothing()); diff --git a/triqs/gfs/refreq.hpp b/triqs/gfs/refreq.hpp index c2d2184f..35ca842e 100644 --- a/triqs/gfs/refreq.hpp +++ b/triqs/gfs/refreq.hpp @@ -30,20 +30,19 @@ namespace triqs { namespace gfs { struct refreq {}; + template struct mesh : linear_mesh { + typedef linear_mesh B; + mesh() = default; + mesh (double wmin, double wmax, size_t n_freq, mesh_kind mk=full_bins) : + B(typename B::domain_t(), wmin, wmax, n_freq, mk){} + }; + namespace gfs_implementation { - - template struct mesh { - typedef linear_mesh type; - typedef typename type::domain_t domain_t; - static type make(double wmin, double wmax, size_t n_freq, mesh_kind mk=full_bins) { - return type(domain_t(), wmin, wmax, n_freq, mk); - } - }; - + // singularity template struct singularity { typedef local::tail type;}; template struct singularity { typedef local::tail type;}; - + // h5 name template struct h5_name { static std::string invoke(){ return "ReFreq";}}; @@ -54,67 +53,67 @@ namespace triqs { namespace gfs { typedef typename std::conditional < std::is_same::value, arrays::matrix >, std::complex>::type rtype; template rtype operator() (G const * g,double w0) const { - //auto operator() (G const * g,double w0) const -> typename decltype ((*g)[0])::regular_type { + //auto operator() (G const * g,double w0) const -> typename decltype ((*g)[0])::regular_type { size_t n; double w; bool in; std::tie(in, n, w) = windowing(g->mesh(),w0); if (!in) TRIQS_RUNTIME_ERROR <<" Evaluation out of bounds"; auto gg = on_mesh(*g); return (1-w) * gg(n) + w * gg(n+1); } - template - local::tail_view operator()(G const * g,freq_infty const &) const {return g->singularity();} - }; - - /// --------------------------- data access --------------------------------- - template struct data_proxy : data_proxy_array,3> {}; - template struct data_proxy : data_proxy_array,1> {}; - - // ------------------------------- Factories -------------------------------------------------- - - //matrix_valued - template struct factories { - typedef gf gf_t; + template + local::tail_view operator()(G const * g,freq_infty const &) const {return g->singularity();} + }; - template - static gf_t make_gf(MeshType && m, tqa::mini_vector shape, local::tail_view const & t) { - typename gf_t::data_regular_t A(shape.front_append(m.size())); A() =0; - return gf_t ( std::forward(m), std::move(A), t, nothing() ) ; - } + /// --------------------------- data access --------------------------------- + template struct data_proxy : data_proxy_array,3> {}; + template struct data_proxy : data_proxy_array,1> {}; - static gf_t make_gf(double wmin, double wmax, size_t n_freq, tqa::mini_vector shape) { - typename gf_t::data_regular_t A(shape.front_append(n_freq)); A() =0; - return gf_t(mesh::make(wmin, wmax, n_freq, full_bins), std::move(A), local::tail(shape), nothing()); - } + // ------------------------------- Factories -------------------------------------------------- - static gf_t make_gf(double wmin, double wmax, size_t n_freq, tqa::mini_vector shape, mesh_kind mk) { - typename gf_t::data_regular_t A(shape.front_append(n_freq)); A() =0; - return gf_t(mesh::make(wmin, wmax, n_freq, mk), std::move(A), local::tail(shape), nothing()); - } - }; - - //scalar_valued - template struct factories { - typedef gf gf_t; + //matrix_valued + template struct factories { + typedef gf gf_t; - template - static gf_t make_gf(MeshType && m, local::tail_view const & t) { - typename gf_t::data_regular_t A(m.size()); A() =0; - return gf_t ( std::forward(m), std::move(A), t, nothing() ) ; - } - - static gf_t make_gf(double wmin, double wmax, size_t n_freq) { - typename gf_t::data_regular_t A(n_freq); A() =0; - return gf_t(mesh::make(wmin, wmax, n_freq), std::move(A), local::tail(tqa::mini_vector(1,1)), nothing()); - } + template + static gf_t make_gf(MeshType && m, tqa::mini_vector shape, local::tail_view const & t) { + typename gf_t::data_regular_t A(shape.front_append(m.size())); A() =0; + return gf_t ( std::forward(m), std::move(A), t, nothing() ) ; + } - static gf_t make_gf(double wmin, double wmax, size_t n_freq, mesh_kind mk) { - typename gf_t::data_regular_t A(n_freq); A() =0; - return gf_t(mesh::make(wmin, wmax, n_freq, mk), std::move(A), local::tail(tqa::mini_vector(1,1)), nothing()); - } + static gf_t make_gf(double wmin, double wmax, size_t n_freq, tqa::mini_vector shape) { + typename gf_t::data_regular_t A(shape.front_append(n_freq)); A() =0; + return gf_t(mesh(wmin, wmax, n_freq, full_bins), std::move(A), local::tail(shape), nothing()); + } - }; - } // gfs_implementation + static gf_t make_gf(double wmin, double wmax, size_t n_freq, tqa::mini_vector shape, mesh_kind mk) { + typename gf_t::data_regular_t A(shape.front_append(n_freq)); A() =0; + return gf_t(mesh(wmin, wmax, n_freq, mk), std::move(A), local::tail(shape), nothing()); + } + }; -}} + //scalar_valued + template struct factories { + typedef gf gf_t; + + template + static gf_t make_gf(MeshType && m, local::tail_view const & t) { + typename gf_t::data_regular_t A(m.size()); A() =0; + return gf_t ( std::forward(m), std::move(A), t, nothing() ) ; + } + + static gf_t make_gf(double wmin, double wmax, size_t n_freq) { + typename gf_t::data_regular_t A(n_freq); A() =0; + return gf_t(mesh(wmin, wmax, n_freq), std::move(A), local::tail(tqa::mini_vector(1,1)), nothing()); + } + + static gf_t make_gf(double wmin, double wmax, size_t n_freq, mesh_kind mk) { + typename gf_t::data_regular_t A(n_freq); A() =0; + return gf_t(mesh(wmin, wmax, n_freq, mk), std::move(A), local::tail(tqa::mini_vector(1,1)), nothing()); + } + + }; + } // gfs_implementation + + }} #endif diff --git a/triqs/gfs/refreq_imtime.hpp b/triqs/gfs/refreq_imtime.hpp index b2970b65..b35cd3c4 100644 --- a/triqs/gfs/refreq_imtime.hpp +++ b/triqs/gfs/refreq_imtime.hpp @@ -27,78 +27,76 @@ #include "./meshes/product.hpp" namespace triqs { namespace gfs { - - struct refreq_imtime {}; - - namespace gfs_implementation { - - // the mesh - template struct mesh { - typedef typename mesh::type m1_t; - typedef typename mesh::type m2_t; - typedef mesh_product type; - static type make (double wmin, double wmax, size_t n_freq, double beta, statistic_enum S, size_t nt, mesh_kind mk=full_bins ) { - return {make_gf_mesh(wmin,wmax,n_freq), make_gf_mesh(beta,S,nt,mk)}; - } - }; - - // singularity - //template struct singularity { typedef gf type;}; - - // h5 name - template struct h5_name { static std::string invoke(){ return "GfReFreqImTime";}}; - - /// --------------------------- data access --------------------------------- - - template struct data_proxy : data_proxy_array,1> {}; - - /// --------------------------- evaluator --------------------------------- - - template - struct evaluator { - static constexpr int arity = 2; - template - std::complex operator() (G const * g, double omega, double tau) const { - double beta = std::get<1>(g->mesh().components()).domain().beta; - int p = std::floor(tau/beta); - tau -= p*beta; - size_t n1,n2; double w1,w2; bool in; - std::tie(in, n1, w1) = windowing( std::get<0>(g->mesh().components()),omega); - if (!in) TRIQS_RUNTIME_ERROR <<" Evaluation out of bounds"; - std::tie(in, n2, w2) = windowing( std::get<1>(g->mesh().components()),tau); - if (!in) TRIQS_RUNTIME_ERROR <<" Evaluation out of bounds"; - auto gg = on_mesh(*g); //[g]( size_t n1, size_t n2) {return g->on_mesh(n1,n2);}; - auto res = w1 *( w2*gg(n1,n2) + (1-w2)*gg(n1,n2+1)) + (1-w1) * ( w2*gg(n1+1,n2) + (1-w2)*gg(n1+1,n2+1)); - - //std::cout << "eval reref imtim"<< n1 << " "<< n2 << " "<< w1 << " " << w2 << " "<< omega << " "<< tau<< std::endl; - return ((std::get<1>(g->mesh().components()).domain().statistic == Fermion) && (p%2==1) ? -res : res); - } - }; + struct refreq_imtime {}; - // ------------------------------- Factories -------------------------------------------------- + // the mesh + template struct mesh :mesh_product,mesh> { + typedef mesh m1_t; + typedef mesh m2_t; + typedef mesh_product B; + mesh (double wmin, double wmax, size_t n_freq, double beta, statistic_enum S, size_t nt, mesh_kind mk=full_bins ) : + B {mesh(wmin,wmax,n_freq), mesh(beta,S,nt,mk)} {} + }; - template struct factories { - typedef gf gf_t; - - template - static gf_t make_gf(MeshType && m) { - typename gf_t::data_regular_t A(m.size()); - A() =0; - return gf_t (m, std::move(A), nothing(), nothing() ) ; - } - - static gf_t make_gf(double wmin, double wmax, size_t n_freq, double beta, statistic_enum S, size_t nt, mesh_kind mk=full_bins) { - auto m = make_gf_mesh(wmin, wmax, n_freq, beta,S, nt, mk); - typename gf_t::data_regular_t A(m.size()); - A() =0; - return gf_t (m, std::move(A), nothing(), nothing() ) ; - } - }; + namespace gfs_implementation { + // singularity + //template struct singularity { typedef gf type;}; - } // gfs_implementation + // h5 name + template struct h5_name { static std::string invoke(){ return "GfReFreqImTime";}}; - //slices + /// --------------------------- data access --------------------------------- + + template struct data_proxy : data_proxy_array,1> {}; + + /// --------------------------- evaluator --------------------------------- + + template + struct evaluator { + static constexpr int arity = 2; + template + std::complex operator() (G const * g, double omega, double tau) const { + double beta = std::get<1>(g->mesh().components()).domain().beta; + int p = std::floor(tau/beta); + tau -= p*beta; + size_t n1,n2; double w1,w2; bool in; + std::tie(in, n1, w1) = windowing( std::get<0>(g->mesh().components()),omega); + if (!in) TRIQS_RUNTIME_ERROR <<" Evaluation out of bounds"; + std::tie(in, n2, w2) = windowing( std::get<1>(g->mesh().components()),tau); + if (!in) TRIQS_RUNTIME_ERROR <<" Evaluation out of bounds"; + auto gg = on_mesh(*g); //[g]( size_t n1, size_t n2) {return g->on_mesh(n1,n2);}; + auto res = w1 *( w2*gg(n1,n2) + (1-w2)*gg(n1,n2+1)) + (1-w1) * ( w2*gg(n1+1,n2) + (1-w2)*gg(n1+1,n2+1)); + + //std::cout << "eval reref imtim"<< n1 << " "<< n2 << " "<< w1 << " " << w2 << " "<< omega << " "<< tau<< std::endl; + + return ((std::get<1>(g->mesh().components()).domain().statistic == Fermion) && (p%2==1) ? -res : res); + } + }; + + // ------------------------------- Factories -------------------------------------------------- + + template struct factories { + typedef gf gf_t; + + template + static gf_t make_gf(MeshType && m) { + typename gf_t::data_regular_t A(m.size()); + A() =0; + return gf_t (m, std::move(A), nothing(), nothing() ) ; + } + + static gf_t make_gf(double wmin, double wmax, size_t n_freq, double beta, statistic_enum S, size_t nt, mesh_kind mk=full_bins) { + auto m = mesh(wmin, wmax, n_freq, beta,S, nt, mk); + typename gf_t::data_regular_t A(m.size()); + A() =0; + return gf_t (m, std::move(A), nothing(), nothing() ) ; + } + }; + + } // gfs_implementation + + //slices inline gf_view slice_mesh_imtime (gf_view g, size_t index) { auto arr = reinterpret_linear_array(g.mesh(),g.data()); // view it as a 2d array return { std::get<0>(g.mesh().components()), arr(arrays::range(),index), local::tail(1,1), nothing() }; diff --git a/triqs/gfs/retime.hpp b/triqs/gfs/retime.hpp index e91b5354..bcb7b25a 100644 --- a/triqs/gfs/retime.hpp +++ b/triqs/gfs/retime.hpp @@ -30,22 +30,18 @@ namespace triqs { namespace gfs { struct retime {}; + template struct mesh : linear_mesh { + typedef linear_mesh B; + mesh() = default; + mesh(double tmin, double tmax, size_t n_points, mesh_kind mk=full_bins) : B (typename B::domain_t(), tmin, tmax, n_points, mk){} + }; + namespace gfs_implementation { - template struct mesh { - typedef linear_mesh type; - typedef typename type::domain_t domain_t; - - static type make(double tmin, double tmax, size_t n_points, mesh_kind mk=full_bins) { - return type(domain_t(), tmin, tmax, n_points, mk); - } - - }; - // singularity template struct singularity { typedef local::tail type;}; template struct singularity { typedef local::tail type;}; - + // h5 name template struct h5_name { static std::string invoke(){ return "ReTime";}}; @@ -56,7 +52,7 @@ namespace triqs { namespace gfs { //typedef typename std::conditional < std::is_same::value, arrays::matrix_view>, std::complex>::type rtype; typedef typename std::conditional < std::is_same::value, arrays::matrix>, std::complex>::type rtype; template - rtype operator() (G const * g,double t0) const { + rtype operator() (G const * g,double t0) const { size_t n; double w; bool in; std::tie(in, n, w) = windowing(g->mesh(),t0); if (!in) TRIQS_RUNTIME_ERROR <<" Evaluation out of bounds"; @@ -68,56 +64,56 @@ namespace triqs { namespace gfs { }; /// --------------------------- data access --------------------------------- - template struct data_proxy : data_proxy_array,3> {}; - template struct data_proxy : data_proxy_array,1> {}; + template struct data_proxy : data_proxy_array,3> {}; + template struct data_proxy : data_proxy_array,1> {}; // ------------------------------- Factories -------------------------------------------------- //matrix_valued template struct factories { typedef gf gf_t; - + template - static gf_t make_gf(MeshType && m, tqa::mini_vector shape, local::tail_view const t) { - typename gf_t::data_regular_t A(shape.front_append(m.size())); A() =0; - return gf_t ( std::forward(m), std::move(A), t, nothing() ) ; - } - + static gf_t make_gf(MeshType && m, tqa::mini_vector shape, local::tail_view const t) { + typename gf_t::data_regular_t A(shape.front_append(m.size())); A() =0; + return gf_t ( std::forward(m), std::move(A), t, nothing() ) ; + } + static gf_t make_gf(double tmin, double tmax, size_t n_points, tqa::mini_vector shape, mesh_kind mk) { typename gf_t::data_regular_t A(shape.front_append(n_points)); A() =0; - return gf_t(mesh::make(tmin, tmax, n_points,mk), std::move(A), local::tail(shape), nothing()); + return gf_t(mesh(tmin, tmax, n_points,mk), std::move(A), local::tail(shape), nothing()); } - + static gf_t make_gf(double tmin, double tmax, size_t n_points, tqa::mini_vector shape) { typename gf_t::data_regular_t A(shape.front_append(n_points)); A() =0; - return gf_t(mesh::make(tmin, tmax, n_points), std::move(A), local::tail(shape), nothing()); + return gf_t(mesh(tmin, tmax, n_points), std::move(A), local::tail(shape), nothing()); } - + }; - + //scalar_valued template struct factories { typedef gf gf_t; - + template - static gf_t make_gf(MeshType && m, local::tail_view const t) { - typename gf_t::data_regular_t A(m.size()); A() =0; - return gf_t ( std::forward(m), std::move(A), t, nothing() ) ; - } - + static gf_t make_gf(MeshType && m, local::tail_view const t) { + typename gf_t::data_regular_t A(m.size()); A() =0; + return gf_t ( std::forward(m), std::move(A), t, nothing() ) ; + } + static gf_t make_gf(double tmin, double tmax, size_t n_points, mesh_kind mk) { typename gf_t::data_regular_t A(n_points); A() =0; - return gf_t(mesh::make(tmin, tmax, n_points,mk), std::move(A), local::tail(tqa::mini_vector(1,1)), nothing()); + return gf_t(mesh(tmin, tmax, n_points,mk), std::move(A), local::tail(tqa::mini_vector(1,1)), nothing()); } - + static gf_t make_gf(double tmin, double tmax, size_t n_points) { typename gf_t::data_regular_t A(n_points); A() =0; - return gf_t(mesh::make(tmin, tmax, n_points), std::move(A), local::tail(tqa::mini_vector(1,1)), nothing()); + return gf_t(mesh(tmin, tmax, n_points), std::move(A), local::tail(tqa::mini_vector(1,1)), nothing()); } - + }; - - + + } // gfs_implementation }} #endif diff --git a/triqs/gfs/two_real_times.hpp b/triqs/gfs/two_real_times.hpp index 513bef2d..b74567d7 100644 --- a/triqs/gfs/two_real_times.hpp +++ b/triqs/gfs/two_real_times.hpp @@ -29,24 +29,17 @@ namespace triqs { namespace gfs { struct two_real_times {}; + // the mesh + template struct mesh :mesh_product ,mesh > { + typedef mesh_product ,mesh > B; + mesh() = default; + mesh (double tmax, double n_time_slices) : + B(mesh ( 0, tmax,n_time_slices, full_bins), + mesh ( 0, tmax,n_time_slices, full_bins) ) {} + }; + namespace gfs_implementation { - // the mesh - template struct mesh { - typedef typename mesh::type m1_t; - typedef mesh_product type; - static type make (double tmax, double n_time_slices) { -#ifndef TRIQS_WORKAROUND_INTEL_COMPILER_BUGS - m1_t m1({},0, tmax,n_time_slices, full_bins); - return {m1,m1}; -#else - m1_t m1(typename m1_t::domain_t(),0, tmax,n_time_slices, full_bins); - type m(m1,m1); - return m; -#endif - } - }; - // h5 name template struct h5_name { static std::string invoke(){ return "GfTwoRealTime";}}; @@ -54,23 +47,23 @@ namespace triqs { namespace gfs { template struct get_closest_point { - typedef typename mesh::type mesh_t; - -// // NOT FINISHED, NOT TESTED -// template -// static typename mesh_t::index_t invoke(G const * g, closest_pt_wrap const & p) { -// return std::floor( double(p.value) / g->mesh().delta() + 0.5); -// } + typedef typename mesh::type mesh_t; + + // // NOT FINISHED, NOT TESTED + // template + // static typename mesh_t::index_t invoke(G const * g, closest_pt_wrap const & p) { + // return std::floor( double(p.value) / g->mesh().delta() + 0.5); + // } }; /// --------------------------- evaluator --------------------------------- template - struct evaluator { + struct evaluator { static constexpr int arity = 2; template - arrays::matrix > operator() (G const * g, double t0, double t1) const { + arrays::matrix > operator() (G const * g, double t0, double t1) const { auto & data = g->data(); auto & m = std::get<0>(g->mesh().components()); size_t n0,n1; double w0,w1; bool in; @@ -80,8 +73,8 @@ namespace triqs { namespace gfs { if (!in) TRIQS_RUNTIME_ERROR <<" Evaluation out of bounds"; auto gg = [g,data]( size_t n0, size_t n1) {return data(g->mesh().index_to_linear(std::tuple{n0,n1}), arrays::ellipsis());}; return w0 * ( w1*gg(n0,n1) + (1-w1)*gg(n0,n1+1) ) + (1-w0) * ( w1*gg(n0+1,n1) + (1-w1)*gg(n0+1,n1+1)); - } - }; + } + }; /// --------------------------- data access --------------------------------- @@ -91,10 +84,10 @@ namespace triqs { namespace gfs { template struct factories { typedef gf gf_t; - typedef typename mesh::type mesh_t; + typedef mesh mesh_t; static gf_t make_gf(double tmax, double n_time_slices, tqa::mini_vector shape) { - auto m = mesh::make(tmax, n_time_slices); + auto m = mesh(tmax, n_time_slices); typename gf_t::data_regular_t A(shape.front_append(m.size())); A() =0; return gf_t (m, std::move(A), nothing(), nothing() ) ; } @@ -131,10 +124,10 @@ namespace triqs { namespace gfs { } // gfs_implementation - // ------------------------------- Additionnal free function for this gf -------------------------------------------------- - - // from g(t,t') and t, return g(t-t') for any t'>t - // + // ------------------------------- Additionnal free function for this gf -------------------------------------------------- + + // from g(t,t') and t, return g(t-t') for any t'>t + // gf slice (gf_view const & g, double t) { auto const & m = std::get<0> (g.mesh().components()); //one-time mesh long it = get_closest_mesh_pt_index(m, t); //index of t on this mesh