public bool8 NextBool8() { bool8 result = ((Random64)this).NextBool8(); NextState(); return(result); }
public static byte8 touint8safe(bool8 x) { if (Sse2.IsSse2Supported) { return(clamp((byte8)(v128)x, 0, 1)); } else { return(clamp(*(byte8 *)&x, 0, 1)); } }
public static short8 toint16safe(bool8 x) { if (Sse2.IsSse2Supported) { return((short8)clamp((byte8)(v128)x, 0, 1)); } else { return((short8)clamp(*(byte8 *)&x, 0, 1)); } }
public static int8 toint32safe(bool8 x) { if (Avx2.IsAvx2Supported) { return((int8)clamp((byte8)(v128)x, 0, 1)); } else if (Sse2.IsSse2Supported) { return(new int8((int4)clamp((byte4)(v128)x, 0, 1), (int4)clamp(vshr((byte4)(v128)x, 4), 0, 1))); } else { return((int8)clamp(*(byte8 *)&x, 0, 1)); } }
public static int bitmask(bool8 x) { if (Sse2.IsSse2Supported) { Assert.IsSafeBoolean(x.x0); Assert.IsSafeBoolean(x.x1); Assert.IsSafeBoolean(x.x2); Assert.IsSafeBoolean(x.x3); Assert.IsSafeBoolean(x.x4); Assert.IsSafeBoolean(x.x5); Assert.IsSafeBoolean(x.x6); Assert.IsSafeBoolean(x.x7); return(byte.MaxValue & Sse2.movemask_epi8(Sse2.slli_epi16(x, 7))); } else { return(((toint32(x.x0) | (toint8(x.x1) << 1)) + ((toint8(x.x2) << 2) | (toint8(x.x3) << 3))) + (((toint8(x.x4) << 4) | (toint8(x.x5) << 5)) + ((toint8(x.x6) << 6) | (toint8(x.x7) << 7)))); } }
public static bool all(bool8 x) { Assert.IsSafeBoolean(x.x0); Assert.IsSafeBoolean(x.x1); Assert.IsSafeBoolean(x.x2); Assert.IsSafeBoolean(x.x3); Assert.IsSafeBoolean(x.x4); Assert.IsSafeBoolean(x.x5); Assert.IsSafeBoolean(x.x6); Assert.IsSafeBoolean(x.x7); if (Sse2.IsSse2Supported) { return(((v128)x).ULong0 == 0x0101_0101_0101_0101); } else { return(*(long *)&x == 0x0101_0101_0101_0101); } }
public static uint count(bool8 x) { Assert.IsSafeBoolean(x.x0); Assert.IsSafeBoolean(x.x1); Assert.IsSafeBoolean(x.x2); Assert.IsSafeBoolean(x.x3); Assert.IsSafeBoolean(x.x4); Assert.IsSafeBoolean(x.x5); Assert.IsSafeBoolean(x.x6); Assert.IsSafeBoolean(x.x7); if (Sse2.IsSse2Supported) { return((uint)math.countbits(((v128)x).ULong0)); } else { return((uint)math.countbits(*(long *)&x)); } }
public static int last(bool8 x) { Assert.IsSafeBoolean(x.x0); Assert.IsSafeBoolean(x.x1); Assert.IsSafeBoolean(x.x2); Assert.IsSafeBoolean(x.x3); Assert.IsSafeBoolean(x.x4); Assert.IsSafeBoolean(x.x5); Assert.IsSafeBoolean(x.x6); Assert.IsSafeBoolean(x.x7); if (Sse2.IsSse2Supported) { return(7 - (int)((uint)math.lzcnt(((v128)x).SLong0) / 8)); } else { return(7 - (int)((uint)math.lzcnt(*(long *)&x) / 8)); } }
public static int8 negate(int8 x, bool8 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); if (Avx2.IsAvx2Supported) { int8 mask = (sbyte8)Sse2.cmpgt_epi8(p, default(v128)); return((x ^ mask) - mask); } else { return(new int8(negate(x.v4_0, p.v4_0), negate(x.v4_4, p.v4_4))); } }
public static short8 negate(short8 x, bool8 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); if (Sse2.IsSse2Supported) { short8 mask = (sbyte8)Sse2.cmpgt_epi8(p, default(v128)); return((x ^ mask) - mask); } else { short8 mask = touint8(p); return((x ^ -mask) + mask); } }
public static float8 negate(float8 x, bool8 p) { return(asfloat(asuint(x) ^ (touint32(p) << 31))); }
public static float8 tof32safe(bool8 x) { return(select(default(float8), new float8(1f), x)); }
public static half8 tof16safe(bool8 x) { return(ashalf(select(ushort8.zero, ((half)1f).value, x))); }
public static quarter8 tof8safe(bool8 x) { return(asquarter(select(byte8.zero, ((quarter)1f).value, x))); }
public bool16(bool4 x0123, bool4 x4567, bool8 x8_9_10_11_12_13_14_15) { this = maxmath.tobool(new byte16(maxmath.touint8(x0123), maxmath.touint8(x4567), maxmath.touint8(x8_9_10_11_12_13_14_15))); }
public bool16(bool4 x0123, bool8 x4_5_6_7_8_9_10_11, bool4 x12_13_14_15) { this = maxmath.tobool(new byte16(maxmath.touint8(x0123), maxmath.touint8(x4_5_6_7_8_9_10_11), maxmath.touint8(x12_13_14_15))); }
public bool16(bool8 x01234567, bool4 x8_9_10_11, bool4 x12_13_14_15) { this = maxmath.tobool(new byte16(maxmath.touint8(x01234567), maxmath.touint8(x8_9_10_11), maxmath.touint8(x12_13_14_15))); }