# NAG Library Routine Document

## 1Purpose

d06daf is a utility which performs an affine transformation of a given mesh.

## 2Specification

Fortran Interface
 Subroutine d06daf ( nv, nelt,
 Integer, Intent (In) :: nv, nedge, nelt, ntrans, itype(ntrans), itrace, lrwork Integer, Intent (Inout) :: edgei(3,nedge), conni(3,nelt), ifail Integer, Intent (Out) :: edgeo(3,nedge), conno(3,nelt) Real (Kind=nag_wp), Intent (In) :: trans(6,ntrans) Real (Kind=nag_wp), Intent (Inout) :: coori(2,nv) Real (Kind=nag_wp), Intent (Out) :: cooro(2,nv), rwork(lrwork)
#include nagmk26.h
 void d06daf_ ( const Integer *nv, const Integer *nedge, const Integer *nelt, const Integer *ntrans, const Integer itype[], const double trans[], double coori[], Integer edgei[], Integer conni[], double cooro[], Integer edgeo[], Integer conno[], const Integer *itrace, double rwork[], const Integer *lrwork, Integer *ifail)

## 3Description

d06daf generates a mesh (coordinates, triangle/vertex connectivities and edge/vertex connectivities) resulting from an affine transformation of a given mesh. This transformation is of the form $Y=A×X+B$, where
• $Y$, $X$ and $B$ are in ${ℝ}^{2}$, and
• $A$ is a real $2$ by $2$ matrix.
Such a transformation includes a translation, a rotation, a scale reduction or increase, a symmetric transformation with respect to a user-supplied line, a user-supplied analytic transformation, or a composition of several transformations.
This routine is partly derived from material in the MODULEF package from INRIA (Institut National de Recherche en Informatique et Automatique).

None.

## 5Arguments

1:     $\mathbf{nv}$ – IntegerInput
On entry: the total number of vertices in the input mesh.
Constraint: ${\mathbf{nv}}\ge 3$.
2:     $\mathbf{nedge}$ – IntegerInput
On entry: the number of the boundary or interface edges in the input mesh.
Constraint: ${\mathbf{nedge}}\ge 1$.
3:     $\mathbf{nelt}$ – IntegerInput
On entry: the number of triangles in the input mesh.
Constraint: ${\mathbf{nelt}}\le 2×{\mathbf{nv}}-1$.
4:     $\mathbf{ntrans}$ – IntegerInput
On entry: the number of transformations of the input mesh.
Constraint: ${\mathbf{ntrans}}\ge 1$.
5:     $\mathbf{itype}\left({\mathbf{ntrans}}\right)$ – Integer arrayInput
On entry: ${\mathbf{itype}}\left(\mathit{i}\right)$, for $\mathit{i}=1,2,\dots ,{\mathbf{ntrans}}$, indicates the type of each transformation as follows:
${\mathbf{itype}}\left(i\right)=0$
Identity transformation.
${\mathbf{itype}}\left(i\right)=1$
Translation.
${\mathbf{itype}}\left(i\right)=2$
Symmetric transformation with respect to a user-supplied line.
${\mathbf{itype}}\left(i\right)=3$
Rotation.
${\mathbf{itype}}\left(i\right)=4$
Scaling.
${\mathbf{itype}}\left(i\right)=10$
User-supplied analytic transformation.
Note that the transformations are applied in the order described in itype.
Constraint: ${\mathbf{itype}}\left(\mathit{i}\right)=0$, $1$, $2$, $3$, $4$ or $10$, for $\mathit{i}=1,2,\dots ,{\mathbf{ntrans}}$.
6:     $\mathbf{trans}\left(6,{\mathbf{ntrans}}\right)$ – Real (Kind=nag_wp) arrayInput
On entry: the arguments for each transformation. For $i=1,2,\dots ,{\mathbf{ntrans}}$, ${\mathbf{trans}}\left(1,i\right)$ to ${\mathbf{trans}}\left(6,i\right)$ contain the arguments of the $i$th transformation.
If ${\mathbf{itype}}\left(i\right)=0$, elements ${\mathbf{trans}}\left(1,i\right)$ to ${\mathbf{trans}}\left(6,i\right)$ are not referenced.
If ${\mathbf{itype}}\left(i\right)=1$, the translation vector is $\stackrel{\to }{u}=\left(\begin{array}{c}a\\ b\end{array}\right)$, where $a={\mathbf{trans}}\left(1,i\right)$ and $b={\mathbf{trans}}\left(2,i\right)$, while elements ${\mathbf{trans}}\left(3,i\right)$ to ${\mathbf{trans}}\left(6,i\right)$ are not referenced.
If ${\mathbf{itype}}\left(i\right)=2$, the user-supplied line is the curve {$\left(x,y\right)\in {ℝ}^{2}$; such that $ax+by+c=0$}, where $a={\mathbf{trans}}\left(1,i\right)$, $b={\mathbf{trans}}\left(2,i\right)$ and $c={\mathbf{trans}}\left(3,i\right)$, while elements ${\mathbf{trans}}\left(4,i\right)$ to ${\mathbf{trans}}\left(6,i\right)$ are not referenced.
If ${\mathbf{itype}}\left(i\right)=3$, the centre of the rotation is $\left({x}_{0},{y}_{0}\right)$ where ${x}_{0}={\mathbf{trans}}\left(1,i\right)$ and ${y}_{0}={\mathbf{trans}}\left(2,i\right)$, $\theta ={\mathbf{trans}}\left(3,i\right)$ is its angle in degrees, while elements ${\mathbf{trans}}\left(4,i\right)$ to ${\mathbf{trans}}\left(6,i\right)$ are not referenced.
If ${\mathbf{itype}}\left(i\right)=4$, $a={\mathbf{trans}}\left(1,i\right)$ is the scaling coefficient in the $x$-direction, $b={\mathbf{trans}}\left(2,i\right)$ is the scaling coefficient in the $y$-direction, and $\left({x}_{0},{y}_{0}\right)$ are the scaling centre coordinates, with ${x}_{0}={\mathbf{trans}}\left(3,i\right)$ and ${y}_{0}={\mathbf{trans}}\left(4,i\right)$; while elements ${\mathbf{trans}}\left(5,i\right)$ to ${\mathbf{trans}}\left(6,i\right)$ are not referenced.
If ${\mathbf{itype}}\left(i\right)=10$, the user-supplied analytic affine transformation $Y=A×X+B$ is such that $A={\left({a}_{kl}\right)}_{1\le k,l\le 2}$ and $B={\left({b}_{k}\right)}_{1\le k\le 2}$ where${a}_{kl}={\mathbf{trans}}\left(2×\left(k-1\right)+l,i\right)$, and ${b}_{k}={\mathbf{trans}}\left(4+k,i\right)$ with $k,l=1,2$.
7:     $\mathbf{coori}\left(2,{\mathbf{nv}}\right)$ – Real (Kind=nag_wp) arrayInput/Output
On entry: ${\mathbf{coori}}\left(1,\mathit{i}\right)$ contains the $x$ coordinate of the $\mathit{i}$th vertex of the input mesh, for $\mathit{i}=1,2,\dots ,{\mathbf{nv}}$; while ${\mathbf{coori}}\left(2,i\right)$ contains the corresponding $y$ coordinate.
On exit: see Section 9.
8:     $\mathbf{edgei}\left(3,{\mathbf{nedge}}\right)$ – Integer arrayInput/Output
On entry: the specification of the boundary or interface edges. ${\mathbf{edgei}}\left(1,j\right)$ and ${\mathbf{edgei}}\left(2,j\right)$ contain the vertex numbers of the two end points of the $j$th boundary edge. ${\mathbf{edgei}}\left(3,j\right)$ is a user-supplied tag for the $j$th boundary edge.
Constraint: $1\le {\mathbf{edgei}}\left(\mathit{i},\mathit{j}\right)\le {\mathbf{nv}}$ and ${\mathbf{edgei}}\left(1,\mathit{j}\right)\ne {\mathbf{edgei}}\left(2,\mathit{j}\right)$, for $\mathit{i}=1,2$ and $\mathit{j}=1,2,\dots ,{\mathbf{nedge}}$.
On exit: see Section 9.
9:     $\mathbf{conni}\left(3,{\mathbf{nelt}}\right)$ – Integer arrayInput/Output
On entry: the connectivity of the input mesh between triangles and vertices. For each triangle $\mathit{j}$, ${\mathbf{conni}}\left(\mathit{i},\mathit{j}\right)$ gives the indices of its three vertices (in anticlockwise order), for $\mathit{i}=1,2,3$ and $\mathit{j}=1,2,\dots ,{\mathbf{nelt}}$.
Constraints:
• $1\le {\mathbf{conni}}\left(i,j\right)\le {\mathbf{nv}}$;
• ${\mathbf{conni}}\left(1,j\right)\ne {\mathbf{conni}}\left(2,j\right)$;
• ${\mathbf{conni}}\left(1,\mathit{j}\right)\ne {\mathbf{conni}}\left(3,\mathit{j}\right)$ and ${\mathbf{conni}}\left(2,\mathit{j}\right)\ne {\mathbf{conni}}\left(3,\mathit{j}\right)$, for $\mathit{i}=1,2,3$ and $\mathit{j}=1,2,\dots ,{\mathbf{nelt}}$.
On exit: see Section 9.
10:   $\mathbf{cooro}\left(2,{\mathbf{nv}}\right)$ – Real (Kind=nag_wp) arrayOutput
On exit: ${\mathbf{cooro}}\left(1,\mathit{i}\right)$ will contain the $x$ coordinate of the $\mathit{i}$th vertex of the transformed mesh, for $\mathit{i}=1,2,\dots ,{\mathbf{nv}}$; while ${\mathbf{cooro}}\left(2,i\right)$ will contain the corresponding $y$ coordinate.
11:   $\mathbf{edgeo}\left(3,{\mathbf{nedge}}\right)$ – Integer arrayOutput
On exit: the specification of the boundary or interface edges of the transformed mesh. If the number of symmetric transformations is even or zero then${\mathbf{edgeo}}\left(\mathit{i},\mathit{j}\right)={\mathbf{edgei}}\left(\mathit{i},\mathit{j}\right)$, for $\mathit{i}=1,2,3$ and $\mathit{j}=1,2,\dots ,{\mathbf{nedge}}$; otherwise ${\mathbf{edgeo}}\left(1,\mathit{j}\right)={\mathbf{edgei}}\left(2,\mathit{j}\right)$,${\mathbf{edgeo}}\left(2,\mathit{j}\right)={\mathbf{edgei}}\left(1,\mathit{j}\right)$ and ${\mathbf{edgeo}}\left(3,\mathit{j}\right)={\mathbf{edgei}}\left(3,\mathit{j}\right)$, for $\mathit{j}=1,2,\dots ,{\mathbf{nedge}}$.
12:   $\mathbf{conno}\left(3,{\mathbf{nelt}}\right)$ – Integer arrayOutput
On exit: the connectivity of the transformed mesh between triangles and vertices. If the number of symmetric transformations is even or zero then${\mathbf{conno}}\left(\mathit{i},\mathit{j}\right)={\mathbf{conni}}\left(\mathit{i},\mathit{j}\right)$, for $\mathit{i}=1,2,3$ and $\mathit{j}=1,2,\dots ,{\mathbf{nelt}}$; otherwise ${\mathbf{conno}}\left(1,\mathit{j}\right)={\mathbf{conni}}\left(1,\mathit{j}\right)$, ${\mathbf{conno}}\left(2,\mathit{j}\right)={\mathbf{conni}}\left(3,\mathit{j}\right)$ and ${\mathbf{conno}}\left(3,\mathit{j}\right)={\mathbf{conni}}\left(2,\mathit{j}\right)$, for $\mathit{j}=1,2,\dots ,{\mathbf{nelt}}$.
13:   $\mathbf{itrace}$ – IntegerInput
On entry: the level of trace information required from d06daf.
${\mathbf{itrace}}\le 0$
No output is generated.
${\mathbf{itrace}}\ge 1$
Details of each transformation, the matrix $A$ and the vector $B$ of the final transformation, which is the composition of all the ntrans transformations, are printed on the current advisory message unit (see x04abf).
14:   $\mathbf{rwork}\left({\mathbf{lrwork}}\right)$ – Real (Kind=nag_wp) arrayWorkspace
15:   $\mathbf{lrwork}$ – IntegerInput
On entry: the dimension of the array rwork as declared in the (sub)program from which d06daf is called.
Constraint: ${\mathbf{lrwork}}\ge 12×{\mathbf{ntrans}}$.
16:   $\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{nv}}<3$; or ${\mathbf{nelt}}>2×{\mathbf{nv}}-1$; or ${\mathbf{nedge}}<1$; or ${\mathbf{edgei}}\left(i,j\right)<1$ or ${\mathbf{edgei}}\left(i,j\right)>{\mathbf{nv}}$ for some $i=1,2$ and $j=1,2,\dots ,{\mathbf{nedge}}$; or ${\mathbf{edgei}}\left(1,j\right)={\mathbf{edgei}}\left(2,j\right)$ for some $j=1,2,\dots ,{\mathbf{nedge}}$; or ${\mathbf{conni}}\left(i,j\right)<1$ or ${\mathbf{conni}}\left(i,j\right)>{\mathbf{nv}}$ for some $i=1,2,3$ and $j=1,2,\dots ,{\mathbf{nelt}}$; or ${\mathbf{conni}}\left(1,j\right)={\mathbf{conni}}\left(2,j\right)$ or ${\mathbf{conni}}\left(1,j\right)={\mathbf{conni}}\left(3,j\right)$ or ${\mathbf{conni}}\left(2,j\right)={\mathbf{conni}}\left(3,j\right)$ for some $j=1,2,\dots ,{\mathbf{nelt}}$; or ${\mathbf{ntrans}}<1$; or ${\mathbf{itype}}\left(i\right)\ne 0$, $1$, $2$, $3$, $4$ or $10$ for some $i=1,2,\dots ,{\mathbf{ntrans}}$; or ${\mathbf{lrwork}}<12×{\mathbf{ntrans}}$.
${\mathbf{ifail}}=2$
A serious error has occurred in an internal call to an auxiliary routine. Check the input mesh especially the triangles/vertices and the edges/vertices connectivities as well as the details of each transformations.
${\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.

Not applicable.

## 8Parallelism and Performance

d06daf makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this routine. Please also consult the Users' Note for your implementation for any additional implementation-specific information.