Uploaded image for project: 'Commons Math'
  1. Commons Math
  2. MATH-1053

QRDecomposition.getSolver() should be able to find pseudo-inverse of non-square matrices

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.2
    • Fix Version/s: 3.3
    • Labels:
      None

      Description

      I don't have a complete solution to this, so don't commit this as-is, but posting in case someone can get it over the line.

      If you process a tall m x n matrix (non-square, m>n) with QRDecomposition and then call getSolver().getInverse(), you will get DimensionMismatchException. There's not a good reason the QR decomposition can't compute the least-squares solution here.

      The issue is that it tries to invert A by solving AX = I. The dimension of I has to match the row dimension of A, or m. However it's using the length of the diagonal of R, which is min(m,n), which is n when m>n.

      That patch is simple and is part of the attached patch. It also includes a test case for a tall matrix.

      However it doesn't work for a fat matrix (m<n). There's a test case for that too. It returns an n x m value but the rows for i >= m are 0 and are not computed. I'm not sure enough about the shape of the computation to be able to fix it, but it is where it's solving the triangular system Rx = y.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              srowen Sean Owen
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: