Пример #1
0
        public static void VerifyBinOp <T>(IPolyrand random, int blocks, Vector256BinOp <T> inXOp, Func <T, T, T> primalOp)
            where T : unmanaged
        {
            var blocklen = Span256 <T> .BlockLength;

            var lhs = random.ReadOnlySpan256 <T>(blocks);

            Claim.eq(blocks * blocklen, lhs.Length);

            var rhs = random.ReadOnlySpan256 <T>(blocks);

            Claim.eq(blocks * blocklen, rhs.Length);

            var expect = Span256.AllocBlocks <T>(blocks);

            Claim.eq(blocks, expect.BlockCount);

            var actual = Span256.AllocBlocks <T>(blocks);

            Claim.eq(blocks, actual.BlockCount);

            var tmp = new T[blocklen];

            for (var block = 0; block < blocks; block++)
            {
                var offset = block * blocklen;
                for (var i = 0; i < blocklen; i++)
                {
                    tmp[i] = primalOp(lhs[offset + i], rhs[offset + i]);
                }

                var vExpect = Vec256.LoadVector <T>(ref tmp[0]);

                var vX      = lhs.LoadVec256(block);
                var vY      = rhs.LoadVec256(block);
                var vActual = inXOp(vX, vY);

                Claim.eq(vExpect, vActual);

                ginx.store(vExpect, ref expect.Block(block));
                ginx.store(vActual, ref actual.Block(block));
            }
            Claim.eq(expect, actual);
        }