JuliaLang/julia — pull request #7804 by Jutho (2014-08-01 10:28:26+00:00)
Title: add Lapack LQ factorizations

I would love to have the functionality for doing LQ factorisations in a package I am working on. While these can be obtained from QR factorisation of the transposed matrix, there is no way to do this in place (since there is no in place transpose) and thus that approach is suboptimal both memory wise and computation wise.

This PR just enables the basis LQ factorisations provided by Lapack, no support for custom types yet. The interface is identical to that of the QR factorization (i.e. there is `lq`, `lqfact` and `lqfact!`).
Using `F=lqfact(A)` produces an `F::LQ` object. `Q=F[:Q]` produces an `LQPackedQ` object, that can be multiplied with a matrix from the left, from the right and (c)transposed.

However, there is not yet any support for `\` (or should it be `/` ) with an `LQ` object.

Currently the methods are not yet exported. If this could still be added to the 0.3 release, I will add them to export.jl and can add tests and documentation. If not, I will have to add this code to my own package, however, it would still be good if the tiny fixes in the lq methods in lapack.jl could be merged (which are completely invisible to the user, as these methods are not even used by anything).

Currently, the following runs without errors:
```julia
using Base.Test

D1=10
D2=20
for T in (Float32, Float64, Complex64, Complex128)
A=rand(T,D1,D2);
F=Base.LinAlg.lqfact(A);
L=F[:L];
Q=F[:Q];
Qf=full(Q,thin=false);
Qt=full(Q,thin=true);
@test_approx_eq L*Q A
@test_approx_eq L*Qt A

B=rand(T,D2,D2);
@test_approx_eq B*Q B*Qf
@test_approx_eq Q'*B Qf'*B
@test_approx_eq Q*B Qf*B
@test_approx_eq B*Q' B*Qf'

C=rand(T,D1,D1);
@test_approx_eq C*Q C*Qt
@test_approx_eq Q'*C Qt'*C
end
```