Repository navigation
v0.5.0
Added
-
Four-tier standard library (Cargo features).
prima-stdlibnow splits its modules into
opt-in tiers —core(default: built-in classes +num),system(io/time/sys),
advanced(linalg/stats/physics/plot; pullsnalgebra), andrender(formula
rendering; the heaviest dependency) — with afullaggregate. Theprimabinary now defaults to
full(all tiers, includingrender); theprima-stdliblibrary baseline remainscore, and
leaner binaries use--no-default-features --features <tier>. CI runs--all-features, with a
tier job compiling each level on its own. This isolates the heavy optional dependencies (e.g. the
LaTeX→SVG backend) from the default library build. -
mathstandard-library module (spec §18.6). Integer number theory —gcd/lcm,
factor(prime factorization),primes(sieve),mod_pow, andcrt(Chinese remainder) —
plus polynomial tools over lowest-degree-firstArray<F64>coefficients (poly_eval,
poly_add,poly_mul,poly_derivative,poly_rootsvia Durand–Kerner returning
Array<Complex>) andcontinued_fraction.primesis a layered@builtin(O1)with a.pra
fallback; allocation is bounded by explicit limits.tayloris not yet implemented (it needs a
call-site interceptor) andfactoruses deterministic trial division. -
sys::process/sys::fs/sys::term(spec §18.6). Run external commands through the
platform shell and capture output (process::run,process::exit_code), filesystem queries
(fs::exists/is_file/is_dir/size/read_dir/metadata), and terminal detection
(term::size/is_tty). All fallible operations returnResultand never panic; the
arbitrary-command and arbitrary-path trust boundaries are documented in the module docs. -
physicsformulas andVector3(spec §18.6). Thephysicsmodule is now an embedded
.pramodule rather than a Rust-hosted constants namespace: the CODATA 2022 constants are
declared as typedpub consts (SI-exactInteger/Rationalforms preserved), and the module
gains elementary formulas implemented as Rust@builtins — kinematics (velocity,
displacement,projectile_*), mechanics (force,momentum,kinetic_energy,
potential_energy,work,power), simple harmonic motion (shm_*,simple_pendulum),
thermodynamics (celsius_to_kelvin,kelvin_to_celsius,heat,ideal_gas_pressure), and
electromagnetism (coulomb_force,ohm_*,electrical_power) — plus aVector3class with
new/add/sub/scale/dot/cross/length/normalize. All formulas take and return
F64and report wrong arity or non-real arguments as errors. -
plotheatmaps and contours (spec §18.6).plot::heatmaprenders a scalar grid as a
color-mapped image (viridis-like ramp with a colorbar in the figure margin),plot::contour
draws evenly spaced iso-lines with marching squares, andplot::histrenders a histogram.
Ragged/empty grids and invalid level/bin counts report aRuntimeError;NaN/Infcells are
skipped rather than panicking. -
renderformula rendering (spec §18.6).render::to_svgrenders a symbolic expression or
LaTeX string to a self-contained SVG (core LaTeX view → RaTeXparse/layout/to_display_list
→render_to_svgwith embedded glyph outlines), andrender::to_terminaltransliterates the
same view into Unicode terminal math text. Available behind therendertier, which keeps the
RaTeX dependencies out of the default build. PNG output and theprintterminal-formula
term-renderintegration remain deferred.
Changed
-
The
primabinary now defaults to thefullstdlib tier (all modules, includingrender).
The root package's default Cargo feature isfull, socargo build/cargo install/cargo run
produce a complete binary without--features; theprima-stdliblibrary baseline remains the
leancore(built-in classes +num), and lean binaries use
--no-default-features --features <tier>. -
Numberslimmed to 16 bytes andValueto 24 bytes (spec §5/§6.1). The interpreter/VM
hot-path value types lost their oversized payloads with semantics unchanged.Number::Complex
is now a single boxed pointer (Number::Complex(Box<Complex>), built viaNumber::from_complex
and read viaNumber::as_complex_parts); previously its two inlineBoxfields formed a
16-byte payload with no spare niche, forcing the enum tag out to 24 bytes.Value::Stringand
Value::Errornow holdBox<str>instead ofString, andValue::TupleholdsBox<[Value]>
instead ofVec<Value>— 16-byte fat pointers rather than 24-byte headers, with no extra
allocation (construction goes throughinto_boxed_str/into_boxed_slice). Compile-time
const _: () = assert!(...)guards pin both sizes so a future variant cannot silently regrow
the hot path. Note: flattening theRealenum was not needed — withComplexboxed the
Realvariant's spare discriminants host theNumbertag, soNumberreaches 16 bytes without
touching the ~500Number::Real(…)sites. The default whole-function JIT path is unchanged;
benches/RESULTS.mdwas regenerated (interpreted paths within run-to-run noise).