public override double ComputeValue(double x)
{
MatrixValue samples = Samples;
if (a.Length > 1)
{
int gap = 1;
double previous = 0.0;
for (int i = 1; i < a.Length; i++)
{
if (samples[i, 1].Re < x && (i == 1 || samples[i, 1].Re > previous))
{
previous = samples[i, 1].Re;
gap = i;
}
}
double x1 = x - previous;
double x2 = h[gap] - x1;
return ((-a[gap - 1] / 6 * (x2 + h[gap]) * x1 + samples[gap, 2].Re) * x2 + (-a[gap] / 6 * (x1 + h[gap]) * x2 + samples[gap + 1, 2].Re) * x1) / h[gap];
}
return 0;
}