Search code examples
matrixjulianumerical-methodsscientific-computing

Pivoted QR in Julia?


In Julia, the function qr(A) will perform a QR decomposition on a given matrix A. However, is there any function/way in Julia to do a "pivoted" QR decomposition on a given matrix?


Solution

  • Just pass in the magic option:

    julia> A = 10*log.(1 .- rand(4,3));
    
    julia> qr(A, ColumnNorm())
    QRPivoted{Float64, Matrix{Float64}}
    Q factor:
    4×4 LinearAlgebra.QRPackedQ{Float64, Matrix{Float64}}:
     -0.0101543  -0.218633   0.804736   -0.551812
     -0.118832   -0.376628   0.446673    0.802816
     -0.118236   -0.88692   -0.390704   -0.216204
     -0.985797    0.154029  -0.0152722  -0.0651594
    R factor:
    3×3 Matrix{Float64}:
     26.4193   4.80784   8.92215
      0.0     18.7537   15.1792
      0.0      0.0      -9.77702
    permutation:
    3-element Vector{Int64}:
     2
     3
     1
    

    Note that the docs are a little off.