LSSTApplications  8.0.0.0+107,8.0.0.1+13,9.1+18,9.2,master-g084aeec0a4,master-g0aced2eed8+6,master-g15627eb03c,master-g28afc54ef9,master-g3391ba5ea0,master-g3d0fb8ae5f,master-g4432ae2e89+36,master-g5c3c32f3ec+17,master-g60f1e072bb+1,master-g6a3ac32d1b,master-g76a88a4307+1,master-g7bce1f4e06+57,master-g8ff4092549+31,master-g98e65bf68e,master-ga6b77976b1+53,master-gae20e2b580+3,master-gb584cd3397+53,master-gc5448b162b+1,master-gc54cf9771d,master-gc69578ece6+1,master-gcbf758c456+22,master-gcec1da163f+63,master-gcf15f11bcc,master-gd167108223,master-gf44c96c709
LSSTDataManagementBasePackage
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
lsst::afw::math::InterpolateConstant Class Reference
Inheritance diagram for lsst::afw::math::InterpolateConstant:
lsst::afw::math::Interpolate

Public Member Functions

virtual ~InterpolateConstant ()
 
virtual double interpolate (double const x) const
 Interpolate a constant to the point xInterp. More...
 
- Public Member Functions inherited from lsst::afw::math::Interpolate
virtual ~Interpolate ()
 

Private Member Functions

 InterpolateConstant (std::vector< double > const &x, std::vector< double > const &y, Interpolate::Style const style)
 

Private Attributes

std::vector< double >
::const_iterator 
_old
 

Friends

boost::shared_ptr< InterpolatemakeInterpolate (std::vector< double > const &x, std::vector< double > const &y, Interpolate::Style const style)
 

Additional Inherited Members

- Public Types inherited from lsst::afw::math::Interpolate
enum  Style {
  UNKNOWN = -1, CONSTANT = 0, LINEAR = 1, NATURAL_SPLINE = 2,
  CUBIC_SPLINE = 3, CUBIC_SPLINE_PERIODIC = 4, AKIMA_SPLINE = 5, AKIMA_SPLINE_PERIODIC = 6,
  NUM_STYLES
}
 
- Protected Member Functions inherited from lsst::afw::math::Interpolate
 Interpolate (std::vector< double > const &x, std::vector< double > const &y, Interpolate::Style const style=UNKNOWN)
 
 Interpolate (std::pair< std::vector< double >, std::vector< double > > const xy, Interpolate::Style const style=UNKNOWN)
 
- Protected Attributes inherited from lsst::afw::math::Interpolate
std::vector< double > const _x
 
std::vector< double > const _y
 
Interpolate::Style const _style
 

Detailed Description

Definition at line 84 of file Interpolate.cc.

Constructor & Destructor Documentation

virtual lsst::afw::math::InterpolateConstant::~InterpolateConstant ( )
inlinevirtual

Definition at line 88 of file Interpolate.cc.

88 {}
lsst::afw::math::InterpolateConstant::InterpolateConstant ( std::vector< double > const &  x,
std::vector< double > const &  y,
Interpolate::Style const  style 
)
inlineprivate
Parameters
xthe x-values of points
ythe values at x[]
styledesired interpolator

Definition at line 91 of file Interpolate.cc.

94  :
95  Interpolate(recenter(x, y)), _old(_x.begin()) {}
std::vector< double >::const_iterator _old
Definition: Interpolate.cc:96
std::vector< double > const _x
Definition: Interpolate.h:67
Interpolate(std::vector< double > const &x, std::vector< double > const &y, Interpolate::Style const style=UNKNOWN)
Definition: Interpolate.h:60

Member Function Documentation

double lsst::afw::math::InterpolateConstant::interpolate ( double const  x) const
virtual

Interpolate a constant to the point xInterp.

Implements lsst::afw::math::Interpolate.

Definition at line 101 of file Interpolate.cc.

103 {
104  //
105  // Look for the interval wherein lies xInterp. We could naively use std::upper_bound, but that requires a
106  // logarithmic time lookup so we'll cache the previous answer in _old -- this is a good idea if people
107  // usually call this routine repeatedly for a range of x
108  //
109  // We start by searching up from _old
110  //
111  if (xInterp < *_old) { // We're to the left of the cache
112  if (_old == _x.begin()) { // ... actually off the array
113  return _y[0];
114  }
115  _old = _x.begin(); // reset the cached point to the start of the array
116  } else { // see if we're still in the same interval
117  if (_old < _x.end() - 1 and xInterp < *(_old + 1)) { // we are, so we're done
118  return _y[_old - _x.begin()];
119  }
120  }
121  // We're to the right of the cached point and not in the same inverval, so search up from _old
122  std::vector<double>::const_iterator low = std::upper_bound(_old, _x.end(), xInterp);
123  //
124  // Did that work?
125  if (low == _old && _old != _x.begin()) {
126  // No. Sigh. Search the entire range.
127  low = std::upper_bound(_x.begin(), low + 1, xInterp);
128  }
129  //
130  // OK, we've found the right interval. Return the desired value, being careful at the ends
131  //
132  if (low == _x.end()) {
133  return _y[_y.size() - 1];
134  } else if (low == _x.begin()) {
135  return _y[0];
136  } else {
137  --low;
138  _old = low;
139  return _y[low - _x.begin()];
140  }
141 }
std::vector< double >::const_iterator _old
Definition: Interpolate.cc:96
std::vector< double > const _x
Definition: Interpolate.h:67
std::vector< double > const _y
Definition: Interpolate.h:68

Friends And Related Function Documentation

boost::shared_ptr< Interpolate > makeInterpolate ( std::vector< double > const &  x,
std::vector< double > const &  y,
Interpolate::Style const  style 
)
friend

A factory function to make Interpolate objects

Member Data Documentation

std::vector<double>::const_iterator lsst::afw::math::InterpolateConstant::_old
mutableprivate

Definition at line 96 of file Interpolate.cc.


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