g05nc performs a pseudorandom permutation of a vector of integers.

Syntax

C#
public static void g05nc(
	int[] indx,
	int n,
	G05..::..G05State g05state,
	out int ifail
)
Visual Basic
Public Shared Sub g05nc ( _
	indx As Integer(), _
	n As Integer, _
	g05state As G05..::..G05State, _
	<OutAttribute> ByRef ifail As Integer _
)
Visual C++
public:
static void g05nc(
	array<int>^ indx, 
	int n, 
	G05..::..G05State^ g05state, 
	[OutAttribute] int% ifail
)
F#
static member g05nc : 
        indx : int[] * 
        n : int * 
        g05state : G05..::..G05State * 
        ifail : int byref -> unit 

Parameters

indx
Type: array<System..::..Int32>[]()[][]
An array of size [n]
On entry: the n integer values to be permuted.
On exit: the n permuted integer values.
n
Type: System..::..Int32
On entry: the number of values to be permuted.
Constraint: n1.
g05state
Type: NagLibrary..::..G05..::..G05State
An Object of type G05.G05State.
ifail
Type: System..::..Int32%
On exit: ifail=0 unless the method detects an error or a warning has been flagged (see [Error Indicators and Warnings]).

Description

g05nc permutes the elements of an integer array without inspecting their values. Each of the n! possible permutations of the n values may be regarded as being equally probable.
Even for modest values of n it is theoretically impossible that all n! permutations may occur, as n! is likely to exceed the cycle length of any of the base generators. For practical purposes this is irrelevant, as the time necessary to generate all possible permutations is many millenia.
One of the initialization methods (G05KFF not in this release) (for a repeatable sequence if computed sequentially) or (G05KGF not in this release) (for a non-repeatable sequence) must be called prior to the first call to g05nc.

References

Kendall M G and Stuart A (1969) The Advanced Theory of Statistics (Volume 1) (3rd Edition) Griffin
Knuth D E (1981) The Art of Computer Programming (Volume 2) (2nd Edition) Addison–Wesley

Error Indicators and Warnings

Errors or warnings detected by the method:
ifail=2
On entry, n<1.
ifail=3
On entry,state vector was not initialized or has been corrupted.
ifail=-9000
An error occured, see message report.
ifail=-8000
Negative dimension for array value
ifail=-6000
Invalid Parameters value

Accuracy

Not applicable.

Parallelism and Performance

None.

Further Comments

None.

Example

See Also