Matrix exponentiation#
Matrix exponentiation backends.
- class TensorFlowExpmBackend[source]#
Bases:
ExpmBackendCompute the matrix exponential using TensorFlow. Tends to be faster than scipy. Note that tensorflow is an optional dependency and thus needs to be installed separately. GPU acceleration may be available depending on the underlying hardware. Tends to be faster than
SciPyExpmBackendfor large matrices and highly parallelized computations.Note
Recommended backend for fast and reliable matrix exponentiation.
- class SciPyExpmBackend(precision: ~typing.Literal['np.float32', 'np.float64'] = <class 'numpy.float64'>)[source]#
Bases:
ExpmBackendCompute the matrix exponential using SciPy.
Note
This is the default backend. Recommended for smaller matrices. Consider switching to other backends for larger matrices, such as
JaxExpmBackend, which is both efficient and lightweight to install.- __init__(precision: ~typing.Literal['np.float32', 'np.float64'] = <class 'numpy.float64'>)[source]#
Initialize the backend.
- Parameters:
precision (
Literal['np.float32','np.float64']) – Precision of the matrix exponential, defaults to double precision. A lower precision may be faster but much more prone to numerical issues, so please use with caution.
- precision#
Precision of the matrix exponential
- class JaxExpmBackend(max_squarings: int = 1024)[source]#
Bases:
ExpmBackendCompute the matrix exponential using Jax. Note that jax is an optional dependency and thus needs to be installed separately. GPU acceleration may be available depending on the underlying hardware. Tends to be faster than
SciPyExpmBackendfor larger matrices and highly parallelized computations.- __init__(max_squarings: int = 1024)[source]#
Initialize the backend.
- Parameters:
max_squarings (
int) – Maximum number of squarings (see jax.scipy.linalg.expm).
- max_squarings#
Maximum number of squarings
- class PyTorchExpmBackend[source]#
Bases:
ExpmBackendCompute the matrix exponential using PyTorch. Note that PyTorch is an optional dependency and thus needs to be installed separately. GPU acceleration may be available depending on the underlying hardware.