import mir.test; import mir.interpolate.linear; auto x = [0.0, 1, 2, 3, 5]; auto y = [4.0, 0, 9, 23, 40]; auto g = [7.0, 10, 15]; import mir.ndslice.allocation: rcslice; auto linear = linear!double( x.rcslice!(immutable double), y.rcslice!(const double), ); auto linearLinear = linear.linearExtrapolator; linearLinear(2).should == linear(2); linearLinear(-1).should == linear(-1); linearLinear.opCall!1(-1).should == [8, -4]; linearLinear(100).shouldApprox == linear(100);
Linear extrapolator.