template<typename M, typename T>
requires std::totally_ordered<T>
class triqs::mesh::detail::linear< M, T >
Linear mesh type.
This class serves as a CRTP base class for other mesh types and satisfies the triqs::mesh::MeshWithValues concept. It is defined by its size \( N \geq 0 \) and the interval \( [a, b] \) with \( a \leq b \). The mesh points are equally spaced on the interval, i.e. the distance between two consecutive mesh points (step size) is constant.
A linear mesh has the following properties:
- Each mesh point is identified by a unique index \( n \in \{0, 1, \ldots, N-1\} \).
- An index \( n \) is mapped to the corresponding data index \( d \) by the identity function \( d(n) = n \) and vice versa.
- An index \( n \) is mapped to the corresponding value \( m \) by the linear function \( m(n) = a + n \cdot
\Delta \) sucht that \( m(0) = a \) and \( m(N-1) = b \). The step size of the mesh is \( \Delta = \frac{b -
a}{N - 1} \) for \( N > 1 \), otherwise it is undefined. For implementation purposes, we set \( \Delta = 0 \) and \( \Delta^{-1} = 0 \) for \( N = 0 \) and \( \Delta = 0 \) and \( \Delta^{-1} = \infty \) for \( N = 1 \).
- An arbitrary value \( x \in [a, b] \) is mapped to the closest mesh point with index \( n \) by the function \( n(x) = \left\lfloor \frac{x - a}{\Delta} + 0.5 \right\rfloor \).
See also triqs::mesh::imtime for an example of a derived classes.
- Template Parameters
-
| M | Mesh type that inherits from this base class. |
| T | Value type of the mesh points. |
Definition at line 74 of file linear.hpp.
|
|
| linear ()=default |
| | Default construct an empty linear mesh of size \( N = 0 \).
|
| | linear (value_t a, value_t b, long N) |
| | Construct a linear mesh on the interval \( [a, b] \) of a given size \( N \geq 0 \).
|
|
auto | begin () const |
| | Get an iterator to the beginning of the mesh.
|
|
auto | cbegin () const |
| | Get a const iterator to the beginning of the mesh.
|
|
auto | cend () const |
| | Get a const iterator to the end of the mesh.
|
|
value_t | delta () const noexcept |
| | Get the step size \( \Delta \) of the mesh, i.e. the distance between two consecutive mesh points.
|
|
value_t | delta_inv () const noexcept |
| | Get the inverse of the step size of the mesh, i.e. \( 1 / \Delta \).
|
| void | deserialize (auto &ar) |
| | Deserialize the mesh from a generic archive.
|
|
auto | end () const |
| | Get an iterator to the end of the mesh.
|
| auto | evaluate (auto const &f, double x) const |
| | Linear interpolation of a function \( f \) defined on a triqs::mesh::detail::linear mesh at a value \(x \in [a, b] \).
|
|
long | first_index () const |
| | Get the first index of the mesh, i.e. \( 0 \).
|
| bool | is_index_valid (index_t n) const noexcept |
| | Check if an index \( n \) is valid.
|
|
long | last_index () const |
| | Get the last index of the mesh, i.e. \( N - 1 \).
|
|
uint64_t | mesh_hash () const noexcept |
| | Get the hash value of the mesh.
|
| mesh_point_t | operator() (index_t n) const noexcept |
| | Function call operator to access a mesh point by its index \( n \in \{0, 1, \ldots, N-1\} \).
|
|
bool | operator== (linear const &rhs) const =default |
| | Equal-to comparison operator compares \( N \) and the interval \( [a, b] \).
|
| mesh_point_t | operator[] (closest_mesh_point_t< value_t > const &cmp) const noexcept |
| | Subscript operator to access a mesh point by a value \( x \) contained in a triqs::mesh::closest_mesh_point_t.
|
| mesh_point_t | operator[] (long d) const noexcept |
| | Subscript operator to access a mesh point by its data index \( d \in \{0, 1, \ldots, N-1\} \).
|
| void | serialize (auto &ar) const |
| | Serialize the mesh to a generic archive.
|
|
long | size () const noexcept |
| | Get the size \( N \) of the mesh, i.e. the number of mesh points.
|
| index_t | to_data_index (closest_mesh_point_t< value_t > const &cmp) const noexcept |
| | Map a value \( x \in [a, b] \) to the closest mesh point and return its data index \( d(x) \).
|
| data_index_t | to_data_index (index_t n) const noexcept |
| | Map an index \( n \in \{0, 1, \ldots, N-1\} \) to its corresponding data index \( d(n) \).
|
| index_t | to_index (closest_mesh_point_t< value_t > const &cmp) const noexcept |
| | Map a value \( x \in [a, b] \) to the closest mesh point and return its index \( n(x) \).
|
| index_t | to_index (data_index_t d) const noexcept |
| | Map a data index \( d \in \{0, 1, \ldots, N-1\} \) to the corresponding index \( n(d) \).
|
| value_t | to_value (index_t n) const noexcept |
| | Map an index \( n \in \{0, 1, \ldots, N-1\} \) to its corresponding value \( m(n) \).
|
template<typename M, typename T>
Linear interpolation of a function \( f \) defined on a triqs::mesh::detail::linear mesh at a value \(x \in [a, b] \).
We calculate
\[ f(x) \approx f_n * (1 - w) + f_{n + 1} * w \; ,
\]
where \( n(x) = \mathrm{min} \left\{ \left\lfloor \frac{x - a}{\Delta} \right\rfloor, N - 2 \right\} \) is the index of the left mesh point used for the interpolation, \( w = \frac{x - m(n)}{\Delta} \) and \( f_n \) is the function value at the mesh point with index \( n \).
- Parameters
-
| f | Callable object \( f \) containing the function values \( f_n \) at the mesh points. |
| x | Value \( x \) at which to interpolate the function. |
- Returns
- Linear interpolation of \( f(x) \).
Definition at line 364 of file linear.hpp.