Skip to content

Commit 6d90730

Browse files
committed
linalg : swap_elementsを追加。
Signed-off-by: Yuya Asano <64895419+sukeya@users.noreply.github.com>
1 parent b2241cc commit 6d90730

File tree

2 files changed

+82
-1
lines changed

2 files changed

+82
-1
lines changed

reference/linalg.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ BLAS 1, 2, 3のアルゴリズムでテンプレートパラメータが特に
6161
| [`setup_givens_rotation_result`](linalg/setup_givens_rotation_result.md) | `setup_givens_rotation`の結果型 (class template) | C++26 |
6262
| [`setup_givens_rotation`](linalg/setup_givens_rotation.md) | xLARTG: ギブンス回転をセットアップする (function template) | C++26 |
6363
| [`apply_givens_rotation`](linalg/apply_givens_rotation.md) | xROT: ベクトルにギブンス回転を適用する (function template) | C++26 |
64-
| `swap_elements` | xSWAP: 2つのベクトル/行列の要素を交換する (function template) | C++26 |
64+
| [`swap_elements`](linalg/swap_elements.md) | xSWAP: 2つのベクトル/行列の要素を交換する (function template) | C++26 |
6565
| `scale` | xSCAL: ベクトル/行列の要素にスカラ値を乗算する (function template) | C++26 |
6666
| `copy` | xCOPY: ベクトル/行列の要素をコピーする (function template) | C++26 |
6767
| `add` | xAXPY: 2つのベクトル/行列の要素を加算する (function template) | C++26 |

reference/linalg/swap_elements.md

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
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

Comments
 (0)