I think you should use qrfact(A,value{true}):
http://docs.julialang.org/en/release-0.4/stdlib/linalg/?highlight=qrfact#Base.qrfact

On Wed, Sep 7, 2016 at 3:37 AM, Stuart Brorson <s...@cloud9.net> wrote:

> Hello Julia users,
>
> Matlab has a variant of the QR decomposition invoked like this:
>
> [Q,R,P] = qr(A)
>
> This variant of qr() returns matrix R where the diagonal elements are
> sorted from largest to smallest magnitude as you go from upper left to
> lower right.  The matrix P is the permutation matrix which permutes
> the rows/cols of A to give this ordering of the diagonal elements of
> R.  That is, Q*R = A*P.
>
> I tried doing the naive, analogous thing in Julia, but get an error:
>
> julia> A = rand(3,3)
> 3x3 Array{Float64,2}:
>  0.243071  0.454947   0.89657
>  0.112843  0.802457   0.375417
>  0.154241  0.0182734  0.992542
>
> julia> Q,R,P = qr(A)
> ERROR: BoundsError: attempt to access (
> 3x3 Array{Float64,2}:
>  -0.786117   0.0985642  -0.610168
>  -0.364946  -0.870763    0.329523
>  -0.498833   0.481723    0.720492,
>
> 3x3 Array{Float64,2}:
>  -0.309204  -0.659611  -1.33693
>   0.0       -0.645106   0.2396
>   0.0        0.0        0.29177)
>   at index [3]
>  in indexed_next at tuple.jl:21
>
> My question:  What's the best way to get the equivalent of Matlab's
> [Q,R,P] = qr(A) in Julia?  Should I write my own qr() (not too
> difficult)?  Or just do some row/col permutation of the output of
> regular qr()?
>
> Thanks for any advice,
>
> Stuart
>
> p.s.  I am using Version 0.4.3-pre+6 (2015-12-11 00:38 UTC)
>

Reply via email to