Exemple #1
0
        public static float Sum(ReadOnlySpan <float> source)
        {
            Contracts.AssertNonEmpty(source);

            if (Avx.IsSupported)
            {
                return(AvxIntrinsics.Sum(source));
            }
            else if (Sse.IsSupported)
            {
                return(SseIntrinsics.Sum(source));
            }
            else
            {
                float sum = 0;
                for (int i = 0; i < source.Length; i++)
                {
                    sum += source[i];
                }
                return(sum);
            }
        }