Reputation: 4864
Suppose I have a symmetric matrix A
and a vector b
and want to find A^(-1) b
. Now, this is well-known to be doable in time O(N^2)
(where N
is the dimension of the vector\matrix), and I believe that in MATLAB this can be done as b\A
. But all I can find in python is numpy.linalg.solve()
which will do Gaussian elimination, which is O(N^3)
. I must not be looking in the right place...
Upvotes: 2
Views: 1020
Reputation: 117681
scipy.linalg.solve
has an argument to make it assume a symmetric matrix:
x = scipy.linalg.solve(A, b, assume_a="sym")
If you know your matrix is not just symmetric but positive definite you can give this stronger assumption instead, as "pos"
.
Upvotes: 4