Matrix exponentiation#
Matrix exponential computation.
- 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.
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. Use
TensorFlowExpmBackendif performance is an issue.- __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 is 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. This is faster than the other backends but tends to be less precise, so please use with caution. Note that jax is an optional dependency and thus needs to be installed separately.
- __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