3
0
mirror of https://github.com/triqs/dft_tools synced 2024-12-25 05:43:40 +01:00

gf : mesh now the class, not a trait.

simplify : mesh was a impl trait,
make it the class itself.
corrected the gf, tests and the cython.
This commit is contained in:
Olivier Parcollet 2013-08-24 14:47:47 +02:00
parent 3d6c030b1f
commit 7898bd8d88
21 changed files with 348 additions and 372 deletions

View File

@ -5,8 +5,7 @@ cdef extern from "triqs/gfs/imfreq.hpp" namespace "triqs::gfs" :
statistic_enum statistic statistic_enum statistic
imfreq_domain () imfreq_domain ()
#cdef cppclass mesh_imfreq "triqs::gfs::linear_mesh<triqs::gfs::imfreq::domain_t>" : cdef cppclass mesh_imfreq "triqs::gfs::mesh<triqs::gfs::imfreq>" :
cdef cppclass mesh_imfreq "triqs::gfs::linear_mesh<triqs::gfs::matsubara_domain<true>>" :
mesh_imfreq () mesh_imfreq ()
mesh_imfreq (mesh_imfreq &) mesh_imfreq (mesh_imfreq &)
imfreq_domain & domain() imfreq_domain & domain()
@ -14,7 +13,7 @@ cdef extern from "triqs/gfs/imfreq.hpp" namespace "triqs::gfs" :
long size() long size()
bint operator ==( mesh_imfreq &) bint operator ==( mesh_imfreq &)
cdef mesh_imfreq make_mesh_imfreq "triqs::gfs::make_gf_mesh<triqs::gfs::imfreq>" (double beta, statistic_enum S, size_t n_max) cdef mesh_imfreq make_mesh_imfreq "triqs::gfs::mesh<triqs::gfs::imfreq>" (double beta, statistic_enum S, size_t n_max)
#cdef mesh_imfreq make_mesh_imfreq "triqs::gfs::gf_implementation::gf_factories<triqs::gfs::imfreq,triqs::gfs::matrix>::make_mesh" (double beta, statistic_enum S, size_t n_max) #cdef mesh_imfreq make_mesh_imfreq "triqs::gfs::gf_implementation::gf_factories<triqs::gfs::imfreq,triqs::gfs::matrix>::make_mesh" (double beta, statistic_enum S, size_t n_max)
cdef cppclass gf_imfreq "triqs::python_tools::cython_proxy<triqs::gfs::gf_view<triqs::gfs::imfreq> >" : cdef cppclass gf_imfreq "triqs::python_tools::cython_proxy<triqs::gfs::gf_view<triqs::gfs::imfreq> >" :

View File

@ -5,8 +5,7 @@ cdef extern from "triqs/gfs/imtime.hpp" namespace "triqs::gfs" :
statistic_enum statistic statistic_enum statistic
imtime_domain () imtime_domain ()
#cdef cppclass mesh_imtime "triqs::gfs::linear_mesh<triqs::gfs::imtime::domain_t>" : cdef cppclass mesh_imtime "triqs::gfs::mesh<triqs::gfs::imtime>" :
cdef cppclass mesh_imtime "triqs::gfs::linear_mesh<triqs::gfs::matsubara_domain<false>>" :
mesh_imtime () mesh_imtime ()
mesh_imtime (mesh_imtime &) mesh_imtime (mesh_imtime &)
imtime_domain & domain() imtime_domain & domain()
@ -15,7 +14,7 @@ cdef extern from "triqs/gfs/imtime.hpp" namespace "triqs::gfs" :
long kind() long kind()
bint operator ==( mesh_imtime &) bint operator ==( mesh_imtime &)
cdef mesh_imtime make_mesh_imtime "triqs::gfs::make_gf_mesh<triqs::gfs::imtime>" (double beta, statistic_enum S, size_t n_time_slices, mesh_enum mk) cdef mesh_imtime make_mesh_imtime "triqs::gfs::mesh<triqs::gfs::imtime>" (double beta, statistic_enum S, size_t n_time_slices, mesh_enum mk)
#cdef mesh_imtime make_mesh_imtime "triqs::gfs::gf_factories<triqs::gfs::imtime>::make_mesh" (double beta, statistic_enum S, size_t n_time_slices, mesh_enum mk) #cdef mesh_imtime make_mesh_imtime "triqs::gfs::gf_factories<triqs::gfs::imtime>::make_mesh" (double beta, statistic_enum S, size_t n_time_slices, mesh_enum mk)
cdef cppclass gf_imtime "triqs::python_tools::cython_proxy<triqs::gfs::gf_view<triqs::gfs::imtime>>" : cdef cppclass gf_imtime "triqs::python_tools::cython_proxy<triqs::gfs::gf_view<triqs::gfs::imtime>>" :

View File

@ -6,15 +6,14 @@ cdef extern from "triqs/gfs/legendre.hpp" namespace "triqs::gfs" :
statistic_enum statistic statistic_enum statistic
legendre_domain () legendre_domain ()
#cdef cppclass mesh_legendre "triqs::gfs::discrete_mesh<triqs::gfs::legendre::domain_t>": cdef cppclass mesh_legendre "triqs::gfs::mesh<triqs::gfs::legendre>" :
cdef cppclass mesh_legendre "triqs::gfs::discrete_mesh<triqs::gfs::legendre_domain>":
mesh_legendre () mesh_legendre ()
mesh_legendre (mesh_legendre &) mesh_legendre (mesh_legendre &)
legendre_domain & domain() legendre_domain & domain()
long size() long size()
bint operator == (mesh_legendre &) bint operator == (mesh_legendre &)
cdef mesh_legendre make_mesh_legendre "triqs::gfs::make_gf_mesh<triqs::gfs::legendre>" (double beta, statistic_enum S, size_t n_leg) cdef mesh_legendre make_mesh_legendre "triqs::gfs::mesh<triqs::gfs::legendre>" (double beta, statistic_enum S, size_t n_leg)
#cdef mesh_legendre make_mesh_legendre "triqs::gfs::gf_factories<triqs::gfs::legendre>::make_mesh" (double beta, statistic_enum S, size_t n_leg) #cdef mesh_legendre make_mesh_legendre "triqs::gfs::gf_factories<triqs::gfs::legendre>::make_mesh" (double beta, statistic_enum S, size_t n_leg)
cdef cppclass gf_legendre "triqs::python_tools::cython_proxy<triqs::gfs::gf_view<triqs::gfs::legendre>>" : cdef cppclass gf_legendre "triqs::python_tools::cython_proxy<triqs::gfs::gf_view<triqs::gfs::legendre>>" :

View File

@ -3,8 +3,7 @@ cdef extern from "triqs/gfs/refreq.hpp" namespace "triqs::gfs" :
cdef cppclass refreq_domain : cdef cppclass refreq_domain :
refreq_domain() refreq_domain()
#cdef cppclass mesh_refreq "triqs::gfs::linear_mesh<triqs::gfs::refreq::domain_t>" : cdef cppclass mesh_refreq "triqs::gfs::mesh<triqs::gfs::refreq>" :
cdef cppclass mesh_refreq "triqs::gfs::linear_mesh<triqs::gfs::R_domain>" :
mesh_refreq () mesh_refreq ()
mesh_refreq (mesh_refreq &) mesh_refreq (mesh_refreq &)
refreq_domain & domain() refreq_domain & domain()
@ -14,7 +13,7 @@ cdef extern from "triqs/gfs/refreq.hpp" namespace "triqs::gfs" :
double kind() double kind()
bint operator ==( mesh_refreq &) bint operator ==( mesh_refreq &)
cdef mesh_refreq make_mesh_refreq "triqs::gfs::make_gf_mesh<triqs::gfs::refreq>" (double omega_min, double omega_max, size_t n_freq, mesh_enum mk) cdef mesh_refreq make_mesh_refreq "triqs::gfs::mesh<triqs::gfs::refreq>" (double omega_min, double omega_max, size_t n_freq, mesh_enum mk)
#cdef mesh_refreq make_mesh_refreq "triqs::gfs::gf_factories<triqs::gfs::refreq>::make_mesh" (double omega_min, double omega_max, size_t n_freq, mesh_enum mk) #cdef mesh_refreq make_mesh_refreq "triqs::gfs::gf_factories<triqs::gfs::refreq>::make_mesh" (double omega_min, double omega_max, size_t n_freq, mesh_enum mk)
cdef cppclass gf_refreq "triqs::python_tools::cython_proxy<triqs::gfs::gf_view<triqs::gfs::refreq>>" : cdef cppclass gf_refreq "triqs::python_tools::cython_proxy<triqs::gfs::gf_view<triqs::gfs::refreq>>" :

