[SciPy-User] scipy.sparse.linalg.bicg for Non Symmetric Matrix.
Pauli Virtanen
pav@iki...
Fri Dec 10 06:51:13 CST 2010
Thu, 09 Dec 2010 21:12:28 -0430, Raul Acuña wrote:
> Am using the iterative methods of scipy.sparse.linalg for solving a
> linear system of equations Ax = b. My matrix A is non symmetric. I've
> been using the scipy.sparse.linalg.cg() function multiplying both matrix
> "A" and "b" with the transpose of A so the matrix will become symmetric:
>
> Asym = matrix(dot(A.T,A))
> bsym = matrix(dot(A.T,b))
> sol = cg(A,b,tol = 1e-10,maxiter=30)
[clip]
> sol = bicg(A,b,tol = 1e-10,maxiter=30)
[clip]
> raise ValueError('expected square matrix (shape=%s)' % shape)
[clip]
The error is saying that your matrix is not a square matrix.
For a non-square matrix A, (A.T*A) is a square matrix, so that's why the
CG algorithm works. So it's not about symmetry of the matrix.
You should check that you have the same number of equations as unknowns.
Otherwise the solution either does not exists or is not unique.
--
Pauli Virtanen
More information about the SciPy-User
mailing list