-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mdspan/layout_left/mapping: 全メンバ(#1077)
- Loading branch information
Showing
10 changed files
with
593 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
# mapping | ||
* mdspan[meta header] | ||
* class template[meta id-type] | ||
* std[meta namespace] | ||
* layout_left[meta class] | ||
* cpp23[meta cpp] | ||
|
||
```cpp | ||
namespace std { | ||
template<class Extents> | ||
class layout_left::mapping; | ||
} | ||
``` | ||
* layout_left[link ../layout_left.md] | ||
* Extents[link ../extents.md] | ||
## 概要 | ||
`layout_left::mapping<E>`は、[`extents`](../extents.md)型の多次元配列サイズ`E`をパラメータとして、Fortran/Matlab多次元配列と互換性のある列優先(column major)[レイアウトマッピング](../LayoutMapping.md)を表現するクラスである。 | ||
`layout_left::mapping<E>`は[トリビアルコピー可能](/reference/type_traits/is_trivially_copyable.md)であり、[`regular`](/reference/concepts/regular.md)のモデルである。 | ||
### 説明専用メンバ変数 | ||
`layout_left::mapping`クラステンプレートは、下記の説明専用メンバ変数を保持する。 | ||
- `extents_` : `extents_type`型の[多次元配列サイズ情報](../extents.md) | ||
## 適格要件 | ||
- `Extents`は[`extents`](../extents.md)の特殊化であること。 | ||
- [`Extents::rank_dynamic()`](../extents/rank_dynamic.md) `== 0`が`true`のとき、多次元インデクス空間`Extents()`のサイズが`Extents::index_type`型で表現できること。 | ||
## メンバ関数 | ||
### 構築・破棄 | ||
| 名前 | 説明 | 対応バージョン | | ||
|------|------|----------------| | ||
| [`(constructor)`](mapping/op_constructor.md) | コンストラクタ | C++23 | | ||
| `(destructor)` | デストラクタ | C++23 | | ||
| `operator=` | コピー代入演算子 | C++23 | | ||
### 観測 | ||
| 名前 | 説明 | 対応バージョン | | ||
|------|------|----------------| | ||
| `extents` | 多次元配列のサイズ`extents_`を取得する | C++23 | | ||
| [`required_span_size`](mapping/required_span_size.md) | 要素アクセス範囲を取得する | C++23 | | ||
| [`operator()`](mapping/op_call.md) | 多次元配列インデクスから要素位置へ変換する | C++23 | | ||
| [`stride`](mapping/stride.md) | 指定次元のストライド幅を取得する | C++23 | | ||
## 静的メンバ関数 | ||
| 名前 | 説明 | 対応バージョン | | ||
|------|------|----------------| | ||
| `is_always_unique` | `true`を返す | C++23 | | ||
| `is_always_exhaustive` | `true`を返す | C++23 | | ||
| `is_always_strided` | `true`を返す | C++23 | | ||
| `is_unique` | `true`を返す | C++23 | | ||
| `is_exhaustive` | `true`を返す | C++23 | | ||
| `is_strided` | `true`を返す | C++23 | | ||
## メンバ型 | ||
| 名前 | 説明 | 対応バージョン | | ||
|------|------|----------------| | ||
| `extents_type` | [`Extents`](../extents.md) | C++23 | | ||
| `index_type` | [`Extents::index_type`](../extents.md) | C++23 | | ||
| `size_type` | [`Extents::size_type`](../extents.md) | C++23 | | ||
| `rank_type` | [`Extents::rank_type`](../extents.md) | C++23 | | ||
| `layout_type` | [`layout_left`](../layout_left.md) | C++23 | | ||
### 比較演算子 | ||
| 名前 | 説明 | 対応バージョン | | ||
|------|------|----------------| | ||
| [`operator==`](mapping/op_equal.md) | 等値比較 | C++23 | | ||
| [`operator!=`](mapping/op_equal.md) | 非等値比較 (`==`により使用可能) | C++23 | | ||
## 例 | ||
```cpp example | ||
#include <mdspan> | ||
#include <iostream> | ||
int main() | ||
{ | ||
double arr[] = {1, 2, 3, 4, 5, 6}; | ||
// 要素数2x3の2次元配列/列優先レイアウト | ||
using Ext2x3 = std::extents<size_t, 2, 3>; | ||
using Mapping = std::layout_left::mapping<Ext2x3>; | ||
std::mdspan mat{arr, Mapping{}}; | ||
for (size_t i = 0; i < mat.extent(0); ++i) { | ||
for (size_t j = 0; j < mat.extent(1); ++j) { | ||
std::cout << (j ? " " : "") << mat[i, j]; | ||
} | ||
std::cout << "\n"; | ||
} | ||
} | ||
``` | ||
* std::layout_left::mapping[color ff0000] | ||
* std::mdspan[link ../mdspan.md] | ||
* std::extents[link ../extents.md] | ||
|
||
### 出力 | ||
``` | ||
1 3 5 | ||
2 4 6 | ||
``` | ||
|
||
|
||
## バージョン | ||
### 言語 | ||
- C++23 | ||
|
||
### 処理系 | ||
- [Clang](/implementation.md#clang): ?? | ||
- [GCC](/implementation.md#gcc): ?? | ||
- [ICC](/implementation.md#icc): ?? | ||
- [Visual C++](/implementation.md#visual_cpp): ?? | ||
|
||
|
||
## 関連項目 | ||
- [`mdspan`](../mdspan.md) | ||
|
||
|
||
## 参照 | ||
- [P0009R18 MDSPAN](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p0009r18.html) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
# operator() | ||
* mdspan[meta header] | ||
* function template[meta id-type] | ||
* std[meta namespace] | ||
* layout_left::mapping[meta class] | ||
* cpp23[meta cpp] | ||
|
||
```cpp | ||
template<class... Indices> | ||
constexpr index_type operator()(Indices... i) const noexcept; | ||
``` | ||
## 概要 | ||
多次元インデクス値`i...`に対応する要素位置を求める。 | ||
## テンプレートパラメータ制約 | ||
- `sizeof...(Indices) ==` [`extents_tyoe::rank()`](../../extents/rank.md)が`true`、かつ | ||
- `(`[`is_convertible_v`](/reference/type_traits/is_convertible.md)`<Indices, index_type> && ...)`が`true`、かつ | ||
- `(`[`is_nothrow_constructible_v`](/reference/type_traits/is_nothrow_constructible.md)`<index_type, Indices> && ...)`が`true`であること。 | ||
## 事前条件 | ||
多次元インデクス値[`extents_type::index-cast(i)`](../../extents/index-cast.md)は、多次元配列サイズ`extents_`における有効なインデクスであること。 | ||
## 戻り値 | ||
説明用のパラメータパック`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`となるとき、以下と等価。 | ||
```cpp | ||
return ((static_cast<index_type>(Indices...) * stride(P)) + ... + 0); | ||
``` | ||
* stride[link stride.md] | ||
|
||
|
||
## 例外 | ||
投げない | ||
|
||
|
||
## 例 | ||
```cpp example | ||
#include <cassert> | ||
#include <mdspan> | ||
|
||
int main() | ||
{ | ||
using Ext3x4 = std::extents<size_t, 3, 4>; | ||
using Mapping3x4 = std::layout_left::mapping<Ext3x4>; | ||
Mapping3x4 map; | ||
assert(map(0,0) == 0); | ||
assert(map(0,1) == 3); | ||
assert(map(1,0) == 1); | ||
assert(map(2,3) == 11); | ||
} | ||
``` | ||
* std::extents[link ../../extents.md] | ||
* std::layout_left::mapping[link ../mapping.md] | ||
|
||
### 出力 | ||
``` | ||
``` | ||
|
||
|
||
## バージョン | ||
### 言語 | ||
- C++23 | ||
|
||
### 処理系 | ||
- [Clang](/implementation.md#clang): ?? | ||
- [GCC](/implementation.md#gcc): ?? | ||
- [ICC](/implementation.md#icc): ?? | ||
- [Visual C++](/implementation.md#visual_cpp): ?? | ||
|
||
|
||
## 参照 | ||
- [P0009R18 MDSPAN](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p0009r18.html) |
Oops, something went wrong.