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

NAG Library Routine Document

G05PXF

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

SUBROUTINE G05PXF ( SIDE, INIT, M, N, STATE, A, LDA, IFAIL)
INTEGER  M, N, STATE(*), LDA, IFAIL
REAL (KIND=nag_wp)  A(LDA,N)
CHARACTER(1)  SIDE, INIT

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.
SIDE='L'
The matrix A is multiplied on the left, i.e., premultiplied.
SIDE='R'
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.
INIT='I'
A is initialized to the identity matrix.
INIT='N'
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.
Constraints:
  • if SIDE='L', M>1;
  • otherwise M1.
4:     N – INTEGERInput
On entry: n, the number of columns of the matrix A.
Constraints:
  • 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:     ALDAN – 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:
IFAIL=1
On entry, SIDE is not valid: SIDE=value.
IFAIL=2
On entry, INIT is not valid: INIT=value.
IFAIL=3
On entry, SIDE=value, M=value.
Constraint: if SIDE='L', M>1; otherwise M1.
IFAIL=4
On entry, SIDE=value, N=value.
Constraint: if SIDE='R', N>1; otherwise N1.
IFAIL=5
On entry, STATE vector has been corrupted or not initialized.
IFAIL=7
On entry, LDA=value and M=value.
Constraint: LDAM.
IFAIL=8
On entry, SIDE=value, M=value.
Constraint: if SIDE='L', M>1; otherwise M1.
On entry, SIDE=value, N=value.
Constraint: if SIDE='R', N>1; otherwise N1.
IFAIL=-99
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 3.8 in the Essential Introduction for further information.
IFAIL=-399
Your licence key may have expired or may not have been installed correctly.
See Section 3.7 in the Essential Introduction for further information.
IFAIL=-999
Dynamic memory allocation failed.
See Section 3.6 in the Essential Introduction for further information.

7  Accuracy

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

8  Parallelism and Performance

G05PXF is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
G05PXF 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.

9  Further Comments

None.

10  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.

10.1  Program Text

Program Text (g05pxfe.f90)

10.2  Program Data

Program Data (g05pxfe.d)

10.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. 2015