/// <summary> /// Transforms an primal enumerator into a bitstream /// </summary> /// <param name="src">The source stream</param> /// <typeparam name="T">The primal type</typeparam> public static IEnumerable <Bit> ToBitStream <T>(this IEnumerator <T> src) where T : unmanaged { while (src.MoveNext()) { var bs = BitString.FromScalar(src.Current); for (var i = 0; i < 64; i++) { yield return(bs[i]); } } }
protected void bitpart_check <A, B>(Partitioner <A, B> part, int count, int width) where A : unmanaged where B : unmanaged { Span <B> dst = stackalloc B[count]; for (var sample = 0; sample < SampleSize; sample++) { var x = Random.Next <A>(); part(x, dst); var y = BitString.FromScalar(x).Partition(width).Map(bs => bs.ToBitVector(n8)); for (var i = 0; i < count; i++) { Claim.eq(y[i], BitString.FromScalar(dst[i]).ToBitVector(n8)); } } }
public static string FormatTable <N, T>(BlockMatrix <N, T> src) where T : struct where N : ITypeNat, new() => src.Format(render : x => BitString.FromScalar(x).Format());
public static BitString ToBitString(this float src) => BitString.FromScalar(src);
public static BitString ToBitString(this ulong src) => BitString.FromScalar(src);
public static BitString ToBitString(this ushort src) => BitString.FromScalar(src);
public static BitString ToBitString(this byte src) => BitString.FromScalar(src);
public static BitString ToBitString(this UInt128 src) => BitString.FromScalar(src.hi) + BitString.FromScalar(src.lo);