G05PXF (PDF version)
G05 Chapter Contents
G05 Chapter Introduction
NAG Library Manual

NAG Library Routine Document


Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

+ Contents

    1  Purpose
    7  Accuracy

1  Purpose

G05PXF generates a random orthogonal matrix.

2  Specification

REAL (KIND=nag_wp)  A(LDA,N)

3  Description

G05PXF pre- or post-multiplies an m by n matrix A by a random orthogonal matrix U, overwriting A. The matrix A may optionally be initialized to the identity matrix before multiplying by U, hence U is returned. U is generated using the method of Stewart (1980). The algorithm can be summarised as follows.
Let x1,x2,,xn-1 follow independent multinormal distributions with zero mean and variance Iσ2 and dimensions n,n-1,,2; let Hj=diagIj-1, Hj*, where Ij-1 is the identity matrix and Hj* is the Householder transformation that reduces xj to rjje1, e1 being the vector with first element one and the remaining elements zero and rjj being a scalar, and let D=diagsignr11,signr22,,signrnn. Then the product U=DH1H2Hn-1 is a random orthogonal matrix distributed according to the Haar measure over the set of orthogonal matrices of n. See Theorem 3.3 in Stewart (1980).
One of the initialization routines G05KFF (for a repeatable sequence if computed sequentially) or G05KGF (for a non-repeatable sequence) must be called prior to the first call to G05PXF.

4  References

Stewart G W (1980) The efficient generation of random orthogonal matrices with an application to condition estimates SIAM J. Numer. Anal. 17 403–409

5  Parameters

1:     SIDE – CHARACTER(1)Input
On entry: indicates whether the matrix A is multiplied on the left or right by the random orthogonal matrix U.
The matrix A is multiplied on the left, i.e., premultiplied.
The matrix A is multiplied on the right, i.e., post-multiplied.
Constraint: SIDE='L' or 'R'.
2:     INIT – CHARACTER(1)Input
On entry: indicates whether or not A should be initialized to the identity matrix.
A is initialized to the identity matrix.
A is not initialized and the matrix A must be supplied in A.
Constraint: INIT='I' or 'N'.
3:     M – INTEGERInput
On entry: m, the number of rows of the matrix A.
  • if SIDE='L', M>1;
  • otherwise M1.
4:     N – INTEGERInput
On entry: n, the number of columns of the matrix A.
  • if SIDE='R', N>1;
  • otherwise N1.
5:     STATE(*) – INTEGER arrayCommunication Array
Note: the actual argument supplied must be the array STATE supplied to the initialization routines G05KFF or G05KGF.
On entry: contains information on the selected base generator and its current state.
On exit: contains updated information on the state of the generator.
6:     A(LDA,N) – REAL (KIND=nag_wp) arrayInput/Output
On entry: if INIT='N', A must contain the matrix A.
On exit: the matrix UA when SIDE='L' or the matrix A U when SIDE='R'.
7:     LDA – INTEGERInput
On entry: the first dimension of the array A as declared in the (sub)program from which G05PXF is called.
Constraint: LDAM.
8:     IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to 0, -1​ or ​1. If you are unfamiliar with this parameter you should refer to Section 3.3 in the Essential Introduction 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 parameter, 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).

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,SIDE'L' or 'R'.
On entry,INIT'I' or 'N'.
On entry,M<1.
On entry,N<1.
On entry,STATE vector was not initialized or has been corrupted.
On entry,LDA<M.
On entry, an orthogonal matrix of dimension 1 has been requested.

7  Accuracy

The maximum error in UT U should be a modest multiple of machine precision (see Chapter X02).

8  Further Comments


9  Example

Following initialization of the pseudorandom number generator by a call to G05KFF, a 4 by 4 orthogonal matrix is generated using the INIT='I' option and the result printed.

9.1  Program Text

Program Text (g05pxfe.f90)

9.2  Program Data

Program Data (g05pxfe.d)

9.3  Program Results

Program Results (g05pxfe.r)

G05PXF (PDF version)
G05 Chapter Contents
G05 Chapter Introduction
NAG Library Manual

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