qr

qr(A [,pivot=Val{false}][;thin=true]) -> Q, R, [p]

Compute the (pivoted) QR factorization of A such that either A = Q*R or A[:,p] = Q*R. Also see qrfact. The default is to compute a thin factorization. Note that R is not extended with zeros when the full Q is requested.

Examples

julia> A = [1 2 3; 4 5 6; 7 8 9]
3×3 Array{Int64,2}:
 1  2  3
 4  5  6
 7  8  9

julia> qr(A)
LinearAlgebra.QRCompactWY{Float64,Array{Float64,2}}
Q factor:
3×3 LinearAlgebra.QRCompactWYQ{Float64,Array{Float64,2}}:
 -0.123091   0.904534  -0.408248
 -0.492365   0.301511   0.816497
 -0.861638  -0.301511  -0.408248
R factor:
3×3 Array{Float64,2}:
 -8.12404  -9.60114  -11.0782
  0.0       0.904534   1.80907
  0.0       0.0       -1.66533e-15

julia> qr(A, Val{true})
LinearAlgebra.QRPivoted{Float64,Array{Float64,2}}
Q factor:
3×3 LinearAlgebra.QRPivotedQ{Float64,Array{Float64,2}}:
 -0.123091   0.904534  -0.408248
 -0.492365   0.301511   0.816497
 -0.861638  -0.301511  -0.408248
R factor:
3×3 Array{Float64,2}:
 -8.12404  -9.60114  -11.0782
  0.0       0.904534   1.80907
  0.0       0.0       -1.66533e-15
permutation:
3-element Array{Int64,1}:
 3
 2
 1

julia> qr(A, pivot=Val{true}, thin=false)
LinearAlgebra.QRPivoted{Float64,Array{Float64,2}}
Q factor:
3×3 LinearAlgebra.QRPivotedQ{Float64,Array{Float64,2}}:
 -0.123091   0.904534  -0.408248
 -0.492365   0.301511   0.816497
 -0.861638  -0.301511  -0.408248
R factor:
3×3 Array{Float64,2}:
 -8.12404  -9.60114  -11.0782
  0.0       0.904534   1.80907
  0.0       0.0       -1.66533e-15
permutation:
3-element Array{Int64,1}:
 3
 2
 1

The qr function computes the QR factorization of a matrix A. It returns the factors Q and R such that either A = Q*R or A[:,p] = Q*R, depending on the arguments passed to the function.

  • A: The matrix for which the QR factorization is computed.
  • pivot: (Optional) A boolean value indicating whether pivoting should be performed. Default is Val{false}.
  • thin: (Optional) A boolean value indicating whether a thin factorization should be computed. Default is true.

If pivot is set to Val{true}, a pivoted QR factorization is computed, and the permutation vector is returned as well.

If thin is set to false, a full factorization is computed, and Q is a square matrix with orthonormal columns.

Note that R is not extended with zeros when the full Q is requested.

It's important to note that the actual values in the factorization examples may differ due to floating-point arithmetic.

See Also

User Contributed Notes

Add a Note

The format of note supported is markdown, use triple backtick to start and end a code block.

*Required Field
Details

Checking you are not a robot: