Skip to content

Commit 93c8059

Browse files
committed
linalg : apply_givens_rotationを追加。
Signed-off-by: Yuya Asano <64895419+sukeya@users.noreply.github.com>
1 parent dc5973f commit 93c8059

File tree

3 files changed

+204
-0
lines changed

3 files changed

+204
-0
lines changed
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
# apply_givens_rotation
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-vector InOutVec1,
13+
inout-vector InOutVec2,
14+
class Real>
15+
void apply_givens_rotation(
16+
InOutVec1 x,
17+
InOutVec2 y,
18+
Real c,
19+
Real s); // (1)
20+
21+
template<class ExecutionPolicy,
22+
inout-vector InOutVec1,
23+
inout-vector InOutVec2,
24+
class Real>
25+
void apply_givens_rotation(
26+
ExecutionPolicy&& exec,
27+
InOutVec1 x,
28+
InOutVec2 y,
29+
Real c,
30+
Real s); // (2)
31+
32+
template<inout-vector InOutVec1,
33+
inout-vector InOutVec2,
34+
class Real>
35+
void apply_givens_rotation(
36+
InOutVec1 x,
37+
InOutVec2 y,
38+
Real c,
39+
complex<Real> s); // (3)
40+
41+
template<class ExecutionPolicy,
42+
inout-vector InOutVec1,
43+
inout-vector InOutVec2,
44+
class Real>
45+
void apply_givens_rotation(
46+
ExecutionPolicy&& exec,
47+
InOutVec1 x,
48+
InOutVec2 y,
49+
Real c,
50+
complex<Real> s); // (4)
51+
}
52+
```
53+
54+
55+
## 概要
56+
`c`と`s`で指定された回転行列を2つの**行**ベクトル`x`と`y`に対して、次のように掛けて代入する。
57+
$$
58+
\begin{pmatrix}
59+
\mathbf{x} \\
60+
\mathbf{y}
61+
\end{pmatrix}
62+
\leftarrow
63+
\begin{pmatrix}
64+
c & s\\
65+
-\overline{s} & c
66+
\end{pmatrix}
67+
\begin{pmatrix}
68+
\mathbf{x} \\
69+
\mathbf{y}
70+
\end{pmatrix}
71+
$$
72+
73+
74+
## 適格要件
75+
- [`compatible-static-extents`](/reference/linalg/compatible-static-extents.md)`<InOutVec1, InOutVec2>(0,0) == true`
76+
77+
78+
## 事前条件
79+
- `x.extent(0) == y.extent(0)`
80+
- $c^2 + |s|^2 = 1$
81+
82+
83+
## 効果
84+
`c`と`s`で指定された回転を行ベクトル`x`と`y`がこの順に隣り合うとして行う。
85+
86+
- (1): 実回転行列に対して逐次実行する。
87+
- (2): 実回転行列に対して、指定された実行ポリシーに応じて実行する。
88+
- (3): `s`が複素数の回転行列に対して逐次実行する。
89+
- (4): `s`が複素数の回転行列に対して、指定された実行ポリシーに応じて実行する。
90+
91+
92+
## 戻り値
93+
なし
94+
95+
96+
## 例
97+
98+
99+
### 出力
100+
101+
102+
## バージョン
103+
### 言語
104+
- C++26
105+
106+
### 処理系
107+
- [Clang](/implementation.md#clang): ??
108+
- [GCC](/implementation.md#gcc): ??
109+
- [ICC](/implementation.md#icc): ??
110+
- [Visual C++](/implementation.md#visual_cpp): ??
111+
112+
113+
## 関連項目
114+
- [`execution`](/reference/execution.md)
115+
116+
117+
## 参照
118+
- [P0788R3 Standard Library Specification in a Concepts and Contracts World](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0788r3.pdf)
119+
- [`LAPACK: crot`](https://netlib.org/lapack/explore-html/d1/d45/group__rot_ga25544801d45dcabdec7b24d863ebea9c.html#ga25544801d45dcabdec7b24d863ebea9c)
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# compatible-static-extents
2+
3+
* linalg[meta header]
4+
* function template[meta id-type]
5+
* std::linalg[meta namespace]
6+
* cpp26[meta cpp]
7+
8+
9+
```cpp
10+
namespace std::linalg {
11+
template<class MDS1, class MDS2>
12+
requires(is-mdspan<MDS1> && is-mdspan<MDS2>)
13+
constexpr bool compatible-static-extents(size_t r1, size_t r2)
14+
{
15+
return MDS1::static_extent(r1) == dynamic_extent ||
16+
MDS2::static_extent(r2) == dynamic_extent ||
17+
MDS1::static_extent(r1) == MDS2::static_extent(r2);
18+
}
19+
}
20+
```
21+
* is-mdspan[link /reference/linalg/is_mdspan.md]
22+
23+
24+
## 概要
25+
左の`mdspan`の`r1`番目の静的要素数と右の`mdspan`の`r2`番目の静的要素数に互換性があるかどうかを返す、説明専用の関数である。
26+
27+
28+
## テンプレートパラメータ制約
29+
- `MDS1`と`MDS2`が両方とも`mdspan`であること。
30+
31+
32+
## 戻り値
33+
左の`mdspan`の`r1`番目の静的要素数と右の`mdspan`の`r2`番目の静的要素数に互換性がある場合、`true`を返す。そうでない場合は、`false`を返す。
34+
35+
36+
## バージョン
37+
### 言語
38+
- C++26
39+
40+
41+
## 関連項目
42+
- [`mdspan`](/reference/mdspan.md)
43+
44+
45+
## 参照
46+
- [P1673R13 A free function linear algebra interface based on the BLAS](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p1673r13.html)

reference/linalg/is_mdspan.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# is-mdspan
2+
3+
* linalg[meta header]
4+
* function template[meta id-type]
5+
* std::linalg[meta namespace]
6+
* cpp26[meta cpp]
7+
8+
9+
```cpp
10+
namespace std::linalg {
11+
template<class T>
12+
constexpr bool is-mdspan = false;
13+
14+
template<class ElementType, class Extents, class Layout, class Accessor>
15+
constexpr bool is-mdspan<mdspan<ElementType, Extents, Layout, Accessor>> = true;
16+
}
17+
```
18+
19+
20+
## 概要
21+
与えられた型が[`mdspan`](/reference/mdspan.md)かどうかを表す、説明専用の定数である。
22+
23+
24+
## 戻り値
25+
与えられた型が`mdspan`の場合、`true`を返す。そうでない場合は、`false`を返す。
26+
27+
28+
## バージョン
29+
### 言語
30+
- C++26
31+
32+
33+
## 関連項目
34+
- [`mdspan`](/reference/mdspan.md)
35+
36+
37+
## 参照
38+
- [P1673R13 A free function linear algebra interface based on the BLAS](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p1673r13.html)
39+

0 commit comments

Comments
 (0)