Beispiel #1
0
    public static void gegenbauer_poly_test( )

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    GEGENBAUER_POLY_TEST tests GEGENBAUER_POLY.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    23 May 2007
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        double a  = 0;
        double fx = 0;
        int    n  = 0;
        double x  = 0;

        Console.WriteLine("");
        Console.WriteLine("GEGENBAUER_POLY_TEST");
        Console.WriteLine("  GEGENBAUER_POLY evaluates the Gegenbauer polynomials.");
        Console.WriteLine("");
        Console.WriteLine("        N       A       X       GPV      GEGENBAUER");
        Console.WriteLine("");

        int n_data = 0;

        for ( ; ;)
        {
            Burkardt.Values.Gegenbauer.gegenbauer_poly_values(ref n_data, ref n, ref a, ref x, ref fx);

            if (n_data == 0)
            {
                break;
            }

            double[] c = new double[n + 1];

            GegenbauerPolynomial.gegenbauer_poly(n, a, x, c);
            double fx2 = c[n];

            Console.WriteLine("  "
                              + n.ToString(CultureInfo.InvariantCulture).PadLeft(6) + "  "
                              + a.ToString(CultureInfo.InvariantCulture).PadLeft(10) + "  "
                              + x.ToString(CultureInfo.InvariantCulture).PadLeft(10) + "  "
                              + fx.ToString(CultureInfo.InvariantCulture).PadLeft(14) + "  "
                              + fx2.ToString(CultureInfo.InvariantCulture).PadLeft(14) + "");
        }
    }
Beispiel #2
0
    private static void gegenbauer_ek_compute_test()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    GEGENBAUER_EK_COMPUTE_TEST tests GEGENBAUER_EK_COMPUTE.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    20 November 2015
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        double alpha;
        int    i;
        int    n;

        double[] w;
        double[] x;

        alpha = 0.5;

        Console.WriteLine("");
        Console.WriteLine("GEGENBAUER_EK_COMPUTE_TEST");
        Console.WriteLine("  GEGENBAUER_EK_COMPUTE computes a Gauss-Gegenbauer rule;");
        Console.WriteLine("");
        Console.WriteLine("  with ALPHA = " + alpha + "");
        Console.WriteLine("  and integration interval [-1,+1]");
        Console.WriteLine("");
        Console.WriteLine("                  W               X");

        for (n = 1; n <= 10; n++)
        {
            Console.WriteLine("");

            w = new double[n];
            x = new double[n];

            GegenbauerPolynomial.gegenbauer_ek_compute(n, alpha, ref x, ref w);

            for (i = 0; i < n; i++)
            {
                Console.WriteLine("          "
                                  + "  " + w[i].ToString("0.################").PadLeft(14)
                                  + "  " + x[i].ToString("0.################").PadLeft(14) + "");
            }
        }
    }
Beispiel #3
0
    private static void gegenbauer_alpha_check_test()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    GEGENBAUER_ALPHA_CHECK_TEST compares GEGENBAUER_ALPHA_CHECK.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    30 November 2015
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        double alpha;
        bool   check;
        int    n;
        int    seed;

        Console.WriteLine("");
        Console.WriteLine("GEGENBAUER_ALPHA_CHECK_TEST");
        Console.WriteLine("  GEGENBAUER_ALPHA_CHECK checks that ALPHA is legal;");
        Console.WriteLine("");
        Console.WriteLine("       ALPHA   Check?");
        Console.WriteLine("");

        seed = 123456789;

        for (n = 1; n <= 10; n++)
        {
            alpha = UniformRNG.r8_uniform_ab(-5.0, +5.0, ref seed);
            check = GegenbauerPolynomial.gegenbauer_alpha_check(alpha);
            Console.WriteLine("  " + alpha.ToString().PadLeft(10)
                              + "       " + check.ToString().PadLeft(1) + "");
        }
    }
Beispiel #4
0
    private static void gegenbauer_polynomial_value_test()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    GEGENBAUER_POLYNOMIAL_VALUE_TEST tests GEGENBAUER_POLYNOMIAL_VALUE.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    30 November 2015
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        double alpha = 0;

        double[] c;
        double   fx = 0;
        int      m  = 0;
        int      n  = 0;
        int      n_data;

        double[] x       = new double[1];
        double   xscalar = 0;

        Console.WriteLine("");
        Console.WriteLine("GEGENBAUER_POLYNOMIAL_VALUE_TEST:");
        Console.WriteLine("  GEGENBAUER_POLYNOMIAL_VALUE evaluates the Gegenbauer polynomial.");
        Console.WriteLine("");
        Console.WriteLine("       M     ALPHA         X           GPV    GEGENBAUER");
        Console.WriteLine("");

        n_data = 0;

        for (;;)
        {
            Burkardt.Values.Gegenbauer.gegenbauer_poly_values(ref n_data, ref m, ref alpha, ref xscalar, ref fx);

            if (n_data == 0)
            {
                break;
            }

            //
            //  Since GEGENBAUER_POLYNOMIAL_VALUE expects a vector input X, we have to
            //  do a little "rewrapping" of the input.
            //
            n    = 1;
            x[0] = xscalar;
            c    = GegenbauerPolynomial.gegenbauer_polynomial_value(m, n, alpha, x);
            Console.WriteLine("  " + m.ToString("0.################").PadLeft(6)
                              + "  " + alpha.ToString("0.################").PadLeft(8)
                              + "  " + x[0].ToString("0.################").PadLeft(8)
                              + "  " + fx.ToString("0.################").PadLeft(12)
                              + "  " + c[m + 0 * (m + 1)].ToString("0.################").PadLeft(12) + "");
        }
    }