I am reviewing the implementation code and the Householder reflections algorithm to figure out why this is the case. The definitions that I have seen (including the ones that you reference in the javadoc) use the second approach (R is square). Generally, m is assumed to be greater than or equal to n and I think the matrix has to be full rank for the decomp to be unique. I am not an expert in this area, so will defer to others if there are good arguments for using the definition that your implementation uses. The important thing is to document exactly what the code does, both in the interface javadoc and the impl. It would be awkward in this case to have the interface under-specified regarding the dimensions of the factors, so this should probably be settled independently of the algorithm.
About the dimensions, it depends on what your requirements are. If you require that the columns of Q form an orthogonal basis of R^m, Q has to be m x m. If that condition is relaxed and m >= n, the last rows of R will be zero. This means that the last columns of Q don't contribute to the product QR. In this case Q can be m x n. The latter form is called "the economy-size decomposition" in MATLAB documentation: http://www.mathworks.com/access/helpdesk/help/techdoc/ref/qr.html The two forms are mentioned also here: http://www.cs.utexas.edu/~plapack/icpp98/node4.html JAMA uses the economy-size decomposition. (After sending my last email I realised that if m <= n, Q can't be m x n already for the fact that at most m vectors can be linearly independent--let alone orthogonal--in R^m.) IIRC, for the factorization to be unique, the matrix has to have full rank and the diagonal elements of R have to be positive, but a factorization exists and can be computed with the Householder algorithm even if the matrix is singular. Another thing I'm not sure of is the naming; I've named the classes without regard to the fact that they work only with real matrices. If there is to be support for complex and arbitrary precision matrices, perhaps a rename would be due?
> It seems that many decompositions are used for solving linear systems. > A decomposition object "knows" what the system is like and has access > to the raw factorized data that can be packed in some way, so it would > make some sense to ask it solve systems, too. Plus: users would be > able to switch between different implementations, like with the > Collections API. Beyond what is available in the API (Q and R), what exactly does the QR Decomp "know" that makes solving easier?
It has Q stored as a list of Householder vectors. Multiplying a matrix with Q or Q' that is stored in this format is not much more expensive than a normal matrix multiplication, but it's a lot more efficient when compared to first calculating an explicit form of Q and then multiplying. It might be better numerically too, but I cannot be sure.
