Beispiel #1
0
    private static void test14()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    TEST14 demonstrates R_JACOBI.
    //
    //  Discussion:
    //
    //    R_JACOBI returns recursion coefficients ALPHA and BETA for rules
    //    using a Jacobi type weight w(x) = (1-x)^A * (1+x)^B.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    17 July 2013
    //
    //  Author:
    //
    //    John Burkardt
    //
    //  Reference
    //
    //    Walter Gautschi,
    //    Orthogonal Polynomials: Computation and Approximation,
    //    Oxford, 2004,
    //    ISBN: 0-19-850672-4,
    //    LC: QA404.5 G3555.
    //
    {
        int i;

        Console.WriteLine("");
        Console.WriteLine("TEST14");
        Console.WriteLine("  R_JACOBI computes recursion coefficients ALPHA and BETA");
        Console.WriteLine("  Gauss quadrature rule, given the ALPHA and BETA");
        Console.WriteLine("  recursion coefficients.");
        //
        //  Legendre rule.
        //
        int n = 10;

        double a = 0.0;
        double b = 0.0;

        double[] alpha = new double[n];
        double[] beta  = new double[n];

        Jacobi.r_jacobi(n, a, b, ref alpha, ref beta);

        Console.WriteLine("");
        Console.WriteLine("  Legendre weight");
        Console.WriteLine("  A = " + a + ",  B = " + b + "");
        Console.WriteLine("  Alpha          Beta");
        Console.WriteLine("");
        for (i = 0; i < n; i++)
        {
            Console.WriteLine("  " + alpha[i].ToString(CultureInfo.InvariantCulture).PadLeft(14)
                              + "  " + beta[i].ToString(CultureInfo.InvariantCulture).PadLeft(14) + "");
        }

        //
        //  Chebyshev Type 1 rule.
        //
        n = 10;

        a     = -0.5;
        b     = -0.5;
        alpha = new double[n];
        beta  = new double[n];

        Jacobi.r_jacobi(n, a, b, ref alpha, ref beta);

        Console.WriteLine("");
        Console.WriteLine("  Chebyshev Type 1 weight");
        Console.WriteLine("  A = " + a + ",  B = " + b + "");
        Console.WriteLine("  Alpha          Beta");
        Console.WriteLine("");
        for (i = 0; i < n; i++)
        {
            Console.WriteLine("  " + alpha[i].ToString(CultureInfo.InvariantCulture).PadLeft(14)
                              + "  " + beta[i].ToString(CultureInfo.InvariantCulture).PadLeft(14) + "");
        }

        //
        //  Chebyshev Type 2 rule.
        //
        n = 10;

        a     = +0.5;
        b     = +0.5;
        alpha = new double[n];
        beta  = new double[n];

        Jacobi.r_jacobi(n, a, b, ref alpha, ref beta);

        Console.WriteLine("");
        Console.WriteLine("  Chebyshev Type 2 weight");
        Console.WriteLine("  A = " + a + ",  B = " + b + "");
        Console.WriteLine("  Alpha          Beta");
        Console.WriteLine("");
        for (i = 0; i < n; i++)
        {
            Console.WriteLine("  " + alpha[i].ToString(CultureInfo.InvariantCulture).PadLeft(14)
                              + "  " + beta[i].ToString(CultureInfo.InvariantCulture).PadLeft(14) + "");
        }

        //
        //  General Jacobi rule.
        //
        n = 10;

        a     = +0.5;
        b     = +1.5;
        alpha = new double[n];
        beta  = new double[n];

        Jacobi.r_jacobi(n, a, b, ref alpha, ref beta);

        Console.WriteLine("");
        Console.WriteLine("  General Jacobi weight");
        Console.WriteLine("  A = " + a + ",  B = " + b + "");
        Console.WriteLine("  Alpha          Beta");
        Console.WriteLine("");
        for (i = 0; i < n; i++)
        {
            Console.WriteLine("  " + alpha[i].ToString(CultureInfo.InvariantCulture).PadLeft(14)
                              + "  " + beta[i].ToString(CultureInfo.InvariantCulture).PadLeft(14) + "");
        }
    }