nag_complex_qr (f01rcc) (PDF version)
f01 Chapter Contents
f01 Chapter Introduction
NAG C Library Manual

NAG Library Function Document

nag_complex_qr (f01rcc)

+ Contents

    1  Purpose
    7  Accuracy

1  Purpose

nag_complex_qr (f01rcc) finds the QR  factorization of the complex m  by n  matrix A , where mn .

2  Specification

#include <nag.h>
#include <nagf01.h>
void  nag_complex_qr (Integer m, Integer n, Complex a[], Integer tda, Complex theta[], NagError *fail)

3  Description

The m  by n  matrix A  is factorized as
A = Q R 0 when ​ m > n A = QR when ​ m = n
where Q  is an m  by m  unitary matrix and R  is an n  by n  upper triangular matrix with real diagonal elements.
The factorization is obtained by Householder's method. The k th transformation matrix, Q k , which is used to introduce zeros into the k th column of A  is given in the form
Q k = I 0 0 T k ,
T k = I - u k ukT ,
u k = ζ k z k ,
γ k  is a scalar for which Reγ k = 1.0 , ζ k  is a real scalar and z k  is an m-k  element vector. γ k , ζ k  and z k  are chosen to annihilate the elements below the triangular part of A  and to make the diagonal elements real.
The scalar γ k  and the vector u k  are returned in the k-1 th element of the array theta and in the k-1 th column of a, such that θ k , given by
θ k = ζ k ,Im γ k ,
is in theta[k-1]  and the elements of z k  are in a[k×tda+k+1] , , a[m-1×tda+k-1] . The elements of R  are returned in the upper triangular part of A .
Q  is given by
Q = Q n Q n-1 Q 1 H .
A good background description to the QR  factorization is given in Dongarra et al. (1979).

4  References

Dongarra J J, Moler C B, Bunch J R and Stewart G W (1979) LINPACK Users' Guide SIAM, Philadelphia
Wilkinson J H (1965) The Algebraic Eigenvalue Problem Oxford University Press, Oxford

5  Arguments

1:     mIntegerInput
On entry: m , the number of rows of A .
Constraint: mn .
2:     nIntegerInput
On entry: n , the number of columns of A .
  • n0;
  • when n=0  then an immediate return is effected.
3:     a[m×tda]ComplexInput/Output
On entry: the leading m  by n  part of the array a must contain the matrix to be factorized.
On exit: the n  by n  upper triangular part of a will contain the upper triangular matrix R , with the imaginary parts of the diagonal elements set to zero, and the m  by n  strictly lower triangular part of a will contain details of the factorization as described above.
4:     tdaIntegerInput
On entry: the stride separating matrix column elements in the array a.
Constraint: tdan .
5:     theta[n]ComplexOutput
On exit: the scalar θ k  for the k th transformation. If T k = I  then theta[k-1] = 0.0 ; if
T k = α 0 0 I Reα < 0.0
then theta[k-1] = α ; otherwise theta[k-1]  contains theta[k-1]  as described in Section 3 and Re theta[k-1]  is always in the range 1.0, 2.0 .
6:     failNagError *Input/Output
The NAG error argument (see Section 3.6 in the Essential Introduction).

6  Error Indicators and Warnings

On entry, m=value  while n=value . These arguments must satisfy mn .
On entry, tda=value  while n=value . These arguments must satisfy tdan .
On entry, n=value.
Constraint: n0.

7  Accuracy

The computed factors Q  and R  satisfy the relation
Q R 0 = A + E
where E c ε A , ε  being the machine precision, c  is a modest function of m  and n  and .  denotes the spectral (two) norm.

8  Further Comments

The approximate number of real floating point operations is given by 8 n 2 3 m - n / 3 .
Following the use of this function the operations
B := QB   and   B := Q H B
where B  is an m  by k  matrix, can be performed by calls to nag_complex_apply_q (f01rdc).
The operation B : = QB  can be obtained by the call:
and B : = Q H B  can be obtained by the call:
If B  is a one-dimensional array (single column) then the argument tdb  can be replaced by 1 . See nag_complex_apply_q (f01rdc) for further details.
The first k  columns of the unitary matrix Q  can either be obtained by setting B  to the first k  columns of the unit matrix and using the first of the above two calls, or by calling nag_complex_form_q (f01rec), which overwrites the k  columns of Q  on the first k  columns of the array a. Q  is obtained by the call:
If k  is larger than n , then A  must have been declared to have at least k  columns.

9  Example

To obtain the QR  factorization of the 5 by 3 matrix
A = 0.5 i -0.5 + 1.5 i -1.0 + 1.0 i 0.4 + 0.3 i - 0.9 + 1.3 i - 0.2 + 1.4 i 0.4 +0.3 i -0.4 + 0.4 i - 1.8 +1.4 i 0.3 - 0.4 i 0.1 + 0.7 i - 0.0 +0.3 i -0.3 i 0.3 + 0.3 i 2.4 i

9.1  Program Text

Program Text (f01rcce.c)

9.2  Program Data

Program Data (f01rcce.d)

9.3  Program Results

Program Results (f01rcce.r)

nag_complex_qr (f01rcc) (PDF version)
f01 Chapter Contents
f01 Chapter Introduction
NAG C Library Manual

© The Numerical Algorithms Group Ltd, Oxford, UK. 2012