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.
1 Purpose
G05PXF generates a random orthogonal matrix.
2 Specification
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
by
matrix
by a random orthogonal matrix
, overwriting
. The matrix
may optionally be initialized to the identity matrix before multiplying by
, hence
is returned.
is generated using the method of
Stewart (1980). The algorithm can be summarised as follows.
Let
follow independent multinormal distributions with zero mean and variance
and dimensions
; let
, where
is the identity matrix and
is the Householder transformation that reduces
to
,
being the vector with first element one and the remaining elements zero and
being a scalar, and let
. Then the product
is a random orthogonal matrix distributed according to the Haar measure over the set of orthogonal matrices of
. 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
is multiplied on the left or right by the random orthogonal matrix
.
- The matrix is multiplied on the left, i.e., premultiplied.
- The matrix is multiplied on the right, i.e., post-multiplied.
Constraint:
or .
- 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 must be supplied in A.
Constraint:
or .
- 3: M – INTEGERInput
On entry: , the number of rows of the matrix .
Constraints:
- if , ;
- otherwise .
- 4: N – INTEGERInput
On entry: , the number of columns of the matrix .
Constraints:
- if , ;
- otherwise .
- 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
,
A must contain the matrix
.
On exit: the matrix when or the matrix when .
- 7: LDA – INTEGERInput
On entry: the first dimension of the array
A as declared in the (sub)program from which G05PXF is called.
Constraint:
.
- 8: IFAIL – INTEGERInput/Output
-
On entry:
IFAIL must be set to
,
. 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
is recommended. If the output of error messages is undesirable, then the value
is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is
.
When the value is used it is essential to test the value of IFAIL on exit.
On exit:
unless the routine detects an error or a warning has been flagged (see
Section 6).
6 Error Indicators and Warnings
If on entry
or
, explanatory error messages are output on the current error message unit (as defined by
X04AAF).
Errors or warnings detected by the routine:
On entry, or .
On entry, or .
On entry, .
On entry, .
On entry,
STATE vector was not initialized or has been corrupted.
On entry, .
On entry, an orthogonal matrix of dimension has been requested.
7 Accuracy
The maximum error in
should be a modest multiple of
machine precision (see
Chapter X02).
None.
9 Example
Following initialization of the pseudorandom number generator by a call to
G05KFF, a
by
orthogonal matrix is generated using the
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)