Numerics
A numerical and control library for Luau and Rune scripts: linear algebra, differential equations, optimization, signal processing and control design, with a table from MATLAB function names to the Eustress calls.
01Overview
What It Is
The numerics library solves the equations that simulation and control work produce: systems of linear equations, differential equations, minimization, and the design of controllers.
The library is the eustress-numerics crate. It is written in pure Rust and uses 64-bit floating-point numbers throughout. Matrices have any size. Function names follow MATLAB (the core language, the Control System Toolbox and the numerics used with it), so a MATLAB name maps directly to a Eustress name. A call with bad input returns an error and does not crash.
Luau and Rune scripts reach the library, in Studio and in the Player. Luau scripts use a read-only global table named Numerics. Rune scripts import the module eustress::realism::numerics. One implementation sits behind both, and the 42 names Luau reaches have the same names and results in Rune.
Luau reaches 42 of the library's routines. Rune reaches those 42, 101 more functions and 10 types, which makes 143 function names in all. The Script column of the name tables below states, for every row, which of three groups its routines fall in: Luau and Rune, Rune only, or Rust only. A routine in the third group is part of the Rust crate eustress-numerics and no script calls it. How a script writes a call, a matrix, a callback and an error is covered once, on this page, under Your First Call and Conventions.
What Is In It
It is organized in six areas, each with its own page. The name tables further down mark which routines of each area Luau and Rune reach, which only Rune reaches, and which stay in Rust.
- Linear Algebra and Polynomials: solving systems, rank and null space, the LU, QR, Cholesky, singular value, eigenvalue and Schur factorizations, matrix exponential, logarithm and square root, Sylvester and Lyapunov equations, polynomial roots, fitting and partial fractions.
- Differential Equations: the ode45, ode23, ode15s, ode23s and ode_radau solvers, with events and dense output.
- Optimization: fzero, fminsearch, fminunc, lsqnonlin and fsolve.
- Calculus and Signal: integral, trapz and cumtrapz, interp1 with pchip and spline, fft, filter and freqz.
- Control Design: transfer function, state-space and zero-pole-gain models, time and frequency response, discretization, Riccati equations, LQR, pole placement, Kalman gains, model reduction and PID tuning.
- Performance: the measured accuracy and run-time tables.
What Works Today
The library is finished and tested: 119 of 119 tests pass. Each routine in the name tables has a named test. What the library does not cover is listed under Not Covered, and What to Use Instead.
The crate compiles for the web target (wasm32-unknown-unknown). Nothing runs on the GPU.
Luau scripts run the 42 routines they reach. Rune scripts run those 42 plus the 101 more functions and the 10 types. Both run in Studio and in the Player. Every other routine on this page is part of the Rust crate only.
02Coming from MATLAB
How to Read the Tables
Each table lists a MATLAB function in the left column and the matching Eustress calls beside it.
Names follow MATLAB. Where the Eustress name differs, both appear: the MATLAB tf2zp is tf2zpk here, and MATLAB's single fminunc is two routines, one that estimates the gradient and one that takes it. One MATLAB function can map to several Eustress routines (solve, solve_vec and lstsq for mldivide), and a Eustress routine with no MATLAB counterpart has a row with a description in the MATLAB column.
The Notes column gives the status of each row. done means the routine is covered. partial means it works with the limit stated. beyond MATLAB marks a routine MATLAB does not have. A note after "done" states a difference in behavior from MATLAB. Anything that is not covered appears under Not Covered, and What to Use Instead.
The Script column states how a script reaches a row, in up to three clauses in this order. Luau and Rune lists names both languages call. The same name serves both: Luau writes Numerics.solve(...)Rune writes numerics::solve(...)?. Rune only lists what only Rune calls: a function by its name, a type by its constructor such as Tf::new, a method written as method poles of Tf and Ss (Rune calls it on a value, as in g.poles()), or an option or argument of a solver. Rust only lists names that no script calls. Every name in the Eustress column sits in exactly one clause, except pchip and spline, which a script reaches as method strings of interp1. The column lists base names; each routine that takes options also has a _with form, described under Your First Call.
Luau reaches 42 names. Rune reaches those 42, 101 more functions and 10 types. Some rows hold more than one Eustress name, and the cell then has one clause per group. A script calls solve with a vector on the right to get what solve_vec returns, and with a non-square matrix to get the least-squares solution that lstsq returns; Rune also calls lstsq itself. A script reaches pchip and spline as method strings of interp1.
Linear Algebra
Details and the factorization shapes are on the Linear Algebra and Polynomials page.
| MATLAB | Eustress | Script | Notes |
|---|---|---|---|
mldivide | solve, solve_owned, solve_vec | Luau and Rune: solve; Rust only: solve_owned, solve_vec | done; a non-square system goes to lstsq; solve_owned takes its matrices by value and factors in place |
| mldivide, non-square matrix | lstsq | Rune only: lstsq | done; a wide or rank-deficient system returns the minimum-norm solution where MATLAB returns a basic one |
inv | inv | Luau and Rune: inv | done |
det | det | Luau and Rune: det | done |
rank | rank | Rune only: rank | done |
null | null | Rune only: null | done |
orth | orth | Rune only: orth | done |
pinv | pinv | Rune only: pinv | done |
norm | norm, vec_norm | Rune only: norm, vec_norm | done; the 1, 2, inf and Frobenius norms |
cond | cond | Rune only: cond | done (2-norm) |
lu | lu | Rune only: lu | done |
qr | qr, qr_thin | Rune only: qr, qr_thin | done |
chol | chol | Rune only: chol | done |
svd | svd, svd_thin, singular_values | Luau and Rune: svd, singular_values; Rust only: svd_thin | done |
eig | eig, eigvals, eig_sym | Luau and Rune: eig, eigvals; Rust only: eig_sym | done |
| eig(A, B) | generalized_eigvals | Rune only: generalized_eigvals | partial: values only |
schur | schur, schur_complex | Rune only: schur, schur_complex | done |
ordschur | ordschur | Rune only: ordschur | done |
rsf2csf | rsf2csf | Rune only: rsf2csf | done |
hess | hess | Rune only: hess | done |
expm | expm | Luau and Rune: expm | done |
logm | logm, logm_real | Rune only: logm, logm_real | done |
sqrtm | sqrtm, sqrtm_real | Rune only: sqrtm, sqrtm_real | done |
kron | kron | Rune only: kron | done |
sylvester | sylvester | Rune only: sylvester | done |
lyap | lyap | Rune only: lyap | done |
dlyap | dlyap | Rune only: dlyap | done |
Polynomials
A polynomial is a list of coefficients with the highest power first, as in MATLAB: the coefficients 1, 2, 3 are s squared plus 2 s plus 3.
| MATLAB | Eustress | Script | Notes |
|---|---|---|---|
poly | poly, poly_real, charpoly | Rune only: poly, poly_real, charpoly | done |
roots | roots | Luau and Rune: roots | done |
polyval | polyval, polyval_c | Luau and Rune: polyval; Rust only: polyval_c | done |
polyfit | polyfit | Luau and Rune: polyfit | done; without the centering and scaling outputs |
conv | conv | Rune only: conv | done |
deconv | deconv | Rune only: deconv | done |
| sum of two polynomials | polyadd | Rune only: polyadd | done; the polynomials can differ in degree |
polyder | polyder | Rune only: polyder | done |
polyint | polyint | Rune only: polyint | done |
residue | residue | Rune only: residue | done; the inverse direction (rebuilding the numerator and denominator from residues, poles and the direct term) is not covered |
Differential Equations
ode15s, ode23s and ode_radau are the stiff solvers. Each solver has a second form that takes event specifications; a terminal event ends the integration.
| MATLAB | Eustress | Script | Notes |
|---|---|---|---|
ode45 | ode45, ode45_events | Luau and Rune: ode45; Rune only: ode45_events | done |
ode23 | ode23, ode23_events | Luau and Rune: ode23; Rune only: ode23_events | done |
ode15s | ode15s, ode15s_events | Luau and Rune: ode15s; Rune only: ode15s_events | done for ODEs; mass matrices and DAEs are not covered; a tolerance below what its backward-difference formulas can deliver is refused with an error that points to ode_radau |
ode23s | ode23s, ode23s_events | Luau and Rune: ode23s; Rune only: ode23s_events | done |
| none (MATLAB has no Radau IIA solver; this is the class of the radau5 code and of the SciPy Radau solver) | ode_radau, ode_radau_events | Luau and Rune: ode_radau; Rune only: ode_radau_events | done for ODEs; mass matrices and DAEs are not covered; the stiff solver to use at tight tolerances |
| odeset (RelTol, AbsTol, MaxStep, InitialStep, Jacobian) | OdeOptions | Luau and Rune: the options rtol, atol, max_step, first_step, max_steps of the _with solvers; Rune only: the option jacobian of ode15s_events, ode23s_events, ode_radau_events; Rust only: OdeOptions | partial: scalar AbsTol only; no NonNegative, OutputFcn or Refine. The Jacobian is passed as the jac argument |
| odeset (Events option) | EventSpec | Rune only: the events array, the last argument of the *_events solvers; Rust only: EventSpec | done |
| deval, tspan vector | eval, t_eval | Luau and Rune: the option t_eval; Rune only: method eval of OdeSolution | done; eval belongs to the solution (OdeSolution), t_eval is an option (OdeOptions) |
Nonlinear Solvers and Minimization
MATLAB's fminunc is covered by two routines: fminunc estimates the gradient by central differences, and fminunc_with_grad takes the gradient from the caller. Both use BFGS with a strong-Wolfe line search.
| MATLAB | Eustress | Script | Notes |
|---|---|---|---|
fzero | fzero, fzero_from | Luau and Rune: fzero, fzero_from | done; fzero takes a bracket, fzero_from takes a starting guess |
fminsearch | fminsearch, fminsearch_trace | Luau and Rune: fminsearch; Rust only: fminsearch_trace | done; fminsearch_trace also returns the trace: entry 0 is the best vertex of the starting simplex, entry k the best vertex after iteration k |
| fminunc (BFGS) | fminunc, fminunc_with_grad | Luau and Rune: fminunc; Rust only: fminunc_with_grad | done (quasi-Newton; no trust-region variant) |
lsqnonlin | lsqnonlin | Rune only: lsqnonlin | partial: no bounds (Levenberg-Marquardt) |
fsolve | fsolve | Rune only: fsolve | done for square systems (trust-region dogleg) |
Calculus and Signal
interp1 covers the linear, nearest, pchip and spline methods. The fft routines are one-dimensional. freqz takes angular frequency in radians per sample.
| MATLAB | Eustress | Script | Notes |
|---|---|---|---|
integral | integral | Luau and Rune: integral | done, infinite limits included; also covers quadgk |
trapz | trapz | Rune only: trapz | done |
cumtrapz | cumtrapz | Rune only: cumtrapz | done |
interp1 | interp1, pchip, spline | Luau and Rune: interp1 | done; makima, previous and next are not covered |
fft | fft, fft_real, FftPlan, FftEngine | Luau and Rune: fft; Rune only: FftPlan::new; Rust only: fft_real, FftEngine | done (1-D) |
ifft | ifft | Luau and Rune: ifft | done (1-D) |
filter | filter, IirFilter | Rune only: filter, IirFilter::new | done |
freqz | freqz | Rune only: freqz | done; angular frequency in radians per sample |
Control Design
A model is one of four types. A transfer function (Tf) is a numerator, a denominator and a sample time. A matrix of transfer functions (TfMatrix) is a multi-input, multi-output model. A state-space model (Ss) is the matrices A, B, C and D and a sample time. A zero-pole-gain model (Zpk) is zeros, poles, a gain and a sample time. A model with no sample time is continuous time; a model with a sample time is discrete time at that sample time. Conversions between the types are listed first.
| MATLAB | Eustress | Script | Notes |
|---|---|---|---|
tf | Tf, TfMatrix | Rune only: Tf::new, TfMatrix::new | done; no time delays, no descriptor (E) form |
ss | Ss | Rune only: Ss::new | done; no time delays, no descriptor (E) form |
zpk | Zpk | Rune only: Zpk::new | done; no time delays, no descriptor (E) form |
| tf2ss, ss2tf, tf2zp, zp2tf, ss2zp, zp2ss | tf2ss, ss2tf, tf2zpk, zpk2tf, ss2zpk, zpk2ss | Rune only: tf2ss, ss2tf, tf2zpk, zpk2tf, ss2zpk, zpk2ss | done; the zero-pole-gain names end in zpk |
minreal | minreal | Rune only: method minreal of Tf, Ss, Zpk | done; works on Tf, Zpk and Ss models |
series | series | Rune only: method series of Tf and Ss | done; methods on Tf (SISO only) and on Ss (SISO and MIMO) |
parallel | parallel | Rune only: method parallel of Tf and Ss | done; methods on Tf (SISO only) and on Ss (SISO and MIMO) |
feedback | feedback | Rune only: method feedback of Tf and Ss | done; methods on Tf (SISO only) and on Ss (SISO and MIMO). connect, append and lft are not covered |
pole | poles | Rune only: method poles of Tf and Ss | done |
| zero, tzero | zeros | Rune only: method zeros of Tf and Ss | done; the zeros of a state-space model need a square system |
dcgain | dcgain | Rune only: method dcgain of Tf and Ss | done |
evalfr | eval | Rune only: method eval of Tf, Ss, Zpk, TfMatrix | done |
freqresp | freqresp | Rune only: method freqresp of Tf and Ss | done |
isstable | is_stable | Rune only: method is_stable of Ss | done |
step | step | Rune only: step | done (MIMO) |
impulse | impulse | Rune only: impulse | done (MIMO) |
initial | initial | Rune only: initial | done (MIMO) |
lsim | lsim | Rune only: lsim | done (MIMO) |
stepinfo | stepinfo, stepinfo_sys | Rune only: stepinfo, stepinfo_sys | done; 2 % settling band and 10 % to 90 % rise by default |
bode | bode, bode_ss | Rune only: bode, bode_ss | done (data, SISO; no plotting); phase in degrees |
nyquist | nyquist | Rune only: nyquist | done (data, SISO; no plotting) |
margin | margin | Rune only: margin | done (SISO); phase margin in degrees, gain margin as an absolute factor |
allmargin | allmargin | Rune only: allmargin | done (SISO) |
c2d | c2d, c2d_tf, c2d_matched | Luau and Rune: c2d; Rust only: c2d_tf, c2d_matched | done for zoh, foh, tustin, prewarp and matched; the impulse and least-squares methods are not covered; matched is SISO |
d2c | d2c | Rune only: d2c | done for zoh, tustin and prewarp |
ctrb | ctrb, ctrb_rank | Rune only: ctrb, ctrb_rank | done |
obsv | obsv, obsv_rank | Rune only: obsv, obsv_rank | done |
gram | gram | Rune only: gram | done for stable models |
| norm(sys, 2) | h2norm | Rune only: h2norm | done for stable models |
hsvd | hsvd | Rune only: hsvd | done for stable models |
lyap | lyap | Rune only: lyap | done; the generalized forms with E are not covered |
dlyap | dlyap | Rune only: dlyap | done; the generalized forms with E are not covered |
care | care, care_with | Luau and Rune: care, care_with | done (with the cross term S; no E); covers icare |
dare | dare, dare_with | Luau and Rune: dare, dare_with | done (with the cross term S; no E); covers idare |
lqr | lqr, lqr_matrices | Luau and Rune: lqr; Rust only: lqr_matrices | done |
dlqr | dlqr | Luau and Rune: dlqr | done |
lqi | lqi | Rune only: lqi | done |
place | place | Rune only: place | done |
acker | acker | Rune only: acker | done |
kalman | kalman | Rune only: kalman | partial: steady-state gains and covariance; no assembled estimator model, no correlated noise N |
lqe | lqe | Rune only: lqe | partial: steady-state gains and covariance; no assembled estimator model, no correlated noise N |
dlqe | dlqe | Rune only: dlqe | partial: steady-state gains and covariance; no assembled estimator model, no correlated noise N |
balreal | balreal | Rune only: balreal | done for stable models |
balred | balred | Rune only: balred | done for stable models; truncation and DC matching |
rlocus | rlocus | Rune only: rlocus | done (points; no plot) |
pidtune | pidtune | Rune only: pidtune | partial: P, PI, PD and PID from a target crossover and phase margin; the gains differ from the proprietary MATLAB rule for the same targets |
pid | Pid | Rune only: Pid::new | partial: see pidtune |
damp | damp | Rune only: damp | done |
| real-time blocks | DiscreteStepper, DiscretePid, IirFilter, FftPlan | Rune only: DiscreteStepper::new, DiscretePid::new, IirFilter::new, FftPlan::new | beyond MATLAB: the per-sample step does not allocate |
03Not Covered, and What to Use Instead
What Is Not Covered
These MATLAB features are not in the library. Each row groups them by area.
| Area | Not covered |
|---|---|
| Linear algebra | sparse matrices, N-D arrays, funm, gsvd, qz, ldl, eigs, svds, balance; the eigenvectors of eig(A, B) |
| Polynomials | the inverse direction of residue |
| Differential equations | ode113, ode78, ode89, ode23t, ode23tb, ode15i, dde23, bvp4c, pdepe; mass matrices and DAEs in ode15s; the NonNegative, OutputFcn and Refine options; a vector AbsTol |
| Optimization | fminbnd, fmincon, lsqcurvefit, linprog, quadprog, ga, particleswarm, patternsearch; bounds in lsqnonlin |
| Calculus, interpolation and signal | integral2, integral3, interp2, griddata, fft2, fftn, filtfilt, butter and other filter design, window functions, pwelch, conv2, xcorr; the makima, previous and next methods of interp1 |
| Control design | time delays (pade, InputDelay), descriptor systems, nichols, sigma, norm(sys, inf), bandwidth, lqg, lqgreg, reg, estim, lqry, connect, append, lft, d2d, modred, canon, frd, diskmargin, sisotool; the impulse and least-squares methods of c2d; the generalized forms of lyap, care and dare with E; an assembled kalman estimator model; correlated noise N; the Robust Control, MPC and System Identification toolboxes; plotting |
The Nearest Alternative
Where a nearby route exists, this table names it. Some of the routes name routines that Luau does not reach, or that only the Rust crate holds; the Script column of the name tables shows which.
| Missing | Use instead |
|---|---|
| sparse matrices, N-D arrays, symbolic math | dense matrices; split N-D data into matrices |
| ode113 | ode45 with a tight tolerance |
| ode78, ode89 | ode45 with a tight tolerance (more steps for the same accuracy) |
| pdepe | discretize in space by hand (method of lines), then use ode15s |
| ode23t, ode23tb | ode15s or ode23s |
| DAEs, mass matrices (ode15i) | eliminate the algebraic variables, then use ode15s |
| dde23, bvp4c | no equivalent; a boundary-value problem can be shot with ode45 inside fsolve |
| fminbnd | fzero on the derivative, or fminsearch in one variable |
| fmincon, bounds in lsqnonlin | a penalty term or a change of variables, then fminunc or lsqnonlin |
| lsqcurvefit | lsqnonlin on the residual model(x, t) - y |
| linprog, quadprog, ga | no equivalent |
| particleswarm, patternsearch | fminsearch from several starting points, keeping the best result |
| integral2, integral3 | nested integral calls |
| interp2 | interp1 along each axis |
| interp1 with makima | the pchip method of interp1, which is also shape preserving |
| interp1 with previous or next | the nearest method of interp1, or find the interval by searching the sorted samples |
| filtfilt | filter forward, reverse the samples, filter again, reverse |
| butter and other filter design | design in continuous time as a Tf, then c2d_tf with the Tustin prewarp method |
| time delays | a Pade approximant written as a Tf, or extra delay states in a discrete Ss |
| nichols, sigma | bode data; singular_values of the state-space frequency response at jw (eval of an Ss model) |
| norm(sys, inf), bandwidth | the peak of the bode magnitude on a fine grid |
| lqg, lqgreg, reg, estim | assemble a state-space model from the lqr and kalman gains yourself |
| connect, append | series, parallel, feedback, or build the block matrices yourself |
| d2d | d2c, then c2d |
| modred, canon | balred; a state transformation of the state-space model (transform) with your own basis |
| plotting | every routine returns the series; draw them with the host application |
04Your First Call
In Luau
This part covers Luau scripts. Choose Luau at the top of the page to read it; Rune scripts are covered under In Rune.
Luau scripts reach the library through the global table Numerics. There is nothing to require and no service to look up. The table is read-only, so one script cannot replace a function that another script calls. Both call styles work and give the same result: Numerics.solve(A, b) and Numerics:solve(A, b).
This script solves 2x + y = 5 and x + 3y = 6:
local x = Numerics.solve({{2, 1}, {1, 3}}, {5, 6})
print(x[1], x[2])The result x is the array {1.8, 1.4}; the tests check both values to within 1e-12. A vector on the right gives a vector. A matrix on the right gives a matrix.
Options go in an optional last table. Each name that ends in _with, such as ode45_with, is the same function as its base name in Luau, so either spelling works. This call integrates y' = -y over the interval 0 to 1 with a tighter relative tolerance:
local sol = Numerics.ode45(function(t, y) return {-y[1]} end, {0, 1}, {1}, {rtol = 1e-8})
print(sol.t[#sol.t], sol.y[#sol.y][1])The last time is 1 and the last state is about 0.3679, the value of e to the power -1. In the result, sol.y[k] is the state at sol.t[k]. Luau arrays start at 1.
Three routines treat a missing argument as a default in Luau:
fzero(f, a, b)searches the bracket from a to b.fzero(f, a)with no b starts from the guess a.fzero_from(f, x0)is the same guess form under its own name.interp1(x, y, xq)uses the linear method unless a method string follows.c2d(sys, ts)uses "zoh". The third argument is a method string ("zoh", "foh", "tustin" or "matched") or an options table with method and prewarp.
In Rune
This part covers Rune scripts. Choose Rune at the top of the page to read it.
Rune scripts import the module with use eustress::realism::numerics; and call its functions by path, as in numerics::solve(a, b)?. Every function returns a Result: Ok holding the value, or Err holding a message. The ? after the call turns an Err into a script error. This script solves the same system:
use eustress::log_info;
use eustress::realism::numerics;
pub fn on_init() {
let x = numerics::solve([[2.0, 1.0], [1.0, 3.0]], [5.0, 6.0])?;
let first = x[0];
let second = x[1];
log_info(`x = ${first}, ${second}`);
}The result x is the array [1.8, 1.4]. Rune arrays start at 0. An integer is accepted wherever a number is, so [5, 6] works in place of [5.0, 6.0].
Rune has no optional arguments. A routine that takes options has a _with form whose last argument is an object written #{rtol: 1e-8}. A result that has fields is an object, and the script reads a field with square brackets:
use eustress::log_info;
use eustress::realism::numerics;
pub fn on_init() {
let sol = numerics::ode45_with(|t, y| [-y[0]], [0.0, 1.0], [1.0], #{rtol: 1e-8})?;
let ys = sol["y"];
let n = ys.len();
let last = ys[n - 1][0];
log_info(`y(1) = ${last}`);
}The last state is about 0.3679, the value of e to the power -1. Rune has no defaults, so three things differ from Luau:
fzero(f, a, b)is the bracket form andfzero_from(f, x0)is the guess form.interp1(x, y, xq, method)andc2d(sys, ts, method)need the method argument.c2dtakes "zoh", "foh", "tustin" or "matched". Prewarping goes throughc2d_with(sys, ts, #{prewarp: w}).- Each routine with options has its
_withform, such asode45_with,fminsearch_with,integral_withandlqr_with.
The calls above use the 42 names that both languages reach. Rune calls 101 more functions and has 10 types, covered next.
Functions Only Rune Calls
Luau does not reach these. Choose Rune at the top of the page to read this part.
Rune calls 101 functions that Luau does not reach. They sit in the same module and follow the same conventions: matrices are arrays of rows, options go in a _with form as an object, and every function returns a Result. They cover the factorizations and matrix functions, the polynomial routines, nonlinear least squares and systems, trapz, cumtrapz, filter and freqz, the ODE solvers with events, and the control routines. The name tables mark each one Rune only. A result with several parts is an object. This script factors a matrix with lu and reads the fields:
use eustress::log_info;
use eustress::realism::numerics;
pub fn on_init() {
let f = numerics::lu([[4.0, 3.0], [6.0, 3.0]])?;
let l = f["l"];
let u = f["u"];
let p = f["p"];
let upper = l[0][1];
log_info(`L[0][1] = ${upper}`);
}The result holds the matrices l, u and p. L is lower triangular, so the entry l[0][1] is 0, and L times U equals P times A.
Types in Rune
Luau does not reach these. Choose Rune at the top of the page to read this part.
Rune also has 10 types in the same module: Tf, TfMatrix, Ss, Zpk, Pid, DiscreteStepper, DiscretePid, IirFilter, FftPlan, OdeSolution. Nine are built with a constructor, written numerics::Tf::new(num, den)? and so on. OdeSolution has no constructor: it comes out of the solvers ode45_events, ode23_events, ode15s_events, ode23s_events and ode_radau_events.
A script calls a method on the value, as in g.dcgain(), and reads a field without parentheses, as in g.num. A method that returns a new model leaves the first one unchanged. A method that cannot fail, such as order and dcgain of a Tf or len of an OdeSolution, returns a plain value. A method that can fail returns a Result and needs the ?. A function that takes a model, such as step, margin or bode, accepts a Tf, an Ss, a Zpk, or an object #{a: A, b: B, c: C, d: D}. The table lists what each type offers.
| Type | Built with | Methods | Fields |
|---|---|---|---|
Tf | Tf::new, Tf::discrete, Tf::gain | is_discrete, order, is_proper, poles, zeros, eval, freq_point, freqresp, dcgain, series, parallel, feedback, feedback_unity, scale, minreal, minreal_with, to_zpk, to_ss | num, den, ts |
TfMatrix | TfMatrix::new, TfMatrix::from_ss | n_outputs, n_inputs, get, eval, to_ss | none |
Ss | Ss::new, Ss::discrete, Ss::from_gain, Ss::from_gain_with | n_states, n_inputs, n_outputs, is_discrete, is_siso, poles, is_stable, zeros, dcgain, eval, freqresp, channel, to_tf, to_zpk, series, parallel, feedback, transform, minreal, minreal_with | a, b, c, d, ts |
Zpk | Zpk::new, Zpk::discrete | to_tf, to_ss, eval, minreal, minreal_with | z, p, k, ts |
Pid | Pid::new | to_tf, freq_point | kp, ki, kd, tf |
DiscreteStepper | DiscreteStepper::new | step, state, set_state, reset | none |
DiscretePid | DiscretePid::new | with_limits, step, reset | none |
IirFilter | IirFilter::new | step, state, set_state, reset | none |
FftPlan | FftPlan::new, FftPlan::with_engine | fft, ifft, len, engine | none |
OdeSolution | the *_events solvers | eval, component, y_last, len, dim | t, y, events, terminated, nfev, nfev_jac, njev, nlu, accepted, rejected |
This script builds two transfer functions, calls a method on one and passes the other to margin:
use eustress::log_info;
use eustress::realism::numerics;
pub fn on_init() {
let g = numerics::Tf::new([1.0], [1.0, 3.0, 2.0])?;
let dc = g.dcgain();
let loop_tf = numerics::Tf::new([2.0], [1.0, 3.0, 3.0, 1.0])?;
let m = numerics::margin(loop_tf)?;
let gm = m["gm"];
log_info(`dc = ${dc}, gain margin = ${gm}`);
}The first function is 1 / (s squared + 3 s + 2), and dcgain is its value at s = 0, which is 0.5. The loop 2 / (s + 1) cubed reaches -180 degrees at the angular frequency of the square root of 3, where its magnitude is 0.25, so the gain margin is 4 to within rounding.
An ODE solver with events returns an OdeSolution. The events argument is an array; an entry that is an object sets terminal and direction. This script drops a ball from a height of 10 under a gravity of 9.81 and stops the run when the height reaches zero:
use eustress::log_info;
use eustress::realism::numerics;
pub fn on_init() {
let hit = #{g: |t, y| y[0], terminal: true, direction: -1};
let sol = numerics::ode45_events(|t, y| [y[1], -9.81], [0.0, 10.0], [10.0, 0.0], #{dense: true}, [hit])?;
let ev = sol.events;
let t_hit = ev[0]["t"];
log_info(`hit at ${t_hit}`);
}The time of the hit is the square root of 2 times 10 divided by 9.81, which is about 1.43. The option dense: true makes sol.eval(t) return the state at any time between the first and the last.
05Conventions
Matrices, Vectors and Models
A matrix is dense and holds 64-bit floating-point numbers; a complex matrix holds complex numbers. The library sets no hard size limit. Memory use is 8 bytes times rows times columns for each real matrix. A vector is a plain list of numbers. A polynomial is a vector of coefficients, highest power first.
In a script a matrix is an array of rows. Luau writes {{1, 2}, {3, 4}}. Rune writes [[1.0, 2.0], [3.0, 4.0]]. Rows of different lengths are an error. A plain number is read as a 1 by 1 matrix. A vector is an array: {5, 6}[5.0, 6.0]. Results come back in the same shapes.
Luau arrays start at 1. Rune arrays start at 0. The data is the same in both languages: the first value of a result is x[1]x[0]. A matrix result is an array of rows, and eig returns its eigenvectors as the columns of that matrix.
A model for c2d is a table, {a = A, b = B, c = C, d = D}an object, #{a: A, b: B, c: C, d: D}. The fields c and d are optional: a missing c is the identity output and a missing d is zero feedthrough. Upper-case names also work. The result of c2d has the same fields plus ts, the sample time.
Callbacks
A script passes a callback as an ordinary function: function(t, y) return {...} end|t, y| [...]. The routine calls it once per evaluation.
- The right-hand side of an ODE takes the time and the state array and returns the derivative as an array with one value per state.
- The objective of
fminsearchandfminunctakes the array x and returns a number. - The function of
fzeroandintegraltakes one number and returns a number.
The time span of an ODE is exactly two numbers, the start and the end. To get output at chosen times, pass the t_eval option. Luau has no event functions and cannot pass a Jacobian: ode15s, ode23s and ode_radau estimate the Jacobian by finite differences when a script calls them. Luau does not reach lsqnonlin, fsolve or ordschur.Rune passes event functions and a Jacobian through the *_events solvers. Their events argument is an array, and each entry is a function |t, y| value or an object #{g: f, terminal: true, direction: -1} (terminal is false and direction is 0 when absent). Their option jacobian is a function |t, y| J that returns the n by n matrix; ode15s_events, ode23s_events and ode_radau_events read it, and ode45_events and ode23_events refuse it with an error. The Rune routines lsqnonlin and fsolve take a function |x| residuals and accept the option jacobian as |x| J; ordschur takes a function |re, im| that returns true or false.
Options and Results
Options are read by name from a tablean object. An option name the routine does not know is an error that lists the valid names. A result that has fields comes back as a tablean object with these names.
| Routine | Result fields | Options |
|---|---|---|
ode45, ode23, ode15s, ode23s, ode_radau | t, y, nfev, accepted, rejected | rtol, atol, max_step, first_step, max_steps, t_eval |
fminsearch | x, fval, iterations, evaluations, converged | tol_x, tol_fun, max_iter, max_fun_evals, adaptive |
fminunc | x, fval, iterations, evaluations, converged | tol_grad, tol_x, max_iter |
fzero, fzero_from | x, fx, iterations, evaluations | none |
integral | value, error, evaluations | abs_tol, rel_tol, max_intervals |
lqr, dlqr | x, k, eigenvalues, residual | n (the cross term), method |
care, dare | x, k, eigenvalues, residual | s (the cross term), method |
c2d | a, b, c, d, ts | method, prewarp |
eig | values, vectors | none |
svd | u, s, v | none |
In an ODE result, y[k] is the state at t[k]. The Riccati methods are auto, schur and iterative. The eigenvalues field is a complex value, described next. The gain k is the state-feedback gain of the closed loop A - B K. The Luau and Rune routines not in the table return a plain number, an array or a matrix.
The Rune only routines have result fields and options of their own. Luau does not reach them. Choose Rune at the top of the page to read them.
The Rune only routines with results that have fields, and the options of their _with forms, follow. The solvers ode45_events, ode23_events, ode15s_events, ode23s_events and ode_radau_events take the options of the Luau and Rune ODE row plus dense, and the stiff ones also take jacobian. They return an OdeSolution with the fields listed under Types in Rune; a plain Luau or Rune solver returns an object. balred returns an Ss.
| Routine | Result fields | Options |
|---|---|---|
lu | l, u, p | none |
qr, qr_thin, deconv | q, r | none |
schur, schur_complex, rsf2csf | u, t | none |
ordschur | u, t, count | none |
hess | q, h | none |
generalized_eigvals | alpha, beta | none |
residue | r, p, k | none |
rank_with, null_with, orth_with | a number, an array or a matrix | tol |
filter_with | y, zf | zi |
lsqnonlin_with, fsolve_with | x, fval, iterations, evaluations, jacobian_evaluations, converged | tol_grad, tol_x, tol_fun, max_iter, jacobian |
step_with, impulse_with | t, y, x | input, t |
initial_with | t, y, x | t |
lsim_with | t, y, x | x0, hold |
stepinfo_with, stepinfo_sys_with | rise_time, settling_time, settling_min, settling_max, overshoot, undershoot, peak, peak_time, final_value | y_final, settling_threshold, rise_limits |
bode_with | w, mag, mag_db, phase_deg | w |
nyquist_with | w, re, im | w |
margin | gm, pm, wcg, wcp | none |
allmargin | gain_margins, gm_freqs, phase_margins, pm_freqs, delay_margins | none |
rlocus_with | k, roots | gains |
damp | poles, wn, zeta | none |
lqi_with | x, k, eigenvalues, residual | n |
kalman, lqe, dlqe | l, p, m, eigenvalues | none |
balreal | sys, hsv, t, t_inv | none |
balred_with | a number, an array or a matrix | method |
pidtune_with | pid, crossover, phase_margin | crossover |
d2c_with | a number, an array or a matrix | method, prewarp |
Complex Numbers
The results that are complex in general are complex numbers with a real part, an imaginary part, a modulus and an argument: eigenvalues and eigenvectors, polynomial roots, residues and poles, Fourier transforms, and frequency responses. The poles and zeros of a model are complex numbers.
Complex values exist in scripts as two arrays of the same length: {re = {...}, im = {...}}#{re: [...], im: [...]}. eigvals, roots, fft and ifft return them, and so do the eigenvalues field of the Riccati routines and the values field of eig. The vectors field of eig is {re = rows, im = rows}#{re: rows, im: rows} with one eigenvector per column. fft and ifft accept a plain array, which is read as a real signal, or the re and im form. The matrices a script passes are real.
Rune returns the same form from more routines than Luau reaches. Choose Rune at the top of the page to read the list.
Rune returns the same form from more routines. generalized_eigvals returns alpha and beta in it, residue returns its r and p fields in it, and poly, freqz and the poles and zeros methods of a model return it. logm and sqrtm return #{re: rows, im: rows}, and schur_complex and rsf2csf return u and t in that form. poly and poly_real accept the roots as a plain array or in the re and im form, and so do place and acker for the poles.
The transform of an impulse is flat:
local X = Numerics.fft({1, 0, 0, 0})
print(X.re[1], X.re[2], X.re[3], X.re[4])use eustress::log_info;
use eustress::realism::numerics;
pub fn on_init() {
let X = numerics::fft([1.0, 0.0, 0.0, 0.0])?;
let re = X["re"];
log_info(`${re[0]} ${re[1]} ${re[2]} ${re[3]}`);
}The script prints four ones: the real part is four ones and the imaginary part is four zeros.
Errors
Bad input produces an error, not a crash. There are eight kinds of error. Each message begins with a prefix that names the kind, and then names the routine that raised it.
| Kind | Meaning | Example message |
|---|---|---|
DimensionMismatch | Matrix or vector sizes do not agree. | dimension mismatch: solve: A is (3, 3), B is (2, 1) |
NotSquare | The operation needs a square matrix. | matrix must be square: inv: got 2x3 |
Singular | The matrix is singular, or numerically singular, for this operation. | singular matrix: solve: matrix is exactly singular |
NotPositiveDefinite | The matrix is not symmetric positive definite. | not positive definite: chol: matrix is not positive definite |
InvalidArgument | An argument is outside its valid range. | invalid argument: roots: coefficients must be finite |
NoConvergence | An iteration did not converge within its budget. | no convergence: ode: step size underflow at t = 0.99...; the problem may be stiff or singular |
NoSolution | The problem has no solution of the requested kind, for example a Riccati equation without a stabilizing solution. | no solution: sqrtm_real: the result is not real |
Unsupported | The operation is not defined for this type of system, for example a continuous-only routine given a discrete model. | unsupported: c2d: the matched method needs a SISO model |
The step-underflow message begins with ode: for ode45 and ode23, and with ode15s:, ode23s: or ode_radau: for the stiff solvers; the rest of the text is the same for all of them. ode15s adds a sentence that names ode_radau as the solver for tolerances that tight, and it refuses a tolerance below what its backward-difference formulas can deliver with an invalid-argument error that says to use ode_radau. Routines that run out of budget handle it in one of two ways. fminsearch, fminunc and lsqnonlin return their best point with a flag that says the run did not converge. fsolve, fzero, integral and the ODE solvers raise a no-convergence error, because a point that is not a root, or an integration that did not finish, is not a usable answer.
A script sees the same messages with a prefix that names the routine.
Every failure is an ordinary Luau error, so pcall catches it. The error text begins with runtime error: Numerics.<name>: then the message, and a stack traceback follows it.
local ok, err = pcall(Numerics.solve, {{1, 2}, {2, 4}}, {1, 1})
print(ok, err)Here ok is false and err begins with runtime error: Numerics.solve: singular matrix: solve: matrix is exactly singular, followed by a stack traceback.
A failure is an Err holding a string that begins numerics::<name>: and continues with the message. Use ? to turn it into a script error, or match to handle it:
use eustress::log_info;
use eustress::realism::numerics;
pub fn on_init() {
match numerics::solve([[1.0, 2.0], [2.0, 4.0]], [1.0, 1.0]) {
Ok(x) => log_info(`solved`),
Err(e) => log_info(`failed: ${e}`),
}
}The message is numerics::solve: singular matrix: solve: matrix is exactly singular. An error raised inside a callback comes back carrying the script's own message. An error raised inside a callback comes back as numerics::<name>: the callback failed: .... The constructors and methods of the Rune types name the type, as in numerics::Tf::new: for a failed constructor and numerics::Tf::series: for a failed method. A bad argument names its position, as in argument 1 (A) must be a matrix.
Units
The library is unit-free: it treats every number as a plain quantity and converts nothing. Time, length and the rest mean whatever units you use for the inputs.
- Angles are in radians. The exceptions follow MATLAB: the phase that bode returns and the phase margin are in degrees.
- Frequencies are angular, in radians per time unit. They are never in hertz. freqz takes radians per sample.
- bode returns the magnitude as an absolute value and in decibels. margin returns the gain margin as an absolute factor.
Determinism
By default every routine runs on one thread. With one thread, every routine returns the same bits on every run. Results from different thread counts can differ in the last bits.
In the measured bit-for-bit table, svd is the one kernel whose bits differ between one thread and several. The table is on the Linear Algebra and Polynomials page.
Scripts cannot change the thread count. The thread setting is part of the Rust crate, and no script routine reaches it.
What the Crate Computes Itself
Most dense routines call the faer library (LU, QR, Cholesky, the Hessenberg reduction, symmetric and generalized eigenvalues, matrix products) and the rustfft library. Five paths are written in this crate instead. The ODE solvers, ode_radau included, are in-crate throughout and use their own small real and complex LU.
- eig and eigvals reduce the matrix to Hessenberg form with faer and then run the real Schur QR written in this crate: a multishift algorithm with aggressive early deflation, with a double-shift iteration below order 75 and inside the deflation windows. The sweeps update the Schur vectors with faer matrix products. The eigenvectors come from a back-substitution on the quasi-triangular factor and one triangular matrix product with the Schur vectors. This path serves every order. If the QR iteration does not converge, eig and eigvals fall back to faer's eigensolver. There is no balancing, so the routine is the counterpart of MATLAB's eig(A, 'nobalance').
- The consuming solve, solve_owned, takes both matrices by value. For one right-hand side and 128 unknowns or more it factors A in place and overwrites B: there is no copy and no scan of the inputs. A NaN or infinite input is caught by the check on the result and reported as a singular-matrix error. Smaller systems and several right-hand sides take faer's owning LU. The borrowing solve makes one copy for the in-place route; when that route fails it looks at the inputs again, so a non-finite input is still named as an invalid argument.
- svd and svd_thin reduce the matrix to bidiagonal form with faer, run a divide-and-conquer method written in this crate on the bidiagonal (the method of LAPACK's dbdsdc, after Gu and Eisenstat), and apply faer's blocked Householder back-transform. A matrix more than 11/6 times taller than wide, or the reverse, and any case where the divide and conquer does not finish, use faer's own SVD.
- singular_values, the values-only routine, reduces the matrix to bidiagonal form with faer and then runs a dqds iteration written in this crate (root-free, of order n squared). A bidiagonal with a zero on its diagonal goes through an implicit-shift QR iteration instead.
- fft has four kernels. When the machine has AVX2 and FMA and every prime factor of the length is at most 13, the default is the mixed-radix kernel written in this crate (radix 8, 4, 2, 3, 5, 7, 11 and 13, two complex values per instruction). It uses its direct form below 32 768 points and its depth-first form from 32 768 points on. A cache-blocked six-step form stays available through FftEngine, and the default does not pick it. Every other case goes to rustfft: other machines (wasm32 included) and lengths with a larger prime factor. FftPlan has with_engine, which forces a kernel, and engine, which reports which one a plan got.
The fixtures kernels.json (19 cases), svd.json (7) and eig.json (4), the unit tests of the in-crate code, and the mutation proof check these paths; see How It Is Proven.
Cost and the Frame Budget
A long call cannot be cancelled from outside and reports no progress. The ODE solvers stop early through a terminal event or a limit on the number of steps. A Luau script has no events: it limits a run with the max_steps option.A Rune script limits a run with the max_steps option or ends it at a terminal event of an *_events solver.
On an 18-core test machine, a 200 by 200 eigenproblem takes about 18 ms and a 100-state Riccati solve takes about 60 ms. Both are too long for a frame at 60 Hz. Run design calls (factorizations, Riccati solves, discretization) outside the frame loop. The per-sample blocks are the ones meant to run inside it: the step calls of DiscreteStepper, DiscretePid and IirFilter, and the in-place transform of FftPlan, do not allocate.
The times on this page are of the Rust routines called directly. A script call adds the cost of converting tables to matrices and back, and a script callback runs once per evaluation. That cost is not measured here.
Luau reaches the design calls (lqr, care, dare, c2d and the factorizations eig, svd and solve) but not the per-sample blocks. A Luau controller computes its gain once with lqr, keeps k, and applies u = -K x with ordinary arithmetic at each step. Rune reaches the per-sample blocks as types: DiscreteStepper::new takes a discrete model, DiscretePid::new takes a Pid and a sample time, IirFilter::new takes the filter coefficients, and each has a step method that runs one sample; FftPlan::new plans a transform of one length. A Rune controller can use them in place of its own arithmetic.
For measured run times, see Performance.
06How It Is Proven
Reference Libraries and Fixtures
Every result is checked against an independent reference. The reference libraries are NumPy 2.5.5, SciPy 1.18.1 and python-control 0.10.2. A generator script runs them on a fixed set of inputs and writes the inputs, the expected outputs and the library versions into JSON fixture files in the crate's tests folder. There are ten files.
| Fixture file | Cases | Area |
|---|---|---|
linalg.json | 25 | Linear algebra |
poly.json | 11 | Polynomials |
ode.json | 6 | Differential equations |
optim.json | 6 | Optimization |
calc.json | 12 | Calculus, interpolation and signal |
control.json | 30 | Control design |
kernels.json | 19 | The mixed-radix, depth-first and six-step FFT, the values-only SVD and the consuming solve |
radau.json | 10 | The ode_radau stiff solver: Radau references for the stiff Van der Pol and Robertson problems, and the error and cost of the SciPy Radau solver at four tolerances |
svd.json | 7 | Full SVD of random, graded, clustered, rank-deficient and near-identity matrices |
eig.json | 4 | Eigenvalues and eigenvectors of order 80 defective, clustered, graded and cyclic-permutation matrices |
Tests
119 of 119 tests pass. A test compares a routine with the stored reference output, or checks a defining property: a factorization multiplies back to the input, a Schur vector matrix is orthogonal, an inverse undoes its forward step. The test names for each routine are on the area pages.
Mutation Proof
A passing test proves little unless it can fail. The mutation check breaks one line of the library at a time and expects a named test to fail. It ran 43 mutations. 41 were caught: the named test failed. 2 survived, and both survivals are expected.
| Mutation | Test | Result |
|---|---|---|
| eig: eigenvalues scaled by 1 + 1e-6 | linalg::eig_general_matches_scipy | caught: the test failed |
| care: Q term of the Riccati residual scaled by 1.001 | control::care_and_lqr_on_an_unstable_plant_match_scipy | caught: the test failed |
| c2d tustin: 0.5 * dt replaced by 0.4 * dt in the numerator factor | control::c2d_zoh_foh_tustin_match_scipy | caught: the test failed |
| ode45 step control: error estimate under-reported 1000 times | ode_optim::ode45_error_tracks_the_tolerance | caught: the test failed |
| ode45 step control: rejected steps accepted (accept threshold raised to 1e6) | ode_optim::ode45_step_control_spends_work_where_the_tolerance_asks | caught: the test failed |
| margin: phase margin offset by one degree | control::margin_matches_python_control | caught: the test failed |
| margin: gain crossover polynomial uses |N|^2 - 1.01 |D|^2 | control::margin_matches_python_control | caught: the test failed |
| expm: last Pade coefficient 182 replaced by 181 | linalg::expm_of_a_rotation_generator_matches_the_closed_form | caught: the test failed |
| ode15s: gamma coefficients accumulate 1/(i+1) instead of 1/i | ode_optim::ode15s_solves_stiff_van_der_pol_mu_1000 | caught: the test failed |
| dare: X scaled by 1.001 in the returned gain | control::dare_and_dlqr_match_scipy | caught: the test failed |
| mixed-radix fft: radix-4 pass loses its rotation by -i (vector code) | kernels::fft_mixed_radix_matches_scipy_on_long_lengths | caught: the test failed |
| mixed-radix fft: odd-radix pass swaps the sign of the sine sum (vector code) | kernels::fft_mixed_radix_matches_numpy_on_composite_lengths | caught: the test failed |
| singular values: sign error in the row rotation of the bidiagonal QR sweep | kernels::singular_values_match_scipy | caught: the test failed |
| solve_owned: single right-hand side solved with A' instead of A | kernels::solve_owned_matches_numpy | caught: the test failed |
| six-step fft: twiddle built from the coarse table only | kernels::fft_six_step_matches_scipy_on_very_long_lengths | caught: the test failed |
| dqds: transform applies the shift twice | kernels::singular_values_match_scipy | caught: the test failed |
| bidiagonal divide and conquer: secular bracket updated on the wrong side | lib::bdc::tests::divide_and_conquer_reconstructs_and_is_orthogonal | caught: the test failed |
| bidiagonal divide and conquer: vectors built from the original z instead of the recomputed one | lib::bdc::tests::hard_cases_graded_clustered_rank_deficient | caught: the test failed |
| bidiagonal divide and conquer: deflation rotation with sine and cosine swapped | lib::bdc::tests::hard_cases_graded_clustered_rank_deficient | caught: the test failed |
| bidiagonal divide and conquer: null vector combined with the wrong sign | lib::bdc::tests::divide_and_conquer_reconstructs_and_is_orthogonal | caught: the test failed |
| bidiagonal divide and conquer: first component of the left vectors +1 instead of -1 | lib::bdc::tests::divide_and_conquer_reconstructs_and_is_orthogonal | caught: the test failed |
| svd: right reflectors applied one row too high | kernels::full_svd_matches_scipy_on_hard_cases | caught: the test failed |
| ode_radau: third error-estimate weight -1/3 replaced by -1/4 | ode_optim::ode_radau_matches_scipy_radau_on_stiff_van_der_pol_at_four_tolerances | caught: the test failed |
| ode_radau: real eigenvalue of the Newton system 3.6378 replaced by 3.6 | ode_optim::ode_radau_has_order_five_dense_output_events_and_an_analytic_jacobian_path | caught: the test failed |
| ode_radau: collocation polynomial coefficient -8/3 replaced by -7/3 | ode_optim::ode_radau_matches_scipy_radau_on_robertson_at_four_tolerances | caught: the test failed |
| ode15s: tolerance refusal removed | ode_optim::ode15s_refuses_tolerances_it_cannot_reach_and_points_to_ode_radau | caught: the test failed |
| radix-8 fft pass, scalar: the quarter turn of the third difference dropped | lib::mixed_fft::tests::every_radix_matches_the_definition_in_scalar_and_simd_code | caught: the test failed |
| radix-8 fft pass, AVX2: the eighth-root factor 1/sqrt 2 replaced by 0.7 | kernels::fft_mixed_radix_matches_numpy_on_composite_lengths | caught: the test failed |
| depth-first fft: outputs of the parts copied back without interleaving | kernels::fft_depth_first_matches_scipy_on_long_lengths | caught: the test failed |
| depth-first fft: the parts are left untransformed after the first split of a part | lib::mixed_fft::tests::depth_first_matches_the_direct_kernel | caught: the test failed |
| divide and conquer merge: the middle row is left out of the upper half of V | lib::bdc::tests::divide_and_conquer_reconstructs_and_is_orthogonal | caught: the test failed |
| divide and conquer merge: sorted singular values written to unsorted places | kernels::full_svd_matches_scipy_on_hard_cases | caught: the test failed |
| divide and conquer merge: rows of block two stored one row too high | lib::bdc::tests::hard_cases_graded_clustered_rank_deficient | caught: the test failed |
| in-crate eig: sweep U row bound taken from the lowest active bulge only | lib::hqr::tests::schur_and_eigenvectors_on_every_driver_path | caught: the test failed |
| in-crate eig: sweep left pass skips the newest bulge's own column | lib::hqr::tests::schur_and_eigenvectors_on_every_driver_path | caught: the test failed |
| in-crate eig: AED spike test reads the second row of V | lib::hqr::tests::hard_matrices_on_every_driver_path | caught: the test failed |
| in-crate eig: 1x1 block swap rotates Q the wrong way | lib::hqr::tests::block_swaps_of_every_shape | caught: the test failed |
| in-crate eig: 2x2 standardization rotation with the wrong sine sign | lib::hqr::tests::schur_and_eigenvectors_on_every_driver_path | caught: the test failed |
| in-crate eig: complex eigenvector started for the conjugate eigenvalue | lib::hqr::tests::schur_and_eigenvectors_on_every_driver_path | caught: the test failed |
| in-crate eig: overflow guard of the real back-substitution removed | lib::hqr::tests::repeated_eigenvalues_give_finite_vectors | caught: the test failed |
| in-crate eig: second column of a complex pair not conjugated | linalg::eig_hard_matrices_match_scipy_through_the_in_crate_solver | caught: the test failed |
| ode15s: order-2 NDF coefficient kappa -1/9 replaced by 0 (this is plain BDF2: a valid method, not a bug) | ode_optim::ode15s_solves_stiff_van_der_pol_mu_1000 | survived, as expected: the test passed |
| dare: doubling iteration drops the G update (the Newton correction that follows repairs the start value) | control::dare_handles_a_singular_state_matrix | survived, as expected: the test passed |
The first survivor changes the order-2 coefficient of the ode15s method to the plain second-order backward-difference method, which is a valid method and not a bug. The second drops one update from the doubling iteration of dare, and the Newton correction that follows repairs the start value.
Accuracy and Speed
The measured accuracy and speed tables are on their own page.
See Performance for the tables and how they were measured.
07What's Next
Pick an Area
Start with the area that matches your problem. Linear Algebra and Polynomials covers solving systems, factorizations and polynomial work. Differential Equations covers integrating a model through time. Optimization covers roots and minimization. Calculus and Signal covers integrals, interpolation, the Fourier transform and filters. Control Design covers models, responses and controller design. Performance holds the measured tables.