--- /dev/null
+#ifndef MSP_INTERPOLATE_LINEARSPLINE_H_
+#define MSP_INTERPOLATE_LINEARSPLINE_H_
+
+#include <vector>
+#include "spline.h"
+
+namespace Msp {
+namespace Interpolate {
+
+/**
+A very simple type of spline. It interpolates the value linearly between
+knots.
+*/
+template<typename T, unsigned N = 1>
+class LinearSpline: public Spline<T, 1, N>
+{
+public:
+ using typename Spline<T, 1, N>::Value;
+ using typename Spline<T, 1, N>::Knot;
+
+ LinearSpline(const std::vector<Knot> &k):
+ Spline<T, 1, N>(k.front())
+ {
+ typedef SplineValue<T, N> SV;
+
+ this->reserve(k.size()-1);
+ for(unsigned i=1; i<k.size(); ++i)
+ {
+ T dx = k[i].x-k[i-1].x;
+ Value slope = (k[i].y-k[i-1].y)/dx;
+ Polynomial<T, 1> p[N];
+ for(unsigned j=0; j<N; ++j)
+ p[j] = Polynomial<T, 1>(LinAl::Vector<T, 2>(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