From 2200e2680f331fe4d4425285386afe8d02f05193 Mon Sep 17 00:00:00 2001 From: Olivier Parcollet Date: Mon, 6 Jan 2014 17:46:09 +0100 Subject: [PATCH] gf: imfreq: fix out of bound product gf imfreq - gf> was not correct when out bounds. Fixed evaluator. - tensor_proxy : fix the trait for algebra which was incorrect. - TODO: clean code (repetition, put in mesh some windowing). --- test/triqs/gfs/gf_2times.cpp | 2 +- triqs/arrays/matrix_tensor_proxy.hpp | 4 ++-- triqs/gfs/imfreq.hpp | 10 +++++++--- triqs/gfs/meshes/matsubara_freq.hpp | 3 +++ 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/test/triqs/gfs/gf_2times.cpp b/test/triqs/gfs/gf_2times.cpp index be590bee..cacfcb32 100644 --- a/test/triqs/gfs/gf_2times.cpp +++ b/test/triqs/gfs/gf_2times.cpp @@ -37,7 +37,7 @@ int main() { auto zz = G_w_wn2(t_,tp_); //std::cout << std::get<0>(zz.childs).data() << std::endl ; auto yy = eval ( zz, t_=2, tp_=3); - std::cout << yy.indexmap()<< std::endl ; + //std::cout << yy.indexmap()<< std::endl ; std::cout << yy << std::endl ; //std::cout << eval ( zz, t_=2, tp_=3)<< std::endl ; //std::cout << eval ( G_w_wn2(t_,tp_), t_=2, tp_=3)<< std::endl ; diff --git a/triqs/arrays/matrix_tensor_proxy.hpp b/triqs/arrays/matrix_tensor_proxy.hpp index 99e02747..8bd90e1b 100644 --- a/triqs/arrays/matrix_tensor_proxy.hpp +++ b/triqs/arrays/matrix_tensor_proxy.hpp @@ -35,7 +35,7 @@ namespace arrays { // tensor const template struct const_matrix_tensor_proxy : std::conditional::type { + TRIQS_CONCEPT_TAG_NAME(ImmutableArray)>::type { typedef typename std::remove_reference::type A_t; static constexpr bool is_const = true; @@ -84,7 +84,7 @@ namespace arrays { // tensor no const template struct matrix_tensor_proxy : std::conditional::type { + TRIQS_CONCEPT_TAG_NAME(MutableArray)>::type { typedef typename std::remove_reference::type A_t; static constexpr bool is_const = false; diff --git a/triqs/gfs/imfreq.hpp b/triqs/gfs/imfreq.hpp index a9f723f1..f1f7e558 100644 --- a/triqs/gfs/imfreq.hpp +++ b/triqs/gfs/imfreq.hpp @@ -55,10 +55,14 @@ namespace gfs { // simple evaluation : take the point on the grid... template <> struct evaluator_fnt_on_mesh { long n; + double w; evaluator_fnt_on_mesh() = default; - template evaluator_fnt_on_mesh(MeshType const &m, long p) { n = p; } - template evaluator_fnt_on_mesh(MeshType const &m, matsubara_freq const &p) { n = p.n; } - template auto operator()(F const &f) const DECL_AND_RETURN(f(n)); + template evaluator_fnt_on_mesh(MeshType const &m, long p) { n = p; w=1; } + template evaluator_fnt_on_mesh(MeshType const &m, matsubara_freq const &p) { + if ((p.n >= m.index_start()) && (p.n < m.size()+m.index_start())) {w=1; n =p.n;} + else {w=0; n=0;} + } + template auto operator()(F const &f) const DECL_AND_RETURN(w*f(n)); }; // ------------- evaluator ------------------- diff --git a/triqs/gfs/meshes/matsubara_freq.hpp b/triqs/gfs/meshes/matsubara_freq.hpp index 617e6685..234410b4 100644 --- a/triqs/gfs/meshes/matsubara_freq.hpp +++ b/triqs/gfs/meshes/matsubara_freq.hpp @@ -69,6 +69,9 @@ namespace gfs { /// Flatten the index in the positive linear index for memory storage (almost trivial here). long index_to_linear(index_t ind) const { return ind - index_start(); } + /// Is the mesh only for positive omega_n (G(tau) real)) + bool positive_only() const { return _positive_only;} + /** * The mesh point *