Exemplo n.º 1
0
Arquivo: Bit.x.cs Projeto: 0xCM/arrows
 /// <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]);
         }
     }
 }
Exemplo n.º 2
0
        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));
                }
            }
        }
Exemplo n.º 3
0
 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());
Exemplo n.º 4
0
 public static BitString ToBitString(this float src)
 => BitString.FromScalar(src);
Exemplo n.º 5
0
 public static BitString ToBitString(this ulong src)
 => BitString.FromScalar(src);
Exemplo n.º 6
0
 public static BitString ToBitString(this ushort src)
 => BitString.FromScalar(src);
Exemplo n.º 7
0
 public static BitString ToBitString(this byte src)
 => BitString.FromScalar(src);
Exemplo n.º 8
0
 public static BitString ToBitString(this UInt128 src)
 => BitString.FromScalar(src.hi) + BitString.FromScalar(src.lo);