LinearInterpolator1D< NT, Coordinates > Class Template Reference#

DiFfRG: LinearInterpolator1D< NT, Coordinates > Class Template Reference
DiFfRG
Discretization Framework for functional Renormalization Group flows
LinearInterpolator1D< NT, Coordinates > Class Template Reference

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

template<typename NT, typename Coordinates>
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
NTvalue type of the data (real, complex or autodiff)
Coordinates1D coordinate system of the grid, e.g. LinearCoordinates1D or LogarithmicCoordinates1D

Member Typedef Documentation

◆ ctype

template<typename NT , typename Coordinates >
using ctype = typename Coordinates::ctype

◆ value_type

template<typename NT , typename Coordinates >
using value_type = NT

Constructor & Destructor Documentation

◆ LinearInterpolator1D() [1/2]

template<typename NT , typename Coordinates >
LinearInterpolator1D ( const Coordinates & coordinates)
inline

Allocate zeroed data on the grid of coordinates.

Parameters
coordinatescoordinate system of the data; its size() is the number of grid points

◆ LinearInterpolator1D() [2/2]

template<typename NT , typename Coordinates >
KOKKOS_DEFAULTED_FUNCTION LinearInterpolator1D ( const LinearInterpolator1D< NT, Coordinates > & )
default

Shallow copy: the copy shares the data, so later update() calls are seen by both.

Member Function Documentation

◆ at()

template<typename NT , typename Coordinates >
NT KOKKOS_FUNCTION at ( const typename Coordinates::ctype idx) const
inline

Interpolate at a fractional grid index, as returned by index().

Parameters
idxfractional grid index; values outside [0, size-1] are clamped (or wrapped, if periodic)

◆ data()

template<typename NT , typename Coordinates >
const NT * data ( ) const
inline

Pointer to the host copy of the values (read-only; change the data with update()).

◆ get_coordinates()

template<typename NT , typename Coordinates >
const Coordinates & get_coordinates ( ) const
inline

Get the coordinate system of the data.

Returns
const Coordinates& the coordinate system

◆ handle()

template<typename NT , typename Coordinates >
template<typename CT >
auto handle ( ) const
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()

template<typename NT , typename Coordinates >
Coordinates::ctype KOKKOS_FUNCTION index ( const typename Coordinates::ctype x) const
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
xphysical coordinate

◆ operator()()

template<typename NT , typename Coordinates >
NT KOKKOS_FUNCTION operator() ( const typename Coordinates::ctype x) const
inline

Interpolate the data at the point x.

Parameters
xphysical coordinate

◆ operator[]()

template<typename NT , typename Coordinates >
NT operator[] ( size_t i) const
inline

Value at grid point i (host only).

◆ update()

template<typename NT , typename Coordinates >
template<typename NT2 >
void update ( const NT2 * in_data)
inline

Replace the data. Host and device copies are both current when this returns.

Parameters
in_datavalues at the grid points, get_coordinates().size() entries, converted to NT

Member Data Documentation

◆ dim

template<typename NT , typename Coordinates >
size_t dim = 1
staticconstexpr

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