1

When doing QR or SVD decomposition on an m x n matrix A in ojalgo, I've hit a snag. My purpose is to find a basis for the column null space. If m >= n, things work fine. For instance, QR decomposition of the transpose A' of a 5 x 4 matrix A with rank 2 gives me a 4 x 4 Q matrix whose last two columns span the null space of A.

On the other hand, if I start with a 5 x 7 matrix A with rank 5 (and do a QR decomposition of A'), I get the correct rank, but Q is 5 x 5 rather than 7 x 7, and I don't get the null space basis. Similarly, SVD with that same matrix A gets me five positive singular values (no zeros), and the Q2 matrix is 5 x 7 rather than 7 x 7 (no null vectors).

Is this expected behavior? I found a work-around for matrices with n > m (adding n-m rows of zeros to A), but it's clunky.

prubin
  • 366
  • 2
  • 14

1 Answers1

0

The matrices can be any size/shape, but calculating the economy sized decomposition is the default behaviour. It is what most users need/want. But there is an interface MatrixDecomposition.EconomySize that lets you control this (to optionally get the full size decomposition). Currently the QR, SVD and Bidiagonal decompositions implement it.

apete
  • 1,250
  • 1
  • 10
  • 16
  • Thanks for the pointer, but I can't seem to make it work. Starting with 5 x 7 A, I call one of the factory methods (QR.PRIMITIVE.make() or QR.make()) and pass in either A.transpose() or the corresponding dimensions. Next, I invoke setFullSize(true) on the QR instance, then call decompose(A.transpose()). The isFullSize() method returns true as expected, but getQ() still returns a 7 x 5 rather than a 7 x 7 matrix. – prubin Jun 14 '18 at 15:08
  • Then I think you should open an issue @ GitHub – apete Jun 14 '18 at 23:18
  • Done. I also discovered, in passing, that setFullSize(true) does not seem to be accepted by SVDs (but is accepted by QRs). – prubin Jun 15 '18 at 19:01