File tree Expand file tree Collapse file tree 1 file changed +47
-0
lines changed
Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Original file line number Diff line number Diff line change @@ -68,9 +68,56 @@ $x + y$ を`z`に代入する。
6868
6969
7070## 例
71+ **[注意] 処理系にあるコンパイラで確認していないため、間違っているかもしれません。**
72+
73+ ```cpp example
74+ #include <cmath>
75+ #include <execution>
76+ #include <iostream>
77+ #include <linalg>
78+ #include <mdspan>
79+ #include <vector>
80+
81+ template <class Vector>
82+ void print(Vector v) {
83+ for (int i = 0; i < v.extent(0) - 1; ++i) {
84+ std::cout << v[i] << ', ';
85+ }
86+ std::cout << v[v.extent(0) - 1] << std::endl;
87+ }
88+
89+ int main()
90+ {
91+ constexpr size_t N = 3;
92+
93+ std::vector<double> a_vec({1, 2, 3});
94+ std::mdspan a(a_vec.data(), N);
95+
96+ std::vector<double> b_vec({4, 5, 6});
97+ std::mdspan b(b_vec.data(), N);
98+
99+ std::vector<double> c_vec(N);
100+ std::mdspan c(c_vec.data(), N);
101+
102+ // (1)
103+ std::linalg::add(a, b, c);
104+ print(c);
105+
106+ // (2)
107+ std::linalg::add(std::execution::par, a, b, c);
108+ print(c);
109+
110+ return 0;
111+ }
112+ ```
113+ * std::linalg::add[ color ff0000]
71114
72115
73116### 出力
117+ ```
118+ 5, 7, 9
119+ 5, 7, 9
120+ ```
74121
75122
76123## バージョン
You can’t perform that action at this time.
0 commit comments