Example #1
0
    private static void halton_test()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    HALTON_TEST tests HALTON.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    19 August 2016
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        int m;

        Console.WriteLine("");
        Console.WriteLine("HALTON_TEST");
        Console.WriteLine("  HALTON returns the I-th element of an M-dimensional");
        Console.WriteLine("  Halton sequence.");
        Console.WriteLine("");
        Console.WriteLine("    I          HALTON(I)");

        for (m = 1; m <= 3; m++)
        {
            Console.WriteLine("");
            Console.WriteLine("  Use M = " + m + "");
            Console.WriteLine("");
            int i;
            for (i = 0; i <= 10; i++)
            {
                double[] r    = Halton.halton(i, m);
                string   cout = "  " + i.ToString(CultureInfo.InvariantCulture).PadLeft(3);
                int      j;
                for (j = 0; j < m; j++)
                {
                    cout += "  " + r[j].ToString(CultureInfo.InvariantCulture).PadLeft(14);
                }

                Console.WriteLine(cout);
            }
        }
    }
Example #2
0
    private static void halton_inverse_test()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    HALTON_INVERSE_TEST tests HALTON_INVERSE.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    19 August 2016
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        int i;

        Console.WriteLine("");
        Console.WriteLine("HALTON_INVERSE_TEST");
        Console.WriteLine("  HALTON_INVERSE inverts an element of a Halton sequence.");
        Console.WriteLine("");
        Console.WriteLine("    I        R=HALTON(I,3)  HALTON_INVERSE(R,3)");
        Console.WriteLine("");

        int m = 3;

        for (i = 0; i <= 10; i++)
        {
            double[] r    = Halton.halton(i, m);
            int      i2   = Halton.halton_inverse(r, m);
            string   cout = "  " + i.ToString(CultureInfo.InvariantCulture).PadLeft(3);
            int      j;
            for (j = 0; j < m; j++)
            {
                cout += "  " + r[j].ToString(CultureInfo.InvariantCulture).PadLeft(14);
            }

            Console.WriteLine(cout + "  " + i2.ToString(CultureInfo.InvariantCulture).PadLeft(3) + "");
        }
    }