Exemplo n.º 1
0
        /// <summary>
        /// Creates the matrix determined by a permutation
        /// </summary>
        /// <param name="src">The source permutation</param>
        public static BitMatrix64 ToBitMatrix(this Perm <N64> src)
        {
            var dst = BitMatrix64.Alloc();

            for (var row = 0; row < src.Length; row++)
            {
                dst[row, src[row]] = Bit.On;
            }
            return(dst);
        }
Exemplo n.º 2
0
 public void bm_and_64x64x64g_check()
 {
     for (var i = 0; i < SampleSize; i++)
     {
         var A  = Random.BitMatrix <N64, ulong>();
         var B  = Random.BitMatrix <N64, ulong>();
         var C1 = BitMatrix.and(in A, in B);
         var C2 = BitMatrix64.From(C1);
         var C3 = BitMatrix64.From(A) & BitMatrix64.From(B);
         Claim.yea(C2 == C3);
     }
 }
Exemplo n.º 3
0
        public static BitMatrix64 bmm(BitMatrix64 lhs, BitMatrix64 rhs)
        {
            var dst = BitMatrix64.Alloc();

            rhs = rhs.Transpose();
            for (var i = 0; i < lhs.RowCount; i++)
            {
                var row = lhs.RowVector(i);
                for (var j = 0; j < rhs.ColCount; j++)
                {
                    var col = rhs.RowVector(j);
                    dst[i, j] = ModProd(row, col);
                }
            }
            return(dst);
        }
Exemplo n.º 4
0
        public void bm_and_64x64_check()
        {
            for (var i = 0; i < SampleSize; i++)
            {
                var A = Random.BitMatrix(n64);
                var B = Random.BitMatrix(n64);

                var xBytes = A.Bytes.Replicate();
                var yBytes = B.Bytes.Replicate();
                var zBytes = gbitspan.and(xBytes, yBytes);
                var expect = BitMatrix64.From(zBytes);

                var C = A & B;
                Claim.yea(expect == C);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Performs no allocation during the benchmark period
        /// </summary>
        /// <param name="sw">The counter</param>
        void bm_xor_64x64_bench_noalloc(SystemCounter sw = default)
        {
            var opname = "bm_xor_64x64";
            var last   = BitMatrix64.Alloc();

            for (var i = 0; i < OpCount; i++)
            {
                var A = Random.BitMatrix(n64);
                var B = Random.BitMatrix(n64);
                sw.Start();
                BitMatrix.xor(in A, in B, ref last);
                sw.Stop();
            }

            Benchmark(opname, sw);
        }
Exemplo n.º 6
0
 public static ref Matrix <N64, T> unpack <T>(BitMatrix64 src, ref Matrix <N64, T> dst)
     where T : unmanaged
 {
     gbits.unpack(src.Data, dst.Data.AsSpan());
     return(ref dst);
 }