nag_rand_matrix_orthog (g05px) 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 functions
nag_rand_init_repeat (g05kf) (for a repeatable sequence if computed sequentially) or
nag_rand_init_nonrepeat (g05kg) (for a non-repeatable sequence) must be called prior to the first call to
nag_rand_matrix_orthog (g05px).
Stewart G W (1980) The efficient generation of random orthogonal matrices with an application to condition estimates SIAM J. Numer. Anal. 17 403–409
The maximum error in
should be a modest multiple of
machine precision (see
Chapter X02).
None.
Following initialization of the pseudorandom number generator by a call to
nag_rand_init_repeat (g05kf), a
by
orthogonal matrix is generated using the
option and the result printed.
function g05px_example
fprintf('g05px example results\n\n');
seed = [int64(1762543)];
genid = int64(1);
subid = int64(1);
[state, ifail] = g05kf( ...
genid, subid, seed);
side = 'Right';
init = 'Initialize';
a = zeros(4, 4);
[state, a, ifail] = g05px( ...
side, init, state, a);
disp('Random orthogonal matrix');
disp(a);