Skip to content

Commit f90532b

Browse files
committed
linalg : copyに例を追加 (#1233)
Signed-off-by: Yuya Asano <64895419+sukeya@users.noreply.github.com>
1 parent 9f61fd2 commit f90532b

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

reference/linalg/copy.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,58 @@ namespace std::linalg {
5757
5858
5959
## 例
60+
**[注意] 処理系にあるコンパイラで確認していないため、間違っているかもしれません。**
61+
62+
```cpp example
63+
#include <cmath>
64+
#include <execution>
65+
#include <iostream>
66+
#include <linalg>
67+
#include <mdspan>
68+
#include <vector>
69+
70+
71+
template <class Vector>
72+
bool IsEqual(Vector a, Vector b) {
73+
if (a.extent(0) != b.extent(0)) {
74+
return false;
75+
}
76+
for (int i = 0; i < a.extent(0); ++i) {
77+
if (a[i] != b[i]) {
78+
return false;
79+
}
80+
}
81+
return true;
82+
}
83+
84+
85+
int main()
86+
{
87+
constexpr size_t N = 3;
88+
89+
std::vector<double> a_vec({1, 2, 3});
90+
std::mdspan a(a_vec.data(), N);
91+
92+
std::vector<double> b_vec(N);
93+
std::mdspan b(b_vec.data(), N);
94+
95+
// (1)
96+
std::linalg::copy(a, b);
97+
assert(IsEqual(a, b));
98+
99+
// (2)
100+
std::linalg::copy(std::execution::par, a, b);
101+
assert(IsEqual(a, b));
102+
103+
return 0;
104+
}
105+
```
106+
* std::linalg::copy[color ff0000]
60107

61108

62109
### 出力
110+
```
111+
```
63112

64113

65114
## バージョン

0 commit comments

Comments
 (0)