OGS
MathLib::LinearIntervalInterpolation< NUMERIC_TYPE > Class Template Reference

Detailed Description

template<typename NUMERIC_TYPE>
class MathLib::LinearIntervalInterpolation< NUMERIC_TYPE >

Class (template) LinearIntervalInterpolation is a functional object performing an interval mapping \(f: [a,b] \to [c,d]\).

Input numeric type has to be a floating point type and must behave well under the operations addition, subtraction, multiplication and division. Let \(a, b, c, d\) objects supporting the mentioned operations. Under the condition \(a \neq b\) an instance of the class computes a value within the interval \([c, d]\), i.e., \(f: [a,b] \to [c,d]\).

Definition at line 32 of file LinearIntervalInterpolation.h.

#include <LinearIntervalInterpolation.h>

Public Member Functions

 LinearIntervalInterpolation (NUMERIC_TYPE a, NUMERIC_TYPE b, NUMERIC_TYPE c, NUMERIC_TYPE d)
 
NUMERIC_TYPE operator() (NUMERIC_TYPE x) const
 

Private Attributes

NUMERIC_TYPE m_
 
NUMERIC_TYPE n_
 

Constructor & Destructor Documentation

◆ LinearIntervalInterpolation()

template<typename NUMERIC_TYPE >
MathLib::LinearIntervalInterpolation< NUMERIC_TYPE >::LinearIntervalInterpolation ( NUMERIC_TYPE a,
NUMERIC_TYPE b,
NUMERIC_TYPE c,
NUMERIC_TYPE d )

Constructor of class template for a linear map \(y = m \cdot x + n\). Under the prerequisite \(a \neq b\) it initializes the coefficients \(m\) and \(n\) in a correct way.

Parameters
afirst endpoint of the first interval
bsecond endpoint of the first interval
cfirst endpoint of the second interval
dsecond endpoint of the second interval

Definition at line 64 of file LinearIntervalInterpolation.h.

66 : m_(d - c), n_(0.0)
67{
68 if (b == a) {
69 OGS_FATAL("LinearIntervalInterpolation::LinearIntervalInterpolation: a == b, empty interval");
70 }
71 m_ /= (b - a);
72 n_ = c - m_ * a;
73}
#define OGS_FATAL(...)
Definition Error.h:26

References MathLib::LinearIntervalInterpolation< NUMERIC_TYPE >::m_, MathLib::LinearIntervalInterpolation< NUMERIC_TYPE >::n_, and OGS_FATAL.

Member Function Documentation

◆ operator()()

template<typename NUMERIC_TYPE >
NUMERIC_TYPE MathLib::LinearIntervalInterpolation< NUMERIC_TYPE >::operator() ( NUMERIC_TYPE x) const
inline

Method computes the value at point \(x\) obtained by linear interpolation.

Parameters
xthe point the interpolation value is searched for
Returns
the interpolation value at point \(x\)

Definition at line 76 of file LinearIntervalInterpolation.h.

77{
78 return m_ * x + n_;
79}

Member Data Documentation

◆ m_

template<typename NUMERIC_TYPE >
NUMERIC_TYPE MathLib::LinearIntervalInterpolation< NUMERIC_TYPE >::m_
private

◆ n_

template<typename NUMERIC_TYPE >
NUMERIC_TYPE MathLib::LinearIntervalInterpolation< NUMERIC_TYPE >::n_
private

the offset of the linear map for \(x\) equals zero

Definition at line 60 of file LinearIntervalInterpolation.h.

Referenced by MathLib::LinearIntervalInterpolation< NUMERIC_TYPE >::LinearIntervalInterpolation().


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