Esempio n. 1
0
    public static void perm0_to_equiv_test()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    PERM0_TO_EQUIV_TEST tests PERM0_TO_EQUIV.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    15 June 2015
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        int[]     a      = new int[9];
        int[]     jarray = new int[9];
        const int n      = 9;
        int       npart  = 0;

        int[] p = { 1, 2, 8, 5, 6, 7, 4, 3, 0 };

        Console.WriteLine("");
        Console.WriteLine("PERM0_TO_EQUIV_TEST");
        Console.WriteLine("  PERM0_TO_EQUIV returns the set partition");
        Console.WriteLine("  or equivalence classes determined by a");
        Console.WriteLine("  permutation of (0,...,N-1).");

        Permutation.perm0_print(n, p, "  The input permutation:");

        Permutation.perm0_to_equiv(n, p, ref npart, ref jarray, ref a);

        Equiv.equiv_print(n, a, "  The partition:");
    }
Esempio n. 2
0
    public static void equiv_random_test()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    EQUIV_RANDOM_TEST tests EQUIV_RANDOM.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    15 May 2009
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        int[]     a = new int[4];
        int       i;
        const int n     = 4;
        int       npart = 0;

        Console.WriteLine("");
        Console.WriteLine("EQUIV_RANDOM_TEST");
        Console.WriteLine("  EQUIV_RANDOM selects a random set partition.");

        int seed = 123456789;

        for (i = 1; i <= 5; i++)
        {
            Equiv.equiv_random(n, ref seed, ref npart, ref a);

            Equiv.equiv_print(n, a, "  The partition:");
        }
    }