CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Static Private Member Functions | Private Attributes
fftjetcms::LinInterpolatedTable1D Class Reference

#include <LinInterpolatedTable1D.h>

Inheritance diagram for fftjetcms::LinInterpolatedTable1D:

Public Member Functions

const double * data () const
 
std::auto_ptr
< LinInterpolatedTable1D
inverse (unsigned npoints, bool leftExtrapolationLinear, bool rightExtrapolationLinear) const
 
bool isMonotonous () const
 
bool leftExtrapolationLinear () const
 
template<typename RealN >
 LinInterpolatedTable1D (const RealN *data, unsigned npoints, double x_min, double x_max, bool leftExtrapolationLinear, bool rightExtrapolationLinear)
 
template<typename RealN >
 LinInterpolatedTable1D (const std::vector< std::pair< RealN, RealN > > &v, unsigned npoints, bool leftExtrapolationLinear, bool rightExtrapolationLinear)
 
 LinInterpolatedTable1D (double c)
 
unsigned npoints () const
 
bool operator!= (const LinInterpolatedTable1D &r) const
 
virtual double operator() (const double &x) const
 
bool operator== (const LinInterpolatedTable1D &r) const
 
bool rightExtrapolationLinear () const
 
double xmax () const
 
double xmin () const
 
virtual ~LinInterpolatedTable1D ()
 

Static Private Member Functions

static double interpolateSimple (const double x0, const double x1, const double y0, const double y1, const double x)
 

Private Attributes

double binwidth_
 
std::vector< double > data_
 
bool leftExtrapolationLinear_
 
bool monotonicityKnown_
 
bool monotonous_
 
unsigned npoints_
 
bool rightExtrapolationLinear_
 
double xmax_
 
double xmin_
 

Detailed Description

Definition at line 24 of file LinInterpolatedTable1D.h.

Constructor & Destructor Documentation

template<typename RealN >
fftjetcms::LinInterpolatedTable1D::LinInterpolatedTable1D ( const RealN *  data,
unsigned  npoints,
double  x_min,
double  x_max,
bool  leftExtrapolationLinear,
bool  rightExtrapolationLinear 
)
inline

Definition at line 114 of file LinInterpolatedTable1D.h.

Referenced by inverse().

template<typename RealN >
fftjetcms::LinInterpolatedTable1D::LinInterpolatedTable1D ( const std::vector< std::pair< RealN, RealN > > &  v,
unsigned  npoints,
bool  leftExtrapolationLinear,
bool  rightExtrapolationLinear 
)

Definition at line 138 of file LinInterpolatedTable1D.h.

fftjetcms::LinInterpolatedTable1D::LinInterpolatedTable1D ( double  c)
explicit
virtual fftjetcms::LinInterpolatedTable1D::~LinInterpolatedTable1D ( )
inlinevirtual

Definition at line 50 of file LinInterpolatedTable1D.h.

Member Function Documentation

const double* fftjetcms::LinInterpolatedTable1D::data ( ) const
inline

Definition at line 68 of file LinInterpolatedTable1D.h.

static double fftjetcms::LinInterpolatedTable1D::interpolateSimple ( const double  x0,
const double  x1,
const double  y0,
const double  y1,
const double  x 
)
inlinestaticprivate

Definition at line 90 of file LinInterpolatedTable1D.h.

std::auto_ptr< LinInterpolatedTable1D > fftjetcms::LinInterpolatedTable1D::inverse ( unsigned  npoints,
bool  leftExtrapolationLinear,
bool  rightExtrapolationLinear 
) const

Definition at line 46 of file LinInterpolatedTable1D.cc.

References binwidth_, data_, i, isMonotonous(), LinInterpolatedTable1D(), npoints_, NULL, xmax_, and xmin_.

