Public Member Functions | Private Attributes | List of all members
WireCell::linterp< Real > Class Template Reference

#include <Interpolate.h>

Public Member Functions

template<class BidiIterator >
 linterp (BidiIterator f, BidiIterator end_p, Real left_endpoint, Real step)
 
Real operator() (Real x) const
 

Private Attributes

std::vector< Real > m_dat
 
Real m_le
 
Real m_re
 
Real m_step
 

Detailed Description

template<class Real>
class WireCell::linterp< Real >

Use like:

linterp<double> lin(f.begin(), f.end(), x0, xstep); ... double y = lin(42.0);

where "f" is some kind of collection of doubles.

Definition at line 27 of file Interpolate.h.

Constructor & Destructor Documentation

template<class Real>
template<class BidiIterator >
WireCell::linterp< Real >::linterp ( BidiIterator  f,
BidiIterator  end_p,
Real  left_endpoint,
Real  step 
)
inline

Definition at line 30 of file Interpolate.h.

31  : m_dat(f,end_p), m_le(left_endpoint), m_step(step) {
32  m_re = m_le + m_step * (m_dat.size()-1);
33  }
std::vector< Real > m_dat
Definition: Interpolate.h:48

Member Function Documentation

template<class Real>
Real WireCell::linterp< Real >::operator() ( Real  x) const
inline

Definition at line 35 of file Interpolate.h.

35  {
36  if (x <= m_le) return m_dat.front();
37  if (x >= m_re) return m_dat.back();
38 
39  int ind = int((x-m_le)/m_step);
40  Real y0 = m_dat[ind];
41  Real y1 = m_dat[ind+1];
42  Real x0 = m_le + ind * m_step;
43 
44  return y0 + (x-x0) * (y1-y0) / m_step;
45  }
std::vector< Real > m_dat
Definition: Interpolate.h:48
list x
Definition: train.py:276

Member Data Documentation

template<class Real>
std::vector<Real> WireCell::linterp< Real >::m_dat
private

Definition at line 48 of file Interpolate.h.

template<class Real>
Real WireCell::linterp< Real >::m_le
private

Definition at line 49 of file Interpolate.h.

template<class Real>
Real WireCell::linterp< Real >::m_re
private

Definition at line 49 of file Interpolate.h.

template<class Real>
Real WireCell::linterp< Real >::m_step
private

Definition at line 49 of file Interpolate.h.


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