nag_rngs_orthog_matrix (g05qac) (PDF version)
g05 Chapter Contents
g05 Chapter Introduction
NAG C Library Manual

NAG Library Function Document

nag_rngs_orthog_matrix (g05qac)

+ Contents

    1  Purpose
    7  Accuracy

1  Purpose

nag_rngs_orthog_matrix (g05qac) generates a random orthogonal matrix.

2  Specification

#include <nag.h>
#include <nagg05.h>
void  nag_rngs_orthog_matrix (Nag_OrderType order, Nag_SideType side, Nag_InitializeA init, Integer m, Integer n, double a[], Integer pda, Integer igen, Integer iseed[], NagError *fail)

3  Description

nag_rngs_orthog_matrix (g05qac) 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 summarized 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 functions nag_rngs_init_repeatable (g05kbc) (for a repeatable sequence if computed sequentially) or nag_rngs_init_nonrepeatable (g05kcc) (for a non-repeatable sequence) must be called prior to the first call to nag_rngs_orthog_matrix (g05qac).

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:     orderNag_OrderTypeInput
On entry: the order argument specifies the two-dimensional storage scheme being used, i.e., row-major ordering or column-major ordering. C language defined storage is specified by order=Nag_RowMajor. See Section 3.2.1.3 in the Essential Introduction for a more detailed explanation of the use of this argument.
Constraint: order=Nag_RowMajor or Nag_ColMajor.
2:     sideNag_SideTypeInput
On entry: indicates whether the matrix A is multiplied on the left or right by the random orthogonal matrix U.
side=Nag_LeftSide
The matrix A is multiplied on the left, i.e., pre-multiplied.
side=Nag_RightSide
The matrix A is multiplied on the right, i.e., post-multiplied.
Constraint: side=Nag_LeftSide or Nag_RightSide.
3:     initNag_InitializeAInput
On entry: indicates whether or not a should be initialized to the identity matrix.
init=Nag_InitializeI
a is initialized to the identity matrix.
init=Nag_InputA
a is not initialized and the matrix A must be supplied in a.
Constraint: init=Nag_InitializeI or Nag_InputA.
4:     mIntegerInput
On entry: m, the number of rows of the matrix A.
Constraints:
  • if side=Nag_LeftSide, m>1;
  • otherwise m1.
5:     nIntegerInput
On entry: n, the number of columns of the matrix A.
Constraints:
  • if side=Nag_RightSide, n>1;
  • otherwise n1.
6:     a[dim]doubleInput/Output
Note: the dimension, dim, of the array a must be at least
  • max1,pda×n when order=Nag_ColMajor;
  • max1,m×pda when order=Nag_RowMajor.
The i,jth element of the matrix A is stored in
  • a[j-1×pda+i-1] when order=Nag_ColMajor;
  • a[i-1×pda+j-1] when order=Nag_RowMajor.
On entry: if init=Nag_InputA, a must contain the matrix A.
On exit: the matrix UA when side=Nag_LeftSide or the matrix A U when side=Nag_RightSide.
7:     pdaIntegerInput
On entry: the stride separating row or column elements (depending on the value of order) in the array a.
Constraints:
  • if order=Nag_ColMajor, pdam;
  • if order=Nag_RowMajor, pdan.
8:     igenIntegerInput
On entry: must contain the identification number for the generator to be used to return a pseudorandom number and should remain unchanged following initialization by a prior call to nag_rngs_init_repeatable (g05kbc) or nag_rngs_init_nonrepeatable (g05kcc).
9:     iseed[4]IntegerCommunication Array
On entry: contains values which define the current state of the selected generator.
On exit: contains updated values defining the new state of the selected generator.
10:   failNagError *Input/Output
The NAG error argument (see Section 3.6 in the Essential Introduction).

6  Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
NE_BAD_PARAM
On entry, argument value had an illegal value.
NE_ENUM_INT
On entry, side=value and m=value.
Constraint: if side=Nag_LeftSide, m>1;
otherwise m1.
On entry, side=value and n=value.
Constraint: if side=Nag_RightSide, n>1;
otherwise n1.
NE_INT
On entry, m=value.
Constraint: m1.
On entry, n=value.
Constraint: n1.
On entry, pda=value.
Constraint: pda>0.
NE_INT_2
On entry, pda=value and m=value.
Constraint: pdam.
On entry, pda=value and n=value.
Constraint: pdan.
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
NE_ORTHOGONAL_MATRIX
Orthogonal matrix of dimension 1 requested.

7  Accuracy

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

8  Further Comments

nag_rngs_corr_matrix (g05qbc) computes a random correlation matrix from a random orthogonal matrix.

9  Example

Following initialization of the pseudorandom number generator by a call to nag_rngs_init_repeatable (g05kbc), a 4 by 4 orthogonal matrix is generated using the init=Nag_InitializeI option and the result printed.

9.1  Program Text

Program Text (g05qace.c)

9.2  Program Data

None.

9.3  Program Results

Program Results (g05qace.r)


nag_rngs_orthog_matrix (g05qac) (PDF version)
g05 Chapter Contents
g05 Chapter Introduction
NAG C Library Manual

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