numeric::factorQR --
QR factorization of a matrix
Introductionnumeric::factorQR(A, ..) returns a
QR factorization A=QR of the matrix
A.
Call(s)numeric::factorQR(A <, Symbolic>)
ParametersA |
- | an m x n matrix of domain type DOM_ARRAY or of category Cat::Matrix |
OptionsSymbolic |
- | prevents numeric::factorQR from using
floating point arithmetic |
ReturnsThe list [Q,R] with Q and R
of domain type DOM_ARRAY is
returned. The components of Q and R are real
or complex floats, unless the option Symbolic is
used.
Side
EffectsThe function is sensitive to the environment variable DIGITS, which determines the
numerical working precision.
Related
Functionslinalg::factorQR,
numeric::factorCholesky,
numeric::factorLU
DetailsPI,
sqrt(2), exp(-1) etc. are accepted. They will
be converted to floats, unless the option Symbolic is used.
Option: Symbolic
Example
1We consider the matrix
>> A := array(1..2, 1..2, [[1, 0] , [1, PI]]):
First we compute a numerical factorization:
>> [Q1, R1] := numeric::factorQR(A)
-- +- -+
| | 0.7071067812, -0.7071067812 |
| | |,
| | 0.7071067812, 0.7071067812 |
-- +- -+
+- -+ --
| 1.414213562, 2.221441469 | |
| | |
| 0, 2.221441469 | |
+- -+ --
Next the symbolic factorization is computed:
>> [Q2, R2] := numeric::factorQR(A, Symbolic)
-- +- -+ +- -+ --
| | 1/2 1/2 | | 1/2 | |
| | 2 2 | | 1/2 PI 2 | |
| | ----, - ---- | | 2 , ------- | |
| | 2 2 | | 2 | |
| | |, | | |
| | 1/2 1/2 | | 1/2 | |
| | 2 2 | | PI 2 | |
| | ----, ---- | | 0, ------- | |
| | 2 2 | | 2 | |
-- +- -+ +- -+ --
For further processing the factors (of domain type
DOM_ARRAY) are converted to
elements of the matrix domain Dom::Matrix():
>> M := Dom::Matrix():
>> Q1 := M(Q1): R1 := M(R1): Q2 := M(Q2): R2 := M(R2):
Now the overloaded arithmetical operators
+, *, ^ etc. can be used for
further computations:
>> Q1*R1, Q2*R2
+- -+ +- -+
| 1.0, -4.33680869e-19 | | 1, 0 |
| |, | |
| 1.0, 3.141592654 | | 1, PI |
+- -+ +- -+
We finally verify the othogonality of the factors
Q1 and Q2:
>> Q1 * M::transpose(Q1), Q2 * M::transpose(Q2)
+- -+ +- -+
| 1.0, -5.421010863e-20 | | 1, 0 |
| |, | |
| -5.421010863e-20, 1.0 | | 0, 1 |
+- -+ +- -+
>> delete A, Q1, R1, Q2, R2, M:
Example
2We consider a non-square matrix of rank 1:
>> A := array(1..3, 1..2, [[0, 0], [I, 1], [I, 1]]):
>> numeric::factorQR(A, Symbolic)
-- +- -+ --
| | 0, 1, 0 | |
| | | +- -+ |
| | 1/2 | | 1/2 1/2 | |
| | 1/2 2 | | 2 , - I 2 | |
| | 1/2 I 2 , 0, ---- | | | |
| | 2 |, | 0, 0 | |
| | | | | |
| | 1/2 | | 0, 0 | |
| | 1/2 2 | +- -+ |
| | 1/2 I 2 , 0, - ---- | |
| | 2 | |
-- +- -+ --
Note that the numerical factorization yields different factors:
>> numeric::factorQR(A)
-- +- -+
| | 0, 0.7071067812 I, 0.7071067812 I |
| | |
| | 0.7071067812 I, 0.5, -0.5 |,
| | |
| | 0.7071067812 I, -0.5, 0.5 |
-- +- -+
+- -+ --
| 1.414213562, - 1.414213562 I | |
| | |
| 0, 0 | |
| | |
| 0, 0 | |
+- -+ --
>> delete A:
BackgroundDOM_ARRAY.