X-Git-Url: http://git.tdb.fi/?p=libs%2Fmath.git;a=blobdiff_plain;f=source%2Finterpolate%2Flinearspline.h;fp=source%2Finterpolate%2Flinearspline.h;h=2c88cebbf4d784d774fb35263b5009b021fd1d18;hp=0000000000000000000000000000000000000000;hb=0d4dcdc1c4717c88e79dfd0b7d4ebe34ff7cc548;hpb=acdb569a0370162ffc282b2e43221f34e35e7c58 diff --git a/source/interpolate/linearspline.h b/source/interpolate/linearspline.h new file mode 100644 index 0000000..2c88ceb --- /dev/null +++ b/source/interpolate/linearspline.h @@ -0,0 +1,42 @@ +#ifndef MSP_INTERPOLATE_LINEARSPLINE_H_ +#define MSP_INTERPOLATE_LINEARSPLINE_H_ + +#include +#include "spline.h" + +namespace Msp { +namespace Interpolate { + +/** +A very simple type of spline. It interpolates the value linearly between +knots. +*/ +template +class LinearSpline: public Spline +{ +public: + using typename Spline::Value; + using typename Spline::Knot; + + LinearSpline(const std::vector &k): + Spline(k.front()) + { + typedef SplineValue SV; + + this->reserve(k.size()-1); + for(unsigned i=1; i p[N]; + for(unsigned j=0; j(LinAl::Vector(SV::get(slope, j), SV::get(k[i-1].y, j)-k[i-1].x*SV::get(slope, j))); + this->add_segment(p, k[i].x); + } + } +}; + +} // namespace Interpolate +} // namespace Msp + +#endif