40 #ifndef _interpolator_h
41 #define _interpolator_h
47 #include "exception.h"
50 #ifndef SWIG // STD headers are bad for Swig
62 template <
typename InterpolatableType,
typename InterpolatorType>
class TrackStorage;
80 typedef std::vector<InterpolatableType>
Storage;
88 {
return ((End-Begin)*Location)+Begin; }
140 template<
typename TIterator>
143 Whole DataPointCount = std::distance(Begin,End);
144 Whole LineSegmentCount = DataPointCount-1;
146 if(LineSegmentCount<1)
147 { MEZZ_EXCEPTION(
Exception::PARAMETERS_RANGE_EXCEPTION,
"Cannot GetPercentageThroughSegment in GenericLinearInterpolator without a data segment. There must be two or more data points."); }
148 if(1==LineSegmentCount)
149 {
return InterpolateMath(*(Begin), *(Begin+1), Location); }
151 Whole UsingLineSegment = Location *
Real(LineSegmentCount);
152 if(UsingLineSegment>=LineSegmentCount)
157 return InterpolateMath(*(Begin+UsingLineSegment),
158 *(Begin+UsingLineSegment+1),
169 template<
typename TIterator>
178 {
return InterpolateMath(*Begin, *(Begin+1), Location); }
180 return GetInterpolatedFromMultiple(Begin, End, Location);
193 template <
typename T>
201 typedef std::vector<InterpolatableType>
Storage;
216 template<
typename TIterator>
219 if(Begin==End || Begin+1==End)
225 std::vector<T> SubSection;
226 for(TIterator Iter=Begin; Iter!=End-1; Iter++)
228 return Interpolate(SubSection.begin(),SubSection.end(),Location);
240 template <
typename T>
255 template<
typename TIterator>
268 std::vector<T> Points(Begin, End);
269 std::vector<Real> Spacing(Points.size());
272 for(std::vector<Real>::iterator Iter=Spacing.begin();
277 CurrentJump+=JumpSize;
281 return Spliney.interpolate(Location);
288 #endif // Include guard