qrfact(A)
.. qrfact(A) -> SPQR.Factorization
Compute the QR factorization of a sparse matrix ``A``. A fill-reducing permutation is used. The main application of this type is to solve least squares problems with ``\``. The function calls the C library SPQR and a few additional functions from the library are wrapped but not exported.
Examples
The qrfact(A, pivot=Val{false})
function computes the QR factorization of matrix A
. The return type of F
depends on the element type of A
and whether pivoting is specified (with pivot==Val{true}
). Here are some examples and explanations of its usage:
-
Compute QR factorization of a matrix:
julia> A = [1 2; 3 4; 5 6]; julia> F = qrfact(A) QR{Float64,Array{Float64,2}} with factorizations Q and R: Q factor: 3×3 LinearAlgebra.QRCompactWYQ{Float64,Array{Float64,2}}: -0.16903 0.897085 -0.408248 -0.507092 -0.276026 -0.816497 -0.845154 0.345033 0.408248 R factor: 2×2 Array{Float64,2}: -5.91608 -7.43735 0.0 0.828078
This example computes the QR factorization of matrix
A
and stores the result inF
. TheQR
objectF
contains theQ
factor and theR
factor. -
Compute QR factorization with pivoting:
julia> A = [1 2; 3 4; 5 6]; julia> F = qrfact(A, pivot=Val{true}) QRPivoted{Float64,Array{Float64,2}} with factorizations Q, R, and P: Q factor: 3×3 LinearAlgebra.QRPackedQ{Float64,Array{Float64,2}}: -0.16903 0.897085 -0.408248 -0.507092 -0.276026 -0.816497 -0.845154 0.345033 0.408248 R factor: 2×2 Array{Float64,2}: -5.91608 -7.43735 0.0 0.828078 P permutation: 3-element Array{Int64,1}: 3 2 1
This example computes the QR factorization of matrix
A
with pivoting enabled. TheQRPivoted
objectF
contains theQ
factor, theR
factor, and the permutation matrixP
. -
Access individual components of the factorization:
julia> Q = F[:Q] 3×3 LinearAlgebra.QRCompactWYQ{Float64,Array{Float64,2}}: -0.16903 0.897085 -0.408248 -0.507092 -0.276026 -0.816497 -0.845154 0.345033 0.408248 julia> R = F[:R] 2×2 Array{Float64,2}: -5.91608 -7.43735 0.0 0.828078 julia> P = F[:P] 3-element Array{Int64,1}: 3 2 1
This example shows how to access the
Q
,R
, andP
components of the factorizationF
.
See Also
Ac_ldiv_B, Ac_ldiv_Bc, Ac_mul_B, Ac_mul_Bc, Ac_rdiv_B, Ac_rdiv_Bc, At_ldiv_B, At_ldiv_Bt, At_mul_B, At_mul_Bt, At_rdiv_B, At_rdiv_Bt, A_ldiv_Bc, A_ldiv_Bt, A_mul_B!, A_mul_Bc, A_mul_Bt, A_rdiv_Bc, A_rdiv_Bt, Bidiagonal, cond, conv2, det, diag, diagind, diagm, diff, eig, eigvals, eigvecs, expm, eye, full, inv, isdiag, ishermitian, isposdef, isposdef!, issym, istril, istriu, logabsdet, logdet, lyap, norm, qrfact, rank, repmat, rot180, rotl90, rotr90, sortrows, sqrtm, SymTridiagonal, trace, Tridiagonal, tril, tril!, triu, triu!, writedlm,User Contributed Notes
Add a Note
The format of note supported is markdown, use triple backtick to start and end a code block.