# In QR and LU factorizations what would the results be with transposed inputs?

I really wish column-major matrix order was never invented. It very quickly stops making sense after two dimensions and now I have to deal with it when interfacing with the cuSolver functions.

The Nvidia Cuda cuBlas and cuSolver library functions all accept matrices in column major order. I've been very successful up to now in adapting them for row-major matrices by moving arguments passed into them around, but with the factorization functions I am out of luck and will have to do an explicit transpose somewhere probably.

I am not at all familiar with how LU and QR decomposition work, so I am not sure whether I just need to transpose the input or whether I will also need to do the output.

• "I really wish column-major matrix order was never invented." I have the same feeling about the row-major ordering and even my C++ matrix classes use the column-major order. It is trivial to implement, one does not need to bother about conversions, and can use BLAS or LAPACK without any unnecessary hassle. – Algebraic Pavel Jul 16 '18 at 8:29
• Interesting comment. Row-major makes more sense because it resembles multidimensional arrays - indexing into them starts from the outermost dimension and goes inwards. This is the tensor standard that I intend to impose in Spiral. It is consistent, generalizes to arbitrary dimensions and is easier to think about. Column major on the other hand would start with the innermost dimension and go outward. It could only ever be considered in the context of 2d matrices. It is a good idea for the same reason the loops should be indexed as a <= i < b rather than a < i < b or a <= i <= b. – Marko Grdinic Jul 16 '18 at 11:53

$$(AB)^T=B^TA^T$$
This works for $LU$, as $L^T$ (resp. $U^T$) is upper (lower) triangular, but not for $QR$ because $Q^T$ is orthogonal, while $R^T$ is lower triangular. So it gives you an $RQ$ decomposition, which does not necessarily coincide with $QR$.
• It doesn't really work for $LU$, because $L$ is invertible, whereas $U$ may not be. But it works as long as the initial matrix is invertible. – egreg Jul 12 '18 at 13:49