colgreen / Redzen

General purpose C# code library.
Other
95 stars 16 forks source link

MathSpanUtils: Support a wider set of types. #12

Closed colgreen closed 3 years ago

colgreen commented 3 years ago

E.g. We have MathSpanUtils.Sum(Span), MathFSpanUtils.Sum(Span), and would be good to do the same for Int32 and other native types. E.g. see the Clamp() overloads here:

https://github.com/dotnet/runtime/blob/master/src/libraries/System.Private.CoreLib/src/System/Math.cs

Consider merging MathSpanUtils and MathFSpanUtils, and using partial classes to split the code into multiple files. Perhaps put all of the like method overloads in one file (i.e. all Clamp method in one file).

Also, consider renaming the class to MathSpan or SpanMath.

colgreen commented 3 years ago

Remaining methods to implement:

MathSpan.Int32.cs Sum(), MinMax(), MedianOfSorted(), Clip()

colgreen commented 3 years ago

Done. In 9777bb004fbce5782576812a8e67c076dbd50b1f and d3ccd83afacaa6832b7429cc498ca71e16e99f93,