Skip to content

Commit 75d3ea3

Browse files
committed
mdspan/layout_left/mapping: 全メンバ(#1077)
1 parent 323fd20 commit 75d3ea3

File tree

10 files changed

+593
-15
lines changed

10 files changed

+593
-15
lines changed

reference/mdspan/layout_left.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace std {
1313
}
1414
```
1515
* Extents[link extents.md]
16-
* mapping[link mapping.md.nolink]
16+
* mapping[link layout_left/mapping.md]
1717
1818
## 概要
1919
`layout_left`は、多次元配列ビュー[`mdspan`](mdspan.md)に対して、FortranやMatlab多次元配列と互換性のある列優先(column major)[レイアウトマッピング](LayoutMapping.md)を表現するポリシークラスである。
@@ -27,7 +27,7 @@ namespace std {
2727
2828
| 名前 | 説明 | 対応バージョン |
2929
|------|------|----------------|
30-
| [`mapping`](mapping.md.nolink) | レイアウトマッピング | C++23 |
30+
| [`mapping`](layout_left/mapping.md) | レイアウトマッピング | C++23 |
3131
3232
3333
## 例
@@ -37,7 +37,7 @@ namespace std {
3737
3838
int main()
3939
{
40-
double arr[] = {1, 4, 2, 5, 3, 6};
40+
double arr[] = {1, 2, 3, 4, 5, 6};
4141
4242
// 要素数2x3の2次元配列/列優先レイアウト
4343
using Ext2x3 = std::extents<size_t, 2, 3>;
@@ -57,8 +57,8 @@ int main()
5757

5858
### 出力
5959
```
60-
1 2 3
61-
4 5 6
60+
1 3 5
61+
2 4 6
6262
```
6363

6464

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
# mapping
2+
* mdspan[meta header]
3+
* class template[meta id-type]
4+
* std[meta namespace]
5+
* layout_left[meta class]
6+
* cpp23[meta cpp]
7+
8+
```cpp
9+
namespace std {
10+
template<class Extents>
11+
class layout_left::mapping;
12+
}
13+
```
14+
* layout_left[link ../layout_left.md]
15+
* Extents[link ../extents.md]
16+
17+
## 概要
18+
`layout_left::mapping<E>`は、[`extents`](../extents.md)型の多次元配列サイズ`E`をパラメータとして、Fortran/Matlab多次元配列と互換性のある列優先(column major)[レイアウトマッピング](../LayoutMapping.md)を表現するクラスである。
19+
20+
`layout_left::mapping<E>`は[トリビアルコピー可能](/reference/type_traits/is_trivially_copyable.md)であり、[`regular`](/reference/concepts/regular.md)のモデルである。
21+
22+
### 説明専用メンバ変数
23+
`layout_left::mapping`クラステンプレートは、下記の説明専用メンバ変数を保持する。
24+
25+
- `extents_` : `extents_type`型の[多次元配列サイズ情報](../extents.md)
26+
27+
28+
## 適格要件
29+
- `Extents`は[`extents`](../extents.md)の特殊化であること。
30+
- [`Extents::rank_dynamic()`](../extents/rank_dynamic.md) `== 0`が`true`のとき、多次元インデクス空間`Extents()`のサイズが`Extents::index_type`型で表現できること。
31+
32+
33+
## メンバ関数
34+
### 構築・破棄
35+
36+
| 名前 | 説明 | 対応バージョン |
37+
|------|------|----------------|
38+
| [`(constructor)`](mapping/op_constructor.md) | コンストラクタ | C++23 |
39+
| `(destructor)` | デストラクタ | C++23 |
40+
| `operator=` | コピー代入演算子 | C++23 |
41+
42+
### 観測
43+
44+
| 名前 | 説明 | 対応バージョン |
45+
|------|------|----------------|
46+
| `extents` | 多次元配列のサイズ`extents_`を取得する | C++23 |
47+
| [`required_span_size`](mapping/required_span_size.md) | 要素アクセス範囲を取得する | C++23 |
48+
| [`operator()`](mapping/op_call.md) | 多次元配列インデクスから要素位置へ変換する | C++23 |
49+
| [`stride`](mapping/stride.md) | 指定次元のストライド幅を取得する | C++23 |
50+
51+
52+
## 静的メンバ関数
53+
54+
| 名前 | 説明 | 対応バージョン |
55+
|------|------|----------------|
56+
| `is_always_unique` | `true`を返す | C++23 |
57+
| `is_always_exhaustive` | `true`を返す | C++23 |
58+
| `is_always_strided` | `true`を返す | C++23 |
59+
| `is_unique` | `true`を返す | C++23 |
60+
| `is_exhaustive` | `true`を返す | C++23 |
61+
| `is_strided` | `true`を返す | C++23 |
62+
63+
64+
## メンバ型
65+
66+
| 名前 | 説明 | 対応バージョン |
67+
|------|------|----------------|
68+
| `extents_type` | [`Extents`](../extents.md) | C++23 |
69+
| `index_type` | [`Extents::index_type`](../extents.md) | C++23 |
70+
| `size_type` | [`Extents::size_type`](../extents.md) | C++23 |
71+
| `rank_type` | [`Extents::rank_type`](../extents.md) | C++23 |
72+
| `layout_type` | [`layout_left`](../layout_left.md) | C++23 |
73+
74+
75+
### 比較演算子
76+
77+
| 名前 | 説明 | 対応バージョン |
78+
|------|------|----------------|
79+
| [`operator==`](mapping/op_equal.md) | 等値比較 | C++23 |
80+
| [`operator!=`](mapping/op_equal.md) | 非等値比較 (`==`により使用可能) | C++23 |
81+
82+
83+
## 例
84+
```cpp example
85+
#include <mdspan>
86+
#include <iostream>
87+
88+
int main()
89+
{
90+
double arr[] = {1, 2, 3, 4, 5, 6};
91+
92+
// 要素数2x3の2次元配列/列優先レイアウト
93+
using Ext2x3 = std::extents<size_t, 2, 3>;
94+
using Mapping = std::layout_left::mapping<Ext2x3>;
95+
std::mdspan mat{arr, Mapping{}};
96+
97+
for (size_t i = 0; i < mat.extent(0); ++i) {
98+
for (size_t j = 0; j < mat.extent(1); ++j) {
99+
std::cout << (j ? " " : "") << mat[i, j];
100+
}
101+
std::cout << "\n";
102+
}
103+
}
104+
```
105+
* std::layout_left::mapping[color ff0000]
106+
* std::mdspan[link ../mdspan.md]
107+
* std::extents[link ../extents.md]
108+
109+
### 出力
110+
```
111+
1 3 5
112+
2 4 6
113+
```
114+
115+
116+
## バージョン
117+
### 言語
118+
- C++23
119+
120+
### 処理系
121+
- [Clang](/implementation.md#clang): ??
122+
- [GCC](/implementation.md#gcc): ??
123+
- [ICC](/implementation.md#icc): ??
124+
- [Visual C++](/implementation.md#visual_cpp): ??
125+
126+
127+
## 関連項目
128+
- [`mdspan`](../mdspan.md)
129+
130+
131+
## 参照
132+
- [P0009R18 MDSPAN](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p0009r18.html)
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# operator()
2+
* mdspan[meta header]
3+
* function template[meta id-type]
4+
* std[meta namespace]
5+
* layout_left::mapping[meta class]
6+
* cpp23[meta cpp]
7+
8+
```cpp
9+
template<class... Indices>
10+
constexpr index_type operator()(Indices... i) const noexcept;
11+
```
12+
13+
## 概要
14+
多次元インデクス値`i...`に対応する要素位置を求める。
15+
16+
17+
## テンプレートパラメータ制約
18+
- `sizeof...(Indices) ==` [`extents_tyoe::rank()`](../../extents/rank.md)が`true`、かつ
19+
- `(`[`is_convertible_v`](/reference/type_traits/is_convertible.md)`<Indices, index_type> && ...)`が`true`、かつ
20+
- `(`[`is_nothrow_constructible_v`](/reference/type_traits/is_nothrow_constructible.md)`<index_type, Indices> && ...)`が`true`であること。
21+
22+
23+
## 事前条件
24+
多次元インデクス値[`extents_type::index-cast(i)`](../../extents/index-cast.md)は、多次元配列サイズ`extents_`における有効なインデクスであること。
25+
26+
27+
## 戻り値
28+
説明用のパラメータパック`P`において、[`is_same_v`](/reference/type_traits/is_same.md)`<`[`index_sequence_for`](/reference/utility/index_sequence_for.md)`<Indices...>,` [`index_sequence`](/reference/utility/index_sequence.md)`<P...>>`が`true`となるとき、以下と等価。
29+
30+
```cpp
31+
return ((static_cast<index_type>(Indices...) * stride(P)) + ... + 0);
32+
```
33+
* stride[link stride.md]
34+
35+
36+
## 例外
37+
投げない
38+
39+
40+
##
41+
```cpp example
42+
#include <cassert>
43+
#include <mdspan>
44+
45+
int main()
46+
{
47+
using Ext3x4 = std::extents<size_t, 3, 4>;
48+
using Mapping3x4 = std::layout_left::mapping<Ext3x4>;
49+
Mapping3x4 map;
50+
assert(map(0,0) == 0);
51+
assert(map(0,1) == 3);
52+
assert(map(1,0) == 1);
53+
assert(map(2,3) == 11);
54+
}
55+
```
56+
* std::extents[link ../../extents.md]
57+
* std::layout_left::mapping[link ../mapping.md]
58+
59+
### 出力
60+
```
61+
```
62+
63+
64+
## バージョン
65+
### 言語
66+
- C++23
67+
68+
### 処理系
69+
- [Clang](/implementation.md#clang): ??
70+
- [GCC](/implementation.md#gcc): ??
71+
- [ICC](/implementation.md#icc): ??
72+
- [Visual C++](/implementation.md#visual_cpp): ??
73+
74+
75+
## 参照
76+
- [P0009R18 MDSPAN](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p0009r18.html)

0 commit comments

Comments
 (0)