public void bitblock32_spans() { var x = BitBlock32.Alloc(); x.Bit0 = 1; x.Bit5 = 1; x.Bit19 = 1; var y = BitBlock.AsSpan(ref x); Claim.eq(y[0], x.Bit0); Claim.eq(y[5], x.Bit19); Claim.eq(x[0], (byte)1); Claim.eq(x[5], (byte)1); Claim.eq(x[19], (byte)1); for (var i = 0; i < SampleSize; i++) { var src = Random.Span <byte>(Pow2.T05); var dstBlock = BitBlock32.FromSpan(src); for (var j = 0; j < src.Length; j++) { Claim.eq(src[j], dstBlock[j]); } var dstSpan = BitBlock.AsSpan(ref dstBlock); for (var j = 0; j < dstSpan.Length; j++) { Bits.toggle(ref dstSpan[j], 0); Claim.neq(dstBlock[j], src[j]); } } }
public uint ToUInt32() => BitBlock.AsSpan(ref this).TakeUInt32();
public static ref byte Bit(ref BitBlock <T> src, BitPos i) => ref Unsafe.Add(ref Unsafe.As <BitBlock <T>, byte>(ref src), i);
public static BitBlock <BitBlock10> ToBitBlock(this BitString src, N10 n) => BitBlock.FromSpan <BitBlock10>(src.BitSeq);
public static BitBlock <BitBlock32> ToBitBlock(this BitString src, N32 n) => BitBlock.FromSpan <BitBlock32>(src.BitSeq);
public static BitBlock <T> AsGeneric <T>(this ref T src) where T : unmanaged, IBitBlock => BitBlock.AsGeneric(ref src);
public static BitBlock <BitBlock21> ToBitBlock(this BitString src, N21 n) => BitBlock.FromSpan <BitBlock21>(src.BitSeq);
public static Span <byte> part32x1(uint src) { BitBlock32 block = default; return(BitBlock.AsSpan(ref part32x1(src, ref block))); }
public static BitBlock <T> Alloc <T>() where T : unmanaged, IBitBlock => BitBlock <T> .Alloc();
public static BitBlock <T> FromSpan <T>(Span <byte> src) where T : unmanaged, IBitBlock => BitBlock <T> .FromSpan(src.Slice(0, Unsafe.SizeOf <T>()));
public ulong ToUInt64() => BitBlock.AsSpan(ref this).TakeUInt64();