Opm::UniformTableLinear< T > Class Template Reference

This class uses linear interpolation to compute the value (and its derivative) of a function f sampled at uniform points. More...

#include <UniformTableLinear.hpp>

Public Types

enum  RangePolicy { Throw = 0 , ClosestValue = 1 , Extrapolate = 2 }
 Policies for how to behave when trying to evaluate outside the domain. More...
 

Public Member Functions

 UniformTableLinear ()
 Default constructor. More...
 
 UniformTableLinear (double xmin, double xmax, const std::vector< T > &y_values)
 Construct from vector of y-values. More...
 
 UniformTableLinear (double xmin, double xmax, const T *y_values, int num_y_values)
 Construct from array of y-values. More...
 
std::pair< double, double > domain ()
 Get the domain. More...
 
void rescaleDomain (std::pair< double, double > new_domain)
 Rescale the domain. More...
 
double operator() (const double x) const
 Evaluate the value at x. More...
 
double derivative (const double x) const
 Evaluate the derivative at x. More...
 
bool operator== (const UniformTableLinear &other) const
 Equality operator. More...
 
void setLeftPolicy (RangePolicy rp)
 Sets the behavioural policy for evaluation to the left of the domain. More...
 
void setRightPolicy (RangePolicy rp)
 Sets the behavioural policy for evaluation to the right of the domain. More...
 

Protected Attributes

double xmin_
 
double xmax_
 
double xdelta_
 
std::vector< T > y_values_
 
RangePolicy left_
 
RangePolicy right_
 

Friends

template<typename U >
std::ostream & operator<< (std::ostream &os, const UniformTableLinear< U > &t)
 

Detailed Description

template<typename T>
class Opm::UniformTableLinear< T >

This class uses linear interpolation to compute the value (and its derivative) of a function f sampled at uniform points.

Template Parameters
Tthe range type of the function (should be an algebraic ring type)

Member Enumeration Documentation

◆ RangePolicy

template<typename T >
enum Opm::UniformTableLinear::RangePolicy

Policies for how to behave when trying to evaluate outside the domain.

Enumerator
Throw 
ClosestValue 
Extrapolate 

Constructor & Destructor Documentation

◆ UniformTableLinear() [1/3]

template<typename T >
Opm::UniformTableLinear< T >::UniformTableLinear
inline

Default constructor.

◆ UniformTableLinear() [2/3]

template<typename T >
Opm::UniformTableLinear< T >::UniformTableLinear ( double  xmin,
double  xmax,
const std::vector< T > &  y_values 
)
inline

Construct from vector of y-values.

Parameters
xminthe x value corresponding to the first y value.
xmaxthe x value corresponding to the last y value.
y_valuesvector of range values.

References Opm::UniformTableLinear< T >::xdelta_.

◆ UniformTableLinear() [3/3]

template<typename T >
Opm::UniformTableLinear< T >::UniformTableLinear ( double  xmin,
double  xmax,
const T *  y_values,
int  num_y_values 
)
inline

Construct from array of y-values.

Parameters
xminthe x value corresponding to the first y value.
xmaxthe x value corresponding to the last y value.
y_valuesarray of range values.
num_y_valuesthe number of values in y_values.

References Opm::UniformTableLinear< T >::xdelta_, and Opm::UniformTableLinear< T >::y_values_.

Member Function Documentation

◆ derivative()

template<typename T >
double Opm::UniformTableLinear< T >::derivative ( const double  x) const
inline

Evaluate the derivative at x.

Parameters
xa domain value
Returns
f'(x)

References exprtk::details::numeric::max(), exprtk::details::numeric::min(), exprtk::details::value(), and exprtk::details::x().

◆ domain()

template<typename T >
std::pair< double, double > Opm::UniformTableLinear< T >::domain
inline

Get the domain.

Returns
the domain as a pair of doubles.

◆ operator()()

template<typename T >
double Opm::UniformTableLinear< T >::operator() ( const double  x) const
inline

Evaluate the value at x.

Parameters
xa domain value
Returns
f(x)

References exprtk::details::numeric::max(), exprtk::details::numeric::min(), and exprtk::details::x().

◆ operator==()

template<typename T >
bool Opm::UniformTableLinear< T >::operator== ( const UniformTableLinear< T > &  other) const
inline

◆ rescaleDomain()

template<typename T >
void Opm::UniformTableLinear< T >::rescaleDomain ( std::pair< double, double >  new_domain)
inline

Rescale the domain.

Parameters
new_domainthe new domain as a pair of doubles.

◆ setLeftPolicy()

template<typename T >
void Opm::UniformTableLinear< T >::setLeftPolicy ( RangePolicy  rp)
inline

Sets the behavioural policy for evaluation to the left of the domain.

Parameters
rpthe policy

References OPM_THROW.

◆ setRightPolicy()

template<typename T >
void Opm::UniformTableLinear< T >::setRightPolicy ( RangePolicy  rp)
inline

Sets the behavioural policy for evaluation to the right of the domain.

Parameters
rpthe policy

References OPM_THROW.

Friends And Related Function Documentation

◆ operator<<

template<typename T >
template<typename U >
std::ostream & operator<< ( std::ostream &  os,
const UniformTableLinear< U > &  t 
)
friend

Member Data Documentation

◆ left_

template<typename T >
RangePolicy Opm::UniformTableLinear< T >::left_
protected

◆ right_

template<typename T >
RangePolicy Opm::UniformTableLinear< T >::right_
protected

◆ xdelta_

template<typename T >
double Opm::UniformTableLinear< T >::xdelta_
protected

◆ xmax_

template<typename T >
double Opm::UniformTableLinear< T >::xmax_
protected

◆ xmin_

template<typename T >
double Opm::UniformTableLinear< T >::xmin_
protected

◆ y_values_

template<typename T >
std::vector<T> Opm::UniformTableLinear< T >::y_values_
protected

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