Public Member Functions | List of all members
lazylookup::grid_interpolator< Ndims, Storage > Class Template Reference

#include <lazylookup.hh>

Public Member Functions

 grid_interpolator (std::function< double(const std::array< double, Ndims > &)> f, const std::array< std::size_t, Ndims > &dim_Ns, const std::array< double, Ndims > &dim_mins, const std::array< double, Ndims > &dim_maxes, double bin_eps=1e-4)
 
double val (const std::array< double, Ndims > &X)
 
double operator[] (std::array< double, Ndims > where)
 

Detailed Description

template<std::size_t Ndims, typename Storage = grid_interpolator_storage::dense>
class lazylookup::grid_interpolator< Ndims, Storage >

A lazy grid interpolator.

This requires a function pointer taking a std::array<double,Ndims>. If the point requested is in the bounds, the function will be evaluated at the appropriate grid points. A linearly-interpolated value will be returned. Out of bounds calls will just call the function directly.

For now just linear interpolation is implemented.

By default this uses dense grid storage (memory is allocated for the entire grid) for Ndim < 3, sparse otherwise

Definition at line 210 of file lazylookup.hh.

Constructor & Destructor Documentation

template<std::size_t Ndims, typename Storage = grid_interpolator_storage::dense>
lazylookup::grid_interpolator< Ndims, Storage >::grid_interpolator ( std::function< double(const std::array< double, Ndims > &)>  f,
const std::array< std::size_t, Ndims > &  dim_Ns,
const std::array< double, Ndims > &  dim_mins,
const std::array< double, Ndims > &  dim_maxes,
double  bin_eps = 1e-4 
)
inline

Initialize the grid interpolator.

Parameters
dim_Nsthe number of bins in each dimension (number of grid points will be this plus 1)
dim_minsthe minimum grid point in each dimension
dim_maxesthe maximum grid point in each timension
bin_epsthe fractional part of a bin that will be considered to be exactly the grid point (this is useful because it can avoid evaluating the neighboring grid points)

Definition at line 292 of file lazylookup.hh.


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