Пример #1
0
        public static void test_hessian()
        {
            Console.WriteLine("\nTesting hessian(x) ...\n");
            MyFunction6 f6 = new MyFunction6();
            double[] x = new double[] { 1, 1, 1 };

            Console.WriteLine("\n\tx = [1, 1, 1]");

            Console.WriteLine("\n\tExpecting:\thessian(x) = [[0.0, 0.0, 0.0], [0.0, 0.0, 5.000000...], [0.0, 5.000000..., 0.0]]");
            Console.WriteLine("\tResult:\t\thessian(x=[1, 1, 1]) = " + f6.hessian(x));
        }
Пример #2
0
        public static void test_partial()
        {
            Console.WriteLine("\nTesting partial(x, i) ...\n");
            MyFunction6 f6 = new MyFunction6();
            double[] x = new double[] {1, 1, 1};

            Console.WriteLine("\n\tf(x[]) =  (2.0 * x[0]) + (3.0 * x[1]) + (5.0 * x[1] * x[2])");

            Console.WriteLine("\n\tExpecting:\t partial(x, 0) = 2.0");
            Console.WriteLine("\t   Result:\t partial(x, 0) = " + f6.partial(x, 0));

            Console.WriteLine("\n\tExpecting:\t partial(x, 2) = 8.0");
            Console.WriteLine("\t   Result:\t partial(x, 1) = " + f6.partial(x, 1));

            Console.WriteLine("\n\tExpecting:\t partial(x, 2) = 5.0");
            Console.WriteLine("\t   Result:\t partial(x, 2) = " + f6.partial(x, 2));
        }
Пример #3
0
        public static void test_gradient()
        {
            Console.WriteLine("\nTesting gradient(x) ...\n");
            MyFunction6 f6 = new MyFunction6();
            double[] x = new double[] {1, 1, 1};

            Console.WriteLine("\n\tx = [1, 1, 1]");

            Console.WriteLine("\n\tExpecting:\tgradient(x) = [[1.999999...], [7.999999...], [4.999999...]]" );
            Console.WriteLine("\tResult:\t\tgradient(x=[1, 1, 1]) = " + f6.gradient(x) );
        }