/// <summary> /// Creates the matrix determined by a permutation /// </summary> /// <param name="src">The source permutation</param> public static BitMatrix32 ToBitMatrix(this Perm <N32> src) { var dst = BitMatrix32.Alloc(); for (var row = 0; row < src.Length; row++) { dst[row, src[row]] = Bit.On; } return(dst); }
public static BitMatrix32 bmm(BitMatrix32 lhs, BitMatrix32 rhs) { var dst = BitMatrix32.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); }
/// <summary> /// Performs no allocation during the benchmark period /// </summary> /// <param name="sw">The counter</param> void bm_xor_32x32_bench_noalloc(SystemCounter sw = default) { var opname = "bm_xor_32x32"; var last = BitMatrix32.Alloc(); for (var i = 0; i < OpCount; i++) { var A = Random.BitMatrix(n32); var B = Random.BitMatrix(n32); sw.Start(); BitMatrix.xor(in A, in B, ref last); sw.Stop(); } Benchmark(opname, sw); }