private double kernel(double[] x, int ni, double[] y, int mi, int pi)
{
double a;
if (ni == 0 || mi == 0)
{
a = 0;
}
else
{
// Retrieve the value from the cache
a = K[ni - 1, mi - 1, pi];
}
// Compute a linear kernel
double k = x[ni] * y[mi];
if (pi == 0)
return a + k;
if (ni == 0 || mi == 0)
return a;
// Retrieve the value from the cache
return a + k * K[ni - 1, mi - 1, pi - 1];
}