PPCKO: Principal Predictive Components for Estimating an Autoregressive Operator
 
Loading...
Searching...
No Matches
interp1D_util.hpp File Reference

Contains a specialization for the template class for interpolating an unidimensional-univariate function in a given point. More...

#include "interp1D.hpp"
#include <numeric>
#include <vector>

Go to the source code of this file.

Classes

class  apsc::internals::map2Vectors< T >
 Maps vector of keys and vector of values in a single entity. More...
 
class  apsc::internals::extractKey_map2Vectors< T >
 extracts the key More...
 
class  apsc::internals::extractValue_map2Vectors< T >
 Extracts the value. More...
 

Functions

template<typename A, typename CompOper = std::less<double>>
double apsc::interp1D (std::vector< A > const &v, double const &keyVal, CompOper const &comp=std::less< double >{})
 
template<typename T, typename CompOper = std::less<double>>
apsc::interp1D (std::vector< double > const &keys, std::vector< T > const &values, double const &keyVal, CompOper const &comp=std::less< double >{})
 

Detailed Description

Contains a specialization for the template class for interpolating an unidimensional-univariate function in a given point.

Author
Luca Formaggia
Note
Taken from pacs-examples, folder of repository PACS Course (https://github.com/pacs-course), Advanced Programming for Scientific Computing, Politecnico di Milano

Function Documentation

◆ interp1D() [1/2]

template<typename A, typename CompOper = std::less<double>>
double apsc::interp1D ( std::vector< A > const & v,
double const & keyVal,
CompOper const & comp = std::less<double>{} )

Implementation for vector<T> where T behaves like an array with 2 components (key value).

Template Parameters
AA type with operator[i] which for i=0 returns the key (x coordinate) and for i=1 returns the value (y coordinate)
CompOperComparison operator. Defaults to less<double>
Parameters
va vector with the interpolation points
keyValthe point to be interpolated
compComparison operator, defaults to less<double>()
Returns

◆ interp1D() [2/2]

template<typename T, typename CompOper = std::less<double>>
T apsc::interp1D ( std::vector< double > const & keys,
std::vector< T > const & values,
double const & keyVal,
CompOper const & comp = std::less<double>{} )

Implementation when interpolation nodes and values are stored in two different vectors

Template Parameters
TThe type of values to be interpolated
CompOperThe comparison operator among keys (default less<double>)
Parameters
keysThe vector containing the keys (interpolation nodes)
valuesThe vector containing the values (interpolation values)
keyValThe value of the key where I have to interpolate
compThe comparison operator (defaulted to less<double>{}).
Returns