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.
|
| 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>> |
| T | apsc::interp1D (std::vector< double > const &keys, std::vector< T > const &values, double const &keyVal, CompOper const &comp=std::less< double >{}) |
| |
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
◆ 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
-
| A | A type with operator[i] which for i=0 returns the key (x coordinate) and for i=1 returns the value (y coordinate) |
| CompOper | Comparison operator. Defaults to less<double> |
- Parameters
-
| v | a vector with the interpolation points |
| keyVal | the point to be interpolated |
| comp | Comparison 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
-
| T | The type of values to be interpolated |
| CompOper | The comparison operator among keys (default less<double>) |
- Parameters
-
| keys | The vector containing the keys (interpolation nodes) |
| values | The vector containing the values (interpolation values) |
| keyVal | The value of the key where I have to interpolate |
| comp | The comparison operator (defaulted to less<double>{}). |
- Returns