when I was looking at the source code of the monotonicCubicInterpolant, I was wondering how the case (which is described in the original paper) delta_k != 0 and signum(d_k) == signum(d_k+1) == signum(delta_k) is checked against? I could not yet figure out, how you make sure that when delta_k != 0 all signums are the same. From what I understand, the case delta_k =! 0 is implicit by checking for if(delta_k == 0) but this does not include the signums condition, does it?
template<class T>
T monotonicCubicInterpolant(const T &f1, const T &f2, const T &f3, const T &f4,
double t)
{
T d_k = T(.5) * (f3 - f1);
T d_k1 = T(.5) * (f4 - f2);
T delta_k = f3 - f2;
if (delta_k == static_cast<T>(0)) {
d_k = static_cast<T>(0);
d_k1 = static_cast<T>(0);
}
T a0 = f2;
T a1 = d_k;
T a2 = (T(3) * delta_k) - (T(2) * d_k) - d_k1;
T a3 = d_k + d_k1 - (T(2) * delta_k);
T t1 = t;
T t2 = t1 * t1;
T t3 = t2 * t1;
return a3 * t3 + a2 * t2 + a1 * t1 + a0;
}