# NAG Library Routine Document

## 1Purpose

f06egf (dswap) interchanges two $n$-element real vectors $x$ and $y$.

## 2Specification

Fortran Interface
 Subroutine f06egf ( n, x, incx, y, incy)
 Integer, Intent (In) :: n, incx, incy Real (Kind=nag_wp), Intent (Inout) :: x(*), y(*)
#include nagmk26.h
 void f06egf_ (const Integer *n, double x[], const Integer *incx, double y[], const Integer *incy)
The routine may be called by its BLAS name dswap.

## 3Description

f06egf (dswap) interchanges the elements of real vectors $x$ and $y$ scattered with stride incx and incy respectively.

## 4References

Lawson C L, Hanson R J, Kincaid D R and Krogh F T (1979) Basic linear algebra supbrograms for Fortran usage ACM Trans. Math. Software 5 308–325

## 5Arguments

1:     $\mathbf{n}$ – IntegerInput
On entry: $n$, the number of elements in $x$ and $y$.
2:     $\mathbf{x}\left(*\right)$ – Real (Kind=nag_wp) arrayInput/Output
Note: the dimension of the array x must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,1+\left({\mathbf{n}}-1\right)×\left|{\mathbf{incx}}\right|\right)$.
On entry: the $n$-element vector $x$.
If ${\mathbf{incx}}>0$, ${x}_{\mathit{i}}$ must be stored in ${\mathbf{x}}\left(1+\left(\mathit{i}-1\right)×{\mathbf{incx}}\right)$, for $\mathit{i}=1,2,\dots ,{\mathbf{n}}$.
If ${\mathbf{incx}}<0$, ${x}_{\mathit{i}}$ must be stored in ${\mathbf{x}}\left(1-\left({\mathbf{n}}-\mathit{i}\right)×{\mathbf{incx}}\right)$, for $\mathit{i}=1,2,\dots ,{\mathbf{n}}$.
Intermediate elements of x are not referenced.
On exit: the original vector $y$ stored in the array elements used to supply the original vector $x$.
Intermediate elements of x are unchanged.
3:     $\mathbf{incx}$ – IntegerInput
On entry: the increment in the subscripts of x between successive elements of $x$.
4:     $\mathbf{y}\left(*\right)$ – Real (Kind=nag_wp) arrayInput/Output
Note: the dimension of the array y must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,1+\left({\mathbf{n}}-1\right)×\left|{\mathbf{incy}}\right|\right)$.
On entry: the $n$-element vector $y$.
If ${\mathbf{incy}}>0$, ${y}_{\mathit{i}}$ must be stored in ${\mathbf{y}}\left(1+\left(\mathit{i}-1\right)×{\mathbf{incy}}\right)$, for $\mathit{i}=1,2,\dots ,{\mathbf{n}}$.
If ${\mathbf{incy}}<0$, ${y}_{\mathit{i}}$ must be stored in ${\mathbf{y}}\left(1-\left({\mathbf{n}}-\mathit{i}\right)×{\mathbf{incy}}\right)$, for $\mathit{i}=1,2,\dots ,{\mathbf{n}}$.
Intermediate elements of y are not referenced.
On exit: the original vector $x$ stored in the array elements used to supply the original vector $y$.
Intermediate elements of y are unchanged.
5:     $\mathbf{incy}$ – IntegerInput
On entry: the increment in the subscripts of y between successive elements of $y$.

None.

Not applicable.

## 8Parallelism and Performance

f06egf (dswap) is not threaded in any implementation.