INET Framework for OMNeT++/OMNEST
inet::math::LineardbInterpolator< X, Y > Class Template Reference

#include <Interpolators.h>

Inheritance diagram for inet::math::LineardbInterpolator< X, Y >:
inet::math::InterpolatorBase< X, Y > inet::math::IInterpolator< X, Y >

Public Member Functions

virtual Y getValue (const X x1, const Y y1, const X x2, const Y y2, const X x) const override
 Returns the interpolated value for the given x. More...
 
virtual Y getMean (const X x1, const Y y1, const X x2, const Y y2) const override
 Returns the mean interpolated value in the closed interval of [x1, x2]. More...
 
- Public Member Functions inherited from inet::math::InterpolatorBase< X, Y >
virtual Y getMin (const X x1, const Y y1, const X x2, const Y y2) const override
 Returns the minimum interpolated value in the closed interval of [x1, x2]. More...
 
virtual Y getMax (const X x1, const Y y1, const X x2, const Y y2) const override
 Returns the maximum interpolated value in the closed interval of [x1, x2]. More...
 
- Public Member Functions inherited from inet::math::IInterpolator< X, Y >
virtual ~IInterpolator ()
 

Static Public Attributes

static LineardbInterpolator< X, Y > singleton
 

Member Function Documentation

◆ getMean()

template<typename X , typename Y >
virtual Y inet::math::LineardbInterpolator< X, Y >::getMean ( const X  x1,
const Y  y1,
const X  x2,
const Y  y2 
) const
inlineoverridevirtual

Returns the mean interpolated value in the closed interval of [x1, x2].

Implements inet::math::IInterpolator< X, Y >.

214  {
215  ASSERT(x1 <= x2);
216  auto y1dB = math::fraction2dB(y1);
217  auto y2dB = math::fraction2dB(y2);
218  return math::dB2fraction((y1dB + y2dB) / 2);
219  }

◆ getValue()

template<typename X , typename Y >
virtual Y inet::math::LineardbInterpolator< X, Y >::getValue ( const X  x1,
const Y  y1,
const X  x2,
const Y  y2,
const X  x 
) const
inlineoverridevirtual

Returns the interpolated value for the given x.

The value of x must fall into the closed interval [x1, x2].

Implements inet::math::IInterpolator< X, Y >.

200  {
201  ASSERT(x1 <= x && x <= x2);
202  if (x1 == x)
203  return y1;
204  else if (x2 == x)
205  return y2;
206  else {
207  auto a = toDouble(x - x1) / toDouble(x2 - x1);
208  auto y1dB = math::fraction2dB(y1);
209  auto y2dB = math::fraction2dB(y2);
210  return math::dB2fraction(y1dB * (1 - a) + y2dB * a);
211  }
212  }

Member Data Documentation

◆ singleton

template<typename X , typename Y >
LineardbInterpolator< X, Y > inet::math::LineardbInterpolator< X, Y >::singleton
static

The documentation for this class was generated from the following file:
inet::math::toDouble
double toDouble(const T v)
Definition: Point.h:28
inet::math::fraction2dB
double fraction2dB(double fraction)
Convert a fraction value to dB.
Definition: INETMath.h:158
inet::math::dB2fraction
double dB2fraction(double dB)
Converts a dB value to fraction.
Definition: INETMath.h:153