LinearInterpolator1D< NT, Coordinates > Class Template Reference#
|
DiFfRG
Discretization Framework for functional Renormalization Group flows
|
Linear interpolation of data given on a 1D grid, usable in host and device code. More...
#include <linear_interpolator_1d.hh>
Public Types | |
| using | ctype = typename Coordinates::ctype |
| using | value_type = NT |
Public Member Functions | |
| LinearInterpolator1D (const Coordinates &coordinates) | |
Allocate zeroed data on the grid of coordinates. | |
| KOKKOS_DEFAULTED_FUNCTION | LinearInterpolator1D (const LinearInterpolator1D &)=default |
| Shallow copy: the copy shares the data, so later update() calls are seen by both. | |
| template<typename NT2 > | |
| void | update (const NT2 *in_data) |
| Replace the data. Host and device copies are both current when this returns. | |
| template<typename CT > | |
| auto | handle () const |
| The read-only view a kernel computing in precision CT receives (see has_kernel_handle). | |
| NT | operator[] (size_t i) const |
| Value at grid point i (host only). | |
| Coordinates::ctype KOKKOS_FUNCTION | index (const typename Coordinates::ctype x) const |
| Fractional grid index of the point x, i.e. Coordinates::backward(x). | |
| NT KOKKOS_FUNCTION | at (const typename Coordinates::ctype idx) const |
| Interpolate at a fractional grid index, as returned by index(). | |
| NT KOKKOS_FUNCTION | operator() (const typename Coordinates::ctype x) const |
| Interpolate the data at the point x. | |
| const Coordinates & | get_coordinates () const |
| Get the coordinate system of the data. | |
| const NT * | data () const |
| Pointer to the host copy of the values (read-only; change the data with update()). | |
Static Public Attributes | |
| static constexpr size_t | dim = 1 |
Detailed Description
class DiFfRG::LinearInterpolator1D< NT, Coordinates >
Linear interpolation of data given on a 1D grid, usable in host and device code.
With \(i(x)\) the fractional grid index of \(x\) (Coordinates::backward), \(i_0 = \lfloor i \rfloor\) and \(t = i - i_0\),
\[ f(x) = (1-t)\, f_{i_0} + t\, f_{i_0+1}\,. \]
The interpolation is linear in the grid index, i.e. linear in \(x\) only for linear coordinates.
Outside the grid the boundary value is returned (constant extrapolation). A periodic coordinate system wraps around instead. The grid needs at least 2 points (bounded axis).
The data is zero after construction; set it with update(). Host and device copies are kept in sync, so the same object can be evaluated on either side. A double-precision interpolator also keeps a single-precision copy, used by single-precision kernels (see handle()).
- Template Parameters
-
NT value type of the data (real, complex or autodiff) Coordinates 1D coordinate system of the grid, e.g. LinearCoordinates1D or LogarithmicCoordinates1D
Member Typedef Documentation
◆ ctype
| using ctype = typename Coordinates::ctype |
◆ value_type
| using value_type = NT |
Constructor & Destructor Documentation
◆ LinearInterpolator1D() [1/2]
|
inline |
Allocate zeroed data on the grid of coordinates.
- Parameters
-
coordinates coordinate system of the data; its size() is the number of grid points
◆ LinearInterpolator1D() [2/2]
|
default |
Shallow copy: the copy shares the data, so later update() calls are seen by both.
Member Function Documentation
◆ at()
|
inline |
Interpolate at a fractional grid index, as returned by index().
- Parameters
-
idx fractional grid index; values outside [0, size-1] are clamped (or wrapped, if periodic)
◆ data()
|
inline |
Pointer to the host copy of the values (read-only; change the data with update()).
◆ get_coordinates()
|
inline |
Get the coordinate system of the data.
- Returns
- const Coordinates& the coordinate system
◆ handle()
|
inline |
The read-only view a kernel computing in precision CT receives (see has_kernel_handle).
For CT = float and double data this reads the single-precision copy, otherwise the data itself.
◆ index()
|
inline |
Fractional grid index of the point x, i.e. Coordinates::backward(x).
f(x) == f.at(f.index(x)). Several interpolators on the same coordinate system can share one index() call, which saves the (possibly expensive) coordinate transform.
- Parameters
-
x physical coordinate
◆ operator()()
|
inline |
Interpolate the data at the point x.
- Parameters
-
x physical coordinate
◆ operator[]()
|
inline |
Value at grid point i (host only).
◆ update()
|
inline |
Replace the data. Host and device copies are both current when this returns.
- Parameters
-
in_data values at the grid points, get_coordinates().size()entries, converted to NT
Member Data Documentation
◆ dim
|
staticconstexpr |
The documentation for this class was generated from the following file:
- /home/runner/work/DiFfRG/DiFfRG/DiFfRG/include/DiFfRG/physics/interpolation/linear_interpolator_1d.hh
Generated by