private void PreCompute()
{
int n = points.Count;
double[] u = new double[n];
IList<double> xa = points.Keys;
IList<double> ya = points.Values;
this.y2 = new double[n];
u[0] = 0;
this.y2[0] = 0;
for (int i = 1; i < n - 1; ++i)
{
// This is the decomposition loop of the tridiagonal algorithm.
// y2 and u are used for temporary storage of the decomposed factors.
double wx = xa[i + 1] - xa[i - 1];
double sig = (xa[i] - xa[i - 1]) / wx;
double p = sig * y2[i - 1] + 2.0;
this.y2[i] = (sig - 1.0) / p;
double ddydx =
(ya[i + 1] - ya[i]) / (xa[i + 1] - xa[i]) -
(ya[i] - ya[i - 1]) / (xa[i] - xa[i - 1]);
u[i] = (6.0 * ddydx / wx - sig * u[i - 1]) / p;
}
this.y2[n - 1] = 0;
// This is the backsubstitution loop of the tridiagonal algorithm
for (int i = n - 2; i >= 0; --i)
{
this.y2[i] = this.y2[i] * this.y2[i + 1] + u[i];
}
}
}