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

NUMERIC_TYPE m_

NUMERIC_TYPE n_

## ◆ 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
 a first endpoint of the first interval b second endpoint of the first interval c first endpoint of the second interval d second 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
constexpr std::array c

## ◆ 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
 x the 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}

## ◆ m_

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

the slope of the linear map

Definition at line 56 of file LinearIntervalInterpolation.h.

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

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