-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
265 additions
and
2 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,79 @@ | ||
# scaled | ||
* linalg[meta header] | ||
* function template[meta id-type] | ||
* std::linalg[meta namespace] | ||
* cpp26[meta cpp] | ||
|
||
```cpp | ||
template<class ScalingFactor, | ||
class ElementType, class Extents, class Layout, class Accessor> | ||
constexpr auto scaled(ScalingFactor alpha, mdspan<ElementType, Extents, Layout, Accessor> x); | ||
``` | ||
* Extents[link /reference/mdspan/extents.md] | ||
* Layout[link /reference/mdspan/LayoutMappingPolicy.md] | ||
* Accessor[link /reference/mdspan/AccessorPolicy.md] | ||
* mdspan[link /reference/mdspan/mdspan.md] | ||
## 概要 | ||
多次元配列ビュー[`std::mdspan`](/reference/mdspan/mdspan.md)に対して、要素値がスカラー倍された新しい多次元配列ビューを作る。 | ||
本操作により`mdspan`参照先メモリブロックが書き換えられることはなく、戻り値`mdspan`を介した要素アクセス時にスケーリング係数の乗算が行われる。 | ||
## 戻り値 | ||
説明用の型`SA`を[`scaled_accessor`](scaled_accessor.md)`<ScalingFactor, Accessor>`として、次の値を返す。 | ||
```cpp | ||
mdspan<typename SA::element_type, Extents, Layout, SA>( | ||
x.data_handle(), x.mapping(), SA(alpha, x.accessor())) | ||
``` | ||
* mdspan[link /reference/mdspan/mdspan.md] | ||
* Extents[link /reference/mdspan/extents.md] | ||
* Layout[link /reference/mdspan/LayoutMappingPolicy.md] | ||
|
||
|
||
## 例 | ||
```cpp example | ||
#include <cassert> | ||
#include <linalg> | ||
#include <mdspan> | ||
|
||
int main() | ||
{ | ||
int arr[] = {1, 2, 3, 4}; | ||
std::mdspan vec0{arr, std::extents<size_t, 4>{}}; | ||
// 1 2 3 4 | ||
|
||
auto vec1 = std::linalg::scaled(2, vec0); | ||
// 2 4 6 8 | ||
assert(vec1[0] == 2); | ||
|
||
// linalg::scaled適用後のmdspan要素は読み取り専用となため、 | ||
// 例えば vec1[0] == 42; はコンパイルエラーを引き起こす。 | ||
} | ||
``` | ||
* std::linalg::scaled[color ff0000] | ||
|
||
### 出力 | ||
``` | ||
``` | ||
|
||
|
||
## バージョン | ||
### 言語 | ||
- C++26 | ||
|
||
### 処理系 | ||
- [Clang](/implementation.md#clang): ?? | ||
- [GCC](/implementation.md#gcc): ?? | ||
- [ICC](/implementation.md#icc): ?? | ||
- [Visual C++](/implementation.md#visual_cpp): ?? | ||
|
||
|
||
## 関連項目 | ||
- [`mdspan`](/reference/mdspan/mdspan.md) | ||
|
||
|
||
## 参照 | ||
- [P1673R13 A free function linear algebra interface based on the BLAS](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p1673r13.html) | ||
- [P1674R2: Evolving a Standard C++ Linear Algebra Library from the BLAS](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p1674r2.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 @@ | ||
# scaled_accessor | ||
* linalg[meta header] | ||
* class template[meta id-type] | ||
* std::linalg[meta namespace] | ||
* cpp26[meta cpp] | ||
|
||
```cpp | ||
namespace std::linalg { | ||
template<class ScalingFactor, class NestedAccessor> | ||
class scaled_accessor; | ||
} | ||
``` | ||
* NestedAccessor[link /reference/mdspan/AccessorPolicy.md] | ||
## 概要 | ||
`scaled_accessor`は、多次元配列ビュー[`mdspan`](/reference/mdspan/mdspan.md)の全要素をスカラー倍した多次元配列ビューを表現する[アクセサポリシー](/reference/mdspan/AccessorPolicy.md)クラスである。 | ||
`scaled_accessor`クラステンプレートは、要素スカラー倍操作[`scaled`](scaled.md)の戻り値型として利用される。 | ||
戻り値`mdspad`の要素型は読み取り専用となる。 | ||
### 説明専用メンバ | ||
`scaled_accessor`クラステンプレートは、下記の説明専用メンバ変数を保持する。 | ||
- `scaling-factor` : `ScalingFactor`型のスケーリング係数 | ||
- `nested-accessor` : `NestedAccessor`型の入れ子アクセサポリシー | ||
## 適格要件 | ||
- `element_type`が適格な型であること | ||
- [`is_copy_constructible_v`](/reference/type_traits/is_copy_constructible.md)`<reference> == true` | ||
- [`is_reference_v`](/reference/type_traits/is_reference.md)`<element_type> == false` | ||
- `ScalingFactor`が[`semiregular`](/reference/concepts/semiregular.md)のモデルであること | ||
- `NestedAccessor`が[アクセサポリシー](/reference/mdspan/AccessorPolicy.md)要件を満たす | ||
## メンバ関数 | ||
| 名前 | 説明 | 対応バージョン | | ||
|------|------|----------------| | ||
| [`(constructor)`](scaled_accessor/op_constructor.md) | コンストラクタ | C++26 | | ||
| `(destructor)` | デストラクタ | C++26 | | ||
| [`access`](scaled_accessor/access.md) | 指定オフセット位置にある要素へアクセスする | C++26 | | ||
| [`offset`](scaled_accessor/offset.md) | 指定オフセット位置のハンドルを取得する | C++26 | | ||
| `scaling_factor` | スケーリング係数`scaling-factor`を取得する | C++26 | | ||
| `nested_accessor` | 入れ子アクセサポリシー`nested-accessor`を取得する | C++26 | | ||
## メンバ型 | ||
| 名前 | 説明 | 対応バージョン | | ||
|------|------|----------------| | ||
| `element_type` | [`add_const_t`](/reference/type_traits/add_const.md)`<decltype(declval<ScalingFactor>() * declval<NestedAccessor::element_type>())>` | C++26 | | ||
| `reference` | [`remove_const_t`](/reference/type_traits/remove_const.md)`<element_type>` | C++26 | | ||
| `data_handle_type` | `NestedAccessor::data_handle_type` | C++26 | | ||
| `offset_policy` | `scaled_accessor<ScalingFactor, NestedAccessor::offset_policy>` | C++26 | | ||
## バージョン | ||
### 言語 | ||
- C++26 | ||
### 処理系 | ||
- [Clang](/implementation.md#clang): ?? | ||
- [GCC](/implementation.md#gcc): ?? | ||
- [ICC](/implementation.md#icc): ?? | ||
- [Visual C++](/implementation.md#visual_cpp): ?? | ||
## 関連項目 | ||
- [`mdspan`](/reference/mdspan/mdspan.md) | ||
- [`scaled`](scaled.md) | ||
## 参照 | ||
- [P1673R13 A free function linear algebra interface based on the BLAS](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p1673r13.html) | ||
- [P1674R2: Evolving a Standard C++ Linear Algebra Library from the BLAS](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p1674r2.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,32 @@ | ||
# acccess | ||
* linalg[meta header] | ||
* function[meta id-type] | ||
* std::linalg[meta namespace] | ||
* scaled_accessor[meta class] | ||
* cpp26[meta cpp] | ||
|
||
```cpp | ||
constexpr reference access(data_handle_type p, size_t i) const; | ||
``` | ||
## 概要 | ||
指定オフセット位置にある要素へアクセスする。 | ||
## 戻り値 | ||
`scaling_factor() * NestedAccessor::element_type(nested-accessor.access(p, i))` | ||
## バージョン | ||
### 言語 | ||
- C++26 | ||
### 処理系 | ||
- [Clang](/implementation.md#clang): ?? | ||
- [GCC](/implementation.md#gcc): ?? | ||
- [ICC](/implementation.md#icc): ?? | ||
- [Visual C++](/implementation.md#visual_cpp): ?? | ||
## 参照 | ||
- [P1673R13 A free function linear algebra interface based on the BLAS](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p1673r13.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,32 @@ | ||
# offset | ||
* linalg[meta header] | ||
* function[meta id-type] | ||
* std::linalg[meta namespace] | ||
* scaled_accessor[meta class] | ||
* cpp26[meta cpp] | ||
|
||
```cpp | ||
constexpr offset_policy::data_handle_type offset(data_handle_type p, size_t i) const; | ||
``` | ||
## 概要 | ||
指定オフセット位置のハンドルを取得する。 | ||
## 戻り値 | ||
`nested-accessor.offset(p, i)` | ||
## バージョン | ||
### 言語 | ||
- C++26 | ||
### 処理系 | ||
- [Clang](/implementation.md#clang): ?? | ||
- [GCC](/implementation.md#gcc): ?? | ||
- [ICC](/implementation.md#icc): ?? | ||
- [Visual C++](/implementation.md#visual_cpp): ?? | ||
## 参照 | ||
- [P1673R13 A free function linear algebra interface based on the BLAS](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p1673r13.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,44 @@ | ||
# コンストラクタ | ||
* linalg[meta header] | ||
* function[meta id-type] | ||
* std::linalg[meta namespace] | ||
* scaled_accessor[meta class] | ||
* cpp26[meta cpp] | ||
|
||
```cpp | ||
constexpr scaled_accessor() = default; // (1) | ||
|
||
template<class OtherNestedAccessor> | ||
explicit(!is_convertible_v<OtherNestedAccessor, NestedAccessor>) | ||
constexpr scaled_accessor(const scaled_accessor<ScalingFactor, OtherNestedAccessor>& other); // (2) | ||
|
||
constexpr scaled_accessor(const ScalingFactor& s, const NestedAccessor& a); // (3) | ||
``` | ||
* is_convertible_v[link /reference/type_traits/is_convertible.md] | ||
* NestedAccessor[link /reference/mdspan/AccessorPolicy.md] | ||
* OtherNestedAccessor[link /reference/mdspan/AccessorPolicy.md] | ||
## 概要 | ||
- (1) : デフォルトコンストラクタ | ||
- (2) : 他`scaled_accessor`からの変換コンストラクタ | ||
- (3) : `ScalingFactor`と`NestedAccessor`から構築 | ||
## 効果 | ||
- (2) : `scaling-factor`を`other.scaling_factor()`で、`nested-accessor`を`other.nested_accessor()`で直接非リスト初期化する。 | ||
- (3) : `scaling-factor`を`s`で、`nested-accessor`を`a`で直接非リスト初期化する。 | ||
## バージョン | ||
### 言語 | ||
- C++26 | ||
### 処理系 | ||
- [Clang](/implementation.md#clang): ?? | ||
- [GCC](/implementation.md#gcc): ?? | ||
- [ICC](/implementation.md#icc): ?? | ||
- [Visual C++](/implementation.md#visual_cpp): ?? | ||
## 参照 | ||
- [P1673R13 A free function linear algebra interface based on the BLAS](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p1673r13.html) |