1

Actually, the problem I have is solving a homogeneous linear equation system Ax = 0, with A being large and sparse while constraining some entries of the solution vector x to specific values. This is equivalent to finding the nullspace of A which is, as I assume it to be, a more common problem. Thus, to achieve this, I try to compute the solution to Ax = 0 using some solvers provided by scipy.sparse but this only returns the trivial result 0.

Until now, I've tried solving it with the least squares solver from scipy.sparse and prior to this approach, I looked into another stackoverflow post which had a similar problem to the former one I described above, but this person worked with a normal numpy array. Unfortunately, I can't seem to find this post any more and don't really know, if it would work for scipy.sparse matrices anyway.

A = sparse.rand(10000, 5000, format="csc")
b = csr_matrix((10000, 1), dtype=np.float64).toarray()   
b = b.reshape((-1,))
x = linalg.lsqr(A, b)

Returns The exact solution is x = 0

Rani
  • 483
  • 7
  • 17
  • Have you checked the value of det(A)? – Patol75 May 08 '19 at 02:11
  • No, I haven't but in my specific problem I know for sure that there exists a non-zero `x` s.t. `Ax = 0`. – Rani May 08 '19 at 06:04
  • Have you looked at those questions? (https://stackoverflow.com/questions/5889142/python-numpy-scipy-finding-the-null-space-of-a-matrix) & (https://stackoverflow.com/questions/2992947/calculating-the-null-space-of-a-matrix) – Patol75 May 08 '19 at 06:24
  • Yes, I applied several different ones from both posts to my problem and [] is the only value that gets returned. – Rani May 08 '19 at 12:12
  • My vague memory from FEM work is that you can use known elements of `x` to reduce the size of `A` - with a `P*A*P.T` multiplication. – hpaulj May 10 '19 at 04:37

0 Answers0