# NAG Library Routine Document

## 1Purpose

f06vjf permutes the rows or columns of a complex rectangular matrix using an integer array of permutations.

## 2Specification

Fortran Interface
 Subroutine f06vjf ( side, n, perm, k, b, ldb)
 Integer, Intent (In) :: n, perm(*), k, ldb Complex (Kind=nag_wp), Intent (Inout) :: b(ldb,*) Character (1), Intent (In) :: side, trans
#include <nagmk26.h>
 void f06vjf_ (const char *side, const char *trans, const Integer *n, const Integer perm[], const Integer *k, Complex b[], const Integer *ldb, const Charlen length_side, const Charlen length_trans)

## 3Description

f06vjf performs one of the permutation operations
 $B←PTB, B←PB, B←BPT or B←BP,$
where $B$ is a complex 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 $\mathit{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 $\mathit{m}$ to be passed as an argument, but assumes that $\mathit{m}\ge {p}_{\mathit{i}}$, for $\mathit{i}=1,2,\dots ,n$.
This routine requires the indices ${p}_{i}$ to be supplied in an integer array; f06vkf performs the same operation with the indices supplied in a real array.
None.

## 5Arguments

1:     $\mathbf{side}$ – Character(1)Input
2:     $\mathbf{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:     $\mathbf{n}$ – IntegerInput
On entry: $n$, the number of interchanges in the representation of $P$.
Constraint: ${\mathbf{n}}\ge 0$.
4:     $\mathbf{perm}\left(*\right)$ – Integer 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 \mathit{m}$, where $\mathit{m}=\underset{\mathit{k}}{\mathrm{max}}\phantom{\rule{0.25em}{0ex}}\left\{{\mathbf{perm}}\left(\mathit{k}\right)\right\}$.
5:     $\mathbf{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:     $\mathbf{b}\left({\mathbf{ldb}},*\right)$ – Complex (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({\mathbf{n}},\underset{\mathit{k}}{\mathrm{max}}\phantom{\rule{0.25em}{0ex}}\left\{{\mathbf{perm}}\left(\mathit{k}\right)\right\}\right)$ if ${\mathbf{side}}=\text{'R'}$.
On entry: the original matrix $B$; $B$ is $\mathit{m}$, where $\mathit{m}=\underset{\mathit{k}}{\mathrm{max}}\phantom{\rule{0.25em}{0ex}}\left\{{\mathbf{perm}}\left(\mathit{k}\right)\right\}$ by $k$ if ${\mathbf{side}}=\text{'L'}$, or $k$ by $\mathit{m}$, where $\mathit{m}=\underset{\mathit{k}}{\mathrm{max}}\phantom{\rule{0.25em}{0ex}}\left\{{\mathbf{perm}}\left(\mathit{k}\right)\right\}$ if ${\mathbf{side}}=\text{'R'}$.
On exit: the permuted matrix $B$.
7:     $\mathbf{ldb}$ – IntegerInput
On entry: the first dimension of the array b as declared in the (sub)program from which f06vjf is called.
Constraints:
• if ${\mathbf{side}}=\text{'L'}$, ${\mathbf{ldb}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{n}},\mathit{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.

## 8Parallelism and Performance

f06vjf is not threaded in any implementation.