예제 #1
0
    public static void pmns_polynomial_value_test()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    PMNS_POLYNOMIAL_VALUE_TEST tests PMNS_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("PMNS_POLYNOMIAL_VALUE_TEST:");
        Console.WriteLine("  PMNS_POLYNOMIAL_VALUE evaluates the Legendre polynomial Pmns(n,m,x).");
        Console.WriteLine("");
        Console.WriteLine("                             Tabulated                 Computed");
        Console.WriteLine(
            "     N     M        X       Pmns(N,M,X)                Pmns(N,M,X)                     Error");
        Console.WriteLine("");

        int n_data = 0;

        for (;;)
        {
            Burkardt.Values.Legendre.pmns_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.pmns_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) + "");
        }
    }