Skip to content

Releases: colgreen/Redzen

v16.0.0

28 Sep 20:23
Compare
Choose a tag to compare
  • Target framework updated from net7.0 from net8.0.
  • Use of C#12 syntax, and new helper extensions.

v15.0.0

22 Jul 18:36
Compare
Choose a tag to compare
  • Target framework updated to net7.0 from net6.0.
  • Generic Math
    • MathSpan: Use of generic math in method signatures and implementations.
    • FloatUtils supersedes DoubleUtils/SingleUtils.
    • DiscreteDistribution supersedes Double/Single.DiscreteDistribution.
    • DiscreteDistribution: added Sample() method, to replace DiscreteDistributionUtils/Sample() static method.
    • Added NumericsUtils.StochasticRound()
    • IRandomSource: Added NextHalf(), NextHalfNonZero(), NextUnitInterval(), NextUnitIntervalNonZero().
    • CircularBufferWithStats supersedes CircularBufferWithStats (that provided double precision stats only).

v14.0.0

01 Jan 10:00
Compare
Choose a tag to compare

Breaking Changes

  • IntroSort API changed from IntroSort{K,V,W}.Sort(...) to IntroSort.Sort{K,V,W}(...).
  • Refactor of the Timsort public API. It now presents a single set of set of Timsort.Sort() methods with generic type parameters on the method. Previously the type params were on the three different Timsort generic classes, which made for a poor public API.
  • Refactor of HistogramData.

New

  • Added AsSpan() method to IntStack and LightweightStack{T}.
    • Added RentedArray.

Improvements

  • XML documentation corrections and improvements.
  • Performance: Defined SkipLocalsInit attribute on the Redzen assembly. The previous attempt to do this was incorrect and didn't actually cause local field initialization to be skipped.

v13.0.0

09 Jan 20:15
Compare
Choose a tag to compare

General

  • Target framework upgraded from net5.0 to net6.0; this allows use of some new API surface in net6.

Fixes

  • BoxMullerGaussianSampler, ZiggurateSampler, BoxMullerGaussianStatelessSampler, ZigguratGaussianStatelessSampler: Fixed Span based Sampler methods to use defined distribution mean and standard deviation.

Breaking Changes

  • Moved Shuffle(Span) from SortUtils to SpanUtils.
  • Deleted ListSortUtils.Shuffle(IList), as this can now be achieved more cleanly and efficiently using CollectionsMarshall.AsSpan() and SpanUtils.Shuffle().
  • Deleted ParallelSort. For most cases a multi-threaded sort is not a good choice, and for those cases where it may be a good choice, doing it with pure quicksort implemented with Parallel.Invoke() is likely not a good choice.
  • Deleted ListSortUtils. For these methods that operate on IList (and in one case List), this functionality can now be achieved by using the Span based methods in SortUtils, in combination with CollectionsMarshal.AsSpan(). Keeping this code would just create maintenance overhead for code that exists only for legacy reasons.

New

  • Added WyRandom PRNG class. This has superior statistical qualities compared to the xoshiro PRNGs, and performs at about the same speed on x86 systems with the BMI2 MULX instructions.
  • Added DoubleUtils, SingleUtils, with methods IsNonNegativeReal(), IsPositiveReal(), AllNonNegativeReal(Span), AllPositiveReal(Span).
  • MathSpan(): Added methods Multiply(Span,Span) for type double, float and Int32.
  • IStatelessSampler: Added Sample(out T x, IRandomSource rng) method.
  • ISampler: Added void Sample(out T x) for fast ref based sampling directly into an existing variable.
  • Added missing class Float.BoxMullerGaussianStatelessSampler.
  • ZigguratGaussian: Added void Sample(IRandomSource rng, out double x) method for fast ref based sampling directly into an existing variable.
  • Added SortUtils.SortUnstable() method; for spans of IComparable types.

Improvements

  • DefaultRandomSeedSource: Use RandomNumberGenerator.Fill() instead of RNGCryptoServiceProvider.GetBytes() (now deprecated).
  • SortUtils.IsSortedAscending: Significant performance improvements for native primitive types, by use of native comparison operators for those types.
  • DiscreteDistribution: Added check for non-legal probability values. Use vectorized span sum and multiplication. Micro-optimizations.
  • ZigguratGaussian, UniformDistribution: micro-optimizations: Set sign bit directly instead of conditional multiply by -1.
  • ZigguratGaussian micro-optimization: Replace single divide op with multiply by reciprocal.
  • Enabled SkipLocalsInit compiler setting. This provides a small performance benefit to most (all?) methods.

v12.0.0

14 Mar 15:06
Compare
Choose a tag to compare
  • Target framework upgraded from netcoreapp3.1 to net5.0; this allows use of some new API surface in net5 which improves performance in places.

  • The redzen assembly is no longer strong named, as this is no longer necessary or helpful within a dotnet core runtime environment.

  • The following classes, interfaces, and methods have been 'spanified':

    • TimSort{T}, TimSort{K,V}, TimSort{K,V,W}
    • IntroSort{K,V,W}
    • SortUtils
    • NumericsUtils
    • Base64EncodingOutputStream
    • ISampler, IStatelessSampler
    • MemoryBlockStream
    • NonClosingStreamWrapper.
  • TimSort: Replaced BinarySort() method with a simple InsertionSort() method that performs much better.

  • IntroSort{K,V,W} performance tweaks.

  • Added MathSpan.Min(), Max() for double, float, and Int32.

  • Added MathSpan.SumOfSquares() for double, float values.

  • Added MathSpan Int32 overloads.

  • EnumerableUtils.RangeRandomOrder() now gets a temp array from ArrayPool (to reduce memory allocs and garbage collection).

  • Added DiscreteDistribution.SingleOutcome singleton field.

  • FileByteArray now uses smaller buffer size.

  • DefaultRandomSeedSource: Sealed the class. Use stackalloc for obaining crypto random bytes. Integer arithmetic using bitshifts (performance tweak).

  • Rename: NumericsUtils.ProbabilisticRound() to StochasticRound().

  • Rename: CalculateMedian() to Median(), and moved from NumericsUtils to MathSpan.

  • Rename: DoubleCircularBufferWithStats to CircularBufferWithStats.

  • Fix: MathUtils.Log2Ceiling(uint) gave incorrect results when the high bit was set.

  • MathUtils.IsPowerOfTwo() implementions changed to use BitOperations.PopCount() instead of arithmetic trick (performance tweak).

  • IRandomSource.NextBytes(Span{byte}) implementations reimplemented to use modern faster techniques for populating 8 bytes at a time (approx. 7% performance boost)

  • SpanUtils.Equals{T}() renamed to Equal{T}().

  • Multiple other small fixes and improvements; see repository git history for full details.

v11.0.0

02 Aug 14:39
Compare
Choose a tag to compare
  • Enabled nullable reference types (introduced as part of C#8).
  • Added Float.BoxMullerGaussian, ZigguratGaussian, DiscreteDistribution and related classes.
  • Rename MathArrayUtils to MathSpanUtils.
  • Added MathFSpanUtils; a single-precision floating-point equivalent of MathSpanUtils.
  • Deleted ArrayUtils; this is superseded by SpanUtils.
  • Fix: Base64EncodingOutputStream.Write() - incorrect offset bound check.
  • Eliminate a single branch from the ZigguratGuassian class; in synthetic benchmarks this improves performance by approx. 36%.
  • Fix: NextDoubleNonZero() could return zero (very infrequently)
  • RandomSourceBase.Next(): Use high bits as the source of entropy, as these generally exhibit high quality randomness in LCG PRNGs.
  • Removed a number of AggressiveInlining attributes where, on balance, they are not useful.
  • XorShiftRandom: Removed redundant test of maxValue.
  • Doubled sampling resolution of NextDoubleNonZero().
  • Added IRandomSource.NextFloatNonZero()

9.1.1

05 Jul 17:03
Compare
Choose a tag to compare

Fix: NextDoubleNonZero() could return zero (#5)