예제 #1
0
        public static ushort SIMD_Average(ushort *ptr, long length, TypeCode range = TypeCode.Empty)
        {
            Assert.IsNonNegative(length);

            range = (range == TypeCode.Empty) ? GetSafeRange.Summation(TypeCode.UInt16, length) : range;

            return((ushort)((SIMD_Sum(ptr, length, range) + 1) / (ulong)length));
        }
예제 #2
0
        public static short SIMD_Average(short *ptr, long length, TypeCode range = TypeCode.Empty)
        {
            Assert.IsNonNegative(length);

            range = (range == TypeCode.Empty) ? GetSafeRange.Summation(TypeCode.UInt16, length) : range;

            long sum      = SIMD_Sum(ptr, length, range);
            bool greater0 = sum > 0;

            return((short)((sum + *(byte *)&greater0) / length));
        }