public static void sbyte16() { Random8 rng = new Random8(135); for (int i = 0; i < 64; i++) { sbyte16 x = rng.NextSByte16(); sbyte16 y = rng.NextSByte16(); Assert.AreEqual(new byte16((byte)_gcd(x.x0, y.x0), (byte)_gcd(x.x1, y.x1), (byte)_gcd(x.x2, y.x2), (byte)_gcd(x.x3, y.x3), (byte)_gcd(x.x4, y.x4), (byte)_gcd(x.x5, y.x5), (byte)_gcd(x.x6, y.x6), (byte)_gcd(x.x7, y.x7), (byte)_gcd(x.x8, y.x8), (byte)_gcd(x.x9, y.x9), (byte)_gcd(x.x10, y.x10), (byte)_gcd(x.x11, y.x11), (byte)_gcd(x.x12, y.x12), (byte)_gcd(x.x13, y.x13), (byte)_gcd(x.x14, y.x14), (byte)_gcd(x.x15, y.x15)), maxmath.gcd(x, y)); } }
public static sbyte16 compareto(byte16 x, byte16 y) { if (Sse2.IsSse2Supported) { sbyte16 xGreatery = Operator.greater_mask_byte(x, y); sbyte16 yGreaterx = Operator.greater_mask_byte(y, x); return((0 - xGreatery) + yGreaterx); } else { return(new sbyte16((sbyte)compareto(x.x0, y.x0), (sbyte)compareto(x.x1, y.x1), (sbyte)compareto(x.x2, y.x2), (sbyte)compareto(x.x3, y.x3), (sbyte)compareto(x.x4, y.x4), (sbyte)compareto(x.x5, y.x5), (sbyte)compareto(x.x6, y.x6), (sbyte)compareto(x.x7, y.x7), (sbyte)compareto(x.x8, y.x8), (sbyte)compareto(x.x9, y.x9), (sbyte)compareto(x.x10, y.x10), (sbyte)compareto(x.x11, y.x11), (sbyte)compareto(x.x12, y.x12), (sbyte)compareto(x.x13, y.x13), (sbyte)compareto(x.x14, y.x14), (sbyte)compareto(x.x15, y.x15))); } }
public static byte16 lcm(sbyte16 x, sbyte16 y) { byte16 absX = (byte16)abs(x); byte16 absY = (byte16)abs(y); return((absX / gcd(absX, absY)) * absY); }
public static void sbyte16() { Random8 rng = new Random8(135); for (int i = 0; i < 64; i++) { sbyte16 x = rng.NextSByte16(); byte16 n = rng.NextByte16(); Assert.AreEqual(new sbyte16((sbyte)_intpow(x.x0, n.x0), (sbyte)_intpow(x.x1, n.x1), (sbyte)_intpow(x.x2, n.x2), (sbyte)_intpow(x.x3, n.x3), (sbyte)_intpow(x.x4, n.x4), (sbyte)_intpow(x.x5, n.x5), (sbyte)_intpow(x.x6, n.x6), (sbyte)_intpow(x.x7, n.x7), (sbyte)_intpow(x.x8, n.x8), (sbyte)_intpow(x.x9, n.x9), (sbyte)_intpow(x.x10, n.x10), (sbyte)_intpow(x.x11, n.x11), (sbyte)_intpow(x.x12, n.x12), (sbyte)_intpow(x.x13, n.x13), (sbyte)_intpow(x.x14, n.x14), (sbyte)_intpow(x.x15, n.x15)), maxmath.intpow(x, n)); } }
public static void sbyte16() { Random8 rng = new Random8(135); for (int i = 0; i < 64; i++) { sbyte16 x = rng.NextSByte16(); Assert.AreEqual(new sbyte16((sbyte)maxmath.lzcnt(x.x0), (sbyte)maxmath.lzcnt(x.x1), (sbyte)maxmath.lzcnt(x.x2), (sbyte)maxmath.lzcnt(x.x3), (sbyte)maxmath.lzcnt(x.x4), (sbyte)maxmath.lzcnt(x.x5), (sbyte)maxmath.lzcnt(x.x6), (sbyte)maxmath.lzcnt(x.x7), (sbyte)maxmath.lzcnt(x.x8), (sbyte)maxmath.lzcnt(x.x9), (sbyte)maxmath.lzcnt(x.x10), (sbyte)maxmath.lzcnt(x.x11), (sbyte)maxmath.lzcnt(x.x12), (sbyte)maxmath.lzcnt(x.x13), (sbyte)maxmath.lzcnt(x.x14), (sbyte)maxmath.lzcnt(x.x15)), maxmath.lzcnt(x)); } }
public static void SByte16() { bool result = true; for (int i = 0; i < Tests.SByte16.NUM_TESTS; i++) { sbyte16 t = maxmath.sign(Tests.SByte16.TestData_LHS[i]); result &= t.x0 == ((Tests.SByte16.TestData_LHS[i].x0 == 0) ? 0 : ((Tests.SByte16.TestData_LHS[i].x0 < 0) ? -1 : 1)); result &= t.x1 == ((Tests.SByte16.TestData_LHS[i].x1 == 0) ? 0 : ((Tests.SByte16.TestData_LHS[i].x1 < 0) ? -1 : 1)); result &= t.x2 == ((Tests.SByte16.TestData_LHS[i].x2 == 0) ? 0 : ((Tests.SByte16.TestData_LHS[i].x2 < 0) ? -1 : 1)); result &= t.x3 == ((Tests.SByte16.TestData_LHS[i].x3 == 0) ? 0 : ((Tests.SByte16.TestData_LHS[i].x3 < 0) ? -1 : 1)); result &= t.x4 == ((Tests.SByte16.TestData_LHS[i].x4 == 0) ? 0 : ((Tests.SByte16.TestData_LHS[i].x4 < 0) ? -1 : 1)); result &= t.x5 == ((Tests.SByte16.TestData_LHS[i].x5 == 0) ? 0 : ((Tests.SByte16.TestData_LHS[i].x5 < 0) ? -1 : 1)); result &= t.x6 == ((Tests.SByte16.TestData_LHS[i].x6 == 0) ? 0 : ((Tests.SByte16.TestData_LHS[i].x6 < 0) ? -1 : 1)); result &= t.x7 == ((Tests.SByte16.TestData_LHS[i].x7 == 0) ? 0 : ((Tests.SByte16.TestData_LHS[i].x7 < 0) ? -1 : 1)); result &= t.x8 == ((Tests.SByte16.TestData_LHS[i].x8 == 0) ? 0 : ((Tests.SByte16.TestData_LHS[i].x8 < 0) ? -1 : 1)); result &= t.x9 == ((Tests.SByte16.TestData_LHS[i].x9 == 0) ? 0 : ((Tests.SByte16.TestData_LHS[i].x9 < 0) ? -1 : 1)); result &= t.x10 == ((Tests.SByte16.TestData_LHS[i].x10 == 0) ? 0 : ((Tests.SByte16.TestData_LHS[i].x10 < 0) ? -1 : 1)); result &= t.x11 == ((Tests.SByte16.TestData_LHS[i].x11 == 0) ? 0 : ((Tests.SByte16.TestData_LHS[i].x11 < 0) ? -1 : 1)); result &= t.x12 == ((Tests.SByte16.TestData_LHS[i].x12 == 0) ? 0 : ((Tests.SByte16.TestData_LHS[i].x12 < 0) ? -1 : 1)); result &= t.x13 == ((Tests.SByte16.TestData_LHS[i].x13 == 0) ? 0 : ((Tests.SByte16.TestData_LHS[i].x13 < 0) ? -1 : 1)); result &= t.x14 == ((Tests.SByte16.TestData_LHS[i].x14 == 0) ? 0 : ((Tests.SByte16.TestData_LHS[i].x14 < 0) ? -1 : 1)); result &= t.x15 == ((Tests.SByte16.TestData_LHS[i].x15 == 0) ? 0 : ((Tests.SByte16.TestData_LHS[i].x15 < 0) ? -1 : 1)); } Assert.AreEqual(true, result); }
public sbyte16 NextSByte16(sbyte16 min, sbyte16 max) { Assert.IsNotSmaller(max.x0, min.x0); Assert.IsNotSmaller(max.x1, min.x1); Assert.IsNotSmaller(max.x2, min.x2); Assert.IsNotSmaller(max.x3, min.x3); Assert.IsNotSmaller(max.x4, min.x4); Assert.IsNotSmaller(max.x5, min.x5); Assert.IsNotSmaller(max.x6, min.x6); Assert.IsNotSmaller(max.x7, min.x7); Assert.IsNotSmaller(max.x8, min.x8); Assert.IsNotSmaller(max.x9, min.x9); Assert.IsNotSmaller(max.x10, min.x10); Assert.IsNotSmaller(max.x11, min.x11); Assert.IsNotSmaller(max.x12, min.x12); Assert.IsNotSmaller(max.x13, min.x13); Assert.IsNotSmaller(max.x14, min.x14); Assert.IsNotSmaller(max.x15, min.x15); if (Avx2.IsAvx2Supported) { ushort16 temp = (ushort16)(max - min) * new ushort16(NextState(), NextState(), NextState(), NextState(), NextState(), NextState(), NextState(), NextState(), NextState(), NextState(), NextState(), NextState(), NextState(), NextState(), NextState(), NextState()); temp = Avx2.mm256_shuffle_epi8(temp, new v256(1, 3, 5, 7, 9, 11, 13, 15, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 5, 7, 9, 11, 13, 15, 0, 0, 0, 0, 0, 0, 0, 0)); return(min + Avx.mm256_castsi256_si128(Avx2.mm256_permute4x64_epi64(temp, Sse.SHUFFLE(0, 0, 2, 0)))); } else { return(new sbyte16(NextSByte8(min.v8_0, max.v8_0), NextSByte8(min.v8_8, max.v8_8))); } }
public static void SByte16x2() { bool result = true; for (int i = 0; i < Tests.SByte16.NUM_TESTS; i++) { sbyte16 x = maxmath.avg(Tests.SByte16.TestData_LHS[i], Tests.SByte16.TestData_RHS[i]); result &= x.x0 == (((Tests.SByte16.TestData_LHS[i].x0 + Tests.SByte16.TestData_RHS[i].x0) > 0 ? 1 : -1) + Tests.SByte16.TestData_LHS[i].x0 + Tests.SByte16.TestData_RHS[i].x0) / 2; result &= x.x1 == (((Tests.SByte16.TestData_LHS[i].x1 + Tests.SByte16.TestData_RHS[i].x1) > 0 ? 1 : -1) + Tests.SByte16.TestData_LHS[i].x1 + Tests.SByte16.TestData_RHS[i].x1) / 2; result &= x.x2 == (((Tests.SByte16.TestData_LHS[i].x2 + Tests.SByte16.TestData_RHS[i].x2) > 0 ? 1 : -1) + Tests.SByte16.TestData_LHS[i].x2 + Tests.SByte16.TestData_RHS[i].x2) / 2; result &= x.x3 == (((Tests.SByte16.TestData_LHS[i].x3 + Tests.SByte16.TestData_RHS[i].x3) > 0 ? 1 : -1) + Tests.SByte16.TestData_LHS[i].x3 + Tests.SByte16.TestData_RHS[i].x3) / 2; result &= x.x4 == (((Tests.SByte16.TestData_LHS[i].x4 + Tests.SByte16.TestData_RHS[i].x4) > 0 ? 1 : -1) + Tests.SByte16.TestData_LHS[i].x4 + Tests.SByte16.TestData_RHS[i].x4) / 2; result &= x.x5 == (((Tests.SByte16.TestData_LHS[i].x5 + Tests.SByte16.TestData_RHS[i].x5) > 0 ? 1 : -1) + Tests.SByte16.TestData_LHS[i].x5 + Tests.SByte16.TestData_RHS[i].x5) / 2; result &= x.x6 == (((Tests.SByte16.TestData_LHS[i].x6 + Tests.SByte16.TestData_RHS[i].x6) > 0 ? 1 : -1) + Tests.SByte16.TestData_LHS[i].x6 + Tests.SByte16.TestData_RHS[i].x6) / 2; result &= x.x7 == (((Tests.SByte16.TestData_LHS[i].x7 + Tests.SByte16.TestData_RHS[i].x7) > 0 ? 1 : -1) + Tests.SByte16.TestData_LHS[i].x7 + Tests.SByte16.TestData_RHS[i].x7) / 2; result &= x.x8 == (((Tests.SByte16.TestData_LHS[i].x8 + Tests.SByte16.TestData_RHS[i].x8) > 0 ? 1 : -1) + Tests.SByte16.TestData_LHS[i].x8 + Tests.SByte16.TestData_RHS[i].x8) / 2; result &= x.x9 == (((Tests.SByte16.TestData_LHS[i].x9 + Tests.SByte16.TestData_RHS[i].x9) > 0 ? 1 : -1) + Tests.SByte16.TestData_LHS[i].x9 + Tests.SByte16.TestData_RHS[i].x9) / 2; result &= x.x10 == (((Tests.SByte16.TestData_LHS[i].x10 + Tests.SByte16.TestData_RHS[i].x10) > 0 ? 1 : -1) + Tests.SByte16.TestData_LHS[i].x10 + Tests.SByte16.TestData_RHS[i].x10) / 2; result &= x.x11 == (((Tests.SByte16.TestData_LHS[i].x11 + Tests.SByte16.TestData_RHS[i].x11) > 0 ? 1 : -1) + Tests.SByte16.TestData_LHS[i].x11 + Tests.SByte16.TestData_RHS[i].x11) / 2; result &= x.x12 == (((Tests.SByte16.TestData_LHS[i].x12 + Tests.SByte16.TestData_RHS[i].x12) > 0 ? 1 : -1) + Tests.SByte16.TestData_LHS[i].x12 + Tests.SByte16.TestData_RHS[i].x12) / 2; result &= x.x13 == (((Tests.SByte16.TestData_LHS[i].x13 + Tests.SByte16.TestData_RHS[i].x13) > 0 ? 1 : -1) + Tests.SByte16.TestData_LHS[i].x13 + Tests.SByte16.TestData_RHS[i].x13) / 2; result &= x.x14 == (((Tests.SByte16.TestData_LHS[i].x14 + Tests.SByte16.TestData_RHS[i].x14) > 0 ? 1 : -1) + Tests.SByte16.TestData_LHS[i].x14 + Tests.SByte16.TestData_RHS[i].x14) / 2; result &= x.x15 == (((Tests.SByte16.TestData_LHS[i].x15 + Tests.SByte16.TestData_RHS[i].x15) > 0 ? 1 : -1) + Tests.SByte16.TestData_LHS[i].x15 + Tests.SByte16.TestData_RHS[i].x15) / 2; } Assert.AreEqual(true, result); }
public static sbyte16 negate(sbyte16 x, bool16 p) { Assert.IsSafeBoolean(p.x0); Assert.IsSafeBoolean(p.x1); Assert.IsSafeBoolean(p.x2); Assert.IsSafeBoolean(p.x3); Assert.IsSafeBoolean(p.x4); Assert.IsSafeBoolean(p.x5); Assert.IsSafeBoolean(p.x6); Assert.IsSafeBoolean(p.x7); Assert.IsSafeBoolean(p.x8); Assert.IsSafeBoolean(p.x9); Assert.IsSafeBoolean(p.x10); Assert.IsSafeBoolean(p.x11); Assert.IsSafeBoolean(p.x12); Assert.IsSafeBoolean(p.x13); Assert.IsSafeBoolean(p.x14); Assert.IsSafeBoolean(p.x15); if (Sse2.IsSse2Supported) { sbyte16 mask = Sse2.cmpgt_epi8(p, default(v128)); return((x ^ mask) - mask); } else { sbyte16 mask = toint8(p); return((x ^ -mask) + mask); } }
public static sbyte16 intpow(sbyte16 x, byte16 n) { if (Sse2.IsSse2Supported) { v128 ZERO = default(v128); sbyte16 ONE = new sbyte16(1); v128 doneMask = ZERO; v128 result = ZERO; sbyte16 p = x; sbyte16 y = ONE; Loop: v128 y_times_p = y * p; y = Mask.BlendV(y, y_times_p, Sse2.cmpeq_epi8(ONE, Sse2.and_si128(ONE, n))); n >>= 1; v128 n_is_zero = Sse2.cmpeq_epi8(ZERO, n); result = Mask.BlendV(result, y, Sse2.andnot_si128(doneMask, n_is_zero)); doneMask = n_is_zero; if (bitmask32(16 * sizeof(sbyte)) != Sse2.movemask_epi8(doneMask)) { p *= p; goto Loop; } else { return(result); } } else { return(new sbyte16((sbyte)intpow((int)x.x0, n.x0), (sbyte)intpow((int)x.x1, n.x1), (sbyte)intpow((int)x.x2, n.x2), (sbyte)intpow((int)x.x3, n.x3), (sbyte)intpow((int)x.x4, n.x4), (sbyte)intpow((int)x.x5, n.x5), (sbyte)intpow((int)x.x6, n.x6), (sbyte)intpow((int)x.x7, n.x7), (sbyte)intpow((int)x.x8, n.x8), (sbyte)intpow((int)x.x9, n.x9), (sbyte)intpow((int)x.x10, n.x10), (sbyte)intpow((int)x.x11, n.x11), (sbyte)intpow((int)x.x12, n.x12), (sbyte)intpow((int)x.x13, n.x13), (sbyte)intpow((int)x.x14, n.x14), (sbyte)intpow((int)x.x15, n.x15))); } }
public static sbyte16 subadd(sbyte16 a, sbyte16 b) { if (Ssse3.IsSsse3Supported) { return(a + Ssse3.sign_epi8(b, new v128(255, 1, 255, 1, 255, 1, 255, 1, 255, 1, 255, 1, 255, 1, 255, 1))); } else { return(a - select(b, -b, new bool16(false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true))); } }
public static sbyte16 divrem(sbyte16 dividend, sbyte divisor, out sbyte16 remainder) { if (Constant.IsConstantExpression(divisor)) { remainder = dividend % divisor; return(dividend / divisor); } else { return(divrem(dividend, (sbyte16)divisor, out remainder)); } }
public static bool16 ispow2(sbyte16 x) { if (Sse2.IsSse2Supported) { return(Sse2.and_si128(Sse2.and_si128(Sse2.cmpgt_epi8(x, default(v128)), Sse2.cmpeq_epi8(default(v128), x & (x - 1))), new sbyte16(1))); } else { return(new bool16(math.ispow2(x.x0), math.ispow2(x.x1), math.ispow2(x.x2), math.ispow2(x.x3), math.ispow2(x.x4), math.ispow2(x.x5), math.ispow2(x.x6), math.ispow2(x.x7), math.ispow2(x.x8), math.ispow2(x.x9), math.ispow2(x.x10), math.ispow2(x.x11), math.ispow2(x.x12), math.ispow2(x.x13), math.ispow2(x.x14), math.ispow2(x.x15))); } }
public static bool16 toboolsafe(sbyte16 x) { if (Sse2.IsSse2Supported) { return((v128)clamp(x, 0, 1)); } else { sbyte16 temp = clamp(x, 0, 1); return(*(bool16 *)&temp); } }
internal static sbyte16 vrem_sbyte(sbyte16 dividend, sbyte16 divisor) { if (Avx2.IsAvx2Supported) { byte16 remainder = vrem_byte((byte16)maxmath.abs(dividend), (byte16)maxmath.abs(divisor)); byte16 mustNegate = Sse2.cmpgt_epi8(sbyte16.zero, dividend); return(Mask.BlendV(remainder, -((sbyte16)remainder), mustNegate)); } else { throw new CPUFeatureCheckException(); } }
public static sbyte16 max(sbyte16 a, sbyte16 b) { if (Sse4_1.IsSse41Supported) { return(Sse4_1.max_epi8(a, b)); } else if (Sse2.IsSse2Supported) { return(Mask.BlendV(a, b, Sse2.cmpgt_epi8(b, a))); } else { return(new sbyte16((sbyte)math.max(a.x0, b.x0), (sbyte)math.max(a.x1, b.x1), (sbyte)math.max(a.x2, b.x2), (sbyte)math.max(a.x3, b.x3), (sbyte)math.max(a.x4, b.x4), (sbyte)math.max(a.x5, b.x5), (sbyte)math.max(a.x6, b.x6), (sbyte)math.max(a.x7, b.x7), (sbyte)math.max(a.x8, b.x8), (sbyte)math.max(a.x9, b.x9), (sbyte)math.max(a.x10, b.x10), (sbyte)math.max(a.x11, b.x11), (sbyte)math.max(a.x12, b.x12), (sbyte)math.max(a.x13, b.x13), (sbyte)math.max(a.x14, b.x14), (sbyte)math.max(a.x15, b.x15))); } }
public static sbyte16 sign(sbyte16 x) { if (Ssse3.IsSsse3Supported) { return(Ssse3.sign_epi8(new sbyte16(1), x)); } else if (Sse2.IsSse2Supported) { return(((sbyte16)Sse2.cmpgt_epi8(x, default(v128)) & 1) + Sse2.cmpgt_epi8(default(v128), x)); } else { return((x >> 7) | (sbyte16)((byte16)(-x) >> 7)); } }
public static sbyte16 nabs(sbyte16 x) { if (Ssse3.IsSsse3Supported) { return(Sse2.sub_epi8(default(v128), Ssse3.abs_epi8(x))); } else if (Sse2.IsSse2Supported) { return(Mask.BlendV(-x, x, Sse2.cmpgt_epi8(default(v128), x))); } else { return(new sbyte16((sbyte)nabs((int)x.x0), (sbyte)nabs((int)x.x1), (sbyte)nabs((int)x.x2), (sbyte)nabs((int)x.x3), (sbyte)nabs((int)x.x4), (sbyte)nabs((int)x.x5), (sbyte)nabs((int)x.x6), (sbyte)nabs((int)x.x7), (sbyte)nabs((int)x.x8), (sbyte)nabs((int)x.x9), (sbyte)nabs((int)x.x10), (sbyte)nabs((int)x.x11), (sbyte)nabs((int)x.x12), (sbyte)nabs((int)x.x13), (sbyte)nabs((int)x.x14), (sbyte)nabs((int)x.x15))); } }
public static void SByte16() { bool result = true; Random64 x = new Random64(47); for (int i = 0; i < Tests.SByte16.NUM_TESTS; i++) { bool16 b = x.NextBool16(); sbyte16 a = maxmath.negate(Tests.SByte16.TestData_LHS[i], b); result &= maxmath.all(a == maxmath.select(Tests.SByte16.TestData_LHS[i], -Tests.SByte16.TestData_LHS[i], b)); } Assert.AreEqual(true, result); }
public static sbyte16 avg(sbyte16 x, sbyte16 y) { if (Avx2.IsAvx2Supported) { short16 result = ((short16)x + (short16)y); // if the intermediate sum is positive add 1 result -= Avx2.mm256_cmpgt_epi16(result, default(v256)); return((sbyte16)(result >> 1)); } else { return(new sbyte16(avg(x.v8_0, y.v8_0), avg(x.v8_8, y.v8_8))); } }
public static int csum(sbyte16 x) { if (Sse2.IsSse2Supported) { short8 cast = (short8)x.v8_0 + (short8)x.v8_8; cast += Sse2.unpackhi_epi64(cast, cast); cast += Sse2.shufflelo_epi16(cast, Sse.SHUFFLE(0, 1, 2, 3)); return(Sse2.add_epi16(cast, Sse2.shufflelo_epi16(cast, Sse.SHUFFLE(0, 0, 0, 1))).SShort0); } else { return((((x.x0 + x.x1) + (x.x2 + x.x3)) + ((x.x4 + x.x5) + (x.x6 + x.x7))) + (((x.x8 + x.x9) + (x.x10 + x.x11)) + ((x.x12 + x.x13) + (x.x14 + x.x15)))); } }
internal static sbyte16 vdiv_sbyte(sbyte16 dividend, sbyte16 divisor) { if (Avx2.IsAvx2Supported) { byte16 quotient = vdiv_byte((byte16)maxmath.abs(dividend), (byte16)maxmath.abs(divisor)); byte16 mustNegate = Sse2.xor_si128(Sse2.cmpgt_epi8(sbyte16.zero, divisor), Sse2.cmpgt_epi8(sbyte16.zero, dividend)); return(Mask.BlendV(quotient, -((sbyte16)quotient), mustNegate)); } else { throw new CPUFeatureCheckException(); } }
public static sbyte3x3 operator /(sbyte3x3 left, sbyte right) { if (Sse2.IsSse2Supported) { if (!Constant.IsConstantExpression(right)) { sbyte16 dividend = Sse2.unpacklo_epi64(Sse2.unpacklo_epi32(left.c0, left.c1), left.c2); sbyte16 div = dividend / right; return(new sbyte3x3(div.v3_0, div.v3_4, div.v3_8)); } } return(new sbyte3x3(left.c0 / right, left.c1 / right, left.c2 / right)); }
public static sbyte3x3 operator %(sbyte3x3 left, sbyte right) { if (Sse2.IsSse2Supported) { if (!Constant.IsConstantExpression(right)) { sbyte16 dividend = Sse2.unpacklo_epi64(Sse2.unpacklo_epi32(left.c0, left.c1), left.c2); sbyte16 rem = dividend % right; return(new sbyte3x3(rem.v3_0, rem.v3_4, rem.v3_8)); } } return(new sbyte3x3(left.c0 % right, left.c1 % right, left.c2 % right)); }
public static sbyte4x4 operator %(sbyte4x4 left, sbyte right) { if (Sse2.IsSse2Supported) { if (!Constant.IsConstantExpression(right)) { sbyte16 dividend = Sse2.unpacklo_epi64(Sse2.unpacklo_epi32(left.c0, left.c1), Sse2.unpacklo_epi32(left.c2, left.c3)); sbyte16 rem = dividend % right; return(new sbyte4x4(rem.v4_0, rem.v4_4, rem.v4_8, rem.v4_12)); } } return(new sbyte4x4(left.c0 % right, left.c1 % right, left.c2 % right, left.c3 % right)); }
public static sbyte4x4 operator /(sbyte4x4 left, sbyte right) { if (Sse2.IsSse2Supported) { if (!Constant.IsConstantExpression(right)) { sbyte16 dividend = Sse2.unpacklo_epi64(Sse2.unpacklo_epi32(left.c0, left.c1), Sse2.unpacklo_epi32(left.c2, left.c3)); sbyte16 div = dividend / right; return(new sbyte4x4(div.v4_0, div.v4_4, div.v4_8, div.v4_12)); } } return(new sbyte4x4(left.c0 / right, left.c1 / right, left.c2 / right, left.c3 / right)); }
public static sbyte16 abs(sbyte16 x) { if (Ssse3.IsSsse3Supported) { return(Ssse3.abs_epi8(x)); } else if (Sse2.IsSse2Supported) { v128 mask = Sse2.cmpgt_epi8(default(v128), x); return((x + mask) ^ mask); } else { return(new sbyte16((sbyte)math.abs(x.x0), (sbyte)math.abs(x.x1), (sbyte)math.abs(x.x2), (sbyte)math.abs(x.x3), (sbyte)math.abs(x.x4), (sbyte)math.abs(x.x5), (sbyte)math.abs(x.x6), (sbyte)math.abs(x.x7), (sbyte)math.abs(x.x8), (sbyte)math.abs(x.x9), (sbyte)math.abs(x.x10), (sbyte)math.abs(x.x11), (sbyte)math.abs(x.x12), (sbyte)math.abs(x.x13), (sbyte)math.abs(x.x14), (sbyte)math.abs(x.x15))); } }
public static sbyte4x4 operator %(sbyte4x4 left, sbyte4x4 right) { if (Sse2.IsSse2Supported) { sbyte16 dividend = Sse2.unpacklo_epi64(Sse2.unpacklo_epi32(left.c0, left.c1), Sse2.unpacklo_epi32(left.c2, left.c3)); sbyte16 divisor = Sse2.unpacklo_epi64(Sse2.unpacklo_epi32(right.c0, right.c1), Sse2.unpacklo_epi32(right.c2, right.c3)); sbyte16 rem = dividend % divisor; return(new sbyte4x4(rem.v4_0, rem.v4_4, rem.v4_8, rem.v4_12)); } else { return(new sbyte4x4(left.c0 % right.c0, left.c1 % right.c1, left.c2 % right.c2, left.c3 % right.c3)); } }
public static sbyte4x4 operator /(sbyte4x4 left, sbyte4x4 right) { if (Sse2.IsSse2Supported) { sbyte16 dividend = Sse2.unpacklo_epi64(Sse2.unpacklo_epi32(left.c0, left.c1), Sse2.unpacklo_epi32(left.c2, left.c3)); sbyte16 divisor = Sse2.unpacklo_epi64(Sse2.unpacklo_epi32(right.c0, right.c1), Sse2.unpacklo_epi32(right.c2, right.c3)); sbyte16 div = dividend / divisor; return(new sbyte4x4(div.v4_0, div.v4_4, div.v4_8, div.v4_12)); } else { return(new sbyte4x4(left.c0 / right.c0, left.c1 / right.c1, left.c2 / right.c2, left.c3 / right.c3)); } }
public static sbyte16 divrem(sbyte16 dividend, sbyte16 divisor, out sbyte16 remainder) { if (Avx2.IsAvx2Supported) { return(Operator.vdivrem_sbyte(dividend, divisor, out remainder)); } else if (Sse2.IsSse2Supported) { return(Operator.vdivrem_sbyte_SSE_FALLBACK(dividend, divisor, out remainder)); } else { sbyte8 lo = divrem(dividend.v8_0, divisor.v8_0, out sbyte8 remLo); sbyte8 hi = divrem(dividend.v8_8, divisor.v8_8, out sbyte8 remHi); remainder = new sbyte16(remLo, remHi); return(new sbyte16(lo, hi)); } }
public static extern sbyte mono_return_sbyte16 (sbyte16 s, int addend);