49  {
50  if (!isMonotonous())
51  return std::auto_ptr<LinInterpolatedTable1D>(NULL);
52 
53  std::vector<std::pair<double,double> > points;
54  points.reserve(npoints_);
55 
56  if (data_[npoints_ - 1U] > data_[0])
57  {
58  points.push_back(std::pair<double,double>(data_[0], xmin_));
59  for (unsigned i=1; i<npoints_ - 1U; ++i)
60  points.push_back(std::pair<double,double>(data_[i], xmin_+i*binwidth_));
61  points.push_back(std::pair<double,double>(data_[npoints_ - 1U], xmax_));
62  }
63  else
64  {
65  points.push_back(std::pair<double,double>(data_[npoints_ - 1U], xmax_));
66  for (unsigned i=npoints_ - 2U; i>0; --i)
67  points.push_back(std::pair<double,double>(data_[i], xmin_+i*binwidth_));
68  points.push_back(std::pair<double,double>(data_[0], xmin_));
69  }
70 
71  return std::auto_ptr<LinInterpolatedTable1D>(
72  new LinInterpolatedTable1D(points, npoints,
75  }
int i
Definition: DBlmapReader.cc:9
#define NULL
Definition: scimark2.h:8
LinInterpolatedTable1D(const RealN *data, unsigned npoints, double x_min, double x_max, bool leftExtrapolationLinear, bool rightExtrapolationLinear)
bool fftjetcms::LinInterpolatedTable1D::isMonotonous ( ) const

Definition at line 29 of file LinInterpolatedTable1D.cc.

References data_, delta, i, monotonicityKnown_, monotonous_, and npoints_.

Referenced by inverse().

30  {
31  if (!monotonicityKnown_)
32  {
33  monotonous_ = true;
34  const double delta = data_[npoints_ - 1U] - data_[0];
35  if (delta == 0.0)
36  monotonous_ = false;
37  const double sg = delta > 0.0 ? 1.0 : -1.0;
38  for (unsigned i=1; i<npoints_ && monotonous_; ++i)
39  if ((data_[i] - data_[i-1])*sg <= 0.0)
40  monotonous_ = false;
41  monotonicityKnown_ = true;
42  }
43  return monotonous_;
44  }
dbl * delta
Definition: mlp_gen.cc:36
int i
Definition: DBlmapReader.cc:9
bool fftjetcms::LinInterpolatedTable1D::leftExtrapolationLinear ( ) const
inline

Definition at line 64 of file LinInterpolatedTable1D.h.

unsigned fftjetcms::LinInterpolatedTable1D::npoints ( ) const
inline

Definition at line 63 of file LinInterpolatedTable1D.h.

bool fftjetcms::LinInterpolatedTable1D::operator!= ( const LinInterpolatedTable1D r) const
inline

Definition at line 57 of file LinInterpolatedTable1D.h.

double fftjetcms::LinInterpolatedTable1D::operator() ( const double &  x) const
virtual

Definition at line 77 of file LinInterpolatedTable1D.cc.

References binwidth_, data_, delta, leftExtrapolationLinear_, npoints_, rightExtrapolationLinear_, xmax_, and xmin_.

78  {
79  if (x <= xmin_)
80  {
82  return data_[0] + (data_[1]-data_[0])*((x-xmin_)/binwidth_);
83  else
84  return data_[0];
85  }
86  else if (x >= xmax_)
87  {
89  return data_[npoints_ - 1U] - (
90  data_[npoints_-2U]-data_[npoints_-1U])*((x-xmax_)/binwidth_);
91  else
92  return data_[npoints_ - 1U];
93  }
94  else
95  {
96  const unsigned ux = static_cast<unsigned>((x - xmin_)/binwidth_);
97  if (ux >= npoints_ - 1U)
98  return data_[npoints_ - 1U];
99  const double delta = x - (ux*binwidth_ + xmin_);
100  return data_[ux] + (data_[ux+1U]-data_[ux])*delta/binwidth_;
101  }
102  }
dbl * delta
Definition: mlp_gen.cc:36
T x() const
Cartesian x coordinate.
bool fftjetcms::LinInterpolatedTable1D::operator== ( const LinInterpolatedTable1D r) const

Definition at line 17 of file LinInterpolatedTable1D.cc.

References binwidth_, data_, leftExtrapolationLinear_, npoints_, rightExtrapolationLinear_, xmax_, and xmin_.

19  {
20  return xmin_ == r.xmin_ &&
21  xmax_ == r.xmax_ &&
22  binwidth_ == r.binwidth_ &&
23  npoints_ == r.npoints_ &&
24  leftExtrapolationLinear_ == r.leftExtrapolationLinear_ &&
25  rightExtrapolationLinear_ == r.rightExtrapolationLinear_ &&
26  data_ == r.data_;
27  }
bool fftjetcms::LinInterpolatedTable1D::rightExtrapolationLinear ( ) const
inline

Definition at line 66 of file LinInterpolatedTable1D.h.

double fftjetcms::LinInterpolatedTable1D::xmax ( ) const
inline

Definition at line 62 of file LinInterpolatedTable1D.h.

double fftjetcms::LinInterpolatedTable1D::xmin ( ) const
inline

Definition at line 61 of file LinInterpolatedTable1D.h.

Member Data Documentation

double fftjetcms::LinInterpolatedTable1D::binwidth_
private

Definition at line 101 of file LinInterpolatedTable1D.h.

Referenced by inverse(), operator()(), and operator==().

std::vector<double> fftjetcms::LinInterpolatedTable1D::data_
private

Definition at line 98 of file LinInterpolatedTable1D.h.

Referenced by inverse(), isMonotonous(), operator()(), and operator==().

bool fftjetcms::LinInterpolatedTable1D::leftExtrapolationLinear_
private

Definition at line 103 of file LinInterpolatedTable1D.h.

Referenced by operator()(), and operator==().

bool fftjetcms::LinInterpolatedTable1D::monotonicityKnown_
mutableprivate

Definition at line 106 of file LinInterpolatedTable1D.h.

Referenced by isMonotonous().

bool fftjetcms::LinInterpolatedTable1D::monotonous_
mutableprivate

Definition at line 105 of file LinInterpolatedTable1D.h.

Referenced by isMonotonous().

unsigned fftjetcms::LinInterpolatedTable1D::npoints_
private

Definition at line 102 of file LinInterpolatedTable1D.h.

Referenced by inverse(), isMonotonous(), operator()(), and operator==().

bool fftjetcms::LinInterpolatedTable1D::rightExtrapolationLinear_
private

Definition at line 104 of file LinInterpolatedTable1D.h.

Referenced by operator()(), and operator==().

double fftjetcms::LinInterpolatedTable1D::xmax_
private

Definition at line 100 of file LinInterpolatedTable1D.h.

Referenced by inverse(), operator()(), and operator==().

double fftjetcms::LinInterpolatedTable1D::xmin_
private

Definition at line 99 of file LinInterpolatedTable1D.h.

Referenced by inverse(), operator()(), and operator==().