예제 #1
0
    //****************************************************************************80

    private static void triangle01_monomial_integral_test()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    TRIANGLE01_MONOMIAL_INTEGRAL_TEST estimates integrals over the unit triangle.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    21 April 2015
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        int d;

        Console.WriteLine("");
        Console.WriteLine("TRIANGLE01_MONOMIAL_INTEGRAL_TEST");
        Console.WriteLine("  TRIANGLE01_MONOMIAL_INTEGRAL returns the integral Q of");
        Console.WriteLine("  a monomial X^I Y^J over the interior of the unit triangle.");

        Console.WriteLine("");
        Console.WriteLine("   I   J         Q(I,J)");

        for (d = 0; d <= 5; d++)
        {
            Console.WriteLine("");
            int i;
            for (i = 0; i <= d; i++)
            {
                int    j = d - i;
                double q = Integrals.triangle01_monomial_integral(i, j);
                Console.WriteLine("  " + i.ToString(InvariantCulture).PadLeft(2)
                                  + "  " + j.ToString(InvariantCulture).PadLeft(2)
                                  + "  " + q + "");
            }
        }
    }
예제 #2
0
    private static void triangle01_poly_integral_test()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    TRIANGLE01_POLY_INTEGRAL_TEST: polynomial integrals over the unit triangle.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    21 April 2015
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        int d_max = 6;
        int d1    = 1;
        int d2    = 2;
        int d3    = 2;

        int i = 0;
        int j = 0;
        int k;
        int m_max = (d_max + 1) * (d_max + 2) / 2;
        int m1    = (d1 + 1) * (d1 + 2) / 2;
        int m2    = (d2 + 1) * (d2 + 2) / 2;
        int m3    = (d3 + 1) * (d3 + 2) / 2;

        double[] p1 =
        {
            1.0, 2.0, 3.0
        }

        ;
        double[] p2 =
        {
            0.0, 0.0, 0.0, 0.0, 1.0, 0.0
        }

        ;
        double[] p3 =
        {
            1.0, -2.0, 3.0, -4.0, 5.0, -6.0
        }

        ;
        double[] qm = new double[28];

        for (k = 1; k <= m_max; k++)
        {
            typeMethods.i4_to_pascal(k, ref i, ref j);
            int km1 = k - 1;
            qm[km1] = Integrals.triangle01_monomial_integral(i, j);
        }

        Console.WriteLine("");
        Console.WriteLine("TRIANGLE01_POLY_INTEGRAL_TEST");
        Console.WriteLine("  TRIANGLE01_POLY_INTEGRAL returns the integral Q of");
        Console.WriteLine("  a polynomial P(X,Y) over the interior of the unit triangle.");

        Console.WriteLine("");
        typeMethods.poly_print(d1, ref p1, "  p(x,y)");
        double q = Integrals.triangle01_poly_integral(d1, p1);

        Console.WriteLine("");
        Console.WriteLine("  Q =         " + q + "");
        double q2 = typeMethods.r8vec_dot_product(m1, p1, qm);

        Console.WriteLine("  Q (exact) = " + q2 + "");

        Console.WriteLine("");
        typeMethods.poly_print(d2, ref p2, "  p(x,y)");
        q = Integrals.triangle01_poly_integral(d2, p2);
        Console.WriteLine("");
        Console.WriteLine("  Q =         " + q + "");
        q2 = typeMethods.r8vec_dot_product(m2, p2, qm);
        Console.WriteLine("  Q (exact) = " + q2 + "");

        Console.WriteLine("");
        typeMethods.poly_print(d3, ref p3, "  p(x,y)");
        q = Integrals.triangle01_poly_integral(d3, p3);
        Console.WriteLine("");
        Console.WriteLine("  Q =         " + q + "");
        q2 = typeMethods.r8vec_dot_product(m3, p3, qm);
        Console.WriteLine("  Q (exact) = " + q2 + "");
    }