View File

@ -3,8 +3,7 @@ cdef extern from "triqs/gfs/retime.hpp" namespace "triqs::gfs" :
cdef cppclass retime_domain : cdef cppclass retime_domain :
retime_domain() retime_domain()
#cdef cppclass mesh_retime "triqs::gfs::linear_mesh<triqs::gfs::retime::domain_t>" : cdef cppclass mesh_retime "triqs::gfs::mesh<triqs::gfs::retime>" :
cdef cppclass mesh_retime "triqs::gfs::linear_mesh<triqs::gfs::R_domain>" :
mesh_retime () mesh_retime ()
mesh_retime (mesh_retime &) mesh_retime (mesh_retime &)
retime_domain & domain() retime_domain & domain()
@ -14,7 +13,7 @@ cdef extern from "triqs/gfs/retime.hpp" namespace "triqs::gfs" :
double kind() double kind()
bint operator ==( mesh_retime &) bint operator ==( mesh_retime &)
cdef mesh_retime make_mesh_retime "triqs::gfs::make_gf_mesh<triqs::gfs::retime>" (double t_min, double t_max, size_t n_freq, mesh_enum mk) cdef mesh_retime make_mesh_retime "triqs::gfs::mesh<triqs::gfs::retime>" (double t_min, double t_max, size_t n_freq, mesh_enum mk)
#cdef mesh_retime make_mesh_retime "triqs::gfs::gf_factories<triqs::gfs::retime>::make_mesh" (double t_min, double t_max, size_t n_freq, mesh_enum mk) #cdef mesh_retime make_mesh_retime "triqs::gfs::gf_factories<triqs::gfs::retime>::make_mesh" (double t_min, double t_max, size_t n_freq, mesh_enum mk)
cdef cppclass gf_retime "triqs::python_tools::cython_proxy<triqs::gfs::gf_view<triqs::gfs::retime>>" : cdef cppclass gf_retime "triqs::python_tools::cython_proxy<triqs::gfs::gf_view<triqs::gfs::retime>>" :

View File

@ -3,8 +3,7 @@ cdef extern from "triqs/gfs/two_real_times.hpp" namespace "triqs::gfs" :
cdef cppclass two_real_times_domain : cdef cppclass two_real_times_domain :
two_real_times_domain() two_real_times_domain()
#cdef cppclass mesh_retime "triqs::gfs::linear_mesh<triqs::gfs::retime::domain_t>" : cdef cppclass mesh_two_real_times "triqs::gfs::mesh<triqs::gfs::two_real_times>" :
cdef cppclass mesh_two_real_times "triqs::gfs::mesh_product<triqs::gfs::linear_mesh<triqs::gfs::R_domain>,triqs::gfs::linear_mesh<triqs::gfs::R_domain>>" :
mesh_two_real_times () mesh_two_real_times ()
mesh_two_real_times (mesh_two_real_times &) mesh_two_real_times (mesh_two_real_times &)
two_real_times_domain & domain() two_real_times_domain & domain()
@ -14,7 +13,7 @@ cdef extern from "triqs/gfs/two_real_times.hpp" namespace "triqs::gfs" :
double kind() double kind()
bint operator ==( mesh_two_real_times &) bint operator ==( mesh_two_real_times &)
cdef mesh_two_real_times make_mesh_two_real_times "triqs::gfs::make_gf_mesh<triqs::gfs::two_real_times>" (double t_max, double n_time_slices) cdef mesh_two_real_times make_mesh_two_real_times "triqs::gfs::mesh<triqs::gfs::two_real_times>" (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 &) cdef mesh_retime & get_1d_mesh_from_2times_mesh "triqs::gfs::get_1d_mesh_from_2times_mesh" (mesh_two_real_times &)

View File

