コード例 #1
0
    private static void test06()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    TEST06 tests L1DD_LU and similar routines.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    02 November 2013
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        const int n = 5;
        int       test;

        Console.WriteLine("");
        Console.WriteLine("TEST06");
        Console.WriteLine("  Compute LU factors for the Laplacian:");
        Console.WriteLine("  L1DD_LU for Dirichlet/Dirichlet BC;");
        Console.WriteLine("  L1DN_LU for Dirichlet/Neumann BC;");
        Console.WriteLine("  L1ND_LU for Neumann/Dirichlet BC;");
        Console.WriteLine("  L1NN_LU for Neumann/Neumann BC;");
        Console.WriteLine("  L1PP_LU for Periodic BC;");

        double[] l = new double[n * n];
        double[] u = new double[n * n];

        for (test = 1; test <= 2; test++)
        {
            double h = test switch
            {
                1 => 1.0,
                _ => 1.0 / (n + 1)
            };

            Console.WriteLine("");
            Console.WriteLine("  Using spacing H = " + h + "");

            double[] a = L1DD.l1dd(n, h);
            L1DD.l1dd_lu(n, h, ref l, ref u);
            typeMethods.r8mat_print(n, n, l, "  L1DD L factor:");
            typeMethods.r8mat_print(n, n, u, "  L1DD U factor:");
            double err = LU.lu_error(n, a, l, u);
            Console.WriteLine("");
            Console.WriteLine("  L1DD LU error = " + err + "");

            a = L1DN.l1dn(n, h);
            L1DN.l1dn_lu(n, h, ref l, ref u);
            typeMethods.r8mat_print(n, n, l, "  L1DN L factor:");
            typeMethods.r8mat_print(n, n, u, "  L1DN U factor:");
            err = LU.lu_error(n, a, l, u);
            Console.WriteLine("");
            Console.WriteLine("  L1DN LU error = " + err + "");

            a = L1ND.l1nd(n, h);
            L1ND.l1nd_lu(n, h, ref l, ref u);
            typeMethods.r8mat_print(n, n, l, "  L1ND L factor:");
            typeMethods.r8mat_print(n, n, u, "  L1ND U factor:");
            err = LU.lu_error(n, a, l, u);
            Console.WriteLine("");
            Console.WriteLine("  L1ND LU error = " + err + "");

            a = L1NN.l1nn(n, h);
            L1NN.l1nn_lu(n, h, ref l, ref u);
            typeMethods.r8mat_print(n, n, l, "  L1NN L factor:");
            typeMethods.r8mat_print(n, n, u, "  L1NN U factor:");
            err = LU.lu_error(n, a, l, u);
            Console.WriteLine("");
            Console.WriteLine("  L1NN LU error = " + err + "");

            a = L1PP.l1pp(n, h);
            L1PP.l1pp_lu(n, h, ref l, ref u);
            typeMethods.r8mat_print(n, n, l, "  L1PP L factor:");
            typeMethods.r8mat_print(n, n, u, "  L1PP U factor:");
            err = LU.lu_error(n, a, l, u);
            Console.WriteLine("");
            Console.WriteLine("  L1PP LU error = " + err + "");
        }
    }
}