NAG Library Routine Document

f01qjf (real_gen_rq)


    1  Purpose
    7  Accuracy


f01qjf finds the RQ factorization of the real m by n (mn) matrix A, so that A is reduced to upper triangular form by means of orthogonal transformations from the right.


Fortran Interface
Subroutine f01qjf ( m, n, a, lda, zeta, ifail)
Integer, Intent (In):: m, n, lda
Integer, Intent (Inout):: ifail
Real (Kind=nag_wp), Intent (Inout):: a(lda,*)
Real (Kind=nag_wp), Intent (Out):: zeta(m)
C Header Interface
#include nagmk26.h
void  f01qjf_ (const Integer *m, const Integer *n, double a[], const Integer *lda, double zeta[], Integer *ifail)


The m by n matrix A is factorized as
A= R 0 PT when  m<n, A=RPT when  m=n,  
where P is an n by n orthogonal matrix and R is an m by m upper triangular matrix.
P is given as a sequence of Householder transformation matrices
the (m-k+1)th transformation matrix, Pk, being used to introduce zeros into the kth row of A. Pk has the form
uk= wk ζk 0 zk ,  
ζk is a scalar, wk is an k-1 element vector and zk is an n-m element vector. uk is chosen to annihilate the elements in the kth row of A.
The vector uk is returned in the kth element of zeta and in the kth row of a, such that ζk is in zetak, the elements of wk are in ak1,,akk-1 and the elements of zk are in akm+1,,akn. The elements of R are returned in the upper triangular part of a.


Golub G H and Van Loan C F (1996) Matrix Computations (3rd Edition) Johns Hopkins University Press, Baltimore
Wilkinson J H (1965) The Algebraic Eigenvalue Problem Oxford University Press, Oxford


1:     m – IntegerInput
On entry: m, the number of rows of the matrix A.
When m=0 then an immediate return is effected.
Constraint: m0.
2:     n – IntegerInput
On entry: n, the number of columns of the matrix A.
Constraint: nm.
3:     alda* – Real (Kind=nag_wp) arrayInput/Output
Note: the second dimension of the array a must be at least max1,n.
On entry: the leading m by n part of the array a must contain the matrix to be factorized.
On exit: the m by m upper triangular part of a will contain the upper triangular matrix R, and the m by m strictly lower triangular part of a and the m by n-m rectangular part of a to the right of the upper triangular part will contain details of the factorization as described in Section 3.
4:     lda – IntegerInput
On entry: the first dimension of the array a as declared in the (sub)program from which f01qjf is called.
Constraint: ldamax1,m.
5:     zetam – Real (Kind=nag_wp) arrayOutput
On exit: zetak contains the scalar ζk for the m-k+1th transformation. If Pk=I then zetak=0.0, otherwise zetak contains ζk as described in Section 3 and ζk is always in the range 1.0,2.0.
6:     ifail – IntegerInput/Output
On entry: ifail must be set to 0, -1​ or ​1. If you are unfamiliar with this argument you should refer to Section 3.4 in How to Use the NAG Library and its Documentation for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value -1​ or ​1 is recommended. If the output of error messages is undesirable, then the value 1 is recommended. Otherwise, if you are not familiar with this argument, the recommended value is 0. When the value -1​ or ​1 is used it is essential to test the value of ifail on exit.
On exit: ifail=0 unless the routine detects an error or a warning has been flagged (see Section 6).

Error Indicators and Warnings

If on entry ifail=0 or -1, explanatory error messages are output on the current error message unit (as defined by x04aaf).
Errors or warnings detected by the routine:
On entry,m<0,
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 3.9 in How to Use the NAG Library and its Documentation for further information.
Your licence key may have expired or may not have been installed correctly.
See Section 3.8 in How to Use the NAG Library and its Documentation for further information.
Dynamic memory allocation failed.
See Section 3.7 in How to Use the NAG Library and its Documentation for further information.


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

Parallelism and Performance

f01qjf makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this routine. Please also consult the Users' Note for your implementation for any additional implementation-specific information.

Further Comments

The approximate number of floating-point operations is given by 2×m23n-m/3.
The first k rows of the orthogonal matrix PT can be obtained by calling f01qkf, which overwrites the k rows of PT on the first k rows of the array a. PT is obtained by the call:
ifail = 0
Call f01qkf('Separate',m,n,k,a,lda,zeta,work,ifail)
WORK must be a maxm-1,k-m,1 element array. If K is larger than M, then a must have been declared to have at least K rows.
Operations involving the matrix R can readily be performed by the Level 2 BLAS routines f06pff (dtrmv) and f06pjf (dtrsv) (see Chapter F06), but note that no test for near singularity of R is incorporated into f06pjf (dtrsv). If R is singular, or nearly singular then f02wuf can be used to determine the singular value decomposition of R.


This example obtains the RQ factorization of the 3 by 5 matrix
A= 2.0 2.0 1.6 2.0 1.2 2.5 2.5 -0.4 -0.5 -0.3 2.5 2.5 2.8 0.5 -2.9 .  

Program Text

Program Text (f01qjfe.f90)

Program Data

Program Data (f01qjfe.d)

Program Results

Program Results (f01qjfe.r)

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