Exemplo n.º 1
0
    private static void hpp_test015()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    HPP_TEST015 tests HEP_COEFFICIENTS.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    22 October 2014
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        double[] c;
        int[]    e;
        int[]    f;
        int[]    l = new int[1];
        int      m;
        int      n;
        int      o;
        int      o_max;
        string   title;

        m = 1;

        Console.WriteLine("");
        Console.WriteLine("HPP_TEST015:");
        Console.WriteLine("  HEP_COEFFICIENTS computes the coefficients and");
        Console.WriteLine("  exponents of the Hermite polynomial He(n,x).");

        for (n = 1; n <= 5; n++)
        {
            o = (n + 2) / 2;
            c = new double[o];
            e = new int[o];
            f = new int[o];

            Hermite.hep_coefficients(n, ref o, ref c, ref f);

            l[0]  = n;
            o_max = o;

            Hermite.hepp_to_polynomial(m, l, o_max, o, ref c, ref e);

            Console.WriteLine("");
            title = "  He(" + n + ",x) =";
            Polynomial.polynomial_print(m, o, c, e, title);
        }
    }
Exemplo n.º 2
0
    private static void hpp_test04()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    HPP_TEST04 tests HEPP_TO_POLYNOMIAL.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    22 October 2014
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        double[] c;
        int[]    e;
        int      i;

        int[]  l;
        string label;
        int    m = 2;
        int    o = 0;
        int    o_max;
        int    rank;

        Console.WriteLine("");
        Console.WriteLine("HPP_TEST04:");
        Console.WriteLine("  HEPP_TO_POLYNOMIAL is given a Hermite product polynomial");
        Console.WriteLine("  and determines its polynomial representation.");

        Console.WriteLine("");
        Console.WriteLine("  Using spatial dimension M = " + m + "");

        for (rank = 1; rank <= 11; rank++)
        {
            l = Comp.comp_unrank_grlex(m, rank);

            o_max = 1;
            for (i = 0; i < m; i++)
            {
                o_max = o_max * (l[i] + 2) / 2;
            }

            c = new double[o_max];
            e = new int[o_max];

            Hermite.hepp_to_polynomial(m, l, o_max, o, ref c, ref e);

            label = "  HePP #" + rank
                    + " = He(" + l[0]
                    + ",X)*He(" + l[1]
                    + ",Y) =";

            Console.WriteLine("");
            Polynomial.polynomial_print(m, o, c, e, label);
        }
    }
Exemplo n.º 3
0
    private static void hpp_test03()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    HPP_TEST03 tests HEPP_VALUE.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    22 October 2014
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        double[] c;
        int[]    e;
        int      i;

        int[] l;
        int   m = 3;
        int   n = 1;
        int   o = 0;
        int   o_max;
        int   rank;
        int   seed;

        double[] v1;
        double[] v2;
        double[] x;
        double   xhi;
        double   xlo;
        string   cout = "";

        Console.WriteLine("");
        Console.WriteLine("HPP_TEST03:");
        Console.WriteLine("  HEPP_VALUE evaluates a Hermite product polynomial.");
        Console.WriteLine("  POLYNOMIAL_VALUE evaluates a polynomial.");

        xlo  = -1.0;
        xhi  = +1.0;
        seed = 123456789;
        x    = UniformRNG.r8vec_uniform_ab_new(m, xlo, xhi, ref seed);

        Console.WriteLine("");
        cout = "  Evaluate at X = ";
        for (i = 0; i < m; i++)
        {
            cout += "  " + x[i + 0 * m];
        }

        Console.WriteLine(cout);
        Console.WriteLine("");
        Console.WriteLine("  Rank  I1  I2  I3:  He(I1,X1)*He(I2,X2)*He(I3,X3)    P(X1,X2,X3)");
        Console.WriteLine("");

        for (rank = 1; rank <= 20; rank++)
        {
            l = Comp.comp_unrank_grlex(m, rank);
            //
            //  Evaluate the HePP directly.
            //
            v1 = Hermite.hepp_value(m, n, l, x);
            //
            //  Convert the HePP to a polynomial.
            //
            o_max = 1;
            for (i = 0; i < m; i++)
            {
                o_max = o_max * (l[i] + 2) / 2;
            }

            c = new double[o_max];
            e = new int[o_max];

            Hermite.hepp_to_polynomial(m, l, o_max, o, ref c, ref e);
            //
            //  Evaluate the polynomial.
            //
            v2 = Polynomial.polynomial_value(m, o, c, e, n, x);
            //
            //  Compare results.
            //
            Console.WriteLine(rank.ToString().PadLeft(6) + "  "
                              + l[0].ToString().PadLeft(2) + "  "
                              + l[1].ToString().PadLeft(2) + "  "
                              + l[2].ToString().PadLeft(2) + "  "
                              + v1[0].ToString().PadLeft(14) + "  "
                              + v2[0].ToString().PadLeft(14) + "");
        }
    }