https://github.com/lezcano/expm
Differentiable and numerically stable implementation of the matrix exponential
https://github.com/lezcano/expm
Last synced: 8 months ago
JSON representation
Differentiable and numerically stable implementation of the matrix exponential
- Host: GitHub
- URL: https://github.com/lezcano/expm
- Owner: lezcano
- License: mit
- Created: 2019-10-17T23:58:30.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-10-20T10:40:53.000Z (over 5 years ago)
- Last Synced: 2025-03-30T20:33:50.646Z (about 1 year ago)
- Language: Python
- Homepage:
- Size: 40 KB
- Stars: 33
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# As of PyTorch 1.7.0, the matrix exponential is supported natively by PyTorch under the name `matrix_exp`
https://pytorch.org/docs/master/generated/torch.matrix_exp.html?highlight=matrix_exp#torch.matrix_exp
## Use the PyTorch native implementation rather than this one in your project if you can as it is faster
Two differentiable implementations of the exponential of matrices in Pytorch.
They implement the papers:
- `expm_taylor.py`:
[Computing the matrix exponential with an optimized Taylor polynomial approximation](https://www.mdpi.com/2227-7390/7/12/1174)
- `expm_pade.py`: [A New Scaling and Squaring Algorithm for the Matrix Exponential](http://eprints.ma.man.ac.uk/1300/1/covered/MIMS_ep2009_9.pdf)
The Taylor implementation should run faster in GPU, as it does not require of a QR decomposition.
The Taylor implementation supports batches of square matrices of shape `(*, n ,n)`.
The Taylor implementation is done entirely in Pytorch.
The Pade implementation requires Scipy. It is itself an adaptation of the implementation of `expm` in Scipy.