private static void TestReadWrite(IKernelFunctionWithParams kf)
        {
            string typeName = kf.GetType().Name;
            string fn       = typeName + ".txt";

            // Write out the kernel
            StreamWriter sw = new StreamWriter(fn);

            kf.Write(sw);
            sw.Close();

            // Now read it back again
            StreamReader              sr    = new StreamReader(fn);
            KernelFactory             kfact = KernelFactory.Instance;
            IKernelFunctionWithParams kf1   = kfact.CreateKernelFunction(typeName);

            kf1.Read(sr);
            sr.Close();

            // Now test that they're the same
            Assert.Equal(kf.ThetaCount, kf1.ThetaCount);
            for (int i = 0; i < kf.ThetaCount; i++)
            {
                Assert.Equal(kf[i], kf1[i], 1e-6);
            }
        }
        public void TestKernelFactory()
        {
            KernelFactory   kfact = KernelFactory.Instance;
            IKernelFunction kf1   = kfact.CreateKernelFunction("WhiteNoise");
            IKernelFunction kf2   = kfact.CreateKernelFunction("SquaredExponential");
            IKernelFunction kf3   = kfact.CreateKernelFunction("ARD");
            IKernelFunction kf4   = kfact.CreateKernelFunction("LinearKernel");
            IKernelFunction kf5   = kfact.CreateKernelFunction("SummationKernel");
            IKernelFunction kf6   = kfact.CreateKernelFunction("NNKernel");

            Assert.NotNull(kf1);
            Assert.NotNull(kf2);
            Assert.NotNull(kf3);
            Assert.NotNull(kf4);
            Assert.NotNull(kf5);
            Assert.NotNull(kf6);

            Assert.IsType <WhiteNoise>(kf1);
            Assert.IsType <SquaredExponential>(kf2);
            Assert.IsType <ARD>(kf3);
            Assert.IsType <LinearKernel>(kf4);
            Assert.IsType <SummationKernel>(kf5);
            Assert.IsType <NNKernel>(kf6);
        }