WOLFRAM SYSTEM MODELER
QRReturn the QR decomposition of a square matrix with optional column pivoting (A(:,p) = Q*R) |
SystemModel["Modelica.Math.Matrices.QR"]
This information is part of the Modelica Standard Library maintained by the Modelica Association.
(Q,R,p) = Matrices.QR(A);
This function returns the QR decomposition of a rectangular matrix A (the number of columns of A must be less than or equal to the number of rows):
Q*R = A[:,p]
where Q is a rectangular matrix that has orthonormal columns and has the same size as A (QTQ=I), R is a square, upper triangular matrix and p is a permutation vector. Matrix R has the following important properties:
This means that if abs(R[i,i]) ≤ ε then abs(R[j,k]) ≤ ε for j ≥ i, i.e., the i-th row up to the last row of R have small elements and can be treated as being zero. This allows to, e.g., estimate the row-rank of R (which is the same row-rank as A). Furthermore, R can be partitioned in two parts
A[:,p] = Q * [R1, R2; 0, 0]
where R1 is a regular, upper triangular matrix.
Note, the solution is computed with the LAPACK functions "dgeqp3"
and "dorgqr", i.e., by Householder transformations with
column pivoting. If Q is not needed, the function may be
called as: (,R,p) = QR(A)
.
Real A[3,3] = [1,2,3; 3,4,5; 2,1,4]; Real R[3,3]; algorithm (,R) := Matrices.QR(A); // R = [-7.07.., -4.24.., -3.67..; 0 , -1.73.., -0.23..; 0 , 0 , 0.65..];
A |
Type: Real[:,:] Description: Rectangular matrix with size(A,1) >= size(A,2) |
---|---|
pivoting |
Default Value: true Type: Boolean Description: = true, if column pivoting is performed. True is default |
Q |
Type: Real[size(A, 1),size(A, 2)] Description: Rectangular matrix with orthonormal columns such that Q*R=A[:,p] |
---|---|
R |
Type: Real[size(A, 2),size(A, 2)] Description: Square upper triangular matrix |
p |
Type: Integer[size(A, 2)] Description: Column permutation vector |