Esempio n. 1
0
 public Average(SIMDOptions options) => (sum, counter, _options) = (math.Zero, 0, options);
Esempio n. 2
0
 public Sum(SIMDOptions options) => (_options, sum) = (options, math.Zero);
Esempio n. 3
0
        internal static BatchProcessResult Average <T, Accumulator, Quotient, Math>(ReadOnlySpan <T> source, SIMDOptions simdOptions, ref Accumulator result, ref long counter)
            where T : struct
            where Accumulator : struct
            where Quotient : struct
            where Math : struct, IMathsOperations <T, Accumulator, Quotient>
        {
            counter += source.Length;

            return(simdOptions switch
            {
                SIMDOptions.OnlyIfSame => SumNoSimd <T, Accumulator, Quotient, Math>(source, ref result),
                SIMDOptions.WithOverflowHandling => SumSimdChecked <T, Accumulator, Quotient, Math>(source, ref result),
                SIMDOptions.Fastest => SumSimdUnchecked <T, Accumulator, Quotient, Math>(source, ref result),

                _ => throw new InvalidOperationException()
            });