|
| 1 | +# swap_elements |
| 2 | + |
| 3 | +* [mathjax enable] |
| 4 | +* linalg[meta header] |
| 5 | +* function template[meta id-type] |
| 6 | +* std::linalg[meta namespace] |
| 7 | +* cpp26[meta cpp] |
| 8 | + |
| 9 | + |
| 10 | +```cpp |
| 11 | +namespace std::linalg { |
| 12 | + template<inout-object InOutObj1, |
| 13 | + inout-object InOutObj2> |
| 14 | + void swap_elements(InOutObj1 x, |
| 15 | + InOutObj2 y); // (1) |
| 16 | + |
| 17 | + template<class ExecutionPolicy, |
| 18 | + inout-object InOutObj1, |
| 19 | + inout-object InOutObj2> |
| 20 | + void swap_elements(ExecutionPolicy&& exec, |
| 21 | + InOutObj1 x, |
| 22 | + InOutObj2 y); // (2) |
| 23 | +} |
| 24 | +``` |
| 25 | +
|
| 26 | +
|
| 27 | +## 概要 |
| 28 | +同じサイズの2つのベクトル`x`と`y`を交換する。 |
| 29 | +
|
| 30 | +
|
| 31 | +## テンプレートパラメータ制約 |
| 32 | +`x`と`y`の次元が等しくなければならない。 |
| 33 | +- `x.rank() == y.rank()` |
| 34 | +
|
| 35 | +
|
| 36 | +## 適格要件 |
| 37 | +- 0以上`x.rank()`未満の整数rに対して、[`compatible-static-extents`](/reference/linalg/compatible-static-extents.md)`<InOutVec1, InOutVec2>(r,r)`が`true` |
| 38 | +
|
| 39 | +
|
| 40 | +## 事前条件 |
| 41 | +`x`と`y`の各次元の要素数が等しくなければならない。 |
| 42 | +- `x.extents() == y.extents()` |
| 43 | +
|
| 44 | +
|
| 45 | +## 効果 |
| 46 | +`x`と`y`の対応する成分全てを交換する。 |
| 47 | +
|
| 48 | +- (1): 逐次実行する。 |
| 49 | +- (2): 指定された実行ポリシーに応じて実行する。 |
| 50 | +
|
| 51 | +
|
| 52 | +## 戻り値 |
| 53 | +なし |
| 54 | +
|
| 55 | +
|
| 56 | +## 例 |
| 57 | +
|
| 58 | +
|
| 59 | +### 出力 |
| 60 | +
|
| 61 | +
|
| 62 | +## バージョン |
| 63 | +### 言語 |
| 64 | +- C++26 |
| 65 | +
|
| 66 | +### 処理系 |
| 67 | +- [Clang](/implementation.md#clang): ?? |
| 68 | +- [GCC](/implementation.md#gcc): ?? |
| 69 | +- [ICC](/implementation.md#icc): ?? |
| 70 | +- [Visual C++](/implementation.md#visual_cpp): ?? |
| 71 | +
|
| 72 | +
|
| 73 | +## 関連項目 |
| 74 | +- [`execution`](/reference/execution.md) |
| 75 | +- [`mdspan`](/reference/mdspan.md) |
| 76 | +
|
| 77 | +
|
| 78 | +## 参照 |
| 79 | +- [P0788R3 Standard Library Specification in a Concepts and Contracts World](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0788r3.pdf) |
| 80 | +- [`LAPACK: cswap`](https://netlib.org/lapack/explore-html/d1/d45/group__rot_ga25544801d45dcabdec7b24d863ebea9c.html#ga25544801d45dcabdec7b24d863ebea9c) |
| 81 | +
|
0 commit comments