Beispiel #1
0
    public static double[] ortho2eva0(int mmax, double[] z)

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    ORTHO2EVA0 evaluates the orthonormal polynomials on the triangle.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU GPL license.
    //
    //  Modified:
    //
    //    30 June 2014
    //
    //  Author:
    //
    //    Original FORTRAN77 version by Hong Xiao, Zydrunas Gimbutas.
    //    C++ version by John Burkardt.
    //
    //  Reference:
    //
    //    Hong Xiao, Zydrunas Gimbutas,
    //    A numerical algorithm for the construction of efficient quadrature
    //    rules in two and higher dimensions,
    //    Computers and Mathematics with Applications,
    //    Volume 59, 2010, pages 663-676.
    //
    //  Parameters:
    //
    //    Input, int MMAX, the maximum order to which the polynomials are
    //    to be evaluated.
    //
    //    Input, double Z[2], the coordinates of the evaluation point.
    //
    //    Output, double ORTHO2EVA0[(mmax+1)*(mmax+2)/2], the orthogonal
    //    polynomials evaluated at the point Z.
    //
    {
        int m;

        int npols = (mmax + 1) * (mmax + 2) / 2;

        double[] pols = new double[npols];

        const double zero  = 0.0;
        double       sqrt3 = Math.Sqrt(3.0);
        const double r11   = -1.0 / 3.0;
        double       r12   = -1.0 / sqrt3;
        const double r21   = -1.0 / 3.0;
        double       r22   = 2.0 / sqrt3;

        double a = z[0];
        double b = z[1];
        //
        //  Map the reference triangle to the right
        //  triangle with the vertices (-1,-1), (1,-1), (-1,1)
        //
        double x = r11 + r12 * b + a;
        double y = r21 + r22 * b;
        //
        //  Evaluate the Koornwinder's polynomials via the three term recursion.
        //
        double par1 = (2.0 * x + 1.0 + y) / 2.0;
        double par2 = (1.0 - y) / 2.0;

        double[] f1 = LegendreScaled.klegeypols(par1, par2, mmax);

        double[] f2 = new double[(mmax + 1) * (mmax + 1)];

        for (m = 0; m <= mmax; m++)
        {
            par1 = 2 * m + 1;
            Jacobi.kjacopols(y, par1, zero, mmax - m, ref f2, polsIndex: +m * (mmax + 1));
        }

        int kk = 0;

        for (m = 0; m <= mmax; m++)
        {
            int n;
            for (n = 0; n <= m; n++)
            {
                //
                //  Evaluate the polynomial (m-n, n)
                //
                pols[kk] = f1[m - n] * f2[n + (m - n) * (mmax + 1)];
                //
                //  Normalize.
                //
                double scale = Math.Sqrt
                                   ((1 + (m - n) + n) * (1 + (m - n) + (m - n)) / sqrt3
                                   );

                pols[kk] *= scale;
                kk       += 1;
            }
        }

        return(pols);
    }