Exemple #1
0
        public static Span128 <T> ToSpan128 <T>(this Vec128 <T> src)
            where T : struct
        {
            var dst = Span128.AllocBlocks <T>(1);

            vstore(src, ref dst[0]);
            return(dst);
        }
Exemple #2
0
 public static Span128 <T> Alloc <T>(int minlen, T?fill = null)
     where T : struct
 {
     Span128.Alignment <T>(minlen, out int blocklen, out int fullBlocks, out int remainder);
     if (remainder == 0)
     {
         return(AllocBlocks <T>(fullBlocks, fill));
     }
     else
     {
         return(Span128.AllocBlocks <T>(fullBlocks + 1, fill));
     }
 }
Exemple #3
0
        public static void VerifyBinOp <T>(IPolyrand random, int blocks, Vector128BinOp <T> inXOp, Func <T, T, T> primalOp)
            where T : unmanaged
        {
            var blocklen = Span128 <T> .BlockLength;

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

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

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

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

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

            Claim.eq(blocks, expect.BlockCount);

            var actual = Span128.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 = Vec128.LoadVector <T>(ref tmp[0]);

                var vX      = lhs.LoadVec128(block);
                var vY      = rhs.LoadVec128(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);
        }
Exemple #4
0
 public static Span128 <T> AllocBlock <T>(T?fill = null)
     where T : struct
 => Span128 <T> .AllocBlocks(1, fill);
Exemple #5
0
 public static Span128 <T> AllocBlocks <T>(int blocks, T?fill = null)
     where T : struct
 => Span128 <T> .AllocBlocks(blocks, fill);