faer-rs icon indicating copy to clipboard operation
faer-rs copied to clipboard

Matrix Exponentiation

Open matthagan15 opened this issue 1 year ago • 3 comments

Is your feature request related to a problem? Please describe. Matrix exponentation utilizing the standard double precision algorithm by Al-Mohy and Higham.

Describe the solution you'd like A simple function that takes in a reference or matrix view (of some sorts not familiar with this library just yet) and yields a Result< ,> containing the exponentiated matrix if it worked and an error if not.

Describe alternatives you've considered n/a

Additional context I have implemented this function for ndarray-linalg but the maintainers have taken months and still no word. I am using my implementation for research purposes, using ndarray I have an error one-norm of about 20x scipy at 200x200 dense matrices and an error of machine precision for 1-sparse matrices up to 1024x1024. It might take some time but I'd be willing to port it over to this library to help move it along, would like to hear how this should best be done.

matthagan15 avatar Apr 10 '23 19:04 matthagan15

i'll look into it. right now i'm in the middle of a full rewrite of the library so i'm hesitant to start working on other stuff at the same time, but i should be done after a week or two hopefully. in the mean time, i could take a look at the algorithm if you have any references i can check out

sarah-quinones avatar Apr 12 '23 08:04 sarah-quinones

Ah sorry I think I miscommunicated, this is an offer for me to port the implemented algorithm from ndarray-linalg over to this project. All I'd need to learn how to do is multiplication and scaled addition, which I'd think shouldn't be too bad. I was mostly wondering what you think the best place to put this would be, it doesn't seem like a core contribution but doesn't quite fit in with the other "crates"/workspaces (still learning this type of organization). Let me know where and how you'd want it to be added and I'll get started on it.

matthagan15 avatar Apr 12 '23 17:04 matthagan15

i think it might make sense to create a new faer-math top level crate that contains math functions, kind of like eigen's matrix functions module https://eigen.tuxfamily.org/dox/unsupported/group__MatrixFunctions__Module.html

sarah-quinones avatar Apr 12 '23 18:04 sarah-quinones

I converted the SciPy version to C in case it makes things easier to convert https://github.com/scipy/scipy/blob/main/scipy/linalg/_matfuncs_expm.c

ilayn avatar Sep 26 '24 20:09 ilayn