[linalg.algs.blas1.swap]

# 29 Numerics library [[numerics]](./#numerics)

## 29.9 Basic linear algebra algorithms [[linalg]](linalg#algs.blas1.swap)

### 29.9.13 BLAS 1 algorithms [[linalg.algs.blas1]](linalg.algs.blas1#swap)

#### 29.9.13.3 Swap matrix or vector elements [linalg.algs.blas1.swap]

[ð](#lib:swap_elements)

`template<[inout-object](linalg.helpers.concepts#concept:inout-object "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InOutObj1, [inout-object](linalg.helpers.concepts#concept:inout-object "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InOutObj2>
  void swap_elements(InOutObj1 x, InOutObj2 y);
template<class ExecutionPolicy, [inout-object](linalg.helpers.concepts#concept:inout-object "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InOutObj1, [inout-object](linalg.helpers.concepts#concept:inout-object "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InOutObj2>
  void swap_elements(ExecutionPolicy&& exec, InOutObj1 x, InOutObj2 y);
`

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L13461)

[*Note [1](#note-1)*:

These functions correspond to the BLAS function xSWAP[[bib]](bibliography#bib:blas1 "Bibliography")[.](#1.sentence-1)

â *end note*]

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L13466)

*Constraints*: x.rank() equals y.rank()[.](#2.sentence-1)

[3](#3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L13470)

*Mandates*: For all r in the range [0, x.rank()),*compatible-static-extents*<InOutObj1, InOutObj2>(r, r) is true[.](#3.sentence-1)

[4](#4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L13478)

*Preconditions*: x.extents() equals y.extents()[.](#4.sentence-1)

[5](#5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L13482)

*Effects*: Swaps all corresponding elements of x and y[.](#5.sentence-1)
