示例#1
0
        public static void test_condition_number()
        {
            Numeric n = new Numeric();
            List<double[]> list1 = new List<double[]>() { new double[] { 1, 2 }, new double[] { 3, 4 } };

            Console.WriteLine("\nTesting test_condition_number(Matrix A) ...\n");
            try
            {
                Console.WriteLine("\tExpecting:\tCondition number of Matrix [[1, 2], [3, 4]] = 21");
                Console.WriteLine("\t   Result:\tCondition number of Matrix " + Matrix.from_list(list1) + " = " + n.condition_number(Matrix.from_list(list1)));
            }
            catch (Exception e)
            {
                Console.WriteLine("{0} Exception caught.", e.ToString());
            }

            Console.WriteLine("\nTesting test_condition_number(f, x=None, h=0.000001) ...\n");
            try
            {
                MyFunction3 fn = new MyFunction3();
                Console.WriteLine("\tExpecting:\tCondition number of function f(x) = (x * x) - (5.0 * x) = 0.75");
                Console.WriteLine("\t   Result:\tCondition number of function f(x) = (x * x) - (5.0 * x) = " + n.condition_number(fn, 1));
            }
            catch (Exception e)
            {
                Console.WriteLine("{0} Exception caught.", e.ToString());
            }
        }