Beispiel #1
0
        public static void Bool8()
        {
            bool result = true;

            Random64 rng = new Random64(RNG_SEED);

            for (int i = 0; i < NUM_TESTS; i++)
            {
                bool8 x = rng.NextBool8();

                int test = 0;

                for (int j = 0; j < 8; j++)
                {
                    if (x[j])
                    {
                        test++;
                    }
                }

                result &= test == maxmath.count(x);
            }

            Assert.AreEqual(true, result);
        }
Beispiel #2
0
        public static void Float8()
        {
            bool     result = true;
            Random64 x      = new Random64(47);

            for (int i = 0; i < Tests.Float8.NUM_TESTS; i++)
            {
                bool8  b = x.NextBool8();
                float8 a = maxmath.negate(Tests.Float8.TestData_LHS[i], b);

                result &= maxmath.all(a == maxmath.select(Tests.Float8.TestData_LHS[i], -Tests.Float8.TestData_LHS[i], b));
            }

            Assert.AreEqual(true, result);
        }
Beispiel #3
0
        public static void Bool8()
        {
            Random32 rng = new Random32(RNG_SEED);

            bool result = true;

            for (int i = 0; i < NUM_TESTS; i++)
            {
                int   r = rng.NextInt(0, byte.MaxValue + 1);
                bool8 x = maxmath.tobool8(r);

                for (int j = 0; j < 8; j++)
                {
                    result &= x[j] == System.Convert.ToBoolean((r >> j) & 1);
                }
            }

            Assert.AreEqual(true, result);
        }
Beispiel #4
0
        public static void GreaterThanOrEqual()
        {
            bool result = true;

            for (int i = 0; i < NUM_TESTS; i++)
            {
                bool8 x = TestData_LHS[i] >= TestData_RHS[i];

                result &= x.Equals(new bool8(new bool4(TestData_LHS[i].x0 >= TestData_RHS[i].x0,
                                                       TestData_LHS[i].x1 >= TestData_RHS[i].x1,
                                                       TestData_LHS[i].x2 >= TestData_RHS[i].x2,
                                                       TestData_LHS[i].x3 >= TestData_RHS[i].x3),
                                             new bool4(TestData_LHS[i].x4 >= TestData_RHS[i].x4,
                                                       TestData_LHS[i].x5 >= TestData_RHS[i].x5,
                                                       TestData_LHS[i].x6 >= TestData_RHS[i].x6,
                                                       TestData_LHS[i].x7 >= TestData_RHS[i].x7)));
            }

            Assert.AreEqual(true, result);
        }
Beispiel #5
0
        public static void LessThanOrEqual()
        {
            bool result = true;

            for (int i = 0; i < NUM_TESTS; i++)
            {
                bool8 x = TestData_LHS[i] <= TestData_RHS[i];

                result &= x.Equals(new bool8(new bool4(TestData_LHS[i].x0 <= TestData_RHS[i].x0,
                                                       TestData_LHS[i].x1 <= TestData_RHS[i].x1,
                                                       TestData_LHS[i].x2 <= TestData_RHS[i].x2,
                                                       TestData_LHS[i].x3 <= TestData_RHS[i].x3),
                                             new bool4(TestData_LHS[i].x4 <= TestData_RHS[i].x4,
                                                       TestData_LHS[i].x5 <= TestData_RHS[i].x5,
                                                       TestData_LHS[i].x6 <= TestData_RHS[i].x6,
                                                       TestData_LHS[i].x7 <= TestData_RHS[i].x7)));
            }

            Assert.AreEqual(true, result);
        }
Beispiel #6
0
        public static void NotEqual()
        {
            bool result = true;

            for (int i = 0; i < NUM_TESTS; i++)
            {
                bool8 x = TestData_LHS[i] != TestData_RHS[i];

                result &= x.Equals(new bool8(new bool4(TestData_LHS[i].x0 != TestData_RHS[i].x0,
                                                       TestData_LHS[i].x1 != TestData_RHS[i].x1,
                                                       TestData_LHS[i].x2 != TestData_RHS[i].x2,
                                                       TestData_LHS[i].x3 != TestData_RHS[i].x3),
                                             new bool4(TestData_LHS[i].x4 != TestData_RHS[i].x4,
                                                       TestData_LHS[i].x5 != TestData_RHS[i].x5,
                                                       TestData_LHS[i].x6 != TestData_RHS[i].x6,
                                                       TestData_LHS[i].x7 != TestData_RHS[i].x7)));
            }

            Assert.AreEqual(true, result);
        }
Beispiel #7
0
        public static void Equal()
        {
            bool result = true;

            for (int i = 0; i < NUM_TESTS; i++)
            {
                bool8 x = TestData_LHS[i] == TestData_RHS[i];

                result &= x.Equals(new bool8(new bool4(TestData_LHS[i].x0 == TestData_RHS[i].x0,
                                                       TestData_LHS[i].x1 == TestData_RHS[i].x1,
                                                       TestData_LHS[i].x2 == TestData_RHS[i].x2,
                                                       TestData_LHS[i].x3 == TestData_RHS[i].x3),
                                             new bool4(TestData_LHS[i].x4 == TestData_RHS[i].x4,
                                                       TestData_LHS[i].x5 == TestData_RHS[i].x5,
                                                       TestData_LHS[i].x6 == TestData_RHS[i].x6,
                                                       TestData_LHS[i].x7 == TestData_RHS[i].x7)));
            }

            Assert.AreEqual(true, result);
        }
Beispiel #8
0
        public static void Byte8()
        {
            bool result = true;

            for (int i = 0; i < Tests.Byte8.NUM_TESTS; i++)
            {
                bool8 t = maxmath.ispow2(Tests.Byte8.TestData_LHS[i]);

                result &= t.x0 == math.ispow2((uint)Tests.Byte8.TestData_LHS[i].x0);
                result &= t.x1 == math.ispow2((uint)Tests.Byte8.TestData_LHS[i].x1);
                result &= t.x2 == math.ispow2((uint)Tests.Byte8.TestData_LHS[i].x2);
                result &= t.x3 == math.ispow2((uint)Tests.Byte8.TestData_LHS[i].x3);
                result &= t.x4 == math.ispow2((uint)Tests.Byte8.TestData_LHS[i].x4);
                result &= t.x5 == math.ispow2((uint)Tests.Byte8.TestData_LHS[i].x5);
                result &= t.x6 == math.ispow2((uint)Tests.Byte8.TestData_LHS[i].x6);
                result &= t.x7 == math.ispow2((uint)Tests.Byte8.TestData_LHS[i].x7);
            }

            Assert.AreEqual(true, result);
        }
Beispiel #9
0
        public static void Bool8()
        {
            bool result = true;

            Random64 rng = new Random64(RNG_SEED);

            for (int i = 0; i < NUM_TESTS; i++)
            {
                bool8 x = rng.NextBool8();

                int test = maxmath.first(x);

                int j = 0;
                while (j < 8 && !x[j])
                {
                    j++;
                }

                result &= test == j;
            }

            Assert.AreEqual(result && maxmath.first(default(bool8)) == 8, true);
        }