Marcel-Rodekamp / NSL

Nanosystem Simulation Library (NSL) implements statistical simulations for systems on the nanoscale
Other
2 stars 0 forks source link

Torch's implementation of matrix exponentiation is surprisingly not very good #89

Open luutom opened 2 years ago

luutom commented 2 years ago

When I choose a random 64x64 matrix (not necessarily symmetric, but I've tested for symmetric as well), which I call A, and use A.mat_exp() to exponentiate this matrix, giving exp(A). I also calculate exp(-A) using a similar procedure. I then calculate matmul(exp(A),exp(-A)) and compare it to the identity matrix. When using almost_equal() to do this comparison, I find that I have to reduce the tolerance GREATLY (something like 10^-2 or 10^-3) to pass the comparison. This is bad!