Version: SMASH-3.1
smash::InterpolateLinear< T > Class Template Reference

#include <interpolation.h>

template<typename T>
class smash::InterpolateLinear< T >

Represent a linear interpolation.

Parameters
TType of interpolated values.

Definition at line 34 of file interpolation.h.

Public Member Functions

 InterpolateLinear (T x0, T y0, T x1, T y1)
 Linear interpolation given two points (x0, y0) and (x1, y1). More...
 
operator() (T x) const
 Calculate spline interpolation at x. More...
 

Public Attributes

slope_
 Slope of the linear interpolation. More...
 
yintercept_
 y-axis intercept of the linear interpolation. More...
 

Constructor & Destructor Documentation

◆ InterpolateLinear()

template<typename T >
smash::InterpolateLinear< T >::InterpolateLinear ( x0,
y0,
x1,
y1 
)

Linear interpolation given two points (x0, y0) and (x1, y1).

Returns
The interpolation function.

Definition at line 92 of file interpolation.h.

92  {
93  assert(x0 != x1);
94  slope_ = (y1 - y0) / (x1 - x0);
95  yintercept_ = y0 - slope_ * x0;
96 }
T yintercept_
y-axis intercept of the linear interpolation.
Definition: interpolation.h:39
T slope_
Slope of the linear interpolation.
Definition: interpolation.h:37

Member Function Documentation

◆ operator()()

template<typename T >
T smash::InterpolateLinear< T >::operator() ( x) const

Calculate spline interpolation at x.

Parameters
xInterpolation argument.
Returns
Interpolated value.

Definition at line 99 of file interpolation.h.

99  {
100  return slope_ * x + yintercept_;
101 }

Member Data Documentation

◆ slope_

template<typename T >
T smash::InterpolateLinear< T >::slope_

Slope of the linear interpolation.

Definition at line 37 of file interpolation.h.

◆ yintercept_

template<typename T >
T smash::InterpolateLinear< T >::yintercept_

y-axis intercept of the linear interpolation.

Definition at line 39 of file interpolation.h.


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