3
0
mirror of https://github.com/triqs/dft_tools synced 2024-12-26 06:14:14 +01:00
dft_tools/triqs/gfs/meshes/mesh_tools.hpp
Olivier Parcollet 1ecec0b933 gfs: Fix bug in imfreq with <0 freq.
- there was a confusion in gf imfreq, in the new case
where freq can be <0 (non real gf, or for product gf).
- index: is the matsubara n, as in the struct matsubara_freq
  index can be >0 or <0
- linear_index : is the shift from the 0. It is always >0.
  Fixed function to compute it.

- Also changed the construction of mesh_point in the generic iterator.
  Before, was constructed with a mesh point of index 0
  Now, added a new constructor on mesh_point_t, just taking the mesh
  which construct the *first* mesh_point.
  Fixed linear, discrete, product accordingly.
  Added to the documentation of the concepts of gf.
2014-01-05 20:10:33 +01:00

51 lines
2.1 KiB
C++

/*******************************************************************************
*
* TRIQS: a Toolbox for Research in Interacting Quantum Systems
*
* Copyright (C) 2012 by M. Ferrero, O. Parcollet
*
* TRIQS is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* TRIQS is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* TRIQS. If not, see <http://www.gnu.org/licenses/>.
*
******************************************************************************/
#ifndef TRIQS_GF_MESHTOOLS_H
#define TRIQS_GF_MESHTOOLS_H
#include "../tools.hpp"
#include <triqs/utility/arithmetic_ops_by_cast.hpp>
namespace triqs {
namespace gfs {
template<typename MeshType>
class mesh_pt_generator :
public boost::iterator_facade< mesh_pt_generator<MeshType>, typename MeshType::mesh_point_t , boost::forward_traversal_tag,
typename MeshType::mesh_point_t const & > {
friend class boost::iterator_core_access;
MeshType const * mesh;
size_t u;
typename MeshType::mesh_point_t pt;
typename MeshType::mesh_point_t const & dereference() const { return pt;}
bool equal(mesh_pt_generator const & other) const { return ((other.u==u) );}
// 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(): mesh(nullptr), u(0) {}
mesh_pt_generator( MeshType const * m, bool atEnd = false): mesh(m), u(atEnd ? m->size(): 0), pt(*m) {}
void increment() { ++u; pt.advance(); }
bool at_end() const { return (u>=mesh->size());}
typename MeshType::domain_t::point_t to_point() const { return pt;}
};
}}
#endif