From 165b44a081b7050268f166bec77fde3ed2405f29 Mon Sep 17 00:00:00 2001 From: Olivier Parcollet Date: Sat, 24 Aug 2013 17:24:02 +0200 Subject: [PATCH] gf: mesh. const_iterator and add cbegin - for meshes : clean concept w/ doc, add cbegin, and changed iterator to const_iterator (more standard name). --- triqs/gfs/block.hpp | 2 +- triqs/gfs/gf.hpp | 4 ++-- triqs/gfs/meshes/discrete.hpp | 8 +++++--- triqs/gfs/meshes/linear.hpp | 12 +++++++----- triqs/gfs/meshes/product.hpp | 8 +++++--- 5 files changed, 20 insertions(+), 14 deletions(-) diff --git a/triqs/gfs/block.hpp b/triqs/gfs/block.hpp index 95766ad6..f74be5b9 100644 --- a/triqs/gfs/block.hpp +++ b/triqs/gfs/block.hpp @@ -142,7 +142,7 @@ namespace triqs { namespace gfs { 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; typedef gf_view big_gf_t; - typedef typename big_gf_t::mesh_t::iterator mesh_iterator_t; + typedef typename big_gf_t::mesh_t::const_iterator mesh_iterator_t; big_gf_t big_gf; mesh_iterator_t mesh_it; diff --git a/triqs/gfs/gf.hpp b/triqs/gfs/gf.hpp index 27fcc0d5..da700d1a 100644 --- a/triqs/gfs/gf.hpp +++ b/triqs/gfs/gf.hpp @@ -35,8 +35,8 @@ namespace triqs { namespace gfs { // GENERALISE matrxi TO DEFAULT template struct mesh; - template class gf; // the value class - template class gf_view; // the view class + template class gf; // the regular type + template class gf_view; // the view type // various implementation traits namespace gfs_implementation { // never use using of this... diff --git a/triqs/gfs/meshes/discrete.hpp b/triqs/gfs/meshes/discrete.hpp index 96585a4f..c2a2a53e 100644 --- a/triqs/gfs/meshes/discrete.hpp +++ b/triqs/gfs/meshes/discrete.hpp @@ -61,9 +61,11 @@ namespace triqs { namespace gfs { mesh_point_t operator[](index_t i) const { return mesh_point_t (*this,i);} /// Iterating on all the points... - typedef mesh_pt_generator iterator; - iterator begin() const { return iterator (this);} - iterator end() const { return iterator (this, true);} + typedef mesh_pt_generator const_iterator; + const_iterator begin() const { return const_iterator (this);} + const_iterator end() const { return const_iterator (this, true);} + const_iterator cbegin() const { return const_iterator (this);} + const_iterator cend() const { return const_iterator (this, true);} /// Mesh comparison bool operator == (discrete_mesh const & M) const { return (_dom == M._dom) ;} diff --git a/triqs/gfs/meshes/linear.hpp b/triqs/gfs/meshes/linear.hpp index 1daaf93b..b2256764 100644 --- a/triqs/gfs/meshes/linear.hpp +++ b/triqs/gfs/meshes/linear.hpp @@ -37,6 +37,8 @@ namespace triqs { namespace gfs { typedef size_t index_t; typedef typename domain_t::point_t domain_pt_t; + linear_mesh () : _dom(), L(0), a_pt(0), b_pt(0), xmin(0), xmax(0), del(0), meshk(half_bins) {} + linear_mesh (domain_t const & dom, double a, double b, size_t n_pts, mesh_kind mk) : _dom(dom), L(n_pts), a_pt(a), b_pt(b), meshk(mk) { switch(mk) { @@ -57,8 +59,6 @@ namespace triqs { namespace gfs { xmax = xmin + del*(L-1); } - linear_mesh () : _dom(), L(0), a_pt(0), b_pt(0), xmin(0), xmax(0), del(0), meshk(half_bins) {} - domain_t const & domain() const { return _dom;} size_t size() const { return L; } double delta() const { return del; } @@ -110,9 +110,11 @@ namespace triqs { namespace gfs { public: /// Iterating on all the points... - typedef mesh_pt_generator iterator; - iterator begin() const { return iterator (this);} - iterator end() const { return iterator (this, true);} + typedef mesh_pt_generator const_iterator; + const_iterator begin() const { return const_iterator (this);} + const_iterator end() const { return const_iterator (this, true);} + const_iterator cbegin() const { return const_iterator (this);} + const_iterator cend() const { return const_iterator (this, true);} /// 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));} diff --git a/triqs/gfs/meshes/product.hpp b/triqs/gfs/meshes/product.hpp index 5d77a885..ee2b8514 100644 --- a/triqs/gfs/meshes/product.hpp +++ b/triqs/gfs/meshes/product.hpp @@ -107,9 +107,11 @@ namespace triqs { namespace gfs { mesh_point_t operator()(typename Meshes::index_t ... i) const { return (*this)[std::make_tuple(i...)];} /// Iterating on all the points... - typedef mesh_pt_generator iterator; - iterator begin() const { return iterator (this);} - iterator end() const { return iterator (this, true);} + typedef mesh_pt_generator const_iterator; + const_iterator begin() const { return const_iterator (this);} + const_iterator end() const { return const_iterator (this, true);} + const_iterator cbegin() const { return const_iterator (this);} + const_iterator cend() const { return const_iterator (this, true);} /// Mesh comparison friend bool operator == (mesh_product const & M1, mesh_product const & M2) { return M1.m_tuple==M2.m_tuple; }