Nullspace Function Vs QR decomposition

In theory yes, by starting with different random vectors. In practice, my recollection is that CG can sometimes experience breakdown for semidefinite matrices, due to floatingh-point issues, so care is required. You might be better off with iterative eigensolver methods like LOBPCG or Lanczos.

When you say “different nullspace bases”, what do you mean? The basis is not unique, of course, since you can multiply it by any unitary matrix.

As @Oscar_Smith alludes to, because numerical computations of nullspace bases and ranks involve an arbitrary threshold on the smallest singular value (or the smallest R diagonal for QR), so even running the same algorithm on different machines (much less entirely different algorithms like QR vs SVD) will sometimes give different dimensions/ranks. You’ll need to think carefully about your problem if you don’t want your algorithm to be sensitive to this issue.

There isn’t any builtin function to compute the nullspace from a QR factorization (though perhaps there should be?), so without seeing your code it’s not clear whether you might have a bug there too.

See also the discussions in How to find the linearly independent columns (rows) of a matrix - #14 by stevengj and How to find the linearly independent columns (rows) of a matrix - #25 by mstewart on rank from QR.

1 Like