Igor Rivin
Igor Rivin

Reputation: 4864

numpy and solving symmetric systems

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

Answers (1)

orlp
orlp

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

Related Questions