F06 Chapter Contents
F06 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentF06QKF

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

## 1  Purpose

F06QKF permutes the rows or columns of a real rectangular matrix using a real array of permutations.

## 2  Specification

 SUBROUTINE F06QKF ( SIDE, TRANS, N, PERM, K, B, LDB)
 INTEGER N, K, LDB REAL (KIND=nag_wp) PERM(*), B(LDB,*) CHARACTER(1) SIDE, TRANS

## 3  Description

F06QKF performs one of the permutation operations
 $B←PTB, B←PB, B←BPT or B←BP,$
where $B$ is a real matrix, and $P$ is a permutation matrix.
$P$ is represented in the form
 $P=P1,p1P2,p2⋯Pn,pn,$
where ${P}_{i,j}$ is the permutation matrix that interchanges items $i$ and $j$; that is, ${P}_{i,j}$ is the unit matrix with rows and columns $i$ and $j$ interchanged. If $i=j$, ${P}_{i,j}=I$.
Let $m$ denote the number of rows of $B$ if ${\mathbf{SIDE}}=\text{'L'}$, or the number of columns of $B$ if ${\mathbf{SIDE}}=\text{'R'}$: the routine does not require $m$ to be passed as an argument, but assumes that $m\ge {p}_{\mathit{i}}$, for $\mathit{i}=1,2,\dots ,n$.
This routine requires the indices ${p}_{i}$ to be supplied in a real array (the routine takes the integer part of the array elements); F06QJF performs the same operation with the indices supplied in an integer array.

None.

## 5  Parameters

1:     SIDE – CHARACTER(1)Input
2:     TRANS – CHARACTER(1)Input
On entry: specifies the operation to be performed.
${\mathbf{SIDE}}=\text{'L'}$ and ${\mathbf{TRANS}}=\text{'T'}$
$B←{P}^{\mathrm{T}}B$.
${\mathbf{SIDE}}=\text{'L'}$ and ${\mathbf{TRANS}}=\text{'N'}$
$B←PB$.
${\mathbf{SIDE}}=\text{'R'}$ and ${\mathbf{TRANS}}=\text{'T'}$
$B←B{P}^{\mathrm{T}}$.
${\mathbf{SIDE}}=\text{'R'}$ and ${\mathbf{TRANS}}=\text{'N'}$
$B←BP$.
Constraints:
• ${\mathbf{SIDE}}=\text{'L'}$ or $\text{'R'}$;
• ${\mathbf{TRANS}}=\text{'N'}$ or $\text{'T'}$.
3:     N – INTEGERInput
On entry: $n$, the number of interchanges in the representation of $P$.
Constraint: ${\mathbf{N}}\ge 0$.
4:     PERM($*$) – REAL (KIND=nag_wp) arrayInput
Note: the dimension of the array PERM must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$.
On entry: the $n$ indices ${p}_{i}$ which define the interchanges in the representation of $P$. It is usual to have ${p}_{i}\ge i$, but this is not necessary.
Constraint: $1\le {\mathbf{PERM}}\left(i\right)\le m$.
5:     K – INTEGERInput
On entry: $k$, the number of columns of $B$ if ${\mathbf{SIDE}}=\text{'L'}$, or the number of rows of $B$ if ${\mathbf{SIDE}}=\text{'R'}$.
Constraint: ${\mathbf{K}}\ge 0$.
6:     B(LDB,$*$) – REAL (KIND=nag_wp) arrayInput/Output
Note: the second dimension of the array B must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{K}}\right)$ if ${\mathbf{SIDE}}=\text{'L'}$ and at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,\underset{\mathit{k}}{\mathrm{max}}\phantom{\rule{0.25em}{0ex}}\left\{\mathrm{int}{\mathbf{PERM}}\left(\mathit{k}\right)\right\}\right)$ if ${\mathbf{SIDE}}=\text{'R'}$.
On entry: the original matrix $B$; $B$ is $m$ by $k$ if ${\mathbf{SIDE}}=\text{'L'}$, or $k$ by $m$ if ${\mathbf{SIDE}}=\text{'R'}$.
On exit: the permuted matrix $B$.
7:     LDB – INTEGERInput
On entry: the first dimension of the array B as declared in the (sub)program from which F06QKF is called.
Constraints:
• if ${\mathbf{SIDE}}=\text{'L'}$, ${\mathbf{LDB}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,m\right)$;
• if ${\mathbf{SIDE}}=\text{'R'}$, ${\mathbf{LDB}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{K}}\right)$.

None.

Not applicable.