koopman-dmd
Dynamic Mode Decomposition (DMD) with Koopman operator theory extensions, in pure Rust.
DMD extracts spatiotemporal coherent structures from time-series data, giving a linear operator that approximates the dynamics of a possibly nonlinear system. This crate implements the core method plus the Koopman-theoretic extensions used for analyzing nonlinear and area-preserving systems.
Linear algebra is provided by faer; no external
BLAS/LAPACK installation is required.
Features
- Core DMD — standard DMD with truncated SVD and optional mean centering
- Extended DMD — polynomial, trigonometric, and delay-coordinate lifting for nonlinear systems
- Hankel-DMD — time-delay embedding via Krylov subspace, for scalar or low-dimensional signals
- GLA — Generalized Laplace Analysis for direct Koopman eigenfunction computation
- Harmonic time averages — phase space analysis and orbit classification via HTA
- Mesochronic plots — grid-based HTA visualization of mixed dynamics, parallelized with rayon
- Built-in maps — Chirikov standard, Froeschlé, extended standard, Hénon, and logistic
- Prediction — mode-based and matrix-based forecasting with lifting-aware back-projection
- Analysis — stability, spectrum, residuals, pseudospectrum, error metrics, dominant modes
Installation
[]
= "0.1"
Requires Rust 1.85 or later.
Quick start
use ;
// A 2-variable oscillating signal, as a 2 x 100 matrix
let n = 100;
let mut data = zeros;
for j in 0..n
let result = dmd.unwrap;
// Inspect the spectrum
for m in &dmd_spectrum
// Forecast 10 steps ahead
let pred = predict_modes.unwrap;
Extended DMD with lifting
Lifting maps observables into a higher-dimensional space where nonlinear dynamics become approximately linear:
use ;
let n = 100;
let mut data = zeros;
for j in 0..n
let config = DmdConfig ;
let result = dmd.unwrap;
Hankel-DMD
Time-delay embedding, for scalar signals or systems with limited measurements:
The signal is a 1 x n matrix (one row per measured variable):
use ;
let n = 200;
let mut signal = zeros;
for j in 0..n
let config = HankelConfig ;
let result = hankel_dmd.unwrap;
Generalized Laplace Analysis
Direct computation of Koopman eigenfunctions via weighted time averages:
use ;
let n = 200;
let mut data = zeros;
for j in 0..n
let config = GlaConfig ;
let result = gla.unwrap;
Harmonic time averages and mesochronic plots
Phase space analysis of area-preserving maps:
use ;
let map = StandardMap ;
// HTA at a single initial condition
let hta = harmonic_time_average.unwrap;
// Mesochronic plot over a grid (parallelized with rayon)
let mhp = mesochronic_compute.unwrap;
Other languages
Python and R bindings live in the same repository:
- Python —
koopman-dmdon PyPI (PyO3 + maturin) - R —
koopman.dmd(extendr)
Benchmarks
Representative results (Apple Silicon):
| Operation | Size | Time |
|---|---|---|
| DMD | 5 × 100 | ~80 µs |
| DMD | 50 × 1000 | ~8.5 ms |
| Predict (modes) | 2 vars, 100 steps | ~215 µs |
| Predict (matrix) | 2 vars, 100 steps | ~36 µs |
| Hankel-DMD | 1 × 200, 20 delays | ~130 µs |
| GLA | 2 × 200 | ~344 µs |
References
- Schmid, P.J. (2010). Dynamic mode decomposition of numerical and experimental data. Journal of Fluid Mechanics, 656, 5–28. doi:10.1017/S0022112010001217
- Kutz, J.N., Brunton, S.L., Brunton, B.W., & Proctor, J.L. (2016). Dynamic Mode Decomposition: Data-Driven Modeling of Complex Systems. SIAM. doi:10.1137/1.9781611974508
- Mezić, I. (2020). Spectrum of the Koopman operator, spectral expansions in functional spaces, and state-space geometry. arXiv:2009.05883
- Levnajić, Z. & Mezić, I. (2014). Ergodic theory and visualization. arXiv:0808.2182v2
License
MIT — see LICENSE.