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_sort_permute_check (m01zb)

Purpose

nag_sort_permute_check (m01zb) checks the validity of a permutation.

Syntax

[iperm, ifail] = m01zb(iperm, m1, 'm2', m2)
[iperm, ifail] = nag_sort_permute_check(iperm, m1, 'm2', m2)

Description

nag_sort_permute_check (m01zb) can be used to check the validity of user-supplied ranks or indices, without the ranks or indices being corrupted.

References

None.

Parameters

Compulsory Input Parameters

1:     iperm(m2) – int64int32nag_int array
m2, the dimension of the array, must satisfy the constraint 0 < m1m20<m1m2.
Elements m1 to m2 of iperm must be set to values which are supposed to be a permutation of the integers m1 to m2. If they are a valid permutation, the function exits with ifail = 0ifail=0.
2:     m1 – int64int32nag_int scalar
The range of elements used in the array iperm and the range of values in the permutation, as specified under iperm.
Constraint: 0 < m1m20<m1m2.

Optional Input Parameters

1:     m2 – int64int32nag_int scalar
Default: The dimension of the array iperm.
The range of elements used in the array iperm and the range of values in the permutation, as specified under iperm.
Constraint: 0 < m1m20<m1m2.

Input Parameters Omitted from the MATLAB Interface

None.

Output Parameters

1:     iperm(m2) – int64int32nag_int array
Used as internal workpsace prior to being restored and hence is unchanged.
2:     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,m2 < 1m2<1,
orm1 < 1m1<1,
orm1 > m2m1>m2.
  ifail = 2ifail=2
Elements m1 to m2 of iperm contain a value outside the range m1 to m2.
  ifail = 3ifail=3
Elements m1 to m2 of iperm contain a repeated value.
If ifail = 2ifail=2 or 33, elements m1 to m2 of iperm do not contain a permutation of the integers m1 to m2.

Accuracy

Not applicable.

Further Comments

None.

Example

function nag_sort_permute_check_example
iperm = [int64(7);6;10;2;8;12;3;4;11;5;1;9];
m1 = int64(1);
[ipermOut, ifail] = nag_sort_permute_check(iperm, m1)
 

ipermOut =

                    7
                    6
                   10
                    2
                    8
                   12
                    3
                    4
                   11
                    5
                    1
                    9


ifail =

                    0


function m01zb_example
iperm = [int64(7);6;10;2;8;12;3;4;11;5;1;9];
m1 = int64(1);
[ipermOut, ifail] = m01zb(iperm, m1)
 

ipermOut =

                    7
                    6
                   10
                    2
                    8
                   12
                    3
                    4
                   11
                    5
                    1
                    9


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