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>

Inheritance diagram for Opm::UniformTableLinear< T >:
Inheritance graph

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

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

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

Default constructor.

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.
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.

Member Function Documentation

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)
template<typename T >
std::pair< double, double > Opm::UniformTableLinear< T >::domain ( )
inline

Get the domain.

Returns
the domain as a pair of doubles.
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)
template<typename T >
bool Opm::UniformTableLinear< T >::operator== ( const UniformTableLinear< T > &  other) const
inline
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.
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
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

Friends And Related Function Documentation

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

Member Data Documentation

template<typename T>
RangePolicy Opm::UniformTableLinear< T >::left_
protected
template<typename T>
RangePolicy Opm::UniformTableLinear< T >::right_
protected
template<typename T>
double Opm::UniformTableLinear< T >::xdelta_
protected
template<typename T>
double Opm::UniformTableLinear< T >::xmax_
protected
template<typename T>
double Opm::UniformTableLinear< T >::xmin_
protected
template<typename T>
std::vector<T> Opm::UniformTableLinear< T >::y_values_
protected

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