示例#1
0
    public static void lp_value_test()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    LP_VALUE_TEST tests LP_VALUE.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    11 September 2014
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        int    o = 0;
        double x = 0;

        double[] xvec = new double[1];
        double   fx1  = 0;

        const int n = 1;

        Console.WriteLine("");
        Console.WriteLine("LP_VALUE_TEST:");
        Console.WriteLine("  LP_VALUE evaluates a Legendre polynomial.");
        Console.WriteLine("");
        Console.WriteLine("                        Tabulated                 Computed");
        Console.WriteLine("     O        X           L(O,X)                    L(O,X)" +
                          "                   Error");
        Console.WriteLine("");

        int n_data = 0;

        for (;;)
        {
            Burkardt.Values.Legendre.lp_values(ref n_data, ref o, ref x, ref fx1);

            if (n_data == 0)
            {
                break;
            }

            xvec[0] = x;

            double[] fx2 = Legendre.lp_value(n, o, xvec);

            double e = fx1 - fx2[0];

            Console.WriteLine(o.ToString(CultureInfo.InvariantCulture).PadLeft(6) + "  "
                              + x.ToString(CultureInfo.InvariantCulture).PadLeft(12) + "  "
                              + fx1.ToString(CultureInfo.InvariantCulture).PadLeft(24) + "  "
                              + fx2[0].ToString(CultureInfo.InvariantCulture).PadLeft(24) + "  "
                              + e.ToString(CultureInfo.InvariantCulture).PadLeft(8) + "");
        }
    }