Пример #1
0
    private static void test10()

    //*****************************************************************************/
    //
    //  Purpose:
    //
    //    TEST10 tests GM_GENERAL_RULE_SET.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    03 March 2017
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        int[] e      = new int[3];
        int[] e_test =
        {
            0, 0, 0,
            1, 0, 0,
            0, 1, 0,
            0, 0, 1,
            2, 0, 0,
            1, 1, 0,
            1, 0, 1,
            0, 2, 0,
            0, 1, 1,
            0, 0, 2
        };
        int       i;
        int       j;
        const int m = 3;
        int       rule;

        double[] t =
        {
            1.0, 0.0, 0.0,
            2.0, 0.0, 0.0,
            1.0, 2.0, 0.0,
            1.0, 0.0, 3.0
        };
        string cout;

        Console.WriteLine("");
        Console.WriteLine("TEST10");
        Console.WriteLine("  GM_GENERAL_RULE_SET determines the weights and abscissas");
        Console.WriteLine("  of a Grundmann-Moeller quadrature rule for");
        Console.WriteLine("  the M dimensional general simplex,");
        Console.WriteLine("  using a rule of index RULE,");
        Console.WriteLine("  which will have degree of exactness 2*RULE+1.");

        Console.WriteLine("");
        Console.WriteLine("  In this test, look at all the monomials up to");
        Console.WriteLine("  some maximum degree, choose a few low order rules");
        Console.WriteLine("  and determine the quadrature error for each.");

        Console.WriteLine("");
        Console.WriteLine("  Simplex vertices:");
        Console.WriteLine("");
        for (j = 0; j < 4; j++)
        {
            cout = "";
            for (i = 0; i < 3; i++)
            {
                cout += "  " + t[i + j * 3].ToString(CultureInfo.InvariantCulture).PadLeft(14);
            }

            Console.WriteLine(cout);
        }

        double volume = Simplex.simplex_general_volume(m, t);

        Console.WriteLine("");
        Console.WriteLine("  Simplex volume = " + volume + "");

        Console.WriteLine("");
        Console.WriteLine("  Here we use M = " + m + "");

        Console.WriteLine("");
        Console.WriteLine("         N        1               X               Y " +
                          "              Z               X^2              XY             XZ" +
                          "              Y^2             YZ               Z^2");
        Console.WriteLine("");

        for (rule = 0; rule <= 5; rule++)
        {
            int n = GrundmannMoellerRule.gm_rule_size(rule, m);

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

            GrundmannMoellerRule.gm_general_rule_set(rule, m, n, t, ref w, ref x);

            cout = "  " + n.ToString().PadLeft(8);

            int k;
            for (k = 0; k < 10; k++)
            {
                for (i = 0; i < m; i++)
                {
                    e[i] = e_test[i + k * m];
                }

                double[] value = Monomial.monomial_value(m, n, e, x);

                double result = typeMethods.r8vec_dot_product(n, w, value);

                cout += "  " + result.ToString(CultureInfo.InvariantCulture).PadLeft(14);
            }

            Console.WriteLine(cout);
        }
    }
Пример #2
0
    private static void test08()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    TEST08 tests GM_GENERAL_RULE_SET.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    03 March 2017
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        int i;
        int j;

        double[] t =
        {
            1.0, 0.0, 0.0,
            2.0, 0.0, 0.0,
            1.0, 2.0, 0.0,
            1.0, 0.0, 3.0
        };
        string cout;

        Console.WriteLine("");
        Console.WriteLine("TEST08");
        Console.WriteLine("  GM_GENERAL_RULE_SET determines the weights and abscissas");
        Console.WriteLine("  of a Grundmann-Moeller quadrature rule for");
        Console.WriteLine("  the M dimensional general simplex,");
        Console.WriteLine("  using a rule of index RULE,");
        Console.WriteLine("  which will have degree of exactness 2*RULE+1.");

        const int m    = 3;
        const int rule = 2;

        Console.WriteLine("");
        Console.WriteLine("  Here we use M = " + m + "");
        Console.WriteLine("  RULE = " + rule + "");
        Console.WriteLine("  DEGREE = " + 2 * rule + 1 + "");

        Console.WriteLine("");
        Console.WriteLine("  Simplex vertices:");
        Console.WriteLine("");
        for (j = 0; j < 4; j++)
        {
            cout = "";
            for (i = 0; i < 3; i++)
            {
                cout += "  " + t[i + j * 3].ToString(CultureInfo.InvariantCulture).PadLeft(14);
            }

            Console.WriteLine(cout);
        }

        int n = GrundmannMoellerRule.gm_rule_size(rule, m);

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

        GrundmannMoellerRule.gm_general_rule_set(rule, m, n, t, ref w, ref x);

        Console.WriteLine("");
        Console.WriteLine("     POINT        W             X             Y             Z");
        Console.WriteLine("");

        for (j = 0; j < n; j++)
        {
            cout = "  " + j.ToString().PadLeft(8)
                   + "  " + w[j].ToString(CultureInfo.InvariantCulture).PadLeft(12);
            for (i = 0; i < m; i++)
            {
                cout += "  " + x[i + j * m].ToString(CultureInfo.InvariantCulture).PadLeft(12);
            }

            Console.WriteLine(cout);
        }
    }