-
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.
linalg: conjugated,conjugate_transposed(#1233)
- Loading branch information
Showing
12 changed files
with
410 additions
and
19 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,30 @@ | ||
# conj-if-needed | ||
* lingalg[meta header] | ||
* function[meta id-type] | ||
* std::linalg[meta namespace] | ||
* cpp26[meta cpp] | ||
|
||
## 概要 | ||
`conj-if-needed`は、[`std::complex`](/reference/complex/complex.md)などの複素数型に対して複素共役を求める、説明専用の関数オブジェクトである。 | ||
|
||
型`T`の式`E`に対して、式`conj-if-needed(E)`は次と等価である。 | ||
|
||
- `T`が算術型かつ式`conj(E)`が下記宣言を含むコンテキストにおいてオーバーロード解決を行った結果が妥当であるとき、`conj(E)` | ||
```cpp | ||
template<class T> T conj(const T&) = delete; | ||
``` | ||
|
||
- そうでなければ、`E` | ||
|
||
|
||
## 備考 | ||
オーバーロード解決により選択された関数が入力値の複素共役(complex conjugate)を返さないとき、プログラムは不適格となる。 | ||
|
||
|
||
## バージョン | ||
### 言語 | ||
- C++26 | ||
|
||
|
||
## 参照 | ||
- [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,80 @@ | ||
# conjugate_transposed | ||
* linalg[meta header] | ||
* function template[meta id-type] | ||
* std::linalg[meta namespace] | ||
* cpp26[meta cpp] | ||
|
||
```cpp | ||
namespace std::linalg { | ||
template<class ElementType, class Extents, class Layout, class Accessor> | ||
constexpr auto conjugate_transposed(mdspan<ElementType, Extents, Layout, Accessor> a); | ||
} | ||
``` | ||
* Extents[link /reference/mdspan/extents.md] | ||
* Layout[link /reference/mdspan/LayoutMappingPolicy.md] | ||
* Accessor[link /reference/mdspan/AccessorPolicy.md] | ||
* mdspan[link /reference/mdspan/mdspan.md] | ||
## 概要 | ||
行列(matrix)を表現する2次元配列ビュー[`std::mdspan`](/reference/mdspan/mdspan.md)に対して、共役転置(conjugate transpose)を表現する新しい2次元配列ビューを作る。 | ||
本操作により`mdspan`参照先メモリブロックが書き換えられることはなく、戻り値`mdspan`を介した要素アクセス時に共役転置変換が行われる。 | ||
## 効果 | ||
以下と等価。 | ||
```cpp | ||
return conjugated(transposed(a)); | ||
``` | ||
* conjugated[link conjugated.md] | ||
* transposed[link transposed.md] | ||
|
||
|
||
## 例 | ||
```cpp example | ||
#include <cassert> | ||
#include <complex> | ||
#include <linalg> | ||
#include <mdspan> | ||
|
||
int main() | ||
{ | ||
std::complex<double> arr[] = {{1, 1}, {2, 2}, {3, 3}, {4, 4}}; | ||
std::mdspan mat0{arr, 2, 2}; | ||
// 1+i 2+2i | ||
// 3+3i 4+4i | ||
|
||
auto mat1 = std::linalg::conjugate_transposed(mat0); | ||
// 1-i 3-3i | ||
// 2-2i 4-4i | ||
assert(imag(mat1[1, 0]) == -3); | ||
|
||
// linalg::conjugate_transposed適用後のmdspan要素は読み取り専用となり、 | ||
// 例えば mat1[0] = {0, 0}; はコンパイルエラーを引き起こす。 | ||
} | ||
``` | ||
* std::linalg::conjugate_transposed[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,91 @@ | ||
# conjugated | ||
* linalg[meta header] | ||
* function template[meta id-type] | ||
* std::linalg[meta namespace] | ||
* cpp26[meta cpp] | ||
|
||
```cpp | ||
namespace std::linalg { | ||
template<class ElementType, class Extents, class Layout, class Accessor> | ||
constexpr auto conjugated(mdspan<ElementType, Extents, Layout, Accessor> a); | ||
} | ||
``` | ||
* 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`を介した要素アクセス時に複素共役変換が行われる。 | ||
## 戻り値 | ||
- `Accessor`が[`conjugated_accessor`](conjugated_accessor.md)の特殊化のとき、説明用の型`A`を[`remove_cvref_t`](/reference/type_traits/remove_cvref.md)`<decltype(a.accessor().nested_accessor())>`として、 | ||
```cpp | ||
mdspan<typename A::element_type, Extents, Layout, A>( | ||
a.data_handle(), a.mapping(), a.accessor().nested_accessor()) | ||
``` | ||
* mdspan[link /reference/mdspan/mdspan.md] | ||
* Extents[link /reference/mdspan/extents.md] | ||
* Layout[link /reference/mdspan/LayoutMappingPolicy.md] | ||
|
||
- そうではないとき、説明用の型`A`を[`conjugated_accessor`](conjugated_accessor.md)`<Accessor>`として、 | ||
|
||
```cpp | ||
mdspan<typename A::element_type, Extents, Layout, A>( | ||
a.data_handle(), a.mapping(), conjugated_accessor(a.accessor())) | ||
``` | ||
* mdspan[link /reference/mdspan/mdspan.md] | ||
* Extents[link /reference/mdspan/extents.md] | ||
* Layout[link /reference/mdspan/LayoutMappingPolicy.md] | ||
|
||
|
||
## 例 | ||
```cpp example | ||
#include <cassert> | ||
#include <complex> | ||
#include <linalg> | ||
#include <mdspan> | ||
|
||
int main() | ||
{ | ||
std::complex<double> arr[] = {{1, 1}, {2, 2}, {3, 3}}; | ||
std::mdspan vec0{arr, 3}; | ||
// 1+i 2+2i 3+3i | ||
|
||
auto vec1 = std::linalg::conjugated(vec0); | ||
// 1-i 2-2i 3-3i | ||
assert(real(vec1[0]) == 1 && imag(vec1[0]) == -1); | ||
|
||
// linalg::conjugated適用後のmdspan要素は読み取り専用となり、 | ||
// 例えば vec1[0] = {4, 4}; はコンパイルエラーを引き起こす。 | ||
} | ||
``` | ||
* std::linalg::conjugated[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,74 @@ | ||
# conjugated_accessor | ||
* linalg[meta header] | ||
* class template[meta id-type] | ||
* std::linalg[meta namespace] | ||
* cpp26[meta cpp] | ||
|
||
```cpp | ||
namespace std::linalg { | ||
template< class NestedAccessor> | ||
class conjugated_accessor; | ||
} | ||
``` | ||
* NestedAccessor[link /reference/mdspan/AccessorPolicy.md] | ||
## 概要 | ||
`conjugated_accessor`は、多次元配列ビュー[`mdspan`](/reference/mdspan/mdspan.md)の全要素を複素共役した多次元配列ビューを表現する[アクセサポリシー](/reference/mdspan/AccessorPolicy.md)クラスである。 | ||
`conjugated_accessor`クラステンプレートは、複素共役操作[`conjugated`](conjugated.md)の戻り値型として利用される。 | ||
戻り値`mdspad`の要素型は読み取り専用となる。 | ||
### 説明専用メンバ | ||
`conjugated_accessor`クラステンプレートは、下記の説明専用メンバ変数を保持する。 | ||
- `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` | ||
- `NestedAccessor`が[アクセサポリシー](/reference/mdspan/AccessorPolicy.md)要件を満たす | ||
## メンバ関数 | ||
| 名前 | 説明 | 対応バージョン | | ||
|------|------|----------------| | ||
| [`(constructor)`](conjugated_accessor/op_constructor.md) | コンストラクタ | C++26 | | ||
| `(destructor)` | デストラクタ | C++26 | | ||
| [`access`](conjugated_accessor/access.md) | 指定オフセット位置にある要素へアクセスする | C++26 | | ||
| [`offset`](conjugated_accessor/offset.md) | 指定オフセット位置のハンドルを取得する | C++26 | | ||
| `nested_accessor` | 入れ子アクセサポリシー`nested-accessor_`を取得する | C++26 | | ||
## メンバ型 | ||
| 名前 | 説明 | 対応バージョン | | ||
|------|------|----------------| | ||
| `element_type` | [`add_const_t`](/reference/type_traits/add_const.md)`<decltype(`[`conj-if-needed`](conj-if-needed.md)`(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` | `conjugated_accessor<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) | ||
- [`conjugated`](conjugated.md) | ||
- [`conjugate_transposed`](conjugate_transposed.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] | ||
* conjugated_accessor[meta class] | ||
* cpp26[meta cpp] | ||
|
||
```cpp | ||
constexpr reference access(data_handle_type p, size_t i) const; | ||
``` | ||
## 概要 | ||
指定オフセット位置にある要素へアクセスする。 | ||
## 戻り値 | ||
[`conj-if-needed`](../conj-if-needed.md)`(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] | ||
* conjugated_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) |
Oops, something went wrong.