hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_rand_matrix_orthog (g05px)

Purpose

nag_rand_matrix_orthog (g05px) generates a random orthogonal matrix.

Syntax

[state, a, ifail] = g05px(side, init, state, a, 'm', m, 'n', n)
[state, a, ifail] = nag_rand_matrix_orthog(side, init, state, a, 'm', m, 'n', n)

Description

nag_rand_matrix_orthog (g05px) pre- or post-multiplies an mm by nn matrix AA by a random orthogonal matrix UU, overwriting AA. The matrix AA may optionally be initialized to the identity matrix before multiplying by UU, hence UU is returned. UU is generated using the method of Stewart (1980). The algorithm can be summarised as follows.
Let x1,x2,,xn1x1,x2,,xn-1 follow independent multinormal distributions with zero mean and variance Iσ2Iσ2 and dimensions n,n1,,2n,n-1,,2; let Hj = diag(Ij1,Hj * )Hj=diag(Ij-1, Hj*), where Ij1Ij-1 is the identity matrix and Hj * Hj* is the Householder transformation that reduces xjxj to rjje1rjje1, e1e1 being the vector with first element one and the remaining elements zero and rjjrjj being a scalar, and let D = diag(sign(r11),sign(r22),,sign(rnn))D=diag(sign(r11),sign(r22),,sign(rnn)). Then the product U = DH1H2Hn1U=DH1H2Hn-1 is a random orthogonal matrix distributed according to the Haar measure over the set of orthogonal matrices of nn. 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).

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

Parameters

Compulsory Input Parameters

1:     side – string (length ≥ 1)
Indicates whether the matrix AA is multiplied on the left or right by the random orthogonal matrix UU.
side = 'L'side='L'
The matrix AA is multiplied on the left, i.e., premultiplied.
side = 'R'side='R'
The matrix AA is multiplied on the right, i.e., post-multiplied.
Constraint: side = 'L'side='L' or 'R''R'.
2:     init – string (length ≥ 1)
Indicates whether or not a should be initialized to the identity matrix.
init = 'I'init='I'
a is initialized to the identity matrix.
init = 'N'init='N'
a is not initialized and the matrix AA must be supplied in a.
Constraint: init = 'I'init='I' or 'N''N'.
3:     state( : :) – int64int32nag_int array
Note: the actual argument supplied must be the array state supplied to the initialization routines nag_rand_init_repeat (g05kf) or nag_rand_init_nonrepeat (g05kg).
Contains information on the selected base generator and its current state.
4:     a(lda,n) – double array
lda, the first dimension of the array, must satisfy the constraint ldamldam.
If init = 'N'init='N', a must contain the matrix AA.

Optional Input Parameters

1:     m – int64int32nag_int scalar
Default: The first dimension of the array a.
mm, the number of rows of the matrix AA.
Constraints:
  • if side = 'L'side='L', m > 1m>1;
  • otherwise m1m1.
2:     n – int64int32nag_int scalar
Default: The second dimension of the array a.
nn, the number of columns of the matrix AA.
Constraints:
  • if side = 'R'side='R', n > 1n>1;
  • otherwise n1n1.

Input Parameters Omitted from the MATLAB Interface

lda

Output Parameters

1:     state( : :) – int64int32nag_int array
Note: the actual argument supplied must be the array state supplied to the initialization routines nag_rand_init_repeat (g05kf) or nag_rand_init_nonrepeat (g05kg).
Contains updated information on the state of the generator.
2:     a(lda,n) – double array
ldamldam.
The matrix UAUA when side = 'L'side='L' or the matrix A UA U when side = 'R'side='R'.
3:     ifail – int64int32nag_int scalar
ifail = 0ifail=0 unless the function detects an error (see [Error Indicators and Warnings]).

Error Indicators and Warnings

Errors or warnings detected by the function:
  ifail = 1ifail=1
On entry,side'L'side'L' or 'R''R'.
  ifail = 2ifail=2
On entry,init'I'init'I' or 'N''N'.
  ifail = 3ifail=3
On entry,m < 1m<1.
  ifail = 4ifail=4
On entry,n < 1n<1.
  ifail = 5ifail=5
On entry,state vector was not initialized or has been corrupted.
  ifail = 7ifail=7
On entry,lda < mlda<m.
  ifail = 8ifail=8
On entry, an orthogonal matrix of dimension 11 has been requested.

Accuracy

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

Further Comments

None.

Example

function nag_rand_matrix_orthog_example
% Initialize the seed
seed = [int64(1762543)];
% genid and subid identify the base generator
genid = int64(1);
subid =  int64(1);

side = 'Right';
init = 'Initialize';
a = zeros(4, 4);
% Initialize the generator to a repeatable sequence
[state, ifail] = nag_rand_init_repeat(genid, subid, seed);

[state, a, ifail] = nag_rand_matrix_orthog(side, init, state, a)
 

state =

                   17
                 1234
                    1
                    0
                17510
                 6613
                28263
                24312
                17917
                13895
                19930
                    8
                    0
                 1234
                    1
                    1
                 1234


a =

    0.1756    0.7401   -0.3067   -0.5722
    0.6593   -0.5781   -0.2191   -0.4279
    0.6680    0.3172    0.6077    0.2895
   -0.2971   -0.1323    0.6990   -0.6369


ifail =

                    0


function g05px_example
% Initialize the seed
seed = [int64(1762543)];
% genid and subid identify the base generator
genid = int64(1);
subid =  int64(1);

side = 'Right';
init = 'Initialize';
a = zeros(4, 4);
% Initialize the generator to a repeatable sequence
[state, ifail] = g05kf(genid, subid, seed);

[state, a, ifail] = g05px(side, init, state, a)
 

state =

                   17
                 1234
                    1
                    0
                17510
                 6613
                28263
                24312
                17917
                13895
                19930
                    8
                    0
                 1234
                    1
                    1
                 1234


a =

    0.1756    0.7401   -0.3067   -0.5722
    0.6593   -0.5781   -0.2191   -0.4279
    0.6680    0.3172    0.6077    0.2895
   -0.2971   -0.1323    0.6990   -0.6369


ifail =

                    0



PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2013