Previous Page Next Page Contents

linalg::factorQR -- QR-decomposition of a matrix

Introduction

linalg::factorQR(A) computes an QR-decomposition of an m x n matrix A, i.e., a decomposition of A into an n x n unitary matrix Q and an n x m upper triangular matrix R such that Q*R = A.

Call(s)

linalg::factorQR(A)

Parameters

A - a matrix of a domain of category Cat::Matrix

Returns

a list [Q, R] of the two matrices Q and R (of the same domain type as A), or the value FAIL.

Related Functions

linalg::factorLU, linalg::factorCholesky, lllint, numeric::factorQR

Details

Example 1

We compute the QR-decomposition of a real matrix:

>> A := Dom::Matrix(Dom::Real)(
     [[2, -3, -1], [1, 1, -1], [0, 1, -1]]
   )
                              +-           -+
                              |  2, -3, -1  |
                              |             |
                              |  1,  1, -1  |
                              |             |
                              |  0,  1, -1  |
                              +-           -+
>> QR := linalg::factorQR(A)
      -- +-                              -+
      |  |     1/2     1/2     1/2   1/2  |
      |  |  2 5       6       8    15     |
      |  |  ------, - ----, - ----------  |
      |  |    5        6          60      |
      |  |                                |
      |  |    1/2     1/2     1/2   1/2   |
      |  |   5       6       8    15      |
      |  |   ----,   ----,   ----------   |,
      |  |    5       3          30       |
      |  |                                |
      |  |            1/2      1/2   1/2  |
      |  |           6        8    15     |
      |  |     0,    ----,  - ----------  |
      |  |            6           12      |
      -- +-                              -+
      
         +-                          -+ --
         |                      1/2   |  |
         |   1/2     1/2     3 5      |  |
         |  5   , - 5   ,  - ------   |  |
         |                     5      |  |
         |                            |  |
         |                     1/2    |  |
         |          1/2       6       |  |
         |    0,   6   ,    - ----    |  |
         |                     3      |  |
         |                            |  |
         |                 1/2   1/2  |  |
         |                8    15     |  |
         |    0,     0,   ----------  |  |
         |                    15      |  |
         +-                          -+ --

The orthogonal matrix Q is the first element und the upper triangular matrix R is the second element of the list QR. The product of these two matrices is equal to the input matrix A:

>> QR[1] * QR[2]
                              +-           -+
                              |  2, -3, -1  |
                              |             |
                              |  1,  1, -1  |
                              |             |
                              |  0,  1, -1  |
                              +-           -+

Example 2

The QR-decomposition of the 3 x 2 matrix:

>> B := Dom::Matrix(Dom::Real)( 
     [[2, -3], [1, 2], [2, 3]]
   )
                                +-       -+
                                |  2, -3  |
                                |         |
                                |  1,  2  |
                                |         |
                                |  2,  3  |
                                +-       -+

yields a 3 x 3 orthogonal matrix and a 3 x 2 upper triangular matrix:

>> QR := linalg::factorQR(B)
         -- +-                              -+                  --
         |  |               1/2       1/2    |                   |
         |  |         31 194       194       |                   |
         |  |  2/3, - ---------,   ------    |  +-           -+  |
         |  |            582        194      |  |  3,   2/3   |  |
         |  |                                |  |             |  |
         |  |              1/2         1/2   |  |        1/2  |  |
         |  |         8 194       6 194      |  |     194     |  |
         |  |  1/3,   --------,   --------   |, |  0, ------  |  |
         |  |           291          97      |  |       3     |  |
         |  |                                |  |             |  |
         |  |              1/2          1/2  |  |  0,    0    |  |
         |  |        23 194        7 194     |  +-           -+  |
         |  |  2/3,  ---------,  - --------  |                   |
         |  |           582          194     |                   |
         -- +-                              -+                  --
>> QR[1] * QR[2]
                                +-       -+
                                |  2, -3  |
                                |         |
                                |  1,  2  |
                                |         |
                                |  2,  3  |
                                +-       -+

For this example we may call numeric::factorQR(B, Symbolic) instead, which in general is faster than linalg::factorQR:

>> QR := numeric::factorQR(B, Symbolic)
         -- +-                              -+                  --
         |  |               1/2       1/2    |                   |
         |  |         31 194       194       |                   |
         |  |  2/3, - ---------,   ------    |  +-           -+  |
         |  |            582        194      |  |  3,   2/3   |  |
         |  |                                |  |             |  |
         |  |              1/2         1/2   |  |        1/2  |  |
         |  |         8 194       6 194      |  |     194     |  |
         |  |  1/3,   --------,   --------   |, |  0, ------  |  |
         |  |           291          97      |  |       3     |  |
         |  |                                |  |             |  |
         |  |              1/2          1/2  |  |  0,    0    |  |
         |  |        23 194        7 194     |  +-           -+  |
         |  |  2/3,  ---------,  - --------  |                   |
         |  |           582          194     |                   |
         -- +-                              -+                  --

Background

Changes




Do you have questions or comments?


Copyright © SciFace Software GmbH & Co. KG 2000