File Exchange

image thumbnail

Batch matrix exponential computation with CPU/GPU

version 1.0.3 (79.7 KB) by Yi-Hao Chen
Calculate several matrix exponentials at a time with Pade approximation

1 Download

Updated 04 Dec 2018

View Version History

View License

This code is based on Ken Johnson's "expm_". I extended it to compute with GPU. Besides, it can compute for several matrices at a time by using Pade approximation. The matrices should be stored in each page of a multidimensional array.
For CPU computation, please install Yuval's "mmx" for a faster matrix computation, otherwise, it uses a for-loop.

This code can be 400x faster than using for-loop Matlab "expm" when calculating 10000 5x5 randn matrices under GPU. It takes only 0.04s, while Matlab "expm" takes 20s.

Future plan: For Hermitian (or possibly anti-Hermitian) matrices, calculate the eigenvectors and eigenvalues for multiple matrices at once with GPU with householder transformation and QR decomposition, and then use them to calculate expm, which should be faster and this is what Matlab expm does when it's a hermitian matrix. This will take a long time since I'm not familiar with these two methods and I can only do it "if I have enough free time".

Cite As

Yi-Hao Chen (2021). Batch matrix exponential computation with CPU/GPU (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (1)

MATLAB Release Compatibility
Created with R2018b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Inspired by: mmx, Matrix exponential, Matrix polynomial

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!