Exemplo n.º 1
0
    public static void pm_polynomial_value_test()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    PM_POLYNOMIAL_VALUE_TEST tests PM_POLYNOMIAL_VALUE.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    14 March 2012
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        double fx1 = 0;
        int    m   = 0;
        int    n   = 0;
        double x   = 0;

        double[] x_vec = new double[1];

        Console.WriteLine("");
        Console.WriteLine("PM_POLYNOMIAL_VALUE_TEST:");
        Console.WriteLine("  PM_POLYNOMIAL_VALUE evaluates the Legendre polynomial Pm(n,m,x).");
        Console.WriteLine("");
        Console.WriteLine("                             Tabulated                 Computed");
        Console.WriteLine(
            "     N     M        X        Pm(N,M,X)                 Pm(N,M,X)                     Error");
        Console.WriteLine("");

        int n_data = 0;

        for (;;)
        {
            Burkardt.Values.Legendre.pm_polynomial_values(ref n_data, ref n, ref m, ref x, ref fx1);

            if (n_data == 0)
            {
                break;
            }

            x_vec[0] = x;
            double[] fx2_vec = Legendre.pm_polynomial_value(1, n, m, x_vec);
            double   fx2     = fx2_vec[n];

            double e = fx1 - fx2;

            Console.WriteLine("  " + n.ToString(CultureInfo.InvariantCulture).PadLeft(4)
                              + "  " + m.ToString(CultureInfo.InvariantCulture).PadLeft(4)
                              + "  " + x.ToString(CultureInfo.InvariantCulture).PadLeft(12)
                              + "  " + fx1.ToString("0.################").PadLeft(24)
                              + "  " + fx2.ToString("0.################").PadLeft(24)
                              + "  " + e.ToString(CultureInfo.InvariantCulture).PadLeft(8) + "");
        }
    }