You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Neil Ireson <n....@sheffield.ac.uk> on 2014/11/12 13:05:49 UTC

[math] QRDecomposition on singular values

Hi all,

I am way out of my comfort zone here, but hit and issue when using QRDecomposition and hacked a solution which I believe is valid “improvement” but would like to have more knowledgeable input.

In the current implementation of QRDecomposition if the matrix is singular (determined by the isNonSingular method returning false) then the solve method will throw a SingularMatrixException.

However as far as I can ascertain it is legitimate to solve the matrix by replacing the calculations involving the diagonal which would result in a large number (or Infinity if the diagonal is zero) with zero if the diagonal < threshold.

According to http://www.kwon3d.com/theory/jkinem/svd.html <http://www.kwon3d.com/theory/jkinem/svd.html>
"When matrix a is singular, it will not have a solution, but replacing 1/wi with 0 will provide the closest x that minimizes [the linear equation |ax -y|]”

Anyway I hacked the code along these lines so that i could get a solution to my problem and wondered if this was a better solution than the current approach.

Rather than getting the solve method to throw the SingularMatrixException, the user can check if the matrix is singular and determine if they still wish to proceed.

N