LSSTApplications  1.1.2+25,10.0+13,10.0+132,10.0+133,10.0+224,10.0+41,10.0+8,10.0-1-g0f53050+14,10.0-1-g4b7b172+19,10.0-1-g61a5bae+98,10.0-1-g7408a83+3,10.0-1-gc1e0f5a+19,10.0-1-gdb4482e+14,10.0-11-g3947115+2,10.0-12-g8719d8b+2,10.0-15-ga3f480f+1,10.0-2-g4f67435,10.0-2-gcb4bc6c+26,10.0-28-gf7f57a9+1,10.0-3-g1bbe32c+14,10.0-3-g5b46d21,10.0-4-g027f45f+5,10.0-4-g86f66b5+2,10.0-4-gc4fccf3+24,10.0-40-g4349866+2,10.0-5-g766159b,10.0-5-gca2295e+25,10.0-6-g462a451+1
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 _y
Definition: Interpolate.h:68
std::vector< double >::const_iterator _old
Definition: Interpolate.cc:96
std::vector< double > const _x
Definition: Interpolate.h:67

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: