|
NAG[g05nac] NAG[nag_rngs_permute] - Pseudo-random permutation of an integer vector
|
|
Calling Sequence
g05nac(index_vector, igen, iseed, 'n'=n, 'fail'=fail)
nag_rngs_permute(. . .)
Parameters
|
index_vector - Vector(1..n, datatype=integer[kernelopts('wordsize')/8]);
|
|
|
On entry: the integer values to be permuted.
|
|
On exit: the permuted integer values.
|
|
|
iseed - Vector(1.. , datatype=integer[kernelopts('wordsize')/8]);
|
|
|
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.
|
|
|
'n'=n - integer; (optional)
|
|
|
On entry: the number of values to be permuted.
|
|
Constraint: . .
|
|
|
'fail'=fail - table; (optional)
|
|
|
The NAG error argument, see the documentation for NagError.
|
|
|
|
Description
|
|
|
Purpose
|
|
nag_rngs_permute (g05nac) performs a pseudo-random permutation of a vector of integers.
|
|
Description
|
|
nag_rngs_permute (g05nac) permutes the elements of an integer array without inspecting their values. Each of the possible permutations of the values may be regarded as being equally probable.
Even for modest values of (greater than 25 say), it is theoretically impossible that all permutations may occur, as exceeds the cycle length of g05kac (nag_rngs_basic) for any valid value of igen. For practical purposes this is irrelevant, as the time necessary to generate all possible permutations is many millenia.
One of the initialization functions g05kbc (nag_rngs_init_repeatable) (for a repeatable sequence if computed sequentially) or g05kcc (nag_rngs_init_nonrepeatable) (for a non-repeatable sequence) must be called prior to the first call to nag_rngs_permute (g05nac).
|
|
Error Indicators and Warnings
|
|
"NE_BAD_PARAM"
On entry, argument had an illegal value.
"NE_INT"
On entry, . Constraint: .
"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 consult NAG for assistance.
|
|
|
Examples
|
|
>
|
n := 8:
igen := 1:
index_vector := Vector([1, 2, 3, 4, 5, 6, 7, 8], datatype=integer[kernelopts('wordsize')/8]):
iseed := Vector([1762543, 9324783, 42344, 742355], datatype=integer[kernelopts('wordsize')/8]):
NAG:-g05nac(index_vector, igen, iseed, 'n' = n):
|
|
|
Download Help Document
Was this information helpful?