예제 #1
0
        public void dot()
        {
            var v1 = Random.BlockVec <N256, double>();
            var v2 = Random.BlockVec <N256, double>();

            var x = mkl.dot(v1, v2).Round(4);
            var y = Dot(v1, v2).Round(4);

            Claim.eq(x, y);
        }
예제 #2
0
        public void vAbsF64()
        {
            var src  = Random.BlockVec <double>(Pow2.T08);
            var dst1 = src.Replicate(true);

            mkl.abs(src, ref dst1);
            var dst2 = src.Replicate();

            mathspan.fabs(src, dst2.Unblocked);
            Claim.yea(dst1 == dst2);
        }
예제 #3
0
        public void vMulF64()
        {
            var lhs  = Random.BlockVec <N256, double>();
            var rhs  = Random.BlockVec <N256, double>();
            var dst1 = BlockVector.Alloc <N256, double>();

            mkl.mul(lhs, rhs, ref dst1);

            var dst2 = lhs.Replicate(true);

            mathspan.mul(lhs.Unsized, rhs.Unsized, dst2.Unsized);
            Claim.yea(dst1 == dst2);
        }
예제 #4
0
        void blockv_sub_check <N, T>()
            where N : ITypeNat, new()
            where T : unmanaged
        {
            var n   = new N();
            var dst = BlockVector.Zero <N, T>();

            for (var i = 0; i < SampleSize; i++)
            {
                var v1 = Random.BlockVec <N, T>();
                var v2 = Random.BlockVec <N, T>();
                var v3 = BlockVector.Load(mathspan.sub(v1.Unsized, v2.Unsized), n);
                Linear.sub(v1, v2, ref v1);
                Claim.yea(v3 == v1);
            }
        }
예제 #5
0
파일: t_blockv_add.cs 프로젝트: 0xCM/arrows
        void blockv_add_check <N, T>()
            where N : ITypeNat, new()
            where T : unmanaged
        {
            var n  = new N();
            var v4 = BlockVector.Alloc <N, T>();

            for (var i = 0; i < CycleCount; i++)
            {
                var v1 = Random.BlockVec <N, T>();
                var v2 = Random.BlockVec <N, T>();
                var v3 = BlockVector.Load(mathspan.add(v1.Unsized, v2.Unsized), n);
                Linear.add(ref v1, v2);
                Claim.yea(v3 == v1);
            }
        }
예제 #6
0
        void blockv_sub_bench <N, T>(N n = default)
            where T : unmanaged
            where N : ITypeNat, new()
        {
            var opcount = CycleCount * RoundCount;
            var sw      = stopwatch(false);
            var opname  = $"blockv_sub_{n}x{bitsize<T>()}";
            var dst     = BlockVector.Zero <N, T>();

            for (var i = 0; i < opcount; i++)
            {
                var v1 = Random.BlockVec <N, T>();
                var v2 = Random.BlockVec <N, T>();
                sw.Start();
                Linear.sub(v1, v2, ref v1);
                sw.Stop();
            }
            Collect((opcount, sw, opname));
        }
예제 #7
0
        void and <N, T>()
            where T : unmanaged
            where N : ITypeNat, new()
        {
            var rep     = new N();
            var len     = (int)rep.value;
            var u       = Random.BlockVec <N, T>();
            var v       = Random.BlockVec <N, T>();
            var vResult = Linear.and(u, v);

            var calcs = span <T>(len);

            for (var i = 0; i < calcs.Length; i++)
            {
                calcs[i] = gmath.and(u[i], v[i]);
            }
            var vExpect = BlockVector.Load(calcs, rep);

            Util.ClaimEqual(vExpect, vResult);
        }
예제 #8
0
 protected BlockVector <double> RVecF64 <N>(N len = default, long?min = null, long?max = null)
     where N : ITypeNat, new()
 => Random.BlockVec <N, long, double>(closed(min ?? -25L, max ?? 25L));
예제 #9
0
 protected BlockVector <float> RVecF32 <N>(N len = default, int?min = null, int?max = null)
     where N : ITypeNat, new()
 => Random.BlockVec <N, int, float>(closed(min ?? -25, max ?? 25));
예제 #10
0
 protected BlockVector <double> RVecF64(int len, long?min = null, long?max = null)
 => Random.BlockVec <long, double>(len, closed(min ?? -25L, max ?? 25L));
예제 #11
0
 protected BlockVector <float> RVecF32(int len, int?min = null, int?max = null)
 => Random.BlockVec <int, float>(len, closed(min ?? -25, max ?? 25));
예제 #12
0
 protected BlockVector <N, T> RVec <N, T>(N len = default, T rep = default)
     where N : ITypeNat, new()
     where T : struct
 => Random.BlockVec <N, T>();
예제 #13
0
 protected BlockVector <T> RVec <T>(int?len = null, T rep = default)
     where T : struct
 => Random.BlockVec <T>(len ?? DefaultVectorLength);