qr
QR decomposition.
Syntax
[Q,R] = qr(A)
[Q,R] = qr(A,econ)
Inputs
- A
- The matrix to decompose.
- econ
- Economy decomposition flag. Set to 0.
Outputs
- Q
- Orthonormal matrix.
- R
- Upper triangular matrix.
Example
Matrix input:
[Q,R] = qr([1,2,3;4,5,6;7,8,10;11,12,15],0)
Q = [Matrix] 4 x 3
-0.073127 -0.8104 0.56383
-0.29251 -0.46944 -0.78362
-0.51189 -0.12848 -0.038225
-0.8044 0.32614 0.25802
R = [Matrix] 3 x 3
-13.675 -15.357 -19.159
0 -1.0822 -1.6406
0 0 0.47782
Comments
[Q,R] = qr(A) computes matrices Q and R such that A = QR.
QR decomposition is often used for solving over-determined linear least squares equations Ax = b. For the economy decomposition of an MxN matrix A with m>n, Q is MxN and R is NxN.
qr uses the LAPACK routines 'dgeqrf' for real matrices and 'zgeqrf' for complex matrices.