Performance
Run time and accuracy of the numerics library measured against SciPy and NumPy, every row of the table, and how to run the same measurement again.
Faster than SciPy on every routine timed (eig 1.3x at 200 and 1.15x to 1.2x at 500, solves 1.4x to 1.7x, FFT level at 131,072 points); more accurate on eig residuals, Riccati, LQR and solves; SciPy keeps smaller full-SVD residuals and better stiff accuracy than ode15s, where ode_radau matches SciPy's Radau. MATLAB not measured.
The eig figures in the sentence above are the paired-run figures, where Eustress and SciPy ran back to back: 1.31x to 1.36x at 200 and 1.15x to 1.22x at 500. The single run in the speed table reads higher: 1.44x at 200 and 1.25x at 500. The machine was loaded, and the paired figures are the ones to trust where a single row swings. The ODE solver and optimizer ratios, 39.1x to 905x in the table, are callback-bound: SciPy calls back into Python for every function evaluation and the Eustress run calls compiled code.
01Overview
What Is Measured
This page reports two measurements of the numerics library: how long a call takes, and how close its result is to a reference. Run times are compared with SciPy and NumPy. Accuracy is reported beside each run time, and again against stored reference results for every routine the tests cover.
The run times are compared with SciPy 1.18.1 and NumPy 2.5.5, running on OpenBLAS (scipy-openblas 0.3.34.237.2). The reference results for the accuracy tests were produced with NumPy 2.5.5, SciPy 1.18.1 and python-control 0.10.2. python-control is a source of reference results only; no run time was measured against it.
Each row is one routine at one problem size, run on one machine. The tables show every row that was measured. No row is left out, and rows are grouped by area, not ordered by result. Where SciPy or NumPy took less time or returned a more accurate result, the row says so in the same words and the same table as the rows where Eustress did.
MATLAB Was Not Measured
MATLAB was not measured, so this page makes no speed comparison with it.
The library's routine names follow MATLAB so that a MATLAB user can find them. Nothing on this page says how a MATLAB call compares with a call here.
Summary
The summary at the top of the page states the result in one sentence. The tables under Speed and Accuracy hold the figures behind it, and the paired runs under Speed hold the figures to trust where a single row swings. The ODE solver and optimizer tables are callback-bound: they compare Eustress calling compiled code against SciPy calling back into Python for every function evaluation. Read the note above those tables before using their ratios.
02Method
Machine and Build
- Machine: Intel Core i9-10980XE (18 cores, 36 logical processors, AVX-512), 256 GB, Windows 11.
- Build: --release, lto = "fat", codegen-units = 1, Rust 1.100.0.
- Timer: std::time::Instant and time.perf_counter.
- Python side: SciPy 1.18.1, NumPy 2.5.5, BLAS scipy-openblas 0.3.34.237.2 (OpenBLAS 0.3.34.237.2 USE64BITINT DYNAMIC_ARCH NO_AFFINITY SkylakeX MAX_THREADS=24); the SciPy process reported 36 logical processors.
- One thread unless stated.
Generic is the default x86-64 build and is what ships. Native is the same code built with the compiler flag -C target-cpu=native, which targets the CPU of the machine that builds it.
The ratio in every table uses the generic build. The native column is reported beside it.
How Time Was Measured
Each call is repeated and the minimum over the repetitions is reported. The machine was shared with other work, so the minimum, the run least disturbed by that work, is used in place of the average. There is no separate warm-up run. Rows with a short call repeat many times, so that the minimum falls after the processor has settled.
The number of repetitions depends on the row and is chosen so that short calls run many times and long calls run a few times. Eustress rows ran from 3 to 2000 repetitions per run, and SciPy and NumPy rows from 3 to 2000 repetitions.
- Each Eustress time is the minimum over two separate runs of the benchmark program, one set per build.
- SciPy and NumPy were run twice, once with one BLAS thread and once with the default number of threads. The ratio uses the lowest time of those two runs and, where a row has several SciPy or NumPy variants, of those variants. Each variant's time is in the table.
- Eustress ran on one thread unless the Threads section says otherwise.
- For the solve rows in the consuming form, the input copies were made outside the timer, for Eustress and for the SciPy call with overwriting turned on. The NumPy solve copies its inputs inside the timer. The borrowing form of the Eustress solve copies once inside the timer.
- The times on this page are of the Rust routines called directly, from a compiled benchmark program. 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 on this page.
How Accuracy Was Measured
Three accuracy measures appear beside the run times. Each is computed by the benchmark program for the Eustress result and by the Python script for the SciPy or NumPy result, with the same formula on both sides.
residualis the scaled residual of the factorization or equation. A residual is how far the returned answer is from satisfying the problem, scaled by the size of the problem.erroris the largest relative error against a reference solution computed at 1e-11 or tighter.fvalis the objective value reached. The objective in these rows is a sum of squares with a minimum value of 0, so a lower fval is closer to the minimum.
A lower value is a more accurate result for all three measures. The separate table under Accuracy lists the error of each routine against stored reference results, with the tolerance the test allows. Those reference results come from SciPy, NumPy and python-control, stored with their inputs in the fixture files under the library's tests folder, together with the library versions that produced them.
Problem Sets
The Radau function evaluation counts exclude the evaluations used for finite-difference Jacobians, as SciPy's counter does. The benchmark matrices are deterministic. Entry (i, j) with seed s is the fractional part of sin(12.9898 i + 78.233 j + s) times 43758.5453, minus 0.5. The Eustress program and the Python script use the same formula, so both sides receive the same numbers.
| Routine | Input |
|---|---|
| eig, eigvals | 200 by 200 matrix with seed 0.1 (eig and eigvals), and 500 by 500 with seed 0.1 (eig) |
| solve | n by n matrix with seed 0.2 and a right-hand side with seed 0.3, n from 200 to 2000 |
| singular values, svd | n by n matrix with seed 0.4, n of 300 and 1000 |
| care | A is 100 by 100 (seed 0.5), B is 100 by 10 (seed 0.6), Q and R are identity matrices |
| lqr, c2d | A is 50 by 50 (seed 0.7) minus twice the identity, B is 50 by 5 (seed 0.8), C is 3 by 50 (seed 0.9), D is zero; lqr uses identity Q and R; c2d uses zero-order hold with a sample time of 0.01 |
| fft | complex signal whose real part is the seeded entry formula (seed 1.0) and whose imaginary part is 0; lengths as named in the rows, from 1,024 to 2,097,152 points |
| ode45, Lorenz | sigma 10, rho 28, beta 8/3, start (1, 1, 1); to t = 100 with rtol 1e-6 and atol 1e-9, and to t = 5 with rtol 1e-8 and atol 1e-10. SciPy runs RK45 with the same tolerances. The t = 5 error is measured against a stored SciPy reference solution. |
| stiff Van der Pol | mu 1000, start (2, 0), to t = 3000, with (rtol, atol) of (1e-4, 1e-6), (1e-6, 1e-8) and (1e-8, 1e-10). Eustress runs ode15s; SciPy runs BDF, LSODA and Radau. The error is the largest relative error of the first component against a stored reference at the reference time points. |
| ode_radau, Van der Pol | mu 1000, start (2, 0), to t = 3000, with rtol of 1e-4, 1e-6, 1e-8 and 1e-10 and atol equal to rtol times 1e-2. SciPy runs Radau with the same tolerances. The error is the largest relative error of the first component against a stored reference at the reference time points. |
| ode_radau, Robertson | the Robertson chemical kinetics problem (rate constants 0.04, 1e4 and 3e7), start (1, 0, 0), to t = 4000, with rtol of 1e-4, 1e-6, 1e-8 and 1e-10 and atol equal to rtol times 1e-6. SciPy runs Radau with the same tolerances. The error is the largest relative error of all three components against a stored reference. |
| Nelder-Mead, BFGS | the 10-dimensional Rosenbrock function, start alternating between -1.2 and 1.0. Nelder-Mead uses tolerances of 1e-8 on x and on the function value and up to 100000 iterations and evaluations, plain and adaptive. BFGS uses the analytic gradient and a gradient tolerance of 1e-8. |
03Speed
The Speed Tables
Times are in milliseconds. Each area has two tables with the same rows in the same order: a time table and a table of accuracy and work. In the time table, generic and native are the two Eustress builds, and the SciPy columns give the SciPy or NumPy times (one BLAS thread, and the lowest time over the variants at default threads). The ratio is the lowest SciPy or NumPy time of the row divided by the Eustress generic time, followed by the side that took less time: a ratio above 1 reads , a ratio below 1 reads . The ratio is not a statement about which result is correct; the second table shows that.
Dense linear algebra
These rows are the like-for-like comparison of kernels: dense factorizations and solves, with no Python code called back during the run on either side.
| Routine | Eustress generic (ms) | Eustress native (ms) | SciPy 1 thread (ms) | SciPy default (ms) | Ratio |
|---|---|---|---|---|---|
| eig, 200x200 (values and vectors) | 16.8 | 17 | 24.2 | 35.4 | 1.44x Eustress |
| eigvals, 200x200 (values only) | 11.9 | 11.7 | 20.3 | 30.3 | 1.71x Eustress |
| eig, 500x500 (values and vectors) | 159 | 147 | 198 | 284 | 1.25x Eustress |
| solve (A\b), 200x200, consuming form | 0.234 | 0.228 | numpy.linalg.solve 0.408 scipy.linalg.solve overwrite, no checks 0.59 | 2.51 | 1.74x Eustress |
| solve (A\b), 500x500, consuming form | 2.84 | 2.78 | numpy.linalg.solve 4.13 scipy.linalg.solve overwrite, no checks 5.26 | 61.2 | 1.45x Eustress |
| solve (A\b), 1000x1000, consuming form | 17.2 | 16.7 | numpy.linalg.solve 28.4 scipy.linalg.solve overwrite, no checks 28.7 | 105 | 1.65x Eustress |
| solve (A\b), 2000x2000, consuming form | 119 | 123 | numpy.linalg.solve 167 scipy.linalg.solve overwrite, no checks 180 | 181 | 1.41x Eustress |
| solve (A\b), 500x500, borrowing form (one copy) | 3.6 | 3.4 | numpy.linalg.solve 4.13 scipy.linalg.solve overwrite, no checks 5.26 | 61.2 | 1.15x Eustress |
| singular values, 300x300 | 7.17 | 7.18 | 8.4 | 10.6 | 1.17x Eustress |
| singular values, 1000x1000 | 289 | 287 | 327 | 337 | 1.13x Eustress |
| svd, 300x300 (full) | 15.5 | 16.3 | 17.1 | 36.2 | 1.1x Eustress |
| svd, 1000x1000 (full) | 459 | 454 | 541 | 546 | 1.18x Eustress |
| Routine | Measure | Eustress | SciPy or NumPy |
|---|---|---|---|
| eig, 200x200 (values and vectors) | residual | 5.77e-15 | 6.30e-15 |
| eigvals, 200x200 (values only) | n/a | n/a | n/a |
| eig, 500x500 (values and vectors) | residual | 8.17e-15 | 9.05e-15 |
| solve (A\b), 200x200, consuming form | residual | 1.10e-16 | numpy.linalg.solve 1.26e-16 |
| solve (A\b), 500x500, consuming form | residual | 1.74e-16 | numpy.linalg.solve 1.99e-16 |
| solve (A\b), 1000x1000, consuming form | residual | 2.33e-16 | numpy.linalg.solve 3.31e-16 |
| solve (A\b), 2000x2000, consuming form | residual | 3.49e-16 | numpy.linalg.solve 5.79e-16 |
| solve (A\b), 500x500, borrowing form (one copy) | n/a | n/a | n/a |
| singular values, 300x300 | n/a | n/a | n/a |
| singular values, 1000x1000 | n/a | n/a | n/a |
| svd, 300x300 (full) | residual | 2.76e-15 | 2.59e-15 |
| svd, 1000x1000 (full) | residual | 4.31e-15 | 3.58e-15 |
Control design routines
Each row is one call of the routine on the model described under Problem Sets.
| Routine | Eustress generic (ms) | Eustress native (ms) | SciPy 1 thread (ms) | SciPy default (ms) | Ratio |
|---|---|---|---|---|---|
| care, 100 states, 10 inputs | 63.2 | 60.7 | 107 | 122 | 1.7x Eustress |
| lqr, 50 states, 5 inputs | 9.12 | 7.9 | 17.8 | 20.3 | 1.96x Eustress |
| c2d zoh, 50 states | 0.147 | 0.261 | 0.153 | 0.37 | 1.04x Eustress |
| Routine | Measure | Eustress | SciPy or NumPy |
|---|---|---|---|
| care, 100 states, 10 inputs | residual | 1.12e-13 | 1.02e-10 |
| lqr, 50 states, 5 inputs | residual | 7.73e-16 | 9.73e-15 |
| c2d zoh, 50 states | n/a | n/a | n/a |
Fourier transform
The second table names the Eustress kernel the plan selected for each length: the in-crate mixed-radix kernel or the rustfft crate.
| Routine | Eustress generic (ms) | Eustress native (ms) | SciPy 1 thread (ms) | SciPy default (ms) | Ratio |
|---|---|---|---|---|---|
| fft, 1 024 points | 0.0035 | 0.0031 | scipy.fft 0.0129 numpy.fft 0.0166 | 0.0121 | 3.46x Eustress |
| fft, 4 096 points | 0.0197 | 0.019 | scipy.fft 0.0399 numpy.fft 0.0615 | 0.0354 | 1.8x Eustress |
| fft, 10 000 points | 0.0526 | 0.0519 | scipy.fft 0.102 numpy.fft 0.145 | 0.0929 | 1.77x Eustress |
| fft, 12 000 points | 0.0595 | 0.0611 | scipy.fft 0.152 numpy.fft 0.168 | 0.137 | 2.3x Eustress |
| fft, 15 000 points | 0.0779 | 0.0756 | scipy.fft 0.204 numpy.fft 0.222 | 0.184 | 2.36x Eustress |
| fft, 16 384 points | 0.116 | 0.0973 | scipy.fft 0.213 numpy.fft 0.262 | 0.194 | 1.66x Eustress |
| fft, 32 768 points | 0.255 | 0.232 | scipy.fft 0.449 numpy.fft 0.587 | 0.41 | 1.61x Eustress |
| fft, 65 536 points | 0.585 | 0.581 | scipy.fft 0.949 numpy.fft 1.41 | 0.95 | 1.62x Eustress |
| fft, 131 072 points | 1.5 | 1.46 | scipy.fft 2.05 numpy.fft 3.05 | 1.64 | 1.09x Eustress |
| fft, 196 608 points | 2.85 | 2.74 | scipy.fft 3.75 numpy.fft 5.64 | 3.33 | 1.17x Eustress |
| fft, 262 144 points | 3.71 | 3.75 | scipy.fft 4.91 numpy.fft 6.89 | 4.34 | 1.17x Eustress |
| fft, 400 000 points | 6.37 | 6.25 | scipy.fft 9.62 numpy.fft 10.4 | 9.68 | 1.51x Eustress |
| fft, 524 288 points | 9.39 | 8.53 | scipy.fft 16.7 numpy.fft 25.7 | 16.5 | 1.75x Eustress |
| fft, 1 000 003 points (prime) | 171 | 193 | scipy.fft 258 numpy.fft 311 | 257 | 1.5x Eustress |
| fft, 1 048 576 points | 21.3 | 20.9 | scipy.fft 35 numpy.fft 52.9 | 33.4 | 1.57x Eustress |
| fft, 2 097 152 points | 47.5 | 47 | scipy.fft 73.7 numpy.fft 110 | 70.9 | 1.49x Eustress |
| Routine | Eustress FFT kernel |
|---|---|
| fft, 1 024 points | MixedRadix |
| fft, 4 096 points | MixedRadix |
| fft, 10 000 points | MixedRadix |
| fft, 12 000 points | MixedRadix |
| fft, 15 000 points | MixedRadix |
| fft, 16 384 points | MixedRadix |
| fft, 32 768 points | DepthFirst |
| fft, 65 536 points | DepthFirst |
| fft, 131 072 points | DepthFirst |
| fft, 196 608 points | DepthFirst |
| fft, 262 144 points | DepthFirst |
| fft, 400 000 points | DepthFirst |
| fft, 524 288 points | DepthFirst |
| fft, 1 000 003 points (prime) | RustFft |
| fft, 1 048 576 points | DepthFirst |
| fft, 2 097 152 points | DepthFirst |
ODE solvers
Every row in these two tables is callback-bound. SciPy calls back into Python for every function evaluation, and the Eustress run calls compiled code. The ratio is large for that reason as well as for the solver. It is not a comparison of kernels. The second table gives the function evaluation counts (nfev), which show how much work each run did.
| Routine | Eustress generic (ms) | Eustress native (ms) | SciPy 1 thread (ms) | SciPy default (ms) | Ratio |
|---|---|---|---|---|---|
| ode45, Lorenz to t = 100 (rtol 1e-6) | 0.722 | 0.63 | 288 | 273 | 377x Eustress |
| ode45, Lorenz to t = 5 (rtol 1e-8) | 0.0623 | 0.0548 | 22.9 | 26 | 367x Eustress |
| stiff Van der Pol mu = 1000 to t = 3000, rtol 1e-4 | 0.208 | 0.202 | BDF 163 LSODA 10.3 Radau 189 | 9.13 | 43.9x Eustress |
| stiff Van der Pol mu = 1000 to t = 3000, rtol 1e-6 | 0.364 | 0.389 | BDF 303 LSODA 16 Radau 399 | 16.6 | 44x Eustress |
| stiff Van der Pol mu = 1000 to t = 3000, rtol 1e-8 | 0.654 | 0.68 | BDF 652 LSODA 25.6 Radau 1220 | 27 | 39.1x Eustress |
| Routine | Measure | Eustress | SciPy or NumPy | nfev Eustress | nfev SciPy |
|---|---|---|---|---|---|
| ode45, Lorenz to t = 100 (rtol 1e-6) | n/a | n/a | n/a | 29504 | 30224 |
| ode45, Lorenz to t = 5 (rtol 1e-8) | error | 8.27e-08 | 8.27e-08 | 2492 | 2492 |
| stiff Van der Pol mu = 1000 to t = 3000, rtol 1e-4 | error | 0.00361 | BDF 0.00259 LSODA 0.00479 Radau 1.39e-05 | 1928 | BDF 2350 LSODA 2114 Radau 3883 |
| stiff Van der Pol mu = 1000 to t = 3000, rtol 1e-6 | error | 6.02e-05 | BDF 7.50e-05 LSODA 8.08e-05 Radau 1.34e-07 | 3261 | BDF 5107 LSODA 3575 Radau 9920 |
| stiff Van der Pol mu = 1000 to t = 3000, rtol 1e-8 | error | 1.49e-06 | BDF 1.03e-06 LSODA 8.27e-07 Radau 8.78e-10 | 5727 | BDF 11480 LSODA 5574 Radau 29951 |
ode_radau against SciPy Radau
Every row in these two tables is callback-bound. ode_radau is the in-crate Radau IIA solver, measured against SciPy Radau at the same tolerances on two stiff problems. SciPy calls back into Python for every function evaluation, and the Eustress run calls compiled code, so the ratio is not a comparison of kernels. The function evaluation counts leave out the evaluations used for finite-difference Jacobians on both sides.
| Routine | Eustress generic (ms) | Eustress native (ms) | SciPy 1 thread (ms) | SciPy default (ms) | Ratio |
|---|---|---|---|---|---|
| ode_radau against SciPy Radau, Van der Pol mu = 1000, rtol 1e-4 | 0.175 | 0.201 | 156 | 163 | 891x Eustress |
| ode_radau against SciPy Radau, Van der Pol mu = 1000, rtol 1e-6 | 0.427 | 0.537 | 419 | 385 | 902x Eustress |
| ode_radau against SciPy Radau, Van der Pol mu = 1000, rtol 1e-8 | 1.28 | 1.55 | 1210 | 1160 | 905x Eustress |
| ode_radau against SciPy Radau, Van der Pol mu = 1000, rtol 1e-10 | 3.73 | 4.68 | 3570 | 3350 | 896x Eustress |
| ode_radau against SciPy Radau, Robertson to t = 4000, rtol 1e-4 | 0.0399 | 0.0485 | 26 | 24.3 | 608x Eustress |
| ode_radau against SciPy Radau, Robertson to t = 4000, rtol 1e-6 | 0.0997 | 0.121 | 66.1 | 64.3 | 645x Eustress |
| ode_radau against SciPy Radau, Robertson to t = 4000, rtol 1e-8 | 0.258 | 0.353 | 199 | 184 | 714x Eustress |
| ode_radau against SciPy Radau, Robertson to t = 4000, rtol 1e-10 | 0.755 | 1.04 | 595 | 559 | 740x Eustress |
| Routine | Measure | Eustress | SciPy or NumPy | nfev Eustress | nfev SciPy |
|---|---|---|---|---|---|
| ode_radau against SciPy Radau, Van der Pol mu = 1000, rtol 1e-4 | error | 1.39e-05 | 1.39e-05 | 3856 | 3883 |
| ode_radau against SciPy Radau, Van der Pol mu = 1000, rtol 1e-6 | error | 1.25e-07 | 1.34e-07 | 9920 | 9920 |
| ode_radau against SciPy Radau, Van der Pol mu = 1000, rtol 1e-8 | error | 8.41e-10 | 8.79e-10 | 29816 | 29951 |
| ode_radau against SciPy Radau, Van der Pol mu = 1000, rtol 1e-10 | error | 1.27e-11 | 1.27e-11 | 88501 | 87898 |
| ode_radau against SciPy Radau, Robertson to t = 4000, rtol 1e-4 | error | 6.04e-06 | 6.15e-06 | 514 | 514 |
| ode_radau against SciPy Radau, Robertson to t = 4000, rtol 1e-6 | error | 7.50e-08 | 1.36e-07 | 1421 | 1421 |
| ode_radau against SciPy Radau, Robertson to t = 4000, rtol 1e-8 | error | 1.12e-09 | 1.21e-09 | 4184 | 4180 |
| ode_radau against SciPy Radau, Robertson to t = 4000, rtol 1e-10 | error | 1.40e-11 | 1.27e-11 | 12636 | 12669 |
Optimizers
Every row in these two tables is callback-bound. SciPy calls back into Python for every function evaluation, and the Eustress run calls compiled code. The ratio is large for that reason as well as for the optimizer. It is not a comparison of kernels. The second table gives the function evaluation counts (nfev), which show how much work each run did.
| Routine | Eustress generic (ms) | Eustress native (ms) | SciPy 1 thread (ms) | SciPy default (ms) | Ratio |
|---|---|---|---|---|---|
| Nelder-Mead, Rosenbrock 10-D | 1.27 | 1.5 | 256 | 256 | 202x Eustress |
| Nelder-Mead (adaptive), Rosenbrock 10-D | 0.498 | 0.621 | 165 | 189 | 331x Eustress |
| BFGS, Rosenbrock 10-D (analytic gradient) | 0.0501 | 0.0519 | 16.7 | 17.7 | 333x Eustress |
| Routine | Measure | Eustress | SciPy or NumPy | nfev Eustress | nfev SciPy |
|---|---|---|---|---|---|
| Nelder-Mead, Rosenbrock 10-D | fval | 1.68e-16 | 3.99 | 6602 | 6946 |
| Nelder-Mead (adaptive), Rosenbrock 10-D | fval | 3.99 | 8.02e-17 | 2894 | 4617 |
| BFGS, Rosenbrock 10-D (analytic gradient) | fval | 4.10e-22 | 3.99 | 101 | 136 |
Ratio by Row
Reading the Speed Tables
The callback-bound rows are the ODE solvers and the optimizers. SciPy calls back into Python for every function evaluation in those rows, and the Eustress run calls compiled code. Their ratios are large because of that difference and are not a comparison of kernels. The dense linear algebra rows are the like-for-like comparison of kernels. The function evaluation counts in the table below show how much work each run did.
Several hot paths in the library are Eustress code and do not go through a dependency's high-level call:
- eig and eigvals reduce the matrix to Hessenberg form with faer, then run an in-crate real Schur QR iteration: the multishift algorithm with aggressive early deflation of LAPACK's dhseqr family, with the double-shift step below order 75 and inside the deflation windows. Eigenvectors come from back-substitution on the quasi-triangular factor and one triangular product. If the iteration does not converge, faer's eigensolver is used. There is no balancing.
- The consuming solve takes both matrices by value. For one right-hand side and 128 unknowns or more it factors the matrix in place and overwrites the right-hand side, with no copy and no scan of the inputs. Smaller systems and several right-hand sides use faer's owning LU.
- The full SVD reduces to bidiagonal form with faer, runs an in-crate divide and conquer on the bidiagonal, and applies faer's blocked Householder back-transform. Matrices 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.
- The singular values routine reduces to bidiagonal form with faer and runs an in-crate dqds iteration on the bidiagonal, which is O(n^2).
- The 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 in-crate mixed-radix kernel (radix 8, 4, 2, 3, 5, 7, 11 and 13): its direct form below 32,768 points and its depth-first form from 32,768 points on. Every other case goes to the rustfft crate.
- The ODE solvers, ode_radau included, are in-crate throughout.
Ratio range by area
- Dense linear algebra: ratio from 1.1 (svd 300x300) to 1.74 (solve 200x200). Eustress time lower in 12 of 12 rows; SciPy or NumPy time lower in 0 of 12 rows.
- Control design routines: ratio from 1.04 (c2d zoh 50 states) to 1.96 (lqr 50 states). Eustress time lower in 3 of 3 rows; SciPy or NumPy time lower in 0 of 3 rows.
- Fourier transform: ratio from 1.09 (fft 131072) to 3.46 (fft 1024). Eustress time lower in 16 of 16 rows; SciPy or NumPy time lower in 0 of 16 rows.
- ODE solvers: ratio from 39.1 (stiff Van der Pol rtol 1e-8) to 377 (ode45 Lorenz t=100). Eustress time lower in 5 of 5 rows; SciPy or NumPy time lower in 0 of 5 rows.
- ode_radau against SciPy Radau: ratio from 608 (Radau Robertson rtol 1e-4) to 905 (Radau VdP rtol 1e-8). Eustress time lower in 8 of 8 rows; SciPy or NumPy time lower in 0 of 8 rows.
- Optimizers: ratio from 202 (Nelder-Mead 10-D) to 333 (BFGS 10-D). Eustress time lower in 3 of 3 rows; SciPy or NumPy time lower in 0 of 3 rows.
Rows where SciPy or NumPy took less time than Eustress
In this round 0 of 47 rows have a ratio below 1. The narrowest rows in the table run are c2d zoh 50 states (1.04x), fft 131072 (1.09x), and svd 300x300 (1.1x). A ratio this close to 1 is inside the spread between repeated runs on a loaded machine; the paired runs below give three sweeps for these rows.
Rows where the two times are within 10 percent
c2d zoh 50 states (ratio 1.04), and fft 131072 (ratio 1.09).
Callback-bound rows and the work done
In the callback-bound rows the ratio runs from 39.1 to 905. The number of function evaluations differs between Eustress and the SciPy variant that sets the ratio by a factor of at most 1.6 in these rows (the smallest factor is 1). The table gives the counts.
| Routine | SciPy variant | nfev Eustress | nfev SciPy | Larger / smaller | Time ratio |
|---|---|---|---|---|---|
| ode45, Lorenz to t = 100 (rtol 1e-6) | solve_ivp RK45 | 29504 | 30224 | 1.02 | 377x |
| ode45, Lorenz to t = 5 (rtol 1e-8) | solve_ivp RK45 | 2492 | 2492 | 1 | 367x |
| stiff Van der Pol mu = 1000 to t = 3000, rtol 1e-4 | solve_ivp LSODA | 1928 | 2114 | 1.1 | 43.9x |
| stiff Van der Pol mu = 1000 to t = 3000, rtol 1e-6 | solve_ivp LSODA | 3261 | 3575 | 1.1 | 44x |
| stiff Van der Pol mu = 1000 to t = 3000, rtol 1e-8 | solve_ivp LSODA | 5727 | 5574 | 1.03 | 39.1x |
| ode_radau against SciPy Radau, Van der Pol mu = 1000, rtol 1e-4 | solve_ivp Radau | 3856 | 3883 | 1.01 | 891x |
| ode_radau against SciPy Radau, Van der Pol mu = 1000, rtol 1e-6 | solve_ivp Radau | 9920 | 9920 | 1 | 902x |
| ode_radau against SciPy Radau, Van der Pol mu = 1000, rtol 1e-8 | solve_ivp Radau | 29816 | 29951 | 1 | 905x |
| ode_radau against SciPy Radau, Van der Pol mu = 1000, rtol 1e-10 | solve_ivp Radau | 88501 | 87898 | 1.01 | 896x |
| ode_radau against SciPy Radau, Robertson to t = 4000, rtol 1e-4 | solve_ivp Radau | 514 | 514 | 1 | 608x |
| ode_radau against SciPy Radau, Robertson to t = 4000, rtol 1e-6 | solve_ivp Radau | 1421 | 1421 | 1 | 645x |
| ode_radau against SciPy Radau, Robertson to t = 4000, rtol 1e-8 | solve_ivp Radau | 4184 | 4180 | 1 | 714x |
| ode_radau against SciPy Radau, Robertson to t = 4000, rtol 1e-10 | solve_ivp Radau | 12636 | 12669 | 1 | 740x |
| Nelder-Mead, Rosenbrock 10-D | minimize Nelder-Mead | 6602 | 6946 | 1.05 | 202x |
| Nelder-Mead (adaptive), Rosenbrock 10-D | minimize Nelder-Mead | 2894 | 4617 | 1.6 | 331x |
| BFGS, Rosenbrock 10-D (analytic gradient) | minimize BFGS | 101 | 136 | 1.35 | 333x |
Which FFT kernel ran
MixedRadix: fft 1024, fft 4096, fft 10000, fft 12000, fft 15000, and fft 16384.DepthFirst: fft 32768, fft 65536, fft 131072, fft 196608, fft 262144, fft 400000, fft 524288, fft 1048576, and fft 2097152.RustFft: fft 1000003 (prime).
Paired Runs
A paired run times both libraries back to back, within each of three sweeps, so that both see the same machine load. The machine was shared and loaded while the single-run tables were measured, so one table row can swing from run to run. Where a row in the speed table and its paired run differ, the paired figures are the ones to trust.
The machine was shared with other work while the benchmarks ran. The report on this run measured the CPU load at 77 percent. Single table rows therefore swing from run to run.
Dense linear algebra, SciPy on one BLAS thread
| Case | Sweep | SciPy (ms) | Eustress (ms) | Ratio |
|---|---|---|---|---|
| svd, 300x300 (full) | 1 | 17.8 | 17 | 1.05x |
| svd, 300x300 (full) | 2 | 18.5 | 17 | 1.09x |
| svd, 300x300 (full) | 3 | 17.8 | 16.8 | 1.06x |
| eig, 200x200 (values and vectors) | 1 | 22.3 | 16.6 | 1.34x |
| eig, 200x200 (values and vectors) | 2 | 22.7 | 16.7 | 1.36x |
| eig, 200x200 (values and vectors) | 3 | 22.3 | 17 | 1.31x |
| eig, 500x500 (values and vectors) | 1 | 185 | 152 | 1.22x |
| eig, 500x500 (values and vectors) | 2 | 192 | 165 | 1.17x |
| eig, 500x500 (values and vectors) | 3 | 200 | 173 | 1.15x |
| Case | Worst ratio | Residual, Eustress | Residual, SciPy |
|---|---|---|---|
| svd, 300x300 (full) | 1.05x | 2.76e-15 | 2.59e-15 |
| eig, 200x200 (values and vectors) | 1.31x | 4.08e-16 | 4.46e-16 |
| eig, 500x500 (values and vectors) | 1.15x | 3.65e-16 | 4.05e-16 |
c2d zoh, 50 states
| Sweep | SciPy (ms) | Eustress (ms) | Ratio |
|---|---|---|---|
| 1 | 0.154 | 0.129 | 1.19x |
| 2 | 0.154 | 0.13 | 1.19x |
| 3 | 0.154 | 0.13 | 1.19x |
Fourier transform, every length swept
Each sweep cell gives the SciPy time in milliseconds, the Eustress time in milliseconds, and the ratio. The kernel is the one the Eustress plan selected.
| Points | Kernel | Sweep 1 | Sweep 2 | Sweep 3 | Worst ratio |
|---|---|---|---|---|---|
| 1024 | MixedRadix | 0.0128 / 0.0031 = 4.13x | 0.0118 / 0.0028 = 4.21x | 0.0131 / 0.0031 = 4.23x | 4.13x |
| 2048 | MixedRadix | 0.0215 / 0.0101 = 2.13x | 0.0198 / 0.008 = 2.47x | 0.022 / 0.0083 = 2.65x | 2.13x |
| 4096 | MixedRadix | 0.0381 / 0.0171 = 2.23x | 0.0389 / 0.0183 = 2.13x | 0.0381 / 0.0207 = 1.84x | 1.84x |
| 8192 | MixedRadix | 0.0867 / 0.0468 = 1.85x | 0.0818 / 0.0464 = 1.76x | 0.0864 / 0.0607 = 1.42x | 1.42x |
| 16384 | MixedRadix | 0.193 / 0.11 = 1.75x | 0.192 / 0.102 = 1.89x | 0.193 / 0.102 = 1.9x | 1.75x |
| 32768 | DepthFirst | 0.45 / 0.303 = 1.48x | 0.409 / 0.276 = 1.48x | 0.41 / 0.274 = 1.5x | 1.48x |
| 65536 | DepthFirst | 0.981 / 0.62 = 1.58x | 0.943 / 0.589 = 1.6x | 0.938 / 0.581 = 1.61x | 1.58x |
| 131072 | DepthFirst | 1.79 / 1.63 = 1.1x | 1.6 / 1.58 = 1.02x | 1.57 / 1.55 = 1.02x | 1.02x |
| 196608 | DepthFirst | 3.28 / 2.81 = 1.16x | 3.2 / 2.89 = 1.11x | 3.47 / 2.86 = 1.21x | 1.11x |
| 262144 | DepthFirst | 5.2 / 4.13 = 1.26x | 4.37 / 4.02 = 1.09x | 4.45 / 3.82 = 1.16x | 1.09x |
| 400000 | DepthFirst | 10 / 6.48 = 1.55x | 11.3 / 7.02 = 1.6x | 10.6 / 6.47 = 1.64x | 1.55x |
| 524288 | DepthFirst | 18.2 / 9.22 = 1.98x | 16.3 / 9.42 = 1.73x | 15.2 / 8.65 = 1.76x | 1.73x |
| 1048576 | DepthFirst | 37.6 / 21.1 = 1.78x | 34.4 / 22.4 = 1.53x | 33.9 / 21.7 = 1.56x | 1.53x |
| 2097152 | DepthFirst | 73.7 / 46.8 = 1.57x | 75.2 / 48 = 1.57x | 70.1 / 46.3 = 1.52x | 1.52x |
Across the Fourier transform lengths the lowest worst-sweep ratio is 1.02x. Lengths with a worst-sweep ratio below 1.05: 131072 points (worst 1.02x). A ratio that close to 1 is inside the spread between sweeps.
04Accuracy
Accuracy Beside Speed
The speed tables carry the accuracy of each run in the same row. The care and lqr rows use the Riccati residual: the Frobenius norm of the equation residual divided by the norm of the solution, computed with the same formula on both sides. The care and dare solvers apply Newton corrections until the corrections stop improving the residual.
Where SciPy is more accurate
- svd, 300x300 (full) (residual): Eustress 2.76e-15; lower SciPy or NumPy values: 2.59e-15.
- svd, 1000x1000 (full) (residual): Eustress 4.31e-15; lower SciPy or NumPy values: 3.58e-15.
- stiff Van der Pol mu = 1000 to t = 3000, rtol 1e-4 (error): Eustress 0.00361; lower SciPy or NumPy values: BDF 0.00259; Radau 1.39e-05. SciPy or NumPy values that are not lower: LSODA 0.00479.
- stiff Van der Pol mu = 1000 to t = 3000, rtol 1e-6 (error): Eustress 6.02e-05; lower SciPy or NumPy values: Radau 1.34e-07. SciPy or NumPy values that are not lower: BDF 7.50e-05; LSODA 8.08e-05.
- stiff Van der Pol mu = 1000 to t = 3000, rtol 1e-8 (error): Eustress 1.49e-06; lower SciPy or NumPy values: BDF 1.03e-06; LSODA 8.27e-07; Radau 8.78e-10.
- ode_radau against SciPy Radau, Robertson to t = 4000, rtol 1e-10 (error): Eustress 1.40e-11; lower SciPy or NumPy values: 1.27e-11.
- Nelder-Mead (adaptive), Rosenbrock 10-D (fval): Eustress 3.99; lower SciPy or NumPy values: 8.02e-17.
- ode_radau against SciPy Radau, Van der Pol mu = 1000, rtol 1e-10 (function evaluations): Eustress 88501; SciPy 87898. Eustress used 0.686 percent more.
- ode_radau against SciPy Radau, Robertson to t = 4000, rtol 1e-8 (function evaluations): Eustress 4184; SciPy 4180. Eustress used 0.0957 percent more.
- eig, order 80, clustered (eigenvalue error against the exact eigenvalues): Eustress 3.63e-15; SciPy 3.13e-15.
Where Eustress is more accurate
- eig, 200x200 (values and vectors) (residual): Eustress 5.77e-15; SciPy or NumPy 6.30e-15.
- eig, 500x500 (values and vectors) (residual): Eustress 8.17e-15; SciPy or NumPy 9.05e-15.
- solve (A\b), 200x200, consuming form (residual): Eustress 1.10e-16; SciPy or NumPy numpy.linalg.solve 1.26e-16.
- solve (A\b), 500x500, consuming form (residual): Eustress 1.74e-16; SciPy or NumPy numpy.linalg.solve 1.99e-16.
- solve (A\b), 1000x1000, consuming form (residual): Eustress 2.33e-16; SciPy or NumPy numpy.linalg.solve 3.31e-16.
- solve (A\b), 2000x2000, consuming form (residual): Eustress 3.49e-16; SciPy or NumPy numpy.linalg.solve 5.79e-16.
- care, 100 states, 10 inputs (residual): Eustress 1.12e-13; SciPy or NumPy 1.02e-10.
- lqr, 50 states, 5 inputs (residual): Eustress 7.73e-16; SciPy or NumPy 9.73e-15.
- ode_radau against SciPy Radau, Van der Pol mu = 1000, rtol 1e-6 (error): Eustress 1.25e-07; SciPy or NumPy 1.34e-07.
- ode_radau against SciPy Radau, Van der Pol mu = 1000, rtol 1e-8 (error): Eustress 8.41e-10; SciPy or NumPy 8.79e-10.
- ode_radau against SciPy Radau, Robertson to t = 4000, rtol 1e-4 (error): Eustress 6.04e-06; SciPy or NumPy 6.15e-06.
- ode_radau against SciPy Radau, Robertson to t = 4000, rtol 1e-6 (error): Eustress 7.50e-08; SciPy or NumPy 1.36e-07.
- ode_radau against SciPy Radau, Robertson to t = 4000, rtol 1e-8 (error): Eustress 1.12e-09; SciPy or NumPy 1.21e-09.
- Nelder-Mead, Rosenbrock 10-D (fval): Eustress 1.68e-16; SciPy or NumPy 3.99.
- BFGS, Rosenbrock 10-D (analytic gradient) (fval): Eustress 4.10e-22; SciPy or NumPy 3.99.
- ode_radau against SciPy Radau, Van der Pol mu = 1000, rtol 1e-4 (function evaluations): Eustress 3856; SciPy 3883.
- ode_radau against SciPy Radau, Van der Pol mu = 1000, rtol 1e-8 (function evaluations): Eustress 29816; SciPy 29951.
- ode_radau against SciPy Radau, Robertson to t = 4000, rtol 1e-10 (function evaluations): Eustress 12636; SciPy 12669.
- eig, order 80, defective (eigenvalue error against the exact eigenvalues): Eustress 1.69e-05; SciPy 2.05e-05.
- eig, order 80, defective (residual): Eustress 3.35e-16; SciPy 3.72e-16.
- eig, order 80, clustered (residual): Eustress 3.19e-16; SciPy 3.34e-16.
- eig, order 80, graded (residual): Eustress 1.89e-16; SciPy 2.79e-16.
- eig, order 80, cyclic (eigenvalue error against the exact eigenvalues): Eustress 5.33e-15; SciPy 7.63e-15.
- eig, order 80, cyclic (residual): Eustress 5.12e-16; SciPy 6.82e-16.
Where the values agree to the digits shown
- ode45, Lorenz to t = 5 (rtol 1e-8) (error): Eustress 8.27e-08; SciPy or NumPy 8.27e-08.
- ode_radau against SciPy Radau, Van der Pol mu = 1000, rtol 1e-4 (error): Eustress 1.39e-05; SciPy or NumPy 1.39e-05.
- ode_radau against SciPy Radau, Van der Pol mu = 1000, rtol 1e-10 (error): Eustress 1.27e-11; SciPy or NumPy 1.27e-11.
Optimizer runs and the converged flag
| Routine | fval, Eustress | converged, Eustress | fval, SciPy | converged, SciPy |
|---|---|---|---|---|
| Nelder-Mead, Rosenbrock 10-D | 1.68e-16 | true | 3.99 | true |
| Nelder-Mead (adaptive), Rosenbrock 10-D | 3.99 | true | 8.02e-17 | true |
| BFGS, Rosenbrock 10-D (analytic gradient) | 4.10e-22 | true | 3.99 | false |
Error Against Every Reference
The accuracy example runs every routine the tests cover against its stored reference result and prints the error reached with the tolerance the test allows. The metric is the largest relative error, except for the Bode data, which is the largest absolute error in decibels and degrees.
| Area | Function | Reference | Metric | Error reached | Test tolerance | Error / tolerance |
|---|---|---|---|---|---|---|
| linalg | solve | scipy.linalg.solve | largest relative error | 3.95e-16 | 1e-12 | 0.000395 |
| linalg | lstsq | numpy.linalg.lstsq | largest relative error | 3.87e-16 | 1e-11 | 0.0000387 |
| linalg | inv | scipy.linalg.inv | largest relative error | 1.55e-15 | 1e-11 | 0.000155 |
| linalg | det | scipy.linalg.det | largest relative error | 8.88e-16 | 1e-11 | 0.0000888 |
| linalg | pinv | scipy.linalg.pinv | largest relative error | 7.41e-16 | 1e-09 | 7.41e-7 |
| linalg | norm (2) | numpy.linalg.norm | largest relative error | 6.66e-16 | 1e-13 | 0.00666 |
| linalg | cond | numpy.linalg.cond | largest relative error | 3.33e-15 | 1e-11 | 0.000333 |
| linalg | chol | scipy.linalg.cholesky | largest relative error | 1.14e-16 | 1e-12 | 0.000114 |
| linalg | svd (values) | scipy.linalg.svdvals | largest relative error | 1.12e-16 | 1e-12 | 0.000112 |
| linalg | eig (values) | scipy.linalg.eigvals | largest relative error | 2.13e-15 | 1e-09 | 0.00000213 |
| linalg | eig, symmetric | scipy.linalg.eigvalsh | largest relative error | 3.86e-16 | 1e-12 | 0.000386 |
| linalg | schur (eigenvalues) | scipy.linalg.eigvals | largest relative error | 2.03e-15 | 1e-09 | 0.00000203 |
| linalg | expm | scipy.linalg.expm | largest relative error | 6.56e-16 | 1e-12 | 0.000656 |
| linalg | logm | scipy.linalg.logm | largest relative error | 2.33e-15 | 1e-11 | 0.000233 |
| linalg | sqrtm | scipy.linalg.sqrtm | largest relative error | 1.73e-15 | 1e-12 | 0.00173 |
| linalg | sylvester | scipy.linalg.solve_sylvester | largest relative error | 2.17e-15 | 1e-11 | 0.000217 |
| linalg | lyap | scipy.linalg.solve_continuous_lyapunov | largest relative error | 1.05e-15 | 1e-11 | 0.000105 |
| linalg | dlyap | scipy.linalg.solve_discrete_lyapunov | largest relative error | 5.80e-15 | 1e-11 | 0.00058 |
| poly | roots | numpy.roots | largest relative error | 6.64e-16 | 1e-11 | 0.0000664 |
| poly | polyfit | numpy.polyfit | largest relative error | 8.72e-16 | 1e-10 | 0.00000872 |
| poly | residue | scipy.signal.residue | largest relative error | 8.88e-16 | 1e-11 | 0.0000888 |
| calc | integral | scipy.integrate.quad | largest relative error | 4.44e-16 | 1e-12 | 0.000444 |
| calc | interp1 pchip | scipy PchipInterpolator | largest relative error | 3.71e-16 | 1e-13 | 0.00371 |
| calc | interp1 spline | scipy CubicSpline (not-a-knot) | largest relative error | 4.81e-16 | 1e-12 | 0.000481 |
| calc | fft (1000 points) | numpy.fft.fft | largest relative error | 4.99e-16 | 1e-13 | 0.00499 |
| calc | filter | scipy.signal.lfilter | largest relative error | 1.31e-15 | 1e-12 | 0.00131 |
| control | step | scipy.signal.step | largest relative error | 2.64e-15 | 1e-10 | 0.0000264 |
| control | impulse | scipy.signal.impulse | largest relative error | 2.10e-15 | 1e-10 | 0.000021 |
| control | lsim | scipy.signal.lsim | largest relative error | 2.59e-15 | 1e-10 | 0.0000259 |
| control | bode | scipy.signal.bode | largest absolute error (dB, degrees) | 8.53e-14 | 1e-09 | 0.0000853 |
| control | margin | control.margin | largest relative error | 0 | 1e-09 | 0 |
| control | c2d zoh | scipy.signal.cont2discrete | largest relative error | 4.21e-16 | 1e-12 | 0.000421 |
| control | c2d foh | scipy.signal.cont2discrete | largest relative error | 2.22e-16 | 1e-12 | 0.000222 |
| control | c2d bilinear | scipy.signal.cont2discrete | largest relative error | 2.22e-16 | 1e-12 | 0.000222 |
| control | gram | scipy solve_continuous_lyapunov | largest relative error | 2.88e-15 | 1e-10 | 0.0000288 |
| control | hsvd / balreal | scipy (square-root method) | largest relative error | 1.38e-14 | 1e-08 | 0.00000138 |
| control | care (X) | scipy.linalg.solve_continuous_are | largest relative error | 3.22e-16 | 1e-09 | 3.22e-7 |
| control | lqr (K) | scipy.linalg.solve_continuous_are | largest relative error | 2.59e-15 | 1e-09 | 0.00000259 |
| control | dare (X) | scipy.linalg.solve_discrete_are | largest relative error | 2.70e-14 | 1e-09 | 0.000027 |
| control | place (K, single input) | scipy.signal.place_poles | largest relative error | 2.34e-15 | 1e-09 | 0.00000234 |
| control | lqe / kalman (L) | scipy.linalg.solve_continuous_are (dual) | largest relative error | 5.16e-15 | 1e-08 | 5.16e-7 |
Hard eigenvalue problems
Four eigenvalue problems of order 80 that run the multishift path. Each is compared with the exact eigenvalues where they are known and with SciPy otherwise. The residual is the scaled residual of the eigenvector equation.
| Matrix | Values against | Eigenvalue error, Eustress | Eigenvalue error, SciPy | Residual, Eustress | Residual, SciPy |
|---|---|---|---|---|---|
| order 80, defective | exact values | 1.69e-05 | 2.05e-05 | 3.35e-16 | 3.72e-16 |
| order 80, clustered | exact values | 3.63e-15 | 3.13e-15 | 3.19e-16 | 3.34e-16 |
| order 80, graded | SciPy values | 2.46e-15 | n/a | 1.89e-16 | 2.79e-16 |
| order 80, cyclic | exact values | 5.33e-15 | 7.63e-15 | 5.12e-16 | 6.82e-16 |
Reading the Accuracy Tables
The error in the table is the distance from the reference library's result, not from the exact answer. Where the reference library and Eustress both carry rounding error, the table shows how far apart they are.
Rows closest to their tolerance (error divided by tolerance)
- norm (2): 6.66e-16 against a tolerance of 1e-13; the error is 0.00666 of the tolerance. Reference: numpy.linalg.norm.
- fft (1000 points): 4.99e-16 against a tolerance of 1e-13; the error is 0.00499 of the tolerance. Reference: numpy.fft.fft.
- interp1 pchip: 3.71e-16 against a tolerance of 1e-13; the error is 0.00371 of the tolerance. Reference: scipy PchipInterpolator.
- sqrtm: 1.73e-15 against a tolerance of 1e-12; the error is 0.00173 of the tolerance. Reference: scipy.linalg.sqrtm.
- filter: 1.31e-15 against a tolerance of 1e-12; the error is 0.00131 of the tolerance. Reference: scipy.signal.lfilter.
The largest error reached in the table is 8.53e-14 (bode, largest absolute error (dB, degrees)).
Error of exactly 0: margin.
05Threads
One Thread Against Four
Eustress runs on one thread unless the host calls set_threads. The benchmark ran the dense kernels and the control design rows again with 4 threads on the generic build. Scripts cannot change the thread count. Nothing runs on the GPU.
More threads take longer at the smaller sizes: the work per call is too small to repay the cost of splitting it. The table shows where that changes.
| Routine | 1 thread (ms) | 4 threads (ms) | 4-thread time / 1-thread time |
|---|---|---|---|
| eig, 200x200 (values and vectors) | 16.8 | 18.2 | 1.08 |
| eigvals, 200x200 (values only) | 11.9 | 11.6 | 0.978 |
| eig, 500x500 (values and vectors) | 159 | 177 | 1.11 |
| solve (A\b), 200x200, consuming form | 0.234 | 1.27 | 5.43 |
| solve (A\b), 500x500, consuming form | 2.84 | 7.35 | 2.59 |
| solve (A\b), 1000x1000, consuming form | 17.2 | 24.9 | 1.45 |
| solve (A\b), 2000x2000, consuming form | 119 | 88 | 0.742 |
| solve (A\b), 500x500, borrowing form (one copy) | 3.6 | 7.66 | 2.13 |
| singular values, 300x300 | 7.17 | 19.1 | 2.66 |
| singular values, 1000x1000 | 289 | 291 | 1.01 |
| svd, 300x300 (full) | 15.5 | 30.2 | 1.95 |
| svd, 1000x1000 (full) | 459 | 392 | 0.855 |
| care, 100 states, 10 inputs | 63.2 | 80.4 | 1.27 |
Rows where 4 threads took more time than 1 thread (10 of 13): eig 200x200, eig 500x500, solve 200x200, solve 500x500, solve 1000x1000, solve 500x500, one copy, singular values 300, singular values 1000, svd 300x300, and care 100 states.
Rows where 4 threads took less time than 1 thread (3 of 13): eigvals 200x200, solve 2000x2000, and svd 1000x1000.
The same comparison for SciPy and NumPy, default BLAS threads against 1 BLAS thread, using the lowest time of each row. Default threads took more time than 1 thread in 23 of 47 rows and less time in 24 rows: fft 1024, fft 4096, fft 10000, fft 12000, fft 15000, fft 16384, fft 32768, fft 131072, fft 196608, fft 262144, fft 524288, fft 1000003 (prime), fft 1048576, fft 2097152, ode45 Lorenz t=100, stiff Van der Pol rtol 1e-4, Radau VdP rtol 1e-6, Radau VdP rtol 1e-8, Radau VdP rtol 1e-10, Radau Robertson rtol 1e-4, Radau Robertson rtol 1e-6, Radau Robertson rtol 1e-8, Radau Robertson rtol 1e-10, and Nelder-Mead 10-D. The tables above report both, and the ratio uses the lower of the two.
06Bit Reproducibility
Same Bits Across Runs and Thread Counts
With one thread, every routine returns the same bits on every run. Results from different thread counts can differ in the last bits. The reproducibility example runs each kernel twice at each thread count and compares the output bits.
Thread counts compared: 1, 4 and 36 (all threads on this machine). Each kernel was run twice at each count and the output bits compared. Each cell answers whether the bits were the same: between two runs at one thread count (the first two columns) or between one thread and the thread count named (the last two columns).
| Kernel | Run to run, 1 thread | Run to run, 36 threads | 1 against 4 threads | 1 against 36 threads |
|---|---|---|---|---|
| matmul_500 | yes | yes | yes | yes |
| solve_500 | yes | yes | yes | yes |
| eig_200 | yes | yes | yes | yes |
| svd_300 | yes | yes | no | no |
| care_100 | yes | yes | yes | yes |
| expm_200 | yes | yes | yes | yes |
| schur_200 | yes | yes | yes | yes |
Kernels whose bits change with the thread count (1 of 7): svd_300.
Kernels whose bits change from one run to the next at the same thread count (0 of 7): none.
07Limits of the Comparison
What These Numbers Do Not Show
- One machine and one operating system. The machine was shared with other work, and the minimum over the repetitions reduces that effect without removing it. Other hardware gives other times.
- One or a few sizes per routine, on deterministic pseudo-random inputs. A different size, a structured matrix, or a different stiffness can change a ratio.
- Only the routines in the tables were timed. Every other routine in the library has no run time on this page.
- The SciPy or NumPy time in each row is the lowest time among the variants measured, which is not always the call a user would write.
- The callback-bound rows measure the cost of calling back into Python for every function evaluation together with the solver or optimizer. They do not measure the solver or optimizer alone.
- The times 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 on this page.
- Luau reaches 42 routines by name. Rune reaches the same 42 plus 101 more functions and 10 types. Of the routines timed here, eig, eigvals, solve, svd, singular_values, care, lqr, c2d, fft, ode45, ode15s, ode_radau and fminsearch have a name in both languages. The consuming form of solve and the analytic-gradient BFGS row are Rust forms: the script solve is the borrowing form, and the script fminunc uses finite-difference gradients.
- MATLAB was not measured. python-control supplied reference results and was not timed.
- The accuracy columns compare against the reference library's result or a stored reference solution. They are not a proof of correctness against the exact answer.
08How to Rerun It
Steps
The numerics crate is in the Eustress source at eustress/crates/numerics, with Cargo.toml, README.md, src and tests. The tests folder holds the 119 tests and the fixture files they read, in tests/fixtures: stored reference results from SciPy, NumPy and python-control, each next to its inputs and the library versions that produced it. From the crate folder, run the tests with:
cargo testThe SciPy comparison harness is not part of the crate folder. The fixture generator, the mutation-proof script, the benchmark programs for Eustress and for SciPy, the paired-run scripts, and the accuracy and reproducibility programs that produced the speed, paired-run, accuracy, bit-reproducibility and mutation tables on this page are not in it. Those tables cannot be regenerated from the crate folder. They were produced by that harness on the machine described under Method. The 119 tests check the library against the stored fixtures with the tolerances listed in the accuracy table.
09Test Totals
What the Tests Cover
The totals come from one run of cargo test. Each line below is one test binary; the counts were matched to the number of test functions in each file.
| Test binary | Passed | Failed |
|---|---|---|
| unit tests in src (bdc 2, hqr 4, mixed_fft 4, ode 1) | 11 | 0 |
| tests/control.rs | 33 | 0 |
| tests/kernels.rs | 8 | 0 |
| tests/linalg.rs | 27 | 0 |
| tests/ode_optim.rs | 22 | 0 |
| tests/poly_calc.rs | 15 | 0 |
| tests/realtime.rs | 3 | 0 |
| documentation tests | 0 | 0 |
| Total | 119 | 0 |
Mutation Proof
A passing test proves little unless it can fail. The mutation proof edits one line of the library at a time to introduce a plausible mistake and checks that the named test fails.
Each mutation breaks one line of the library and runs the named test. A caught mutation makes the test fail; a survivor is a mutation after which the test still passes. Before each mutation the same test was run unmodified as a control; the control passed in 43 of 43 cases. After the last mutation the source was restored and the test files rerun.
| Mutation | Test | Result |
|---|---|---|
| eig: eigenvalues scaled by 1 + 1e-6 | linalg::eig_general_matches_scipy | test failed (caught) |
| care: Q term of the Riccati residual scaled by 1.001 | control::care_and_lqr_on_an_unstable_plant_match_scipy | test failed (caught) |
| c2d tustin: 0.5 * dt replaced by 0.4 * dt in the numerator factor | control::c2d_zoh_foh_tustin_match_scipy | test failed (caught) |
| ode45 step control: error estimate under-reported 1000 times | ode_optim::ode45_error_tracks_the_tolerance | test failed (caught) |
| ode45 step control: rejected steps accepted (accept threshold raised to 1e6) | ode_optim::ode45_step_control_spends_work_where_the_tolerance_asks | test failed (caught) |
| margin: phase margin offset by one degree | control::margin_matches_python_control | test failed (caught) |
| margin: gain crossover polynomial uses |N|^2 - 1.01 |D|^2 | control::margin_matches_python_control | test failed (caught) |
| expm: last Pade coefficient 182 replaced by 181 | linalg::expm_of_a_rotation_generator_matches_the_closed_form | test failed (caught) |
| ode15s: gamma coefficients accumulate 1/(i+1) instead of 1/i | ode_optim::ode15s_solves_stiff_van_der_pol_mu_1000 | test failed (caught) |
| dare: X scaled by 1.001 in the returned gain | control::dare_and_dlqr_match_scipy | test failed (caught) |
| mixed-radix fft: radix-4 pass loses its rotation by -i (vector code) | kernels::fft_mixed_radix_matches_scipy_on_long_lengths | test failed (caught) |
| mixed-radix fft: odd-radix pass swaps the sign of the sine sum (vector code) | kernels::fft_mixed_radix_matches_numpy_on_composite_lengths | test failed (caught) |
| singular values: sign error in the row rotation of the bidiagonal QR sweep | kernels::singular_values_match_scipy | test failed (caught) |
| solve_owned: single right-hand side solved with A' instead of A | kernels::solve_owned_matches_numpy | test failed (caught) |
| six-step fft: twiddle built from the coarse table only | kernels::fft_six_step_matches_scipy_on_very_long_lengths | test failed (caught) |
| dqds: transform applies the shift twice | kernels::singular_values_match_scipy | test failed (caught) |
| bidiagonal divide and conquer: secular bracket updated on the wrong side | lib::bdc::tests::divide_and_conquer_reconstructs_and_is_orthogonal | test failed (caught) |
| bidiagonal divide and conquer: vectors built from the original z instead of the recomputed one | lib::bdc::tests::hard_cases_graded_clustered_rank_deficient | test failed (caught) |
| bidiagonal divide and conquer: deflation rotation with sine and cosine swapped | lib::bdc::tests::hard_cases_graded_clustered_rank_deficient | test failed (caught) |
| bidiagonal divide and conquer: null vector combined with the wrong sign | lib::bdc::tests::divide_and_conquer_reconstructs_and_is_orthogonal | test failed (caught) |
| bidiagonal divide and conquer: first component of the left vectors +1 instead of -1 | lib::bdc::tests::divide_and_conquer_reconstructs_and_is_orthogonal | test failed (caught) |
| svd: right reflectors applied one row too high | kernels::full_svd_matches_scipy_on_hard_cases | test failed (caught) |
| 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 | test failed (caught) |
| 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 | test failed (caught) |
| ode_radau: collocation polynomial coefficient -8/3 replaced by -7/3 | ode_optim::ode_radau_matches_scipy_radau_on_robertson_at_four_tolerances | test failed (caught) |
| ode15s: tolerance refusal removed | ode_optim::ode15s_refuses_tolerances_it_cannot_reach_and_points_to_ode_radau | test failed (caught) |
| 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 | test failed (caught) |
| 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 | test failed (caught) |
| depth-first fft: outputs of the parts copied back without interleaving | kernels::fft_depth_first_matches_scipy_on_long_lengths | test failed (caught) |
| 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 | test failed (caught) |
| 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 | test failed (caught) |
| divide and conquer merge: sorted singular values written to unsorted places | kernels::full_svd_matches_scipy_on_hard_cases | test failed (caught) |
| divide and conquer merge: rows of block two stored one row too high | lib::bdc::tests::hard_cases_graded_clustered_rank_deficient | test failed (caught) |
| in-crate eig: sweep U row bound taken from the lowest active bulge only | lib::hqr::tests::schur_and_eigenvectors_on_every_driver_path | test failed (caught) |
| in-crate eig: sweep left pass skips the newest bulge's own column | lib::hqr::tests::schur_and_eigenvectors_on_every_driver_path | test failed (caught) |
| in-crate eig: AED spike test reads the second row of V | lib::hqr::tests::hard_matrices_on_every_driver_path | test failed (caught) |
| in-crate eig: 1x1 block swap rotates Q the wrong way | lib::hqr::tests::block_swaps_of_every_shape | test failed (caught) |
| in-crate eig: 2x2 standardisation rotation with the wrong sine sign | lib::hqr::tests::schur_and_eigenvectors_on_every_driver_path | test failed (caught) |
| in-crate eig: complex eigenvector started for the conjugate eigenvalue | lib::hqr::tests::schur_and_eigenvectors_on_every_driver_path | test failed (caught) |
| in-crate eig: overflow guard of the real back-substitution removed | lib::hqr::tests::repeated_eigenvalues_give_finite_vectors | test failed (caught) |
| in-crate eig: second column of a complex pair not conjugated | linalg::eig_hard_matrices_match_scipy_through_the_in_crate_solver | test failed (caught) |
| 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 | test passed (survivor) |
| dare: doubling iteration drops the G update (the Newton correction that follows repairs the start value) | control::dare_handles_a_singular_state_matrix | test passed (survivor) |
41 of 43 mutations were caught by the named test. 2 survived, and each survivor was expected, with the reason in its Mutation cell. Results that differ from the expected column: none.
10What's Next
Related Pages
The routines in the dense linear algebra rows are described in Linear Algebra and Polynomials. The solvers in the ODE rows are in Differential Equations, and the optimizers in Optimization. The Fourier transform is in Calculus and Signal, and the Riccati solvers, the discretization and the other control rows are in Control Design. The full list of routines is on the Numerics overview.
Read the routine, then check its row.