On Sat, Oct 19, 2013 at 12:21 AM, Phil Steitz <phil.ste...@gmail.com> wrote:
> The decomposition solvers can "invert" non-square matrices.  There
> is no documentation describing what exactly is being returned in
> these cases.  It is not obvious to me exactly what conditions the
> returned value satisfies in each case when the actual parameter is
> not square.  Do all of them return pseudo-inverses X satisfying AXA
> = A where A is the input matrix?  Do they satisfy other conditions
> as well?  Under what conditions will exceptions be thrown?  We
> should either throw NonSquareMatrixException (as MatrixUtils now
> does) on non-square arguments or define precisely what is being
> computed by each of the solvers for non-square arguments and what
> the preconditions are.

Lots of the decompositions are not even defined for non-square
matrices -- for example LU. I think this covers that pretty well:
http://commons.apache.org/proper/commons-math/userguide/linear.html
(end of 3.4)

Looks like these decompositions do check and reject non-square
matrices, and javadoc that. So set those aside. I think we're talking
about QR and SVD here.


For non-square matrices, the inverse can't exist, so the result is
intended to be a pseudo-inverse. Yes it will always satisfy AXA = A.
We can point people to the definition of pseudo-inverse but I think
the salient fact is that in Ax = b, the "best" answer for x is
pinv(A)*b in the sense that:

- if there are no exact solutions, x gives the closest solution
(minimizes L2 norm of Ax-b)
- if there are many solutions, x is the smallest solution (smallest L2
norm of x)

You can make more specific and useful statements too, like, pinv(A)
will be a left- or right-inverse of A if it's not singular. And of
course if A is square and non-singular you get the real inverse out of
this, which also satisfies the generalized conditions above.


1. The javadoc does say it's a pseudo-inverse which is correct but
maybe it bears explaining that slightly?

2. The DecompositionSolver javadoc says that SingularMatrixException
is thrown if A is singular, but, at the least the SVD impl does not.
And indeed it does the meaningful thing in this case. This comment can
be moved down to, say, the QR decomposition, which does reject a
singular matrix (and it's beyond me whether it can be modified to not
do so)

3. While playing with it I was not able to get the QR decomposition to
(pseudo-)invert a tall/skinny (non-singular) matrix. I think it is a
small bug in that it solves for an identity matrix of the wrong size
here, but again, some chance I'm missing something.)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org

Reply via email to