コード例 #1
0
ファイル: subset.cs プロジェクト: philstopford/DesignLibs_GPL
    private static void subset_complement_test()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    SUBSET_COMPLEMENT_TEST tests SUBSET_COMPLEMENT.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    06 January 2016
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        Console.WriteLine("");
        Console.WriteLine("SUBSET_COMPLEMENT_TEST");
        Console.WriteLine("  SUBSET_COMPLEMENT returns the complement of a subset.");
        Console.WriteLine("");
        const int n    = 5;
        int       seed = 123456789;

        int[] s1 = Subset.subset_random(n, ref seed);
        typeMethods.i4vec_transpose_print(n, s1, "  Subset S1:            ");

        int[] s2 = Subset.subset_complement(n, s1);
        typeMethods.i4vec_transpose_print(n, s2, "  S2 = complement of S1:");
    }
コード例 #2
0
    public static void subset_random_test()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    SUBSET_RANDOM_TEST tests SUBSET_RANDOM.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    05 January 2007
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        const int N = 5;

        int j;

        Console.WriteLine("");
        Console.WriteLine("SUBSET_RANDOM_TEST");
        Console.WriteLine("  SUBSET_RANDOM picks a subset at random.");
        Console.WriteLine("  The number of elements in the main set is " + N + "");
        Console.WriteLine("");

        int seed = 123456789;

        for (j = 1; j <= 5; j++)
        {
            int[] a = Subset.subset_random(N, ref seed);

            string cout = j.ToString().PadLeft(4) + "    ";
            int    i;
            for (i = 0; i < N; i++)
            {
                cout += a[i].ToString().PadLeft(2);
            }

            Console.WriteLine(cout);
        }
    }
コード例 #3
0
ファイル: subset.cs プロジェクト: philstopford/DesignLibs_GPL
    private static void subset_distance_test()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    SUBSET_DISTANCE_TEST tests SUBSET_DISTANCE.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    08 January 2016
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        Console.WriteLine("");
        Console.WriteLine("SUBSET_DISTANCE_TEST");
        Console.WriteLine("  SUBSET_DISTANCE returns the distance between two subsets.");
        Console.WriteLine("");

        const int n    = 5;
        int       seed = 123456789;

        int[] s1 = Subset.subset_random(n, ref seed);
        typeMethods.i4vec_transpose_print(n, s1, "  Subset S1:");

        int[] s2 = Subset.subset_random(n, ref seed);
        typeMethods.i4vec_transpose_print(n, s2, "  Subset S2:");

        int distance = Subset.subset_distance(n, s1, s2);

        Console.WriteLine("");
        Console.WriteLine("  Distance = " + distance + "");
    }
コード例 #4
0
ファイル: subset.cs プロジェクト: philstopford/DesignLibs_GPL
    private static void subset_xor_test()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    SUBSET_XOR_TEST tests SUBSET_XOR.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    09 January 2016
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        Console.WriteLine("");
        Console.WriteLine("SUBSET_XOR_TEST");
        Console.WriteLine("  SUBSET_XOR returns the exclusive OR of two subsets.");
        Console.WriteLine("");

        const int n    = 7;
        int       seed = 123456789;

        int[] s1 = Subset.subset_random(n, ref seed);
        typeMethods.i4vec_transpose_print(n, s1, "  Subset S1:");

        int[] s2 = Subset.subset_random(n, ref seed);
        typeMethods.i4vec_transpose_print(n, s2, "  Subset S2:");

        int[] s3 = Subset.subset_xor(n, s1, s2);
        typeMethods.i4vec_transpose_print(n, s3, "  XOR:      ");
    }
コード例 #5
0
ファイル: subset.cs プロジェクト: philstopford/DesignLibs_GPL
    private static void subset_weight_test()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    SUBSET_WEIGHT_TEST tests SUBSET_WEIGHT.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    07 January 2016
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        Console.WriteLine("");
        Console.WriteLine("SUBSET_WEIGHT_TEST");
        Console.WriteLine("  SUBSET_WEIGHT returns the weight of a subset.");

        const int n    = 5;
        int       seed = 123456789;

        int[] s = Subset.subset_random(n, ref seed);
        typeMethods.i4vec_transpose_print(n, s, "  Subset S:");

        int weight = Subset.subset_weight(n, s);

        Console.WriteLine("");
        Console.WriteLine("  Weight = " + weight + "");
    }
コード例 #6
0
ファイル: subset.cs プロジェクト: philstopford/DesignLibs_GPL
    private static void subset_random_test()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    SUBSET_RANDOM_TEST tests SUBSET_RANDOM.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    25 December 2015
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        int i;

        Console.WriteLine("");
        Console.WriteLine("SUBSET_RANDOM_TEST");
        Console.WriteLine("  SUBSET_RANDOM returns a random subset.");

        const int n    = 5;
        int       seed = 123456789;

        for (i = 0; i < 10; i++)
        {
            int[] s = Subset.subset_random(n, ref seed);
            typeMethods.i4vec_transpose_print(n, s, "  Subset:");
        }
    }