@ -34,11 +34,11 @@ try {
auto G_w_tau= make_gf<refreq_imtime, scalar_valued>(wmin, wmax, n_re_freq, beta, Fermion, n_im_time); auto G_w_tau= make_gf<refreq_imtime, scalar_valued>(wmin, wmax, n_re_freq, beta, Fermion, n_im_time);
auto G_w= make_gf<refreq, scalar_valued>(wmin, wmax, n_re_freq); auto G_w= make_gf<refreq, scalar_valued>(wmin, wmax, n_re_freq);
auto G_t_tau= make_gf<cartesian_product<retime,imtime>, scalar_valued>( make_gf_mesh<retime>(tmin, tmax, n_re_time), make_gf_mesh<imtime>(beta, Fermion, n_im_time)); auto G_t_tau= make_gf<cartesian_product<retime,imtime>, scalar_valued>(mesh<retime>(tmin, tmax, n_re_time), mesh<imtime>(beta, Fermion, n_im_time));
//auto G_t_tau_N= make_gf<cartesian_product<retime,imtime>, scalar_valued>( {tmin, tmax, n_re_time}, {beta, Fermion, n_im_time}); //auto G_t_tau_N= make_gf<cartesian_product<retime,imtime>, scalar_valued>( {tmin, tmax, n_re_time}, {beta, Fermion, n_im_time});
auto G_w_wn2 = make_gf<cartesian_product<refreq,imfreq>, scalar_valued>( make_gf_mesh<refreq>(wmin, wmax, n_re_freq), make_gf_mesh<imfreq>(beta, Fermion, n_im_freq)); auto G_w_wn2 = make_gf<cartesian_product<refreq,imfreq>, scalar_valued>( mesh<refreq>(wmin, wmax, n_re_freq), mesh<imfreq>(beta, Fermion, n_im_freq));
auto G_w_tau2 = make_gf<cartesian_product<refreq,imtime>, scalar_valued>( make_gf_mesh<refreq>(wmin, wmax, n_re_freq), make_gf_mesh<imtime>(beta, Fermion, n_im_time,full_bins)); auto G_w_tau2 = make_gf<cartesian_product<refreq,imtime>, scalar_valued>( mesh<refreq>(wmin, wmax, n_re_freq), mesh<imtime>(beta, Fermion, n_im_time,full_bins));
//auto g_tau = slice_mesh1(G_w_tau(),1); //auto g_tau = slice_mesh1(G_w_tau(),1);

View File

@ -29,9 +29,13 @@ namespace triqs { namespace gfs {
struct block_index {}; struct block_index {};
template<typename Opt> struct mesh<block_index,Opt> : discrete_mesh<discrete_domain> {
mesh() = default;
mesh(size_t s) : discrete_mesh<discrete_domain>(s) {}
};
namespace gfs_implementation { namespace gfs_implementation {
template<typename Opt> struct mesh<block_index,Opt> { typedef discrete_mesh<discrete_domain> type;};
template<typename Target, typename Opt> struct h5_name<block_index,Target,Opt> { static std::string invoke(){ return "BlockGf";}}; template<typename Target, typename Opt> struct h5_name<block_index,Target,Opt> { static std::string invoke(){ return "BlockGf";}};
/// --------------------------- h5_rw --------------------------------- /// --------------------------- h5_rw ---------------------------------
@ -62,7 +66,7 @@ namespace triqs { namespace gfs {
template<typename Target, typename Opt> template<typename Target, typename Opt>
struct factories<block_index,Target,Opt> { struct factories<block_index,Target,Opt> {
typedef typename mesh<block_index, Opt>::type mesh_t; typedef mesh<block_index, Opt> mesh_t;
typedef gf<block_index,Target> gf_t; typedef gf<block_index,Target> gf_t;
typedef gf_view<block_index,Target> gf_view_t; typedef gf_view<block_index,Target> gf_view_t;
@ -76,11 +80,11 @@ namespace triqs { namespace gfs {
return gf_t(mesh_t(block_names), std::move(V), nothing(), nothing() ); return gf_t(mesh_t(block_names), std::move(V), nothing(), nothing() );
} }
/* static gf_t make_gf(std::initializer_list<Target> const & l) { /* static gf_t make_gf(std::initializer_list<Target> const & l) {
auto v = std::vector<Target> {l}; auto v = std::vector<Target> {l};
return make_gf(v); return make_gf(v);
} }
*/ */
/* template<typename... Args> /* template<typename... Args>
static gf_t make_gf(size_t N, Args&& ...args) { static gf_t make_gf(size_t N, Args&& ...args) {
std::vector<Target> V; V.reserve(N); std::vector<Target> V; V.reserve(N);
@ -133,7 +137,7 @@ namespace triqs { namespace gfs {
// also experimental // also experimental
// an iterator over the block // an iterator over the block
template<typename Target, typename Opt> template<typename Target, typename Opt>
class block_gf_iterator : class block_gf_iterator :
public boost::iterator_facade< block_gf_iterator<Target,Opt>, typename Target::view_type , boost::forward_traversal_tag, typename Target::view_type > { public boost::iterator_facade< block_gf_iterator<Target,Opt>, typename Target::view_type , boost::forward_traversal_tag, typename Target::view_type > {
friend class boost::iterator_core_access; friend class boost::iterator_core_access;
@ -150,10 +154,10 @@ namespace triqs { namespace gfs {
bool at_end() const { return mesh_it.at_end();} bool at_end() const { return mesh_it.at_end();}
}; };
template<typename Target, typename Opt, bool B> template<typename Target, typename Opt, bool B>
block_gf_iterator<Target,Opt> begin(gf_impl<block_index,Target,Opt,B> const & bgf) { return {bgf,false};} block_gf_iterator<Target,Opt> begin(gf_impl<block_index,Target,Opt,B> const & bgf) { return {bgf,false};}
template<typename Target, typename Opt, bool B> template<typename Target, typename Opt, bool B>
block_gf_iterator<Target,Opt> end(gf_impl<block_index,Target,Opt,B> const & bgf) { return {bgf,true};} block_gf_iterator<Target,Opt> end(gf_impl<block_index,Target,Opt,B> const & bgf) { return {bgf,true};}

View File

@ -119,7 +119,7 @@ namespace triqs { namespace gfs {
Opt> Opt>
curry (gf_impl<cartesian_product<Ms...>, Target,Opt,B> const & g) { curry (gf_impl<cartesian_product<Ms...>, Target,Opt,B> const & g) {
auto comp = pv_<cartesian_product<Ms...>,pos...>::m(std::make_tuple(),g.mesh().components()); auto comp = pv_<cartesian_product<Ms...>,pos...>::m(std::make_tuple(),g.mesh().components());
typedef typename mesh< typename pv_<cartesian_product<Ms...>,pos...>::type,Opt>::type m_t; typedef mesh< typename pv_<cartesian_product<Ms...>,pos...>::type,Opt> m_t;
return {triqs::tuple::apply_construct<m_t>(comp),curry_polymorphic_lambda<gf_view<cartesian_product<Ms...>, Target,Opt>, pos ...>{g}, nothing(), nothing()}; return {triqs::tuple::apply_construct<m_t>(comp),curry_polymorphic_lambda<gf_view<cartesian_product<Ms...>, Target,Opt>, pos ...>{g}, nothing(), nothing()};
}; };

View File

@ -34,13 +34,12 @@ namespace triqs { namespace gfs {
using arrays::make_shape; using arrays::make_shape;
// GENERALISE matrxi TO DEFAULT // GENERALISE matrxi TO DEFAULT
template<typename Variable, typename Opt=void> struct mesh;
template<typename Variable, typename Target=matrix_valued, typename Opt=void> class gf; // the value class template<typename Variable, typename Target=matrix_valued, typename Opt=void> class gf; // the value class
template<typename Variable, typename Target=matrix_valued, typename Opt=void> class gf_view; // the view class template<typename Variable, typename Target=matrix_valued, typename Opt=void> class gf_view; // the view class
// various implementation traits // various implementation traits
namespace gfs_implementation { // never use using of this... namespace gfs_implementation { // never use using of this...
// what is the mesh
template<typename Variable, typename Opt> struct mesh;
// evaluator regroup functions to evaluate the function. Cf descriptors // evaluator regroup functions to evaluate the function. Cf descriptors
template<typename Variable, typename Target, typename Opt> struct evaluator{ static constexpr int arity = 0;}; template<typename Variable, typename Target, typename Opt> struct evaluator{ static constexpr int arity = 0;};
@ -80,9 +79,6 @@ namespace triqs { namespace gfs {
template <typename Variable, typename Target=matrix_valued, typename Opt=void, typename ... U> template <typename Variable, typename Target=matrix_valued, typename Opt=void, typename ... U>
gf_view<Variable,Target,Opt> make_gf_view(U && ... x) { return gfs_implementation::factories<Variable,Target,Opt>::make_gf_view(std::forward<U>(x)...);} gf_view<Variable,Target,Opt> make_gf_view(U && ... x) { return gfs_implementation::factories<Variable,Target,Opt>::make_gf_view(std::forward<U>(x)...);}
template <typename Variable, typename Opt=void, typename ... U>
typename gfs_implementation::mesh<Variable,Opt>::type make_gf_mesh(U && ... x) { return gfs_implementation::mesh<Variable,Opt>::make(std::forward<U>(x)...);}
template<typename Variable, typename Target, typename Opt> struct gf_desc{}; template<typename Variable, typename Target, typename Opt> struct gf_desc{};
template<typename Descriptor> struct gf_tag{}; template<typename Descriptor> struct gf_tag{};
@ -105,7 +101,7 @@ namespace triqs { namespace gfs {
typedef Variable variable_t; typedef Variable variable_t;
typedef Opt option_t; typedef Opt option_t;
typedef typename gfs_implementation::mesh<Variable,Opt>::type mesh_t; typedef mesh<Variable,Opt> mesh_t;
typedef typename mesh_t::domain_t domain_t; typedef typename mesh_t::domain_t domain_t;
typedef typename mesh_t::mesh_point_t mesh_point_t; typedef typename mesh_t::mesh_point_t mesh_point_t;
typedef typename mesh_t::index_t mesh_index_t; typedef typename mesh_t::index_t mesh_index_t;

View File

@ -29,19 +29,16 @@ namespace triqs { namespace gfs {
struct imfreq {}; struct imfreq {};
template<typename Opt> struct mesh<imfreq,Opt> : linear_mesh<matsubara_domain<true>> {
typedef linear_mesh<matsubara_domain<true>> 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 { namespace gfs_implementation {
// mesh type and its factories
template<typename Opt> struct mesh<imfreq,Opt> {
typedef linear_mesh<matsubara_domain<true>> 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 //singularity
template<typename Opt> struct singularity<imfreq,matrix_valued,Opt> { typedef local::tail type;}; template<typename Opt> struct singularity<imfreq,matrix_valued,Opt> { typedef local::tail type;};
template<typename Opt> struct singularity<imfreq,scalar_valued,Opt> { typedef local::tail type;}; template<typename Opt> struct singularity<imfreq,scalar_valued,Opt> { typedef local::tail type;};
@ -71,22 +68,22 @@ namespace triqs { namespace gfs {
// matrix_valued // matrix_valued
template<typename Opt> struct factories<imfreq,matrix_valued,Opt> { template<typename Opt> struct factories<imfreq,matrix_valued,Opt> {
typedef gf<imfreq,matrix_valued,Opt> gf_t; typedef gf<imfreq,matrix_valued,Opt> gf_t;
template<typename MeshType> template<typename MeshType>
static gf_t make_gf(MeshType && m, tqa::mini_vector<size_t,2> shape, local::tail_view const & t) { static gf_t make_gf(MeshType && m, tqa::mini_vector<size_t,2> shape, local::tail_view const & t) {
typename gf_t::data_regular_t A(shape.front_append(m.size())); A() =0; typename gf_t::data_regular_t A(shape.front_append(m.size())); A() =0;
return gf_t ( std::forward<MeshType>(m), std::move(A), t, nothing() ) ; return gf_t ( std::forward<MeshType>(m), std::move(A), t, nothing() ) ;
}
static gf_t make_gf(double beta, statistic_enum S, tqa::mini_vector<size_t,2> shape) {
return make_gf(mesh<imfreq,Opt>::make(beta,S), shape, local::tail(shape));
}
static gf_t make_gf(double beta, statistic_enum S, tqa::mini_vector<size_t,2> shape, size_t Nmax) {
return make_gf(mesh<imfreq,Opt>::make(beta,S,Nmax), shape, local::tail(shape));
}
static gf_t make_gf(double beta, statistic_enum S, tqa::mini_vector<size_t,2> shape, size_t Nmax, local::tail_view const & t) {
return make_gf(mesh<imfreq,Opt>::make(beta,S,Nmax), shape, t);
} }
static gf_t make_gf(double beta, statistic_enum S, tqa::mini_vector<size_t,2> shape) {
return make_gf(mesh<imfreq,Opt>(beta,S), shape, local::tail(shape));
}
static gf_t make_gf(double beta, statistic_enum S, tqa::mini_vector<size_t,2> shape, size_t Nmax) {
return make_gf(mesh<imfreq,Opt>(beta,S,Nmax), shape, local::tail(shape));
}
static gf_t make_gf(double beta, statistic_enum S, tqa::mini_vector<size_t,2> shape, size_t Nmax, local::tail_view const & t) {
return make_gf(mesh<imfreq,Opt>(beta,S,Nmax), shape, t);
}
}; };
// scalar_valued // scalar_valued
@ -94,18 +91,18 @@ namespace triqs { namespace gfs {
typedef gf<imfreq,scalar_valued,Opt> gf_t; typedef gf<imfreq,scalar_valued,Opt> gf_t;
template<typename MeshType> template<typename MeshType>
static gf_t make_gf(MeshType && m, local::tail_view const & t) { static gf_t make_gf(MeshType && m, local::tail_view const & t) {
typename gf_t::data_regular_t A(m.size()); A() =0; typename gf_t::data_regular_t A(m.size()); A() =0;
return gf_t ( std::forward<MeshType>(m), std::move(A), t, nothing() ) ; return gf_t ( std::forward<MeshType>(m), std::move(A), t, nothing() ) ;
} }
static gf_t make_gf(double beta, statistic_enum S) { static gf_t make_gf(double beta, statistic_enum S) {
return make_gf(mesh<imfreq,Opt>::make(beta,S), local::tail(tqa::mini_vector<size_t,2> (1,1))); return make_gf(mesh<imfreq,Opt>(beta,S), local::tail(tqa::mini_vector<size_t,2> (1,1)));
} }
static gf_t make_gf(double beta, statistic_enum S, size_t Nmax) { static gf_t make_gf(double beta, statistic_enum S, size_t Nmax) {
return make_gf(mesh<imfreq,Opt>::make(beta,S,Nmax), local::tail(tqa::mini_vector<size_t,2> (1,1))); return make_gf(mesh<imfreq,Opt>(beta,S,Nmax), local::tail(tqa::mini_vector<size_t,2> (1,1)));
} }
static gf_t make_gf(double beta, statistic_enum S, size_t Nmax, local::tail_view const & t) { static gf_t make_gf(double beta, statistic_enum S, size_t Nmax, local::tail_view const & t) {
return make_gf(mesh<imfreq,Opt>::make(beta,S,Nmax), t); return make_gf(mesh<imfreq,Opt>(beta,S,Nmax), t);
} }
}; };
} // gfs_implementation } // gfs_implementation

View File

@ -30,16 +30,15 @@ namespace triqs { namespace gfs {
struct imtime {}; struct imtime {};
namespace gfs_implementation { // mesh type and its factories
template<typename Opt> struct mesh<imtime,Opt> : linear_mesh<matsubara_domain<false>> {
typedef linear_mesh<matsubara_domain<false>> 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){}
};
// mesh type and its factories namespace gfs_implementation {
template<typename Opt> struct mesh<imtime,Opt> {
typedef linear_mesh<matsubara_domain<false>> 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 // singularity
template<typename Opt> struct singularity<imtime,matrix_valued,Opt> { typedef local::tail type;}; template<typename Opt> struct singularity<imtime,matrix_valued,Opt> { typedef local::tail type;};
@ -53,7 +52,7 @@ namespace triqs { namespace gfs {
template<typename Opt> struct data_proxy<imtime,matrix_valued,Opt> : data_proxy_array<double,3> {}; template<typename Opt> struct data_proxy<imtime,matrix_valued,Opt> : data_proxy_array<double,3> {};
template<typename Opt> struct data_proxy<imtime,scalar_valued,Opt> : data_proxy_array<double,1> {}; template<typename Opt> struct data_proxy<imtime,scalar_valued,Opt> : data_proxy_array<double,1> {};
/// --------------------------- closest mesh point on the grid --------------------------------- /// --------------------------- closest mesh point on the grid ---------------------------------
template<typename Opt, typename Target> template<typename Opt, typename Target>
struct get_closest_point <imtime,Target,Opt> { struct get_closest_point <imtime,Target,Opt> {
@ -123,7 +122,7 @@ namespace triqs { namespace gfs {
typename G::singularity_t const & operator()(G const * g,freq_infty const &) const {return g->singularity();} typename G::singularity_t const & operator()(G const * g,freq_infty const &) const {return g->singularity();}
}; };
// ------------------------------- Factories -------------------------------------------------- // ------------------------------- Factories --------------------------------------------------
// matrix_valued // matrix_valued
template<typename Opt> struct factories<imtime,matrix_valued,Opt> { template<typename Opt> struct factories<imtime,matrix_valued,Opt> {
@ -135,10 +134,10 @@ namespace triqs { namespace gfs {
return gf_t (std::forward<MeshType>(m), std::move(A), t, nothing(), evaluator<imtime,matrix_valued,Opt>(shape[0],shape[1]) ) ; return gf_t (std::forward<MeshType>(m), std::move(A), t, nothing(), evaluator<imtime,matrix_valued,Opt>(shape[0],shape[1]) ) ;
} }
static gf_t make_gf(double beta, statistic_enum S, tqa::mini_vector<size_t,2> shape, size_t Nmax=1025, mesh_kind mk= half_bins) { static gf_t make_gf(double beta, statistic_enum S, tqa::mini_vector<size_t,2> shape, size_t Nmax=1025, mesh_kind mk= half_bins) {
return make_gf(mesh<imtime,Opt>::make(beta,S,Nmax,mk), shape, local::tail(shape)); return make_gf(mesh<imtime,Opt>(beta,S,Nmax,mk), shape, local::tail(shape));
} }
static gf_t make_gf(double beta, statistic_enum S, tqa::mini_vector<size_t,2> shape, size_t Nmax, mesh_kind mk, local::tail_view const & t) { static gf_t make_gf(double beta, statistic_enum S, tqa::mini_vector<size_t,2> shape, size_t Nmax, mesh_kind mk, local::tail_view const & t) {
return make_gf(mesh<imtime,Opt>::make(beta,S,Nmax,mk), shape, t); return make_gf(mesh<imtime,Opt>(beta,S,Nmax,mk), shape, t);
} }
}; };
@ -151,10 +150,10 @@ namespace triqs { namespace gfs {
return gf_t (std::forward<MeshType>(m), std::move(A), t, nothing()); return gf_t (std::forward<MeshType>(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) { static gf_t make_gf(double beta, statistic_enum S, size_t Nmax=1025, mesh_kind mk= half_bins) {
return make_gf(mesh<imtime,Opt>::make(beta,S,Nmax,mk), local::tail(tqa::mini_vector<size_t,2> (1,1))); return make_gf(mesh<imtime,Opt>(beta,S,Nmax,mk), local::tail(tqa::mini_vector<size_t,2> (1,1)));
} }
static gf_t make_gf(double beta, statistic_enum S, size_t Nmax, mesh_kind mk, local::tail_view const & t) { 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<imtime,Opt>::make(beta,S,Nmax,mk), t); return make_gf(mesh<imtime,Opt>(beta,S,Nmax,mk), t);
} }
}; };
} // gfs_implementation. } // gfs_implementation.

View File

@ -30,14 +30,14 @@ namespace triqs { namespace gfs {
struct legendre {}; struct legendre {};
namespace gfs_implementation { // mesh type and its factories
template<typename Opt> struct mesh<legendre,Opt> :discrete_mesh<legendre_domain> {
typedef discrete_mesh<legendre_domain> B;
mesh() = default;
mesh(double beta, statistic_enum S, size_t n_leg) : B(typename B::domain_t(beta,S,n_leg)) {}
};
// mesh type and its factories namespace gfs_implementation {
template<typename Opt> struct mesh<legendre,Opt> {
typedef discrete_mesh<legendre_domain> 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 // h5 name
template<typename Opt> struct h5_name<legendre,matrix_valued,Opt> { static std::string invoke(){ return "Legendre";}}; template<typename Opt> struct h5_name<legendre,matrix_valued,Opt> { 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<size_t,2> shape, size_t n_leg) { static gf_t make_gf(double beta, statistic_enum S, tqa::mini_vector<size_t,2> shape, size_t n_leg) {
typename gf_t::data_regular_t A(shape.front_append(n_leg)); A() = 0; typename gf_t::data_regular_t A(shape.front_append(n_leg)); A() = 0;
return gf_t(mesh<legendre,Opt>::make(beta, S, n_leg), std::move(A), nothing(), nothing()); return gf_t(mesh<legendre,Opt>(beta, S, n_leg), std::move(A), nothing(), nothing());
} }
}; };

View File

@ -116,6 +116,7 @@ namespace triqs { namespace gfs {
/// Mesh comparison /// 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 ((_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 /// Write into HDF5
friend void h5_write (h5::group fg, std::string subgroup_name, linear_mesh const & m) { friend void h5_write (h5::group fg, std::string subgroup_name, linear_mesh const & m) {

View File

@ -31,13 +31,14 @@ namespace triqs { namespace gfs {
static constexpr size_t size = sizeof...(Ms); static constexpr size_t size = sizeof...(Ms);
}; };
// the mesh is simply a cartesian product
template<typename Opt, typename ... Ms> struct mesh<cartesian_product<Ms...>,Opt> : mesh_product< mesh<Ms,Opt> ... > {
typedef mesh_product< mesh<Ms,Opt> ... > B;
typedef std::tuple<Ms...> mesh_name_t;
mesh (mesh<Ms,Opt> ... ms) : B {std::move(ms)...} {}
};
namespace gfs_implementation { namespace gfs_implementation {
// the mesh is simply a cartesian product
template<typename Opt, typename ... Ms> struct mesh<cartesian_product<Ms...>,Opt> {
typedef mesh_product< typename mesh<Ms,Opt>::type ... > type;
typedef std::tuple<Ms...> mesh_name_t;
static type make (typename mesh<Ms,Opt>::type ... ms) { return type{std::move(ms)...};}
};
// h5 name : name1_x_name2_..... // h5 name : name1_x_name2_.....
template<typename Opt, typename ... Ms> struct h5_name<cartesian_product<Ms...>,matrix_valued,Opt> { template<typename Opt, typename ... Ms> struct h5_name<cartesian_product<Ms...>,matrix_valued,Opt> {
@ -159,7 +160,7 @@ namespace triqs { namespace gfs {
template<typename ... Meshes> template<typename ... Meshes>
static gf_t make_gf(Meshes && ... meshes) { static gf_t make_gf(Meshes && ... meshes) {
auto m = make_gf_mesh<cartesian_product<Ms...>,Opt>(meshes...); auto m = mesh<cartesian_product<Ms...>,Opt>(meshes...);
typename gf_t::data_regular_t A(m.size()); typename gf_t::data_regular_t A(m.size());
A() =0; A() =0;
return gf_t (m, std::move(A), nothing(), nothing()); return gf_t (m, std::move(A), nothing(), nothing());

View File

@ -30,60 +30,59 @@ namespace triqs { namespace gfs {
struct re_im_freq {}; struct re_im_freq {};
// the mesh
template<typename Opt> struct mesh<re_im_freq,Opt> : mesh_product<mesh<refreq,Opt>,mesh<imfreq,Opt>> {
typedef mesh<refreq,Opt> m1_t;
typedef mesh<imfreq,Opt> m2_t;
typedef mesh_product<m1_t,m2_t> B;
mesh (double wmin, double wmax, size_t n_freq_re, double beta, statistic_enum S, size_t n_freq_im) :
B { mesh<refreq,Opt>(wmin,wmax,n_freq_re,full_bins), mesh<imfreq,Opt>(beta, S, n_freq_im)} {}
};
namespace gfs_implementation { namespace gfs_implementation {
// the mesh // singularity
template<typename Opt> struct mesh<re_im_freq,Opt> { template<typename Opt> struct singularity<re_im_freq,scalar_valued,Opt> { typedef gf<refreq,scalar_valued> type;};
typedef typename mesh<refreq,Opt>::type m1_t;
typedef typename mesh<imfreq,Opt>::type m2_t;
typedef mesh_product<m1_t,m2_t> 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<refreq,Opt>(wmin,wmax,n_freq_re,full_bins), make_gf_mesh<imfreq,Opt>(beta, S, n_freq_im)};
}
};
// singularity // h5 name
template<typename Opt> struct singularity<re_im_freq,scalar_valued,Opt> { typedef gf<refreq,scalar_valued> type;}; template<typename Opt> struct h5_name<re_im_freq,scalar_valued,Opt> { static std::string invoke(){ return "GfReImFreq";}};
// h5 name /// --------------------------- data access ---------------------------------
template<typename Opt> struct h5_name<re_im_freq,scalar_valued,Opt> { static std::string invoke(){ return "GfReImFreq";}};
/// --------------------------- data access --------------------------------- template<typename Opt> struct data_proxy<re_im_freq,scalar_valued,Opt> : data_proxy_array<std::complex<double>,1> {};
template<typename Opt> struct data_proxy<re_im_freq,scalar_valued,Opt> : data_proxy_array<std::complex<double>,1> {}; /// --------------------------- evaluator ---------------------------------
/// --------------------------- evaluator --------------------------------- template<typename Opt>
template<typename Opt>
struct evaluator<re_im_freq,scalar_valued,Opt> { struct evaluator<re_im_freq,scalar_valued,Opt> {
static constexpr int arity = 2; static constexpr int arity = 2;
template<typename G> template<typename G>
std::complex<double> operator() (G const * g, double w, long n) const { std::complex<double> operator() (G const * g, double w, long n) const {
auto & data = g->data(); auto & data = g->data();
auto & mesh = g->mesh(); auto & mesh = g->mesh();
size_t nr; double wr; bool in; size_t nr; double wr; bool in;
std::tie(in, nr, wr) = windowing( std::get<0>(g->mesh().components()), w); std::tie(in, nr, wr) = windowing( std::get<0>(g->mesh().components()), w);
if (!in) TRIQS_RUNTIME_ERROR <<" Evaluation out of bounds"; 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<size_t,size_t>{nr,n}));}; auto gg = [g,data,mesh]( size_t nr, size_t n) {return data(mesh.index_to_linear(std::tuple<size_t,size_t>{nr,n}));};
return wr * gg(nr,n) + (1-wr) * gg(nr+1,n) ; return wr * gg(nr,n) + (1-wr) * gg(nr+1,n) ;
} }
}; };
// ------------------------------- Factories -------------------------------------------------- // ------------------------------- Factories --------------------------------------------------
template<typename Opt> struct factories<re_im_freq, scalar_valued,Opt> { template<typename Opt> struct factories<re_im_freq, scalar_valued,Opt> {
typedef gf<re_im_freq, scalar_valued,Opt> gf_t; typedef gf<re_im_freq, scalar_valued,Opt> gf_t;
// typedef typename mesh<re_im_freq, Opt>::type mesh_t; // typedef typename mesh<re_im_freq, Opt>::type mesh_t;
static gf_t make_gf(double wmin, double wmax, size_t nw, double beta, statistic_enum S, size_t nwn) { 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<re_im_freq,Opt>(wmin, wmax, nw, beta, S, nwn); auto m = mesh<re_im_freq,Opt>(wmin, wmax, nw, beta, S, nwn);
typename gf_t::data_regular_t A(m.size()); typename gf_t::data_regular_t A(m.size());
A() =0; A() =0;
return gf_t (m, std::move(A), gfs::make_gf<refreq,scalar_valued>(wmin, wmax, nw), nothing() ) ; return gf_t (m, std::move(A), gfs::make_gf<refreq,scalar_valued>(wmin, wmax, nw), nothing() ) ;
} }
}; };
} // gfs_implementation } // gfs_implementation
}} }}
#endif #endif

View File

@ -30,17 +30,16 @@ namespace triqs { namespace gfs {
struct re_im_time {}; struct re_im_time {};
namespace gfs_implementation { // the mesh
template<typename Opt> struct mesh<re_im_time,Opt> : mesh_product<mesh<retime,Opt>,mesh<imtime,Opt>> {
typedef mesh<retime,Opt> m1_t;
typedef mesh<imtime,Opt> m2_t;
typedef mesh_product<m1_t,m2_t> B;
mesh (double tmin, double tmax, size_t nt, double beta, statistic_enum S, size_t ntau, mesh_kind mk=full_bins) :
B {mesh<retime,Opt>(tmin,tmax,nt), mesh<imtime,Opt>(beta,S, ntau, mk)} {}
};
// the mesh namespace gfs_implementation {
template<typename Opt> struct mesh<re_im_time,Opt> {
typedef typename mesh<retime,Opt>::type m1_t;
typedef typename mesh<imtime,Opt>::type m2_t;
typedef mesh_product<m1_t,m2_t> 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<retime,Opt>(tmin,tmax,nt), make_gf_mesh<imtime,Opt>(beta,S, ntau, mk)};
}
};
// singularity // singularity
//template<typename Opt> struct singularity<re_im_time, scalar_valued, Opt> { typedef gf<retime,scalar_valued> type;}; //template<typename Opt> struct singularity<re_im_time, scalar_valued, Opt> { typedef gf<retime,scalar_valued> type;};
@ -80,14 +79,14 @@ namespace triqs { namespace gfs {
typedef gf<re_im_time, scalar_valued,Opt> gf_t; typedef gf<re_im_time, scalar_valued,Opt> gf_t;
template<typename MeshType> template<typename MeshType>
static gf_t make_gf(MeshType && m) { static gf_t make_gf(MeshType && m) {
typename gf_t::data_regular_t A(m.size()); typename gf_t::data_regular_t A(m.size());
A() =0; A() =0;
return gf_t (m, std::move(A), nothing(), nothing() ) ; 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) { 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<re_im_time,Opt>(tmin,tmax, nt, beta, S, ntau, mk); auto m = mesh<re_im_time,Opt>(tmin,tmax, nt, beta, S, ntau, mk);
typename gf_t::data_regular_t A(m.size()); typename gf_t::data_regular_t A(m.size());
A() =0; A() =0;
return gf_t (m, std::move(A), nothing(), nothing()); return gf_t (m, std::move(A), nothing(), nothing());

View File

@ -30,15 +30,14 @@ namespace triqs { namespace gfs {
struct refreq {}; struct refreq {};
namespace gfs_implementation { template<typename Opt> struct mesh<refreq,Opt> : linear_mesh<R_domain> {
typedef linear_mesh<R_domain> 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){}
};
template<typename Opt> struct mesh<refreq,Opt> { namespace gfs_implementation {
typedef linear_mesh<R_domain> 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 // singularity
template<typename Opt> struct singularity<refreq,matrix_valued,Opt> { typedef local::tail type;}; template<typename Opt> struct singularity<refreq,matrix_valued,Opt> { typedef local::tail type;};
@ -54,67 +53,67 @@ namespace triqs { namespace gfs {
typedef typename std::conditional < std::is_same<Target, matrix_valued>::value, arrays::matrix<std::complex<double> >, std::complex<double>>::type rtype; typedef typename std::conditional < std::is_same<Target, matrix_valued>::value, arrays::matrix<std::complex<double> >, std::complex<double>>::type rtype;
template<typename G> template<typename G>
rtype operator() (G const * g,double w0) const { 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; size_t n; double w; bool in;
std::tie(in, n, w) = windowing(g->mesh(),w0); std::tie(in, n, w) = windowing(g->mesh(),w0);
if (!in) TRIQS_RUNTIME_ERROR <<" Evaluation out of bounds"; if (!in) TRIQS_RUNTIME_ERROR <<" Evaluation out of bounds";
auto gg = on_mesh(*g); auto gg = on_mesh(*g);
return (1-w) * gg(n) + w * gg(n+1); return (1-w) * gg(n) + w * gg(n+1);
} }
template<typename G> template<typename G>
local::tail_view operator()(G const * g,freq_infty const &) const {return g->singularity();} local::tail_view operator()(G const * g,freq_infty const &) const {return g->singularity();}
}; };
/// --------------------------- data access --------------------------------- /// --------------------------- data access ---------------------------------
template<typename Opt> struct data_proxy<refreq,matrix_valued,Opt> : data_proxy_array<std::complex<double>,3> {}; template<typename Opt> struct data_proxy<refreq,matrix_valued,Opt> : data_proxy_array<std::complex<double>,3> {};
template<typename Opt> struct data_proxy<refreq,scalar_valued,Opt> : data_proxy_array<std::complex<double>,1> {}; template<typename Opt> struct data_proxy<refreq,scalar_valued,Opt> : data_proxy_array<std::complex<double>,1> {};
// ------------------------------- Factories -------------------------------------------------- // ------------------------------- Factories --------------------------------------------------
//matrix_valued //matrix_valued
template<typename Opt> struct factories<refreq, matrix_valued,Opt> { template<typename Opt> struct factories<refreq, matrix_valued,Opt> {
typedef gf<refreq,matrix_valued> gf_t; typedef gf<refreq,matrix_valued> gf_t;
template<typename MeshType> template<typename MeshType>
static gf_t make_gf(MeshType && m, tqa::mini_vector<size_t,2> shape, local::tail_view const & t) { static gf_t make_gf(MeshType && m, tqa::mini_vector<size_t,2> shape, local::tail_view const & t) {
typename gf_t::data_regular_t A(shape.front_append(m.size())); A() =0; typename gf_t::data_regular_t A(shape.front_append(m.size())); A() =0;
return gf_t ( std::forward<MeshType>(m), std::move(A), t, nothing() ) ; return gf_t ( std::forward<MeshType>(m), std::move(A), t, nothing() ) ;
} }
static gf_t make_gf(double wmin, double wmax, size_t n_freq, tqa::mini_vector<size_t,2> shape) { static gf_t make_gf(double wmin, double wmax, size_t n_freq, tqa::mini_vector<size_t,2> shape) {
typename gf_t::data_regular_t A(shape.front_append(n_freq)); A() =0; typename gf_t::data_regular_t A(shape.front_append(n_freq)); A() =0;
return gf_t(mesh<refreq,Opt>::make(wmin, wmax, n_freq, full_bins), std::move(A), local::tail(shape), nothing()); return gf_t(mesh<refreq,Opt>(wmin, wmax, n_freq, full_bins), std::move(A), local::tail(shape), nothing());
} }
static gf_t make_gf(double wmin, double wmax, size_t n_freq, tqa::mini_vector<size_t,2> shape, mesh_kind mk) { static gf_t make_gf(double wmin, double wmax, size_t n_freq, tqa::mini_vector<size_t,2> shape, mesh_kind mk) {
typename gf_t::data_regular_t A(shape.front_append(n_freq)); A() =0; typename gf_t::data_regular_t A(shape.front_append(n_freq)); A() =0;
return gf_t(mesh<refreq,Opt>::make(wmin, wmax, n_freq, mk), std::move(A), local::tail(shape), nothing()); return gf_t(mesh<refreq,Opt>(wmin, wmax, n_freq, mk), std::move(A), local::tail(shape), nothing());
} }
}; };
//scalar_valued //scalar_valued
template<typename Opt> struct factories<refreq,scalar_valued,Opt> { template<typename Opt> struct factories<refreq,scalar_valued,Opt> {
typedef gf<refreq,scalar_valued> gf_t; typedef gf<refreq,scalar_valued> gf_t;
template<typename MeshType> template<typename MeshType>
static gf_t make_gf(MeshType && m, local::tail_view const & t) { static gf_t make_gf(MeshType && m, local::tail_view const & t) {
typename gf_t::data_regular_t A(m.size()); A() =0; typename gf_t::data_regular_t A(m.size()); A() =0;
return gf_t ( std::forward<MeshType>(m), std::move(A), t, nothing() ) ; return gf_t ( std::forward<MeshType>(m), std::move(A), t, nothing() ) ;
} }
static gf_t make_gf(double wmin, double wmax, size_t n_freq) { static gf_t make_gf(double wmin, double wmax, size_t n_freq) {
typename gf_t::data_regular_t A(n_freq); A() =0; typename gf_t::data_regular_t A(n_freq); A() =0;
return gf_t(mesh<refreq,Opt>::make(wmin, wmax, n_freq), std::move(A), local::tail(tqa::mini_vector<size_t,2>(1,1)), nothing()); return gf_t(mesh<refreq,Opt>(wmin, wmax, n_freq), std::move(A), local::tail(tqa::mini_vector<size_t,2>(1,1)), nothing());
} }
static gf_t make_gf(double wmin, double wmax, size_t n_freq, mesh_kind mk) { 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; typename gf_t::data_regular_t A(n_freq); A() =0;
return gf_t(mesh<refreq,Opt>::make(wmin, wmax, n_freq, mk), std::move(A), local::tail(tqa::mini_vector<size_t,2>(1,1)), nothing()); return gf_t(mesh<refreq,Opt>(wmin, wmax, n_freq, mk), std::move(A), local::tail(tqa::mini_vector<size_t,2>(1,1)), nothing());
} }
}; };
} // gfs_implementation } // gfs_implementation
}} }}
#endif #endif

View File

@ -28,77 +28,75 @@
namespace triqs { namespace gfs { namespace triqs { namespace gfs {
struct refreq_imtime {}; struct refreq_imtime {};
namespace gfs_implementation { // the mesh
template<typename Opt> struct mesh<refreq_imtime,Opt> :mesh_product<mesh<refreq,Opt>,mesh<imtime,Opt>> {
typedef mesh<refreq,Opt> m1_t;
typedef mesh<imtime,Opt> m2_t;
typedef mesh_product<m1_t,m2_t> 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<refreq,Opt>(wmin,wmax,n_freq), mesh<imtime,Opt>(beta,S,nt,mk)} {}
};
// the mesh namespace gfs_implementation {
template<typename Opt> struct mesh<refreq_imtime,Opt> { // singularity
typedef typename mesh<refreq,Opt>::type m1_t; //template<typename Opt> struct singularity<refreq_imtime,scalar_valued,Opt> { typedef gf<retime,scalar_valued> type;};
typedef typename mesh<imtime,Opt>::type m2_t;
typedef mesh_product<m1_t,m2_t> 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<refreq,Opt>(wmin,wmax,n_freq), make_gf_mesh<imtime,Opt>(beta,S,nt,mk)};
}
};
// singularity // h5 name
//template<typename Opt> struct singularity<refreq_imtime,scalar_valued,Opt> { typedef gf<retime,scalar_valued> type;}; template<typename Opt> struct h5_name<refreq_imtime,scalar_valued,Opt> { static std::string invoke(){ return "GfReFreqImTime";}};
// h5 name /// --------------------------- data access ---------------------------------
template<typename Opt> struct h5_name<refreq_imtime,scalar_valued,Opt> { static std::string invoke(){ return "GfReFreqImTime";}};
/// --------------------------- data access --------------------------------- template<typename Opt> struct data_proxy<refreq_imtime,scalar_valued,Opt> : data_proxy_array<std::complex<double>,1> {};
template<typename Opt> struct data_proxy<refreq_imtime,scalar_valued,Opt> : data_proxy_array<std::complex<double>,1> {}; /// --------------------------- evaluator ---------------------------------
/// --------------------------- evaluator --------------------------------- template<typename Opt>
struct evaluator<refreq_imtime,scalar_valued,Opt> {
static constexpr int arity = 2;
template<typename G>
std::complex<double> 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));
template<typename Opt> //std::cout << "eval reref imtim"<< n1 << " "<< n2 << " "<< w1 << " " << w2 << " "<< omega << " "<< tau<< std::endl;
struct evaluator<refreq_imtime,scalar_valued,Opt> {
static constexpr int arity = 2;
template<typename G>
std::complex<double> 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);
return ((std::get<1>(g->mesh().components()).domain().statistic == Fermion) && (p%2==1) ? -res : res);
}
};
// ------------------------------- Factories --------------------------------------------------
template<typename Opt> struct factories<refreq_imtime, scalar_valued,Opt> {
typedef gf<refreq_imtime, scalar_valued,Opt> gf_t;
template<typename MeshType>
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) { // ------------------------------- Factories --------------------------------------------------
auto m = make_gf_mesh<refreq_imtime,Opt>(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 template<typename Opt> struct factories<refreq_imtime, scalar_valued,Opt> {
typedef gf<refreq_imtime, scalar_valued,Opt> gf_t;
//slices template<typename MeshType>
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<refreq_imtime,Opt>(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<refreq,scalar_valued> slice_mesh_imtime (gf_view<refreq_imtime,scalar_valued> g, size_t index) { inline gf_view<refreq,scalar_valued> slice_mesh_imtime (gf_view<refreq_imtime,scalar_valued> g, size_t index) {
auto arr = reinterpret_linear_array(g.mesh(),g.data()); // view it as a 2d array 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() }; return { std::get<0>(g.mesh().components()), arr(arrays::range(),index), local::tail(1,1), nothing() };

View File

@ -30,18 +30,14 @@ namespace triqs { namespace gfs {
struct retime {}; struct retime {};
template<typename Opt> struct mesh<retime,Opt> : linear_mesh<R_domain> {
typedef linear_mesh<R_domain> 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 { namespace gfs_implementation {
template<typename Opt> struct mesh<retime,Opt> {
typedef linear_mesh<R_domain> 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 // singularity
template<typename Opt> struct singularity<retime,matrix_valued,Opt> { typedef local::tail type;}; template<typename Opt> struct singularity<retime,matrix_valued,Opt> { typedef local::tail type;};
template<typename Opt> struct singularity<retime,scalar_valued,Opt> { typedef local::tail type;}; template<typename Opt> struct singularity<retime,scalar_valued,Opt> { typedef local::tail type;};
@ -56,7 +52,7 @@ namespace triqs { namespace gfs {
//typedef typename std::conditional < std::is_same<Target, matrix_valued>::value, arrays::matrix_view<std::complex<double>>, std::complex<double>>::type rtype; //typedef typename std::conditional < std::is_same<Target, matrix_valued>::value, arrays::matrix_view<std::complex<double>>, std::complex<double>>::type rtype;
typedef typename std::conditional < std::is_same<Target, matrix_valued>::value, arrays::matrix<std::complex<double>>, std::complex<double>>::type rtype; typedef typename std::conditional < std::is_same<Target, matrix_valued>::value, arrays::matrix<std::complex<double>>, std::complex<double>>::type rtype;
template<typename G> template<typename G>
rtype operator() (G const * g,double t0) const { rtype operator() (G const * g,double t0) const {
size_t n; double w; bool in; size_t n; double w; bool in;
std::tie(in, n, w) = windowing(g->mesh(),t0); std::tie(in, n, w) = windowing(g->mesh(),t0);
if (!in) TRIQS_RUNTIME_ERROR <<" Evaluation out of bounds"; if (!in) TRIQS_RUNTIME_ERROR <<" Evaluation out of bounds";
@ -68,8 +64,8 @@ namespace triqs { namespace gfs {
}; };
/// --------------------------- data access --------------------------------- /// --------------------------- data access ---------------------------------
template<typename Opt> struct data_proxy<retime,matrix_valued,Opt> : data_proxy_array<std::complex<double>,3> {}; template<typename Opt> struct data_proxy<retime,matrix_valued,Opt> : data_proxy_array<std::complex<double>,3> {};
template<typename Opt> struct data_proxy<retime,scalar_valued,Opt> : data_proxy_array<std::complex<double>,1> {}; template<typename Opt> struct data_proxy<retime,scalar_valued,Opt> : data_proxy_array<std::complex<double>,1> {};
// ------------------------------- Factories -------------------------------------------------- // ------------------------------- Factories --------------------------------------------------
@ -78,19 +74,19 @@ namespace triqs { namespace gfs {
typedef gf<retime,matrix_valued> gf_t; typedef gf<retime,matrix_valued> gf_t;
template<typename MeshType> template<typename MeshType>
static gf_t make_gf(MeshType && m, tqa::mini_vector<size_t,2> shape, local::tail_view const t) { static gf_t make_gf(MeshType && m, tqa::mini_vector<size_t,2> shape, local::tail_view const t) {
typename gf_t::data_regular_t A(shape.front_append(m.size())); A() =0; typename gf_t::data_regular_t A(shape.front_append(m.size())); A() =0;
return gf_t ( std::forward<MeshType>(m), std::move(A), t, nothing() ) ; return gf_t ( std::forward<MeshType>(m), std::move(A), t, nothing() ) ;
} }
static gf_t make_gf(double tmin, double tmax, size_t n_points, tqa::mini_vector<size_t,2> shape, mesh_kind mk) { static gf_t make_gf(double tmin, double tmax, size_t n_points, tqa::mini_vector<size_t,2> shape, mesh_kind mk) {
typename gf_t::data_regular_t A(shape.front_append(n_points)); A() =0; typename gf_t::data_regular_t A(shape.front_append(n_points)); A() =0;
return gf_t(mesh<retime,Opt>::make(tmin, tmax, n_points,mk), std::move(A), local::tail(shape), nothing()); return gf_t(mesh<retime,Opt>(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<size_t,2> shape) { static gf_t make_gf(double tmin, double tmax, size_t n_points, tqa::mini_vector<size_t,2> shape) {
typename gf_t::data_regular_t A(shape.front_append(n_points)); A() =0; typename gf_t::data_regular_t A(shape.front_append(n_points)); A() =0;
return gf_t(mesh<retime,Opt>::make(tmin, tmax, n_points), std::move(A), local::tail(shape), nothing()); return gf_t(mesh<retime,Opt>(tmin, tmax, n_points), std::move(A), local::tail(shape), nothing());
} }
}; };
@ -100,19 +96,19 @@ namespace triqs { namespace gfs {
typedef gf<retime,scalar_valued> gf_t; typedef gf<retime,scalar_valued> gf_t;
template<typename MeshType> template<typename MeshType>
static gf_t make_gf(MeshType && m, local::tail_view const t) { static gf_t make_gf(MeshType && m, local::tail_view const t) {
typename gf_t::data_regular_t A(m.size()); A() =0; typename gf_t::data_regular_t A(m.size()); A() =0;
return gf_t ( std::forward<MeshType>(m), std::move(A), t, nothing() ) ; return gf_t ( std::forward<MeshType>(m), std::move(A), t, nothing() ) ;
} }
static gf_t make_gf(double tmin, double tmax, size_t n_points, mesh_kind mk) { 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; typename gf_t::data_regular_t A(n_points); A() =0;
return gf_t(mesh<retime,Opt>::make(tmin, tmax, n_points,mk), std::move(A), local::tail(tqa::mini_vector<size_t,2>(1,1)), nothing()); return gf_t(mesh<retime,Opt>(tmin, tmax, n_points,mk), std::move(A), local::tail(tqa::mini_vector<size_t,2>(1,1)), nothing());
} }
static gf_t make_gf(double tmin, double tmax, size_t n_points) { static gf_t make_gf(double tmin, double tmax, size_t n_points) {
typename gf_t::data_regular_t A(n_points); A() =0; typename gf_t::data_regular_t A(n_points); A() =0;
return gf_t(mesh<retime,Opt>::make(tmin, tmax, n_points), std::move(A), local::tail(tqa::mini_vector<size_t,2>(1,1)), nothing()); return gf_t(mesh<retime,Opt>(tmin, tmax, n_points), std::move(A), local::tail(tqa::mini_vector<size_t,2>(1,1)), nothing());
} }
}; };

View File

@ -29,23 +29,16 @@ namespace triqs { namespace gfs {
struct two_real_times {}; struct two_real_times {};
namespace gfs_implementation { // the mesh
template<typename Opt> struct mesh<two_real_times,Opt> :mesh_product<mesh<retime,Opt> ,mesh<retime,Opt> > {
typedef mesh_product<mesh<retime,Opt> ,mesh<retime,Opt> > B;
mesh() = default;
mesh (double tmax, double n_time_slices) :
B(mesh<retime,Opt> ( 0, tmax,n_time_slices, full_bins),
mesh<retime,Opt> ( 0, tmax,n_time_slices, full_bins) ) {}
};
// the mesh namespace gfs_implementation {
template<typename Opt> struct mesh<two_real_times,Opt> {
typedef typename mesh<retime,Opt>::type m1_t;
typedef mesh_product<m1_t,m1_t> 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 // h5 name
template<typename Opt> struct h5_name<two_real_times,matrix_valued,Opt> { static std::string invoke(){ return "GfTwoRealTime";}}; template<typename Opt> struct h5_name<two_real_times,matrix_valued,Opt> { static std::string invoke(){ return "GfTwoRealTime";}};
@ -54,23 +47,23 @@ namespace triqs { namespace gfs {
template<typename Opt> template<typename Opt>
struct get_closest_point <two_real_times,matrix_valued,Opt> { struct get_closest_point <two_real_times,matrix_valued,Opt> {
typedef typename mesh<two_real_times, Opt>::type mesh_t; typedef typename mesh<two_real_times, Opt>::type mesh_t;
// // NOT FINISHED, NOT TESTED // // NOT FINISHED, NOT TESTED
// template<typename G, typename T> // template<typename G, typename T>
// static typename mesh_t::index_t invoke(G const * g, closest_pt_wrap<T,T> const & p) { // static typename mesh_t::index_t invoke(G const * g, closest_pt_wrap<T,T> const & p) {
// return std::floor( double(p.value) / g->mesh().delta() + 0.5); // return std::floor( double(p.value) / g->mesh().delta() + 0.5);
// } // }
}; };
/// --------------------------- evaluator --------------------------------- /// --------------------------- evaluator ---------------------------------
template<typename Opt> template<typename Opt>
struct evaluator<two_real_times,matrix_valued,Opt> { struct evaluator<two_real_times,matrix_valued,Opt> {
static constexpr int arity = 2; static constexpr int arity = 2;
template<typename G> template<typename G>
arrays::matrix<std::complex<double> > operator() (G const * g, double t0, double t1) const { arrays::matrix<std::complex<double> > operator() (G const * g, double t0, double t1) const {
auto & data = g->data(); auto & data = g->data();
auto & m = std::get<0>(g->mesh().components()); auto & m = std::get<0>(g->mesh().components());
size_t n0,n1; double w0,w1; bool in; 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"; 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<size_t,size_t>{n0,n1}), arrays::ellipsis());}; auto gg = [g,data]( size_t n0, size_t n1) {return data(g->mesh().index_to_linear(std::tuple<size_t,size_t>{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)); 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 --------------------------------- /// --------------------------- data access ---------------------------------
@ -91,10 +84,10 @@ namespace triqs { namespace gfs {
template<typename Opt> struct factories<two_real_times, matrix_valued,Opt> { template<typename Opt> struct factories<two_real_times, matrix_valued,Opt> {
typedef gf<two_real_times, matrix_valued,Opt> gf_t; typedef gf<two_real_times, matrix_valued,Opt> gf_t;
typedef typename mesh<two_real_times, Opt>::type mesh_t; typedef mesh<two_real_times, Opt> mesh_t;
static gf_t make_gf(double tmax, double n_time_slices, tqa::mini_vector<size_t,2> shape) { static gf_t make_gf(double tmax, double n_time_slices, tqa::mini_vector<size_t,2> shape) {
auto m = mesh<two_real_times,Opt>::make(tmax, n_time_slices); auto m = mesh<two_real_times,Opt>(tmax, n_time_slices);
typename gf_t::data_regular_t A(shape.front_append(m.size())); A() =0; typename gf_t::data_regular_t A(shape.front_append(m.size())); A() =0;
return gf_t (m, std::move(A), nothing(), nothing() ) ; return gf_t (m, std::move(A), nothing(), nothing() ) ;
} }
@ -131,10 +124,10 @@ namespace triqs { namespace gfs {
} // gfs_implementation } // gfs_implementation
// ------------------------------- Additionnal free function for this gf -------------------------------------------------- // ------------------------------- Additionnal free function for this gf --------------------------------------------------
// from g(t,t') and t, return g(t-t') for any t'>t // from g(t,t') and t, return g(t-t') for any t'>t
// //
gf<retime> slice (gf_view<two_real_times> const & g, double t) { gf<retime> slice (gf_view<two_real_times> const & g, double t) {
auto const & m = std::get<0> (g.mesh().components()); //one-time mesh 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 long it = get_closest_mesh_pt_index(m, t); //index of t on this mesh