When I use the QR factorization I do not get a upper triangular matrix.
9 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
According to the documentation if A is an mxn matrix the function R=qr(A) should return a mxn upper triangular matrix. If I use the following example:
A=[1 0 0 0 ; 0 1 0 1; 0 1 1 0];
R=qr(A)
I get the following output, which is not an upper triangular matrix
R=
1.0000 0 0 0
0 -1.4142 -0.7071 -0.7071
0 0.4142 0.7071 -0.7071
Likewise if I try to compute the "economy size" QR-decomposition via R=qr(A, 0) I also get a matrix that is not upper triangular:
ans =
1.0000 0 0 0
0 -1.4142 -0.7071 -0.7071
0 0.4142 0.7071 -0.7071
If on the other hand I use the code:
A=[1 0 0 0 ; 0 1 0 1; 0 1 1 0];
[Q,R,P]=qr(A);
R = 1.0000 0 0 0
0 -1.4142 -0.7071 -0.7071
0 0 0.7071 -0.7071
I get that R is an upper triangular matrix. Am I misunderstanding the documentation for qr? Ideally I would like to use qr(A,0) to compute the economy QR decomposition of a matrix, but have the output be upper triangular.
0 comentarios
Respuestas (1)
Steven Lord
el 11 de Dic. de 2015
Yes, you are misunderstanding the documentation. On the documentation page, the section of the description that describes the syntax "R = qr(A)" appears right after the statement "If A is sparse:"
Your matrix A is full not sparse, and so what you're actually computing is "X = qr(A) and X = qr(A,0) return a matrix X such that triu(X) is the upper triangular factor R." from the section "If A is full:"
0 comentarios
Ver también
Categorías
Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!