Beispiel #1
0
    private static void test05()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    TEST05 tests CYCLE_BRENT for F5.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    17 June 2012
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        int lam = 0;
        int mu  = 0;

        Console.WriteLine("");
        Console.WriteLine("TEST05");
        Console.WriteLine("  Test CYCLE_BRENT for F5().");
        Console.WriteLine("  f5(i) = mod ( 16383 * i + 1, 65536 ).");

        int x0 = 1;

        Console.WriteLine("");
        Console.WriteLine("  Starting argument X0 = " + x0 + "");

        Brent.cycle_brent(f5, x0, ref lam, ref mu);

        Console.WriteLine("");
        Console.WriteLine("  Reported cycle length is " + lam + "");
        Console.WriteLine("  Expected value is 8");
        Console.WriteLine("");
        Console.WriteLine("  Reported distance to first cycle element is " + mu + "");
        Console.WriteLine("  Expected value is 0");

        int i = 0;

        x0 = 1;
        Console.WriteLine("  " + i + "  " + x0 + "");
        for (i = 1; i <= 10; i++)
        {
            x0 = f5(x0);
            Console.WriteLine("  " + i + "  " + x0 + "");
        }
    }
Beispiel #2
0
    private static void test01()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    TEST01 tests CYCLE_BRENT for a tiny example.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    17 June 2012
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        int lam = 0;
        int mu  = 0;

        Console.WriteLine("");
        Console.WriteLine("TEST01");
        Console.WriteLine("  Test CYCLE_BRENT on F1().");
        Console.WriteLine("  f1(0) = 6.");
        Console.WriteLine("  f1(1) = 6.");
        Console.WriteLine("  f1(2) = 0.");
        Console.WriteLine("  f1(3) = 1.");
        Console.WriteLine("  f1(4) = 4.");
        Console.WriteLine("  f1(5) = 3.");
        Console.WriteLine("  f1(6) = 3.");
        Console.WriteLine("  f1(7) = 4.");
        Console.WriteLine("  f1(8) = 0.");

        const int x0 = 2;

        Console.WriteLine("");
        Console.WriteLine("  Starting argument X0 = " + x0 + "");

        Brent.cycle_brent(f1, x0, ref lam, ref mu);

        Console.WriteLine("");
        Console.WriteLine("  Reported cycle length is " + lam + "");
        Console.WriteLine("  Expected value is 3");
        Console.WriteLine("");
        Console.WriteLine("  Reported distance to first cycle element is " + mu + "");
        Console.WriteLine("  Expected value is 2");
    }
Beispiel #3
0
    private static void test04()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    TEST04 tests CYCLE_BRENT for F4.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    17 June 2012
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        int lam = 0;
        int mu  = 0;

        Console.WriteLine("");
        Console.WriteLine("TEST04");
        Console.WriteLine("  Test CYCLE_BRENT for F4().");
        Console.WriteLine("  f4(i) = mod ( 31421 * i + 6927, 65536 ).");

        const int x0 = 1;

        Console.WriteLine("");
        Console.WriteLine("  Starting argument X0 = " + x0 + "");

        Brent.cycle_brent(f4, x0, ref lam, ref mu);

        Console.WriteLine("");
        Console.WriteLine("  Reported cycle length is " + lam + "");
        Console.WriteLine("  Expected value is 65536");
        Console.WriteLine("");
        Console.WriteLine("  Reported distance to first cycle element is " + mu + "");
        Console.WriteLine("  Expected value is 0");
    }
Beispiel #4
0
    private static void test03()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    TEST03 tests CYCLE_BRENT for F3.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    14 June 2012
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        int lam = 0;
        int mu  = 0;

        Console.WriteLine("");
        Console.WriteLine("TEST03");
        Console.WriteLine("  Test CYCLE_BRENT for F3().");
        Console.WriteLine("  f3(i) = mod ( 123 * i + 456, 100000 ).");

        const int x0 = 789;

        Console.WriteLine("");
        Console.WriteLine("  Starting argument X0 = " + x0 + "");

        Brent.cycle_brent(f3, x0, ref lam, ref mu);

        Console.WriteLine("");
        Console.WriteLine("  Reported cycle length is " + lam + "");
        Console.WriteLine("  Expected value is 50000");
        Console.WriteLine("");
        Console.WriteLine("  Reported distance to first cycle element is " + mu + "");
        Console.WriteLine("  Expected value is 0");
    }