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)); }
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)); }