From 184274c89300c36f1df55fb8c7c0e469a184789b Mon Sep 17 00:00:00 2001 From: Olivier Parcollet Date: Mon, 18 Nov 2013 22:48:52 +0100 Subject: [PATCH] gf : fix bug in mesh_pt_generator - in the default constructor, do not call the pointer that may be null. - appeared only in python (unused in c++), for new matsubara... --- triqs/gfs/meshes/discrete.hpp | 1 + triqs/gfs/meshes/linear.hpp | 1 + triqs/gfs/meshes/mesh_tools.hpp | 3 ++- triqs/gfs/meshes/product.hpp | 1 + 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/triqs/gfs/meshes/discrete.hpp b/triqs/gfs/meshes/discrete.hpp index be4c95db..ef00f653 100644 --- a/triqs/gfs/meshes/discrete.hpp +++ b/triqs/gfs/meshes/discrete.hpp @@ -46,6 +46,7 @@ namespace triqs { namespace gfs { discrete_mesh const * m; index_t _index; public: + mesh_point_t() = default; mesh_point_t( discrete_mesh const & mesh, index_t const & index_): m(&mesh), _index(index_) {} void advance() { ++_index;} typedef size_t cast_t; diff --git a/triqs/gfs/meshes/linear.hpp b/triqs/gfs/meshes/linear.hpp index c632d4da..2128ede0 100644 --- a/triqs/gfs/meshes/linear.hpp +++ b/triqs/gfs/meshes/linear.hpp @@ -87,6 +87,7 @@ namespace gfs { index_t _index; public: + mesh_point_t() : m(nullptr) {} mesh_point_t(linear_mesh const &mesh, index_t const &index_) : m(&mesh), _index(index_) {} void advance() { ++_index; } typedef domain_pt_t cast_t; diff --git a/triqs/gfs/meshes/mesh_tools.hpp b/triqs/gfs/meshes/mesh_tools.hpp index fae3dc75..7f0fe6f7 100644 --- a/triqs/gfs/meshes/mesh_tools.hpp +++ b/triqs/gfs/meshes/mesh_tools.hpp @@ -63,7 +63,8 @@ namespace gfs { // do NOT check = of mesh, otherwise e.g. block iterator does not work (infinite loop...) //bool equal(mesh_pt_generator const & other) const { return ((mesh == other.mesh) && (other.u==u) );} public: - mesh_pt_generator( MeshType const * m=NULL, bool atEnd = false): mesh(m), u(atEnd ? m->size(): 0), pt((*m)[typename MeshType::index_t()]) {} + mesh_pt_generator(): mesh(nullptr), u(0) {} + mesh_pt_generator( MeshType const * m, bool atEnd = false): mesh(m), u(atEnd ? m->size(): 0), pt((*m)[typename MeshType::index_t()]) {} void increment() { ++u; pt.advance(); } bool at_end() const { return (u>=mesh->size());} typename MeshType::domain_t::point_t to_point() const { return pt;} diff --git a/triqs/gfs/meshes/product.hpp b/triqs/gfs/meshes/product.hpp index c1703abe..12b4107e 100644 --- a/triqs/gfs/meshes/product.hpp +++ b/triqs/gfs/meshes/product.hpp @@ -83,6 +83,7 @@ namespace triqs { namespace gfs { struct F2 { template typename M::mesh_point_t operator()(M const & m, typename M::index_t const & i) const { return m[i];}}; struct F1 { template typename M::mesh_point_t operator()(M const & m) const { return m[typename M::index_t()];}}; public : + mesh_point_t() = default; mesh_point_t(mesh_product const & m_, index_t index_ ) : m(&m_), _c (triqs::tuple::apply_on_zip(F2(), m_.m_tuple, index_)), _atend(false) {} mesh_point_t(mesh_product const & m_) : m(&m_), _c (triqs::tuple::apply(F1(), m_.m_tuple)), _atend(false) {} m_pt_tuple_t const & components_tuple() const { return _c;}