TRIQS/TRIQS 4.0.0
Researching Interacting Quantum Systems
Loading...
Searching...
No Matches
triqs::lattice::grid_generator

#include <triqs/lattice/grid_generator.hpp>

Detailed Description

Forward iterator generating uniformly-spaced points in the d-dimensional unit cube \( [0,1)^d \).

For a given dimension \( d \in \{1,2,3\} \) and a number of points \( n \) per dimension, the generator iterates over the cuboid grid of \( n^d \) points

\[ \mathbf{p}_{(i_1,\dots,i_d)} = \left( \frac{i_1 + 1/2}{n}, \dots, \frac{i_d + 1/2}{n} \right) , \quad i_k \in \{0,\dots,n-1\} \; , \]

i.e. each point is shifted by half a step away from the cuboid faces so that the grid lies strictly inside the open unit cube. The iteration order is x (fastest), then y, then z (slowest).

The generated points are always 3-dimensional. For \( d < 3 \) the trailing coordinates are kept at their half-step value \( 1/2 \).

Typical usage in C++ is via the implicit bool conversion and the increment operator inherited from itertools::iterator_facade:

for (auto gen = grid_generator{3, 10}; gen; ++gen) {
nda::vector<double> const& k = *gen;
// ... use k ...
}
grid_generator(int dim, int nkpts)
Construct a grid generator with the given dimension and number of points per dimension.

Definition at line 66 of file grid_generator.hpp.

Public Member Functions

 grid_generator ()
 Default constructor: produces a 3-dimensional generator with zero points (an empty/end iterator).
 grid_generator (int dim, int nkpts)
 Construct a grid generator with the given dimension and number of points per dimension.
int index () const
 Linear index of the current grid point in the iteration order (x fastest, then y, then z).
 operator bool () const
 Implicit conversion to bool: true while the generator has not yet been exhausted.
bool operator== (grid_generator const &other) const
 Equal-to comparison: two generators are equal if they share the same dimension, number of points and index.
int size () const
 Total number of grid points, equal to \( N_X \cdot N_Y \cdot N_Z \) (trailing factors are 1 for dim < 3).

Constructor & Destructor Documentation

◆ grid_generator()

triqs::lattice::grid_generator::grid_generator ( int dim,
int nkpts )
inline

Construct a grid generator with the given dimension and number of points per dimension.

Parameters
dimDimension of the grid (1, 2 or 3).
nkptsNumber of points along each dimension.

Definition at line 119 of file grid_generator.hpp.


The documentation for this class was generated from the following file: