Softanza
StartFrançais
Softanza
Core data & language

Numeric & optimization

Exactness NumPy lacks, LAPACK-tier decompositions and autodiff; not a NumPy by design.

5 Strong · 5 Solid · 2 Partial · 0 Emerging

Measured against: NumPy · Eigen · GSL · SciPy · Folders: base/number(opens in a new tab) · base/optim(opens in a new tab) · For programmers: this area's reference

a scatter plot of x squared from the chart family
a scatter plot of x squared from the chart family. rendered on 2026-10-01 at 04:00 by the site's render script tools/areas.ring, run inside the library at commit 0e72e2e2c · the source(opens in a new tab)

Rethought from first principles

What Softanza kept from what works, and what it rethought, as the library wrote it down in its design documents and narrations.

The Softanza wayA number should know whether it is exact and say why when it is not, and the frame that bends a result must be visible where the number is used.

Kept from the best practice

  • Machine numbers stay IEEE-754 double precision, with half-even rounding as the stated default, the accounting rule, because half-up rounding drifts a long ledger upward. source(opens in a new tab)
  • Numerically stable textbook methods by default: compensated summation, Welford moments, and the standard LU, QR, Cholesky and SVD decompositions. source(opens in a new tab)
  • Results are judged against reference oracles — NumPy and exact rationals — with a tolerance derived from the problem's conditioning, never a hand-picked constant. source(opens in a new tab)

Rethought

  • One number type, many inner forms — integer, big integer, rational, decimal — chosen automatically, because users should not carry a type decision the system can make. source(opens in a new tab)
  • A number knows whether it is exact, and WhyNotExact() names what was lost, because numeric surprise usually comes from a frame the caller could not see. source(opens in a new tab)
  • The regime travels with the value: money keeps two places with banker's rounding, an exact number refuses to become approximate, instead of a global mode set by whoever ran last. source(opens in a new tab)
  • An optimization model can be an object, a sentence or a file, all building one model, so two surfaces can never silently disagree; Why() names the solver used. source(opens in a new tab)

The most rigorously measured module in the library: P0-P7 complete, ~1,827 assertions, every parallel route gated by a measured threshold and every kernel bit-identical under threads. It leads with something NumPy has no concept of, exactness: an arbitrary-precision numeric tower with a register that tells you why a value is exact or not. It reaches LAPACK-tier decompositions and ships reverse-mode autodiff with L-BFGS. It is deliberately not a NumPy: no broadcasting, raw matmul peak below tuned BLAS, and it refuses what it cannot measure a use for.

What a crafter does with it, and what stands out

  • An exactness register (IsExact, Why, Representation) that NumPy has no concept of
  • General non-symmetric eigen with a Francis double-shift QR, hand-rolled and verified
  • Reverse-mode autodiff paired with a real quasi-Newton (L-BFGS) optimizer
  • Nothing parallel ships without a measurement; many gaps are deliberate, measured refusals

What is owed

  • Arbitrary-N and multi-dimensional FFT (mixed-radix / Bluestein, rfft, 2-D)
  • Complete the complex surface: log, inverse-trig and general powers
  • Adaptive quadrature and an ODE stepper
  • Broaden sampling distributions (binomial, Poisson, gamma, beta, Dirichlet)

The Softanza way, run

What Softanza does differently in this area, shown by code taken from its narrations and guards, and run for this page.

One divided by three does not pretend to be exact, and the number itself says why.

Softanza
oThird = new stzNumber("1")
oThird.Divide("3")
Then("1 / 3 does NOT claim to be exact", oThird.IsExact(), FALSE)
Then("...and says why", StzFindFirst("does not terminate", oThird.Why()) > 0, TRUE)
Output
  THEN  1 / 3 does NOT claim to be exact  [PASS]
  THEN  ...and says why  [PASS]

run on 2026-10-01 21:17 inside the library at commit 0e72e2e2c; taken from base/test/number/numeric_exactness_narrated.ring(opens in a new tab)

A price declared as money stays money: a rate applied to it lands on two decimal places, not 2.9985.

Softanza
oPrice = StzMoneyQ("19.99")
oPrice.MultiplyBy("0.15")
Then("a rate applied to it lands on money, not 2.9985", oPrice.Content(), "3.00")
Output
  THEN  a rate applied to it lands on money, not 2.9985  [PASS]

run on 2026-10-01 21:17 inside the library at commit 0e72e2e2c; taken from base/test/number/numeric_regime_narrated.ring(opens in a new tab)

An optimization problem written as a sentence is solved like the same model built in code, and reaches 130.

Softanza
oS = StzOptimNaturally("
maximize 3*x + 2*y
where x is between 0 and 40
and y is a whole number at least 0
keeping x + y under 50
and keeping 2*x + y under 80
")
oS.SolveWith(:auto)
? oS.Objective()
Output
130

run on 2026-10-01 21:17 inside the library at commit 0e72e2e2c; taken from base/test/optim/optim_modelling_narrated.ring(opens in a new tab)

The articles of this area (4)

The lanes, one by one

Lanes and their notes are quoted as they were read at the source, on Read from the source on 2026-09-16.

Scalar arithmetic and exactness
Strong
Arbitrary-precision tower over std.math.big: bignum, exact rationals, money-exact decimal (0.1+0.2 is exactly 0.3), plus IsExact()/Why()/Representation()IsExact() / Why() / Representation()
Matrices and linear algebra
Strong
matrix.zig + linalg.zig: SIMD/threaded matmul, LU determinant, Solve, Inverse, LeastSquares, PseudoInverse (Penrose-4 verified), rank, condition; vs NumPymatrix.zig / linalg.zig vs NumPy oracle
Eigen and decompositions
Strong
Symmetric Jacobi eigen plus general non-symmetric eigen (balancing, Hessenberg, Francis double-shift QR, Schur), Jacobi SVD, Householder QR, Cholesky, rootseigen_general.zig
Automatic differentiation and optimization
Strong
Reverse-mode autodiff (compiled tape, valueAndGradient) and L-BFGS with strong-Wolfe line search; verified to 8-12 decimals; Rosenbrock in 34 iterationsautodiff.zig / lbfgs.zig
Acceleration and residency
Strong
SIMD + row-banded threaded matmul (16x cache reorder, up to 7x threaded), Neumaier summation (2.5x), resident reductions 19x; every route gated by calib.Gatecalib.Gate thresholds; bit-identical under threads
Vectors and buffers
Solid
stzNumBuffer over numbuf.zig: an engine-owned f64 buffer with dot/scale/add/sub/mul and reductions that never marshal; no broadcasting, no n-D arraysnumbuf.zig
Linear and integer programming
Solid
Engine simplex (41x after a cubic re-parse fix) with branch-and-bound MIP, stzOptimModel DSL, exact coefficient compiler, .zopt round-trip; no IPM, no QPsimplex.zig; base/optim
Special functions
Solid
special.zig: erf/erfc, log-gamma and gamma, incomplete gamma and beta, Normal/t/chi-square/F CDFs and quantiles; no Bessel, Airy, elliptic or hypergeometricspecial.zig
Solvers and roots
Solid
solver.zig: linear and quadratic roots, bisection, Newton, Simpson integration, polynomial eval, lerp/clamp/map-range; no adaptive quadrature, no ODE/BVPsolver.zig
Random and sampling
Solid
random.zig over Xoshiro/PCG/ChaCha: seeded ints, floats, Gaussian, exponential, shuffle, Bernoulli, weighted choice under SeedRandom; no binomial/Poisson/gammarandom.zig
FFT and spectral
Partial
fft.zig: radix-2 Cooley-Tukey with the NumPy fft/ifft convention, convolveReal, magnitudes, phases, power spectrum; radix-2 only, no rfft, no multi-dimensionalfft.zig
Complex numbers
Partial
complex.zig: arithmetic, modulus (hypot), argument, conjugate, principal sqrt and exp, division via Smith's formula; no log, inverse-trig or general powerscomplex.zig