NAG Library Routine Document

1Purpose

m01zbf checks the validity of a permutation.

2Specification

Fortran Interface
 Subroutine m01zbf ( m1, m2,
 Integer, Intent (In) :: m1, m2 Integer, Intent (Inout) :: iperm(m2), ifail
#include nagmk26.h
 void m01zbf_ (Integer iperm[], const Integer *m1, const Integer *m2, Integer *ifail)

3Description

m01zbf can be used to check the validity of user-supplied ranks or indices, without the ranks or indices being corrupted.

None.

5Arguments

1:     $\mathbf{iperm}\left({\mathbf{m2}}\right)$ – Integer arrayInput/Output
On entry: 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 routine exits with ${\mathbf{ifail}}={\mathbf{0}}$.
On exit: used as internal workpsace prior to being restored and hence is unchanged.
2:     $\mathbf{m1}$ – IntegerInput
3:     $\mathbf{m2}$ – IntegerInput
On entry: the range of elements used in the array iperm and the range of values in the permutation, as specified under iperm.
Constraint: $0<{\mathbf{m1}}\le {\mathbf{m2}}$.
4:     $\mathbf{ifail}$ – IntegerInput/Output
On entry: ifail must be set to $0$, $-1\text{​ or ​}1$. If you are unfamiliar with this argument you should refer to Section 3.4 in How to Use the NAG Library and its Documentation for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value $-1\text{​ or ​}1$ is recommended. If the output of error messages is undesirable, then the value $1$ is recommended. Otherwise, if you are not familiar with this argument, the recommended value is $0$. When the value $-\mathbf{1}\text{​ or ​}\mathbf{1}$ is used it is essential to test the value of ifail on exit.
On exit: ${\mathbf{ifail}}={\mathbf{0}}$ unless the routine detects an error or a warning has been flagged (see Section 6).

6Error Indicators and Warnings

If on entry ${\mathbf{ifail}}=0$ or $-1$, explanatory error messages are output on the current error message unit (as defined by x04aaf).
Errors or warnings detected by the routine:
${\mathbf{ifail}}=1$
 On entry, ${\mathbf{m2}}<1$, or ${\mathbf{m1}}<1$, or ${\mathbf{m1}}>{\mathbf{m2}}$.
${\mathbf{ifail}}=2$
Elements m1 to m2 of iperm contain a value outside the range m1 to m2.
${\mathbf{ifail}}=3$
Elements m1 to m2 of iperm contain a repeated value.
${\mathbf{ifail}}=-99$
See Section 3.9 in How to Use the NAG Library and its Documentation for further information.
${\mathbf{ifail}}=-399$
Your licence key may have expired or may not have been installed correctly.
See Section 3.8 in How to Use the NAG Library and its Documentation for further information.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.
See Section 3.7 in How to Use the NAG Library and its Documentation for further information.
If ${\mathbf{ifail}}={\mathbf{2}}$ or ${\mathbf{3}}$, elements m1 to m2 of iperm do not contain a permutation of the integers m1 to m2.

Not applicable.

8Parallelism and Performance

m01zbf is not threaded in any implementation.

None.

10Example

This example reads in a vector of real numbers, and a vector of ranks; it calls m01zbf to check the validity of the ranks before calling m01eaf to rearrange the real numbers into the specified order.

10.1Program Text

Program Text (m01zbfe.f90)

10.2Program Data

Program Data (m01zbfe.d)

10.3Program Results

Program Results (m01zbfe.r)

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