[ 
https://issues.apache.org/jira/browse/MATH-1053?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13813240#comment-13813240
 ] 

Sean Owen commented on MATH-1053:
---------------------------------

As a more conservative change for now, it could merely reject a tall matrix 
with an exception, and document this. That would probably be nicer than the 
current DimesnionMismatchException.

> QRDecomposition.getSolver() should be able to find pseudo-inverse of 
> non-square matrices
> ----------------------------------------------------------------------------------------
>
>                 Key: MATH-1053
>                 URL: https://issues.apache.org/jira/browse/MATH-1053
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 3.2
>            Reporter: Sean Owen
>            Priority: Minor
>         Attachments: MATH-1053.patch
>
>
> 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.



--
This message was sent by Atlassian JIRA
(v6.1#6144)

Reply via email to