Runnable samples
The repository ships runnable, self-contained sample projects for Bodu.Numerics (and its
Bodu.Numerics.Serialization.Json companion) under
samples/Numerics/. All four
samples are offline and deterministic - they format with the invariant culture so output
does not vary by machine - and are members of bodu.slnx, built and executed by CI, so the code
they show cannot drift from the current API. Each sample's README documents every scenario
individually: its intent, what the code does, the output to expect, and the APIs demonstrated.
Run any sample from the repository root:
dotnet run --project samples/Numerics/<SampleName>
The samples
Bodu.Numerics.Samples.Fractions
Exact rational arithmetic with Fraction<T>: construction and auto-reduction,
+ − × ÷ over Fraction<int> and Fraction<BigInteger>, parse/format, Fraction<T> as a
first-class INumber<TSelf> in generic algorithms, and the continued-fraction
surface (ToContinuedFraction, Approximate, LimitDenominator - e.g. approximating π to
355/113). Package: Bodu.Numerics.
Bodu.Numerics.Samples.Intervals
The interval algebra: Interval<T> closed/open/half-open factories with
Contains/Overlaps; the convex-hull union and the two-piece Difference /
SymmetricDifference results as IntervalPair<T>; the integer-aware
DiscreteInterval<T> with adjacency-merge and DiscreteIntervalPair<T>; and
the normalizing IntervalSet<T> with membership, union/intersect/except, and
complement. Package: Bodu.Numerics.
Bodu.Numerics.Samples.StreamingStatistics
The single-pass statistics types: RunningStatistics<T> (Welford mean, population/sample
variance and standard deviation, min/max), the sliding-window MovingSum<T> and
MovingMinMax<T>, the streaming RunningQuantile<T> (median and p95 estimators), and
BigDecimal exact scaled arithmetic with rounding modes. Package: Bodu.Numerics.
Bodu.Numerics.Samples.ComplexNumbers
Complex<T>, the generic counterpart of the double-only
Complex: the arithmetic operators (including the non-componentwise
multiply), Conjugate / Reciprocal / Magnitude / Phase, polar construction, and the
transcendental surface (Sqrt of a negative real, Euler's identity through Exp, Log, Pow,
and the trig functions) - each result printed beside System.Numerics.Complex's answer for the
same call. A closing scenario runs one generic Mandelbrot iteration over Complex<float>,
Complex<double>, and Complex<Half> to show where the precision choice actually changes the
answer, and covers parse/format round-tripping and the Equals-versus-== split on NaN.
Package: Bodu.Numerics.
Bodu.Numerics.Samples.JsonConverters
System.Text.Json integration from the companion package: AddNumericsJsonConverters()
registration round-tripping Fraction<T> / Interval<T> / DiscreteInterval<T> /
IntervalSet<T>, the NumericsJsonPolicy string-vs-object wire shapes, the
FractionJsonExtensions read/write helpers, and a nested POCO whose numeric-typed properties
round-trip in one document. Package: Bodu.Numerics.Serialization.Json.
Related
- Financial samples - money and exchange-rate types, including a dedicated JSON sample built on the same companion-package pattern.