Skip to content

Commit 0d07fe9

Browse files
committed
add benchmark script
1 parent 098c54e commit 0d07fe9

3 files changed

Lines changed: 526 additions & 0 deletions

File tree

‎benchmark/Project.toml‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[deps]
2+
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
3+
DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab"
4+
GenericLinearAlgebra = "14197337-ba66-59df-a3e3-ca00e7dcff7a"
5+
GenericSchur = "c145ed77-6b09-5dd9-b285-bf645a82121e"
6+
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
7+
MatrixAlgebraKit = "6c742aac-3347-4629-af66-fc926824e5e4"
8+
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
9+
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
10+
StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3"

‎benchmark/README.md‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Matrix exponential benchmarks
2+
3+
`bench_exponential.jl` times and accuracy-tests every applicable `MatrixAlgebraKit.exponential`
4+
algorithm (`MatrixFunctionViaTaylor`, `MatrixFunctionViaLA`, `MatrixFunctionViaEig`,
5+
`MatrixFunctionViaEigh`) for `Float64`, `ComplexF64`, `BigFloat` and `Complex{BigFloat}`.
6+
7+
Accuracy inputs are built from a *known* spectrum as `A = V · Diag(λ) · V⁻¹`, so the exact
8+
`exp(A) = V · Diag(exp λ) · V⁻¹` is available analytically (computed at high precision).
9+
Eigenvalue families (`small`, `wide`, `imaginary`, `stiff`, `illconditioned`, `hermitian`)
10+
and eigenvector families (`unitary`, `general`, `illconditioned`) are chosen to stress or
11+
favor particular algorithms.
12+
13+
## Setup (once)
14+
15+
From the repository root:
16+
17+
```sh
18+
julia --project=benchmark -e 'using Pkg; Pkg.develop(path=pwd()); Pkg.instantiate()'
19+
```
20+
21+
This `dev`s the in-tree `MatrixAlgebraKit` into the benchmark's own environment.
22+
23+
## Run
24+
25+
```sh
26+
julia --project=benchmark benchmark/bench_exponential.jl # full run
27+
julia --project=benchmark benchmark/bench_exponential.jl --quick # fast smoke run
28+
julia --project=benchmark benchmark/bench_exponential.jl --csv out.csv
29+
```
30+
31+
Results are printed as per-type accuracy and timing tables and written to two CSVs derived
32+
from the `--csv` path (default base `benchmark/results.csv`): `*-accuracy.csv` and
33+
`*-timing.csv`. They are separate files because the accuracy and timing passes report
34+
disjoint quantities — a single combined table would leave the timing columns empty on the
35+
accuracy rows and vice-versa.
36+
37+
## Accuracy columns
38+
39+
- `analytic_err` — relative error vs the analytic `V·Diag(exp λ)·V⁻¹` reference (primary).
40+
- `recomp_err` — relative error vs an independent high-precision `exp` of the exact input.
41+
- `expexp_err` — `‖exp(A)·exp(−A) − I‖₁` (reference-free consistency check).
42+
- `det_err` — relative error of `det(exp A)` against `exp(tr A)`.
43+
- `condV` — designed condition number of the eigenvector basis (context for non-normal cases).

0 commit comments

Comments
 (0)