Matrix exponential

I have a need for a matrix exponential function. I’ve implemented one using the Hipparchus RealMatrix classes and I’d like to contribute it into the project, assuming that I didn’t overlook an existing implementation.

So I have two questions:

  • I’ve translated the C++ Eigen implementation, so is that going to be OK from a licensing perspective?
  • Where is an appropriate place to put it? I was thinking a static method in the MatrixUtils class?

No, it’s not. Eigen is published under the terms of the MPL2 license (see, which is a weak copyleft type, whereas Hipparchus is published under the terms of the Apache V2 license which is a permissive type. So a clean-room implementation or an implementation derived for another type of software license would be needed.

Yes, I think this would be appropriate.

No worries. I’ve looked at the primary sources

Higham, Nicholas J. “The Scaling and Squaring Method for the Matrix Exponential Revisited.” SIAM Journal on Matrix Analysis and Applications 26, no. 4 (January 2005): 1179–93.


Golub, Gene H., and Charles F. van Loan. Matrix Computations . 4th ed. John Hopkins University Press, 2013.

and the algorithm is straightforward to follow. I’ll go for a clean-room implementation.

I’ve made a pull request on github.
I’m relatively new to open source contributions, so please let me know if there’s something I should do differently.