public static void Byte16() { bool result = true; for (int i = 0; i < Tests.Byte16.NUM_TESTS; i++) { bool16 t = maxmath.ispow2(Tests.Byte16.TestData_LHS[i]); result &= t.x0 == math.ispow2((uint)Tests.Byte16.TestData_LHS[i].x0); result &= t.x1 == math.ispow2((uint)Tests.Byte16.TestData_LHS[i].x1); result &= t.x2 == math.ispow2((uint)Tests.Byte16.TestData_LHS[i].x2); result &= t.x3 == math.ispow2((uint)Tests.Byte16.TestData_LHS[i].x3); result &= t.x4 == math.ispow2((uint)Tests.Byte16.TestData_LHS[i].x4); result &= t.x5 == math.ispow2((uint)Tests.Byte16.TestData_LHS[i].x5); result &= t.x6 == math.ispow2((uint)Tests.Byte16.TestData_LHS[i].x6); result &= t.x7 == math.ispow2((uint)Tests.Byte16.TestData_LHS[i].x7); result &= t.x8 == math.ispow2((uint)Tests.Byte16.TestData_LHS[i].x8); result &= t.x9 == math.ispow2((uint)Tests.Byte16.TestData_LHS[i].x9); result &= t.x10 == math.ispow2((uint)Tests.Byte16.TestData_LHS[i].x10); result &= t.x11 == math.ispow2((uint)Tests.Byte16.TestData_LHS[i].x11); result &= t.x12 == math.ispow2((uint)Tests.Byte16.TestData_LHS[i].x12); result &= t.x13 == math.ispow2((uint)Tests.Byte16.TestData_LHS[i].x13); result &= t.x14 == math.ispow2((uint)Tests.Byte16.TestData_LHS[i].x14); result &= t.x15 == math.ispow2((uint)Tests.Byte16.TestData_LHS[i].x15); } Assert.AreEqual(true, result); }
public static void Bool16() { bool result = true; Random64 rng = new Random64(RNG_SEED); for (int i = 0; i < NUM_TESTS; i++) { bool16 x = new bool16(rng.NextBool8(), rng.NextBool8()); int test = 0; for (int j = 0; j < 16; j++) { if (x[j]) { test++; } } result &= test == maxmath.count(x); } Assert.AreEqual(true, result); }
public static void Short16() { bool result = true; Random64 x = new Random64(47); for (int i = 0; i < Tests.Short16.NUM_TESTS; i++) { bool16 b = x.NextBool16(); short16 a = maxmath.negate(Tests.Short16.TestData_LHS[i], b); result &= maxmath.all(a == maxmath.select(Tests.Short16.TestData_LHS[i], -Tests.Short16.TestData_LHS[i], b)); } Assert.AreEqual(true, result); }
public static void Bool16() { Random32 rng = new Random32(RNG_SEED); bool result = true; for (int i = 0; i < NUM_TESTS; i++) { int r = rng.NextInt(0, ushort.MaxValue + 1); bool16 x = maxmath.tobool16(r); for (int j = 0; j < 4; j++) { result &= x[j] == System.Convert.ToBoolean((r >> j) & 1); } } Assert.AreEqual(true, result); }
public static void Bool16() { bool result = true; Random64 rng = new Random64(RNG_SEED); for (int i = 0; i < NUM_TESTS; i++) { bool16 x = new bool16(rng.NextBool8(), rng.NextBool8()); int test = maxmath.first(x); int j = 0; while (j < 16 && !x[j]) { j++; } result &= test == j; } Assert.AreEqual(result && maxmath.first(default(bool16)) == 32, true); }