- Scilab help
- Linear Algebra
- aff2ab
- balanc
- bdiag
- chfact
- chol
- chsolve
- classmarkov
- cmb_lin
- coff
- colcomp
- companion
- cond
- det
- eigenmarkov
- ereduc
- expm
- fstair
- fullrf
- fullrfk
- genmarkov
- givens
- glever
- gschur
- gspec
- hess
- householder
- im_inv
- inv
- kernel
- kroneck
- linsolve
- lsq
- lu
- lyap
- nlev
- orth
- pbig
- pencan
- penlaur
- pinv
- polar
- proj
- projspec
- psmall
- qr
- quaskro
- randpencil
- range
- rank
- rankqr
- rcond
- rowcomp
- rowshuff
- rref
- schur
- spaninter
- spanplus
- spantwo
- spec
- sqroot
- squeeze
- sva
- svd
- sylv
- trace
Please note that the recommended version of Scilab is 2026.0.0. This page might be outdated.
See the recommended documentation of this function
qr
QR decomposition
Calling Sequence
[Q,R]=qr(X [,"e"]) [Q,R,E]=qr(X [,"e"]) [Q,R,rk,E]=qr(X [,tol])
Arguments
- X
- real or complex matrix 
- tol
- nonnegative real number 
- Q
- square orthogonal or unitary matrix 
- R
- matrix with same dimensions as - X
- E
- permutation matrix 
- rk
- integer (QR-rank of - X)
Description
- [Q,R] = qr(X)
- produces an upper triangular matrix - Rof the same dimension as- Xand an orthogonal (unitary in the complex case) matrix- Qso that- X = Q*R.- [Q,R] = qr(X,"e")produces an "economy size": If- Xis m-by-n with m > n, then only the first n columns of- Qare computed as well as the first n rows of- R.- From - Q*R = X, it follows that the kth column of the matrix- X, is expressed as a linear combination of the k first columns of- Q(with coefficients- R(1,k), ..., R(k,k)). The k first columns of- Qmake an orthogonal basis of the subspace spanned by the k first comumns of- X. If column- kof- X(i.e.- X(:,k)) is a linear combination of the first- pcolumns of- X, then the entries- R(p+1,k), ..., R(k,k)are zero. It this situation,- Ris upper trapezoidal. If- Xhas rank- rk, rows- R(rk+1,:), R(rk+2,:), ...are zeros.
- [Q,R,E] = qr(X)
- produces a (column) permutation matrix - E, an upper triangular- Rwith decreasing diagonal elements and an orthogonal (or unitary)- Qso that- X*E = Q*R. If- rkis the rank of- X, the- rkfirst entries along the main diagonal of- R, i.e.- R(1,1), R(2,2), ..., R(rk,rk)are all different from zero.- [Q,R,E] = qr(X,"e")produces an "economy size": If- Xis m-by-n with m > n, then only the first n columns of- Qare computed as well as the first n rows of- R.
- [Q,R,rk,E] = qr(X ,tol)
- returns - rk= rank estimate of- Xi.e.- rkis the number of diagonal elements in- Rwhich are larger than a given threshold- tol.
- [Q,R,rk,E] = qr(X)
- returns - rk= rank estimate of- Xi.e.- rkis the number of diagonal elements in- Rwhich are larger than- tol=R(1,1)*%eps*max(size(R)). See- rankqrfor a rank revealing QR factorization, using the condition number of- R.
Examples
// QR factorization, generic case // X is tall (full rank) X=rand(5,2);[Q,R]=qr(X); [Q'*X R] //X is fat (full rank) X=rand(2,3);[Q,R]=qr(X); [Q'*X R] //Column 4 of X is a linear combination of columns 1 and 2: X=rand(8,5);X(:,4)=X(:,1)+X(:,2); [Q,R]=qr(X); R, R(:,4) //X has rank 2, rows 3 to $ of R are zero: X=rand(8,2)*rand(2,5);[Q,R]=qr(X); R //Evaluating the rank rk: column pivoting ==> rk first //diagonal entries of R are non zero : A=rand(5,2)*rand(2,5); [Q,R,rk,E] = qr(A,1.d-10); norm(Q'*A-R) svd([A,Q(:,1:rk)]) //span(A) =span(Q(:,1:rk))
See Also
Used Functions
qr decomposition is based the Lapack routines DGEQRF, DGEQPF, DORGQR for the real matrices and ZGEQRF, ZGEQPF, ZORGQR for the complex case.
| << psmall | Linear Algebra | quaskro >> |