tdmd-toolbox is a JAX-based library for tensor dynamic mode decomposition
under transform-induced tensor algebras.
The package currently focuses on:
- tensor DMD (
TDMD) - multirank TDMDII (
TDMDII) inspired by thestar_M-product formulation - configurable transform bases through
FFTTransformandMatrixTransform
Classical matrix DMD is not part of the library API. It is used only inside the example notebooks for side-by-side comparisons against tensor methods.
Clone the repository and install dependencies with uv:
git clone https://github.com/p4sttt/tdmd-toolbox
cd tdmd-toolbox
uv venv
uv syncThe project requires Python >=3.12.
Public exports from tdmd:
FFTTransformMatrixTransformTDMDTDMDII
FFTTransformapplies an FFT along the third tensor axis.MatrixTransformuses an explicit invertible square matrix on the third axis.
Both transforms define the tensor algebra used by the TDMD algorithms.
The repository also contains low-level algebra and decomposition primitives in
tdmd.core, including tensor products, tensor SVD variants, and tensor Schur
decomposition. They are kept as internal or advanced building blocks rather
than top-level library entry points.
TDMD(transform, ...)provides a model-stylefit,predict_next(),predict_step(step), andforecast(horizon)interface for tensor DMD.TDMDII(transform, ...)provides the same model-style API for the multirank TDMDII variant and additionally exposesmultirank.
TDMDII is the article-style multirank variant used in the cylinder and graph
examples.
import jax.numpy as jnp
from tdmd import FFTTransform, TDMD
L = FFTTransform()
snapshots = jnp.ones((8, 16, 4))
model = TDMD(
L,
svd_threshold=0.0,
signvals_threshold=1.0e-8,
)
model.fit(snapshots)
modes = model.modes
schur_tensor = model.schur_tensor
next_snapshot = model.predict_next()
step_5_snapshot = model.predict_step(5)For the multirank TDMDII variant:
import jax.numpy as jnp
from tdmd import MatrixTransform, TDMDII
M = jnp.eye(6)
L = MatrixTransform(M)
snapshots = jnp.ones((10, 21, 6))
model = TDMDII(
L,
gamma=0.999,
signvals_threshold=1.0e-8,
)
model.fit(snapshots)
modes = model.modes
schur_tensor = model.schur_tensor
amplitudes = model.amplitudes
multirank = model.multirank
next_snapshot = model.predict_next()The examples/ directory contains notebooks for three comparison settings.
examples/dmd-plasma.ipynbexamples/tdmd-plasma.ipynb
These notebooks compare classical matrix DMD against TDMDII on a synthetic
plasma-like space-time field. Both notebooks evaluate reconstruction error over
multiple forecasted snapshots and plot error growth across the prediction
horizon.
examples/dmd-cylinder.ipynbexamples/tdmd-cylinder.ipynb
These notebooks compare matrix DMD and TDMDII on the cylinder wake dataset
from the Dynamics Lab data repository. The TDMDII setup uses a DCT-based
transform and reproduces the article-style comparison where tensor structure is
beneficial.
examples/dmd-temporal-graph.ipynbexamples/tdmd-temporal-graph.ipynb
These notebooks compare matrix DMD and TDMDII on temporal graph snapshots
constructed from the Stanford SNAP email-Eu-core-temporal-Dept3 dataset.
Some notebooks download data automatically on first run:
- cylinder wake data from the Dynamics Lab public dataset
- temporal graph data from Stanford SNAP
The downloads are cached under examples/data/.
Run the test suite with:
./.venv/bin/pytest tdmd/testsAt the time of this README update, the repository test suite passes with:
22 passed
tdmd/
core/
tensor_product.py
decomposition.py
dmd.py
tests/
examples/
*.ipynb
*.py