NAG Library Routine Document

g05pxf  (matrix_orthog)

 Contents

    1  Purpose
    7  Accuracy

1
Purpose

g05pxf generates a random orthogonal matrix.

2
Specification

Fortran Interface
Subroutine g05pxf ( side, init, m, n, state, a, lda, ifail)
Integer, Intent (In):: m, n, lda
Integer, Intent (Inout):: state(*), ifail
Real (Kind=nag_wp), Intent (Inout):: a(lda,n)
Character (1), Intent (In):: side, init
C Header Interface
#include nagmk26.h
void  g05pxf_ ( const char *side, const char *init, const Integer *m, const Integer *n, Integer state[], double a[], const Integer *lda, Integer *ifail, const Charlen length_side, const Charlen length_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
Arguments

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

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.9 in How to Use the NAG Library and its Documentation for further information.
ifail=-399
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.
ifail=-999
Dynamic memory allocation failed.
See Section 3.7 in How to Use the NAG Library and its Documentation 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)

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