Ejemplo n.º 1
0
    private static void lobatto_polynomial_value_test()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    LOBATTO_POLYNOMIAL_VALUE_TEST tests LOBATTO_POLYNOMIAL_VALUE.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    20 November 2014
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        double fx1 = 0;
        int    n   = 0;
        double x   = 0;

        double[] xvec = new double[1];

        const int m = 1;

        Console.WriteLine("");
        Console.WriteLine("LOBATTO_POLYNOMIAL_VALUE_TEST:");
        Console.WriteLine("  LOBATTO_POLYNOMIAL_VALUES stores values of");
        Console.WriteLine("  the completed Lobatto polynomial L(n,x).");
        Console.WriteLine("  LOBATTO_POLYNOMIAL_VALUE evaluates the completed Lobatto polynomial.");
        Console.WriteLine("");
        Console.WriteLine("                                       Tabulated                 Computed");
        Console.WriteLine("     N        X                        L(N,X)                    L(N,X)        Error");
        Console.WriteLine("");

        int n_data = 0;

        for (;;)
        {
            Lobatto.lobatto_polynomial_values(ref n_data, ref n, ref x, ref fx1);

            if (n_data == 0)
            {
                break;
            }

            xvec[0] = x;

            double[] l = Lobatto.lobatto_polynomial_value(m, n, xvec);

            double fx2 = l[0 + (n - 1) * m];

            double e = fx1 - fx2;

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