public Average(SIMDOptions options) => (sum, counter, _options) = (math.Zero, 0, options);
Exemple #2
0
 public Sum(SIMDOptions options) => (_options, sum) = (options, math.Zero);
Exemple #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()
            });