Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

matrix inversion is very slow #326

Closed
grzegorzmazur opened this issue Feb 18, 2021 · 0 comments
Closed

matrix inversion is very slow #326

grzegorzmazur opened this issue Feb 18, 2021 · 0 comments

Comments

@grzegorzmazur
Copy link
Owner

I tested pow.yac_symbol with a 2 by 2 matrix using a negative n power and it worked properly.

Apparently the inverse of x in the case above takes forever on my machine using any of the following: y_fn(ysym(x), "MatrixPower", -1), yac_str(paste0("MatrixPower(", ysym(x), ",", -1, ")")), and solve(x)

I also tried the same matrix as input in yacas (see below) and the same happens. There is nothing wrong with the implementation of pow.yac_symbol. It just takes to long to obtain a solution in yacas for this case. Obtaining the inverse of a matrix is not a trivial task.

x := {{36.32,-633.09,-320.73,2.19,-5.11,4.50},
        {-633.09, 15360.79, 6721.15, -47.06, 107.68, -96.05},
        {-320.73, 6721.15, 4700.86, -16.45, 44.19, -86.77},
        {2.19, -47.06, -16.45, 0.28, -0.37, 0.08},
        {-5.11, 107.68, 44.19, -0.37, 0.95, -0.30},
        {4.50, -96.05, -86.77, 0.08, -0.30, 3.19}};
Inverse(x);
MatrixPower(x, -1);

Note, however, that pow.default does not have this issue.

In summary,

  • pow.yac_symbol is in order, however, it might have performance issues with negative exponents for larger matrix inputs and
  • pow.default using exponentiation by squaring is fast enough for most applications.

Let me know which direction you wish to take.

Originally posted by @jeksterslab in r-cas/ryacas#56 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant