/// <summary> /// B-Spline Kernel Function /// </summary> /// /// <param name="x">Vector <c>x</c> in input space.</param> /// <param name="y">Vector <c>y</c> in input space.</param> /// <returns>Dot product in feature (kernel) space.</returns> /// public override double Function(double[] x, double[] y) { double k = 1.0; int n = 2 * order + 1; for (int p = 0; p < x.Length; p++) { k *= Special.BSpline(n, x[p] - y[p]); } return(k); }
public void FunctionTest() { { double expected = cubic(0.5); double actual = Special.BSpline(3, 0.5); Assert.AreEqual(0.47916666666666669, actual, 1e-8); Assert.AreEqual(expected, actual, 1e-8); } for (double x = -10; x < 10; x = Math.Round(x + 0.01, 2)) { double expected = cubic(x); double actual = Special.BSpline(3, x); Assert.IsTrue(expected.IsEqual(actual, rtol: 1e-5)); } }