Exemplo n.º 1
0
        public static Span <N, T> Contract <N, T>(this Span <N, T> src, Span <N, T> max)
            where N : ITypeNat, new()
            where T : struct
        {
            var dst = NatSpan.Alloc <N, T>();

            for (var i = 0; i < dst.Length; i++)
            {
                dst[i] = Contractors.Contract(src[i], max[i]);
            }
            return(dst);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Effects a component-wise contraction on the source vector on a source vector of unsigned primal type,
        /// dst[i] = src[i].Contract(max[i])
        /// </summary>
        /// <param name="src">The vector to contract</param>
        /// <param name="max">The upper bound</param>
        /// <typeparam name="N">The length type</typeparam>
        /// <typeparam name="T">The unsigned primal type</typeparam>
        public static BlockVector <T> Contract <T>(this BlockVector <T> src, BlockVector <T> max)
            where T : struct
        {
            var len = src.Length;

            require(len == max.Length);
            var dst = BlockVector.Alloc <T>(len);

            for (var i = 0; i < dst.Length; i++)
            {
                dst[i] = Contractors.Contract(src[i], max[i]);
            }
            return(dst);
        }