NAG Library Routine Document
g05pxf
(matrix_orthog)
1
Purpose
g05pxf generates a random orthogonal matrix.
2
Specification
Fortran Interface
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 |
|
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
Arguments
- 1: – 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: – 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: – IntegerInput
-
On entry: , the number of rows of the matrix .
Constraints:
- if , ;
- otherwise .
- 4: – IntegerInput
-
On entry: , the number of columns of the matrix .
Constraints:
- if , ;
- otherwise .
- 5: – 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: – Real (Kind=nag_wp) arrayInput/Output
-
On entry: if
,
a must contain the matrix
.
On exit: the matrix when or the matrix when .
- 7: – IntegerInput
-
On entry: the first dimension of the array
a as declared in the (sub)program from which
g05pxf is called.
Constraint:
.
- 8: – IntegerInput/Output
-
On entry:
ifail must be set to
,
. 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
is recommended. If the output of error messages is undesirable, then the value
is recommended. Otherwise, if you are not familiar with this argument, 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,
side is not valid:
.
-
On entry,
init is not valid:
.
-
On entry, , .
Constraint: if , ; otherwise .
-
On entry, , .
Constraint: if , ; otherwise .
-
On entry,
state vector has been corrupted or not initialized.
-
On entry, and .
Constraint: .
-
On entry, , .
Constraint: if , ; otherwise .
On entry, , .
Constraint: if , ; otherwise .
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.
7
Accuracy
The maximum error in
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.
None.
10
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.
10.1
Program Text
Program Text (g05pxfe.f90)
10.2
Program Data
Program Data (g05pxfe.d)
10.3
Program Results
Program Results (g05pxfe.r)