From 2b315fcdea960b64a5eec86281c7663280e24b0b Mon Sep 17 00:00:00 2001 From: Olivier Parcollet Date: Tue, 18 Feb 2014 19:25:29 +0100 Subject: [PATCH] gf : corrections - correct previous commit (for scalar gf, the new check was not compiling) - correct windowing of linear mesh (left point corrected as right point for rounding error --- test/triqs/gfs/test_fit_tail.cpp | 2 -- test/triqs/gfs/test_fit_tail.output | 6 +++--- triqs/gfs/local/fit_tail.hpp | 2 -- triqs/gfs/local/no_tail.hpp | 19 +++++++++++++++---- triqs/gfs/meshes/linear.hpp | 7 ++++++- 5 files changed, 24 insertions(+), 12 deletions(-) diff --git a/test/triqs/gfs/test_fit_tail.cpp b/test/triqs/gfs/test_fit_tail.cpp index 57a55acb..f2b6c7d8 100644 --- a/test/triqs/gfs/test_fit_tail.cpp +++ b/test/triqs/gfs/test_fit_tail.cpp @@ -9,8 +9,6 @@ using triqs::gfs::local::tail; #define TEST(X) std::cout << BOOST_PP_STRINGIZE((X)) << " ---> "<< (X) < iom_; double beta =10; int N=100; diff --git a/test/triqs/gfs/test_fit_tail.output b/test/triqs/gfs/test_fit_tail.output index 15b38302..81f5231e 100644 --- a/test/triqs/gfs/test_fit_tail.output +++ b/test/triqs/gfs/test_fit_tail.output @@ -66,7 +66,7 @@ ... Order 2 = [[(1,0)]] ... Order 3 = -[[(0.999288,0)]] +[[(0.999247,0)]] ... Order 4 = [[(0.998655,0)]] @@ -80,7 +80,7 @@ ... Order 2 = [[(1,0)]] ... Order 3 = -[[(0.999209,0)]] +[[(0.999186,0)]] ... Order 4 = [[(0.998631,0)]] @@ -94,7 +94,7 @@ ... Order 2 = [[(1,0)]] ... Order 3 = -[[(0.999251,0)]] +[[(0.999214,0)]] ... Order 4 = [[(0.998655,0)]] diff --git a/triqs/gfs/local/fit_tail.hpp b/triqs/gfs/local/fit_tail.hpp index cb9d704a..86e07fb1 100644 --- a/triqs/gfs/local/fit_tail.hpp +++ b/triqs/gfs/local/fit_tail.hpp @@ -57,8 +57,6 @@ namespace triqs { namespace gfs { namespace local { // if known_moments.size()==0, the lowest order to be obtained from the fit is determined by order_min in known_moments // if known_moments.size()==0, the lowest order is the one following order_max in known_moments - const double beta = gf.mesh().domain().beta; - int n_unknown_moments = n_moments - known_moments.size(); if (n_unknown_moments < 1) return known_moments; diff --git a/triqs/gfs/local/no_tail.hpp b/triqs/gfs/local/no_tail.hpp index 37702cbf..80be390d 100644 --- a/triqs/gfs/local/no_tail.hpp +++ b/triqs/gfs/local/no_tail.hpp @@ -33,10 +33,22 @@ namespace gfs { return {g.mesh(), g.data(), {}, g.symmetry()}; } + namespace details { // dispatch the test for scalar_valued and matrix_valued + using arrays::mini_vector; + + inline void _equal_or_throw(mini_vector const &s_t, mini_vector const &g_t) { + if (s_t != g_t) TRIQS_RUNTIME_ERROR << "make_gf_from_g_and_tail: Shape of the gf target and of the tail mismatch"; + } + + inline void _equal_or_throw(mini_vector const &s_t, mini_vector const &g_t) { + if (s_t != mini_vector{1, 1}) + TRIQS_RUNTIME_ERROR << "make_gf_from_g_and_tail: tail shape must be 1x1 for a scalar gf"; + } + } + template gf_view make_gf_from_g_and_tail(gf_impl const &g, local::tail t) { - if (t.shape() != get_target_shape(g)) - TRIQS_RUNTIME_ERROR << "make_gf_from_g_and_tail: Shape of the gf target and of the tail mismatch"; + details::_equal_or_throw(t.shape(), get_target_shape(g)); auto g2 = gf{g}; // copy the function without tail return {std::move(g2.mesh()), std::move(g2.data()), std::move(t), g2.symmetry()}; } @@ -44,8 +56,7 @@ namespace gfs { template gf_view make_gf_view_from_g_and_tail(gf_impl const &g, local::tail_view t) { - if (t.shape() != get_target_shape(g)) - TRIQS_RUNTIME_ERROR << "make_gf_from_g_and_tail: Shape of the gf target and of the tail mismatch"; + details::_equal_or_throw(t.shape(), get_target_shape(g)); return {g.mesh(), g.data(), t, g.symmetry()}; } } diff --git a/triqs/gfs/meshes/linear.hpp b/triqs/gfs/meshes/linear.hpp index 32465594..0e624e66 100644 --- a/triqs/gfs/meshes/linear.hpp +++ b/triqs/gfs/meshes/linear.hpp @@ -200,7 +200,12 @@ namespace gfs { double w = a - i; if (i == imax) { --i; - in = (std::abs(w) < 1.e-14); + in = (std::abs(w) < 1.e-12); + w = 1.0; + } + if (i == -1) { + i = 0; + in = (std::abs(1 - w) < 1.e-12); w = 1.0; } return std::make_tuple(in, i, w);