QR decomposition with modified Gram-Schmidt orthonormalization
[Q,R] = qdgqr(A)
QD matrix
QD matrices: Q is orthogonal, R is upper-Right, and Q*R==A
.
returns a (m,n) orthogonal matrix Q and a (n,n) upper Right triangular matrix R, such that A = Q*R.
Decomposing a square matrix:
A = qdrand(4,4); [Q, R] = qdgqr(A); R // upper-Right Q'*Q // Q orthogonal Q*R-A // {Q, R} such that A = Q*R | ![]() | ![]() |
--> A = qdrand(4,4); --> [Q, R] = qdgqr(A); --> R // upper-Right R = [d1] 1.4029373 1.1278077 0.5983773 1.0920244 0. 0.2197976 -0.0226192 0.4762974 0. 0. 0.3030321 0.8666805 0. 0. 0. 0.026052 [d2] 10^-17 * 4.4497528 0.4789732 3.4040136 -0.5176044 0. -1.3391656 -0.059136 -1.9788856 0. 0. 0.8363172 4.9765785 0. 0. 0. 0.0736546 [d3] 10^-34 * 18.975848 -0.589498 -5.0376968 1.3392224 0. -1.7725521 0.2809045 3.4130812 0. 0. -5.2942099 -30.61483 0. 0. 0. 0.4252575 [d4] 10^-51 * 112.06023 -3.6135207 5.1691145 -0.3923409 0. -8.3671828 2.3851052 10.45023 0. 0. 14.713691 -139.16724 0. 0. 0. -2.4250226 --> Q'*Q // Q orthogonal ans = [d1] 1. 0. 0. 0. 0. 1. 0. 0. 0. 0. 1. 0. 0. 0. 0. 1. [d2] 10^-17 * 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. [d3] zeros(4,4) [d4] zeros(4,4) --> Q*R-A // {Q, R} such that A = Q*R ans = [d1] 10^-65 * 5.2225623 9.2581786 3.7982271 -3.7982271 -4.5103947 0.9495568 0. 0. -1.8991135 -5.5489724 -0.2373892 -4.3917001 -0.3857574 0.5341257 -1.7210717 3.7982271 [d2] zeros(4,4) [d3] zeros(4,4) [d4] zeros(4,4)
With a rectangular matrix:
A = qdrand(3,4); [Q, R] = qdgqr(A); R // upper-Right Q'*Q // Q orthogonal Q*R-A // {Q, R} such that A = Q*R | ![]() | ![]() |
--> A = qdrand(3,4); --> [Q, R] = qdgqr(A); --> R // upper-Right R = [d1] 0.8468846 0.0480157 0.8400779 0.6050737 0. 0.8722477 0.6473926 0.2390266 0. 0. 0.7514185 0.163592 0. 0. 0. 0. [d2] 10^-17 * -4.3691617 -0.0955502 0.7306212 3.959902 0. -2.0875525 5.385732 1.3817957 0. 0. 4.967595 -0.2752122 0. 0. 0. 0. [d3] 10^-34 * 22.209151 -0.3864361 -4.8143222 -4.4520127 0. 10.240153 26.609205 3.0490374 0. 0. 29.742515 0.3813211 0. 0. 0. 0. [d4] 10^-51 * -35.347197 -0.6653356 -14.770851 -19.897968 0. -0.9747981 -154.11853 -2.916253 0. 0. -44.504195 1.6654111 0. 0. 0. 0. --> Q'*Q // Q orthogonal ans = [d1] 1. 0. 0. 0.5834909 0. 1. 0. 0.0253955 0. 0. 1. -0.8117225 0.5834909 0.0253955 -0.8117225 1. [d2] 10^-17 * 0. 0. 0. -4.1491468 0. 0. 0. -0.0820512 0. 0. 0. -1.68034 -4.1491468 -0.0820512 -1.68034 0. [d3] 10^-34 * 0. 0. 0. 0.6303418 0. 0. 0. -0.0776001 0. 0. 0. -4.6005905 0.6303418 -0.0776001 -4.6005905 0. [d4] 10^-51 * 0. 0. 0. -0.3767355 0. 0. 0. 0.1611753 0. 0. 0. 1.284789 -0.3767355 0.1611753 1.284789 0. --> Q*R-A // {Q, R} such that A = Q*R ans = [d1] 10^-65 * 0.0556381 3.7982271 2.3738919 0.5341257 -3.7982271 -0.0593473 0. 0.2967365 0.341247 -0.4747784 2.6112811 -0.2670628 [d2] zeros(3,4) [d3] zeros(3,4) [d4] zeros(3,4)