]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/multiprecision/test/ublas_interop/test32.cpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / libs / multiprecision / test / ublas_interop / test32.cpp
CommitLineData
7c673cae
FG
1//
2// Copyright (c) 2000-2002
3// Joerg Walter, Mathias Koch
4//
5// Distributed under the Boost Software License, Version 1.0. (See
6// accompanying file LICENSE_1_0.txt or copy at
7// http://www.boost.org/LICENSE_1_0.txt)
8//
9// The authors gratefully acknowledge the support of
10// GeNeSys mbH & Co. KG in producing this work.
11//
12
92f5a8d4
TL
13#if defined(__GNUC__) && (__GNUC__ >= 9)
14#pragma GCC diagnostic ignored "-Wdeprecated-copy"
15#endif
16
7c673cae
FG
17#include "test3.hpp"
18
19// Test matrix & vector expression templates
92f5a8d4
TL
20template <class V, class M, int N>
21struct test_my_matrix_vector
22{
23 typedef typename V::value_type value_type;
24
25 template <class VP, class MP>
26 void test_with(VP& v1, VP& v2, MP& m1) const
27 {
28 {
29 // Rows and columns
30 initialize_matrix(m1);
31 for (int i = 0; i < N; ++i)
32 {
33 v1 = ublas::row(m1, i);
34 std::cout << "row (m, " << i << ") = " << v1 << std::endl;
35 v1 = ublas::column(m1, i);
36 std::cout << "column (m, " << i << ") = " << v1 << std::endl;
37 }
38
39 // Outer product
40 initialize_vector(v1);
41 initialize_vector(v2);
42 m1 = ublas::outer_prod(v1, v2);
43 std::cout << "outer_prod (v1, v2) = " << m1 << std::endl;
44
45 // Matrix vector product
46 initialize_matrix(m1);
47 initialize_vector(v1);
48 v2 = ublas::prod(m1, v1);
49 std::cout << "prod (m1, v1) = " << v2 << std::endl;
50 v2 = ublas::prod(v1, m1);
51 std::cout << "prod (v1, m1) = " << v2 << std::endl;
52 }
53 }
54 void operator()() const
55 {
56 {
57 V v1(N, N), v2(N, N);
58 M m1(N, N, N * N);
59
60 test_with(v1, v2, m1);
61
62 ublas::matrix_row<M> mr1(m1, 0), mr2(m1, N - 1);
63 test_with(mr1, mr2, m1);
64
65 ublas::matrix_column<M> mc1(m1, 0), mc2(m1, N - 1);
66 test_with(mc1, mc2, m1);
7c673cae
FG
67
68#ifdef USE_RANGE
92f5a8d4
TL
69 ublas::matrix_vector_range<M> mvr1(m1, ublas::range(0, N), ublas::range(0, N)),
70 mvr2(m1, ublas::range(0, N), ublas::range(0, N));
71 test_with(mvr1, mvr2, m1);
7c673cae
FG
72#endif
73
74#ifdef USE_SLICE
92f5a8d4
TL
75 ublas::matrix_vector_slice<M> mvs1(m1, ublas::slice(0, 1, N), ublas::slice(0, 1, N)),
76 mvs2(m1, ublas::slice(0, 1, N), ublas::slice(0, 1, N));
77 test_with(mvs1, mvs2, m1);
7c673cae 78#endif
92f5a8d4
TL
79 }
80 }
7c673cae
FG
81};
82
83// Test matrix & vector
92f5a8d4
TL
84void test_matrix_vector()
85{
86 std::cout << "test_matrix_vector" << std::endl;
7c673cae
FG
87
88#ifdef USE_SPARSE_MATRIX
89#ifdef USE_MAP_ARRAY
90#ifdef USE_FLOAT
92f5a8d4
TL
91 std::cout << "mp_test_type, map_array" << std::endl;
92 test_my_matrix_vector<ublas::mapped_vector<mp_test_type, ublas::map_array<std::size_t, mp_test_type> >,
93 ublas::mapped_matrix<mp_test_type, ublas::row_major, ublas::map_array<std::size_t, mp_test_type> >, 3>()();
7c673cae
FG
94#endif
95
96#ifdef USE_DOUBLE
92f5a8d4
TL
97 std::cout << "double, map_array" << std::endl;
98 test_my_matrix_vector<ublas::mapped_vector<double, ublas::map_array<std::size_t, double> >,
99 ublas::mapped_matrix<double, ublas::row_major, ublas::map_array<std::size_t, double> >, 3>()();
7c673cae
FG
100#endif
101
102#ifdef USE_STD_COMPLEX
103#ifdef USE_FLOAT
92f5a8d4
TL
104 std::cout << "std::complex<mp_test_type>, map_array" << std::endl;
105 test_my_matrix_vector<ublas::mapped_vector<std::complex<mp_test_type>, ublas::map_array<std::size_t, std::complex<mp_test_type> > >,
106 ublas::mapped_matrix<std::complex<mp_test_type>, ublas::row_major, ublas::map_array<std::size_t, std::complex<mp_test_type> > >, 3>()();
7c673cae
FG
107#endif
108
109#ifdef USE_DOUBLE
92f5a8d4
TL
110 std::cout << "std::complex<double>, map_array" << std::endl;
111 test_my_matrix_vector<ublas::mapped_vector<std::complex<double>, ublas::map_array<std::size_t, std::complex<double> > >,
112 ublas::mapped_matrix<std::complex<double>, ublas::row_major, ublas::map_array<std::size_t, std::complex<double> > >, 3>()();
7c673cae
FG
113#endif
114#endif
115#endif
116
117#ifdef USE_STD_MAP
118#ifdef USE_FLOAT
92f5a8d4
TL
119 std::cout << "mp_test_type, std::map" << std::endl;
120 test_my_matrix_vector<ublas::mapped_vector<mp_test_type, std::map<std::size_t, mp_test_type> >,
121 ublas::mapped_matrix<mp_test_type, ublas::row_major, std::map<std::size_t, mp_test_type> >, 3>()();
7c673cae
FG
122#endif
123
124#ifdef USE_DOUBLE
92f5a8d4
TL
125 std::cout << "double, std::map" << std::endl;
126 test_my_matrix_vector<ublas::mapped_vector<double, std::map<std::size_t, double> >,
127 ublas::mapped_matrix<double, ublas::row_major, std::map<std::size_t, double> >, 3>()();
7c673cae
FG
128#endif
129
130#ifdef USE_STD_COMPLEX
131#ifdef USE_FLOAT
92f5a8d4
TL
132 std::cout << "std::complex<mp_test_type>, std::map" << std::endl;
133 test_my_matrix_vector<ublas::mapped_vector<std::complex<mp_test_type>, std::map<std::size_t, std::complex<mp_test_type> > >,
134 ublas::mapped_matrix<std::complex<mp_test_type>, ublas::row_major, std::map<std::size_t, std::complex<mp_test_type> > >, 3>()();
7c673cae
FG
135#endif
136
137#ifdef USE_DOUBLE
92f5a8d4
TL
138 std::cout << "std::complex<double>, std::map" << std::endl;
139 test_my_matrix_vector<ublas::mapped_vector<std::complex<double>, std::map<std::size_t, std::complex<double> > >,
140 ublas::mapped_matrix<std::complex<double>, ublas::row_major, std::map<std::size_t, std::complex<double> > >, 3>()();
7c673cae
FG
141#endif
142#endif
143#endif
144#endif
145
146#ifdef USE_SPARSE_VECTOR_OF_SPARSE_VECTOR
147#ifdef USE_MAP_ARRAY
148#ifdef USE_FLOAT
92f5a8d4
TL
149 std::cout << "mp_test_type, mapped_vector map_array" << std::endl;
150 test_my_matrix_vector<ublas::mapped_vector<mp_test_type, ublas::map_array<std::size_t, mp_test_type> >,
151 ublas::mapped_vector<mp_test_type, ublas::row_major, ublas::map_array<std::size_t, ublas::map_array<std::size_t, mp_test_type> > >, 3>()();
7c673cae
FG
152#endif
153
154#ifdef USE_DOUBLE
92f5a8d4
TL
155 std::cout << "double, mapped_vector map_array" << std::endl;
156 test_my_matrix_vector<ublas::mapped_vector<double, ublas::map_array<std::size_t, double> >,
157 ublas::mapped_vector<double, ublas::row_major, ublas::map_array<std::size_t, ublas::map_array<std::size_t, double> > >, 3>()();
7c673cae
FG
158#endif
159
160#ifdef USE_STD_COMPLEX
161#ifdef USE_FLOAT
92f5a8d4
TL
162 std::cout << "std::complex<mp_test_type>, mapped_vector map_array" << std::endl;
163 test_my_matrix_vector<ublas::mapped_vector<std::complex<mp_test_type>, ublas::map_array<std::size_t, std::complex<mp_test_type> > >,
164 ublas::mapped_vector<std::complex<mp_test_type>, ublas::row_major, ublas::map_array<std::size_t, ublas::map_array<std::size_t, std::complex<mp_test_type> > > >, 3>()();
7c673cae
FG
165#endif
166
167#ifdef USE_DOUBLE
92f5a8d4
TL
168 std::cout << "std::complex<double>,mapped_vector map_array" << std::endl;
169 test_my_matrix_vector<ublas::mapped_vector<std::complex<double>, ublas::map_array<std::size_t, std::complex<double> > >,
170 ublas::mapped_vector<std::complex<double>, ublas::row_major, ublas::map_array<std::size_t, ublas::map_array<std::size_t, std::complex<double> > > >, 3>()();
7c673cae
FG
171#endif
172#endif
173#endif
174
175#ifdef USE_STD_MAP
176#ifdef USE_FLOAT
92f5a8d4
TL
177 std::cout << "mp_test_type, mapped_vector std::map" << std::endl;
178 test_my_matrix_vector<ublas::mapped_vector<mp_test_type, std::map<std::size_t, mp_test_type> >,
179 ublas::mapped_vector<mp_test_type, ublas::row_major, std::map<std::size_t, std::map<std::size_t, mp_test_type> > >, 3>()();
7c673cae
FG
180#endif
181
182#ifdef USE_DOUBLE
92f5a8d4
TL
183 std::cout << "double, mapped_vector std::map" << std::endl;
184 test_my_matrix_vector<ublas::mapped_vector<double, std::map<std::size_t, double> >,
185 ublas::mapped_vector<double, ublas::row_major, std::map<std::size_t, std::map<std::size_t, double> > >, 3>()();
7c673cae
FG
186#endif
187
188#ifdef USE_STD_COMPLEX
189#ifdef USE_FLOAT
92f5a8d4
TL
190 std::cout << "std::complex<mp_test_type>, mapped_vector std::map" << std::endl;
191 test_my_matrix_vector<ublas::mapped_vector<std::complex<mp_test_type>, std::map<std::size_t, std::complex<mp_test_type> > >,
192 ublas::mapped_vector<std::complex<mp_test_type>, ublas::row_major, std::map<std::size_t, std::map<std::size_t, std::complex<mp_test_type> > > >, 3>()();
7c673cae
FG
193#endif
194
195#ifdef USE_DOUBLE
92f5a8d4
TL
196 std::cout << "std::complex<double>, mapped_vector std::map" << std::endl;
197 test_my_matrix_vector<ublas::mapped_vector<std::complex<double>, std::map<std::size_t, std::complex<double> > >,
198 ublas::mapped_vector<std::complex<double>, ublas::row_major, std::map<std::size_t, std::map<std::size_t, std::complex<double> > > >, 3>()();
7c673cae
FG
199#endif
200#endif
201#endif
202#endif
203
204#ifdef USE_GENERALIZED_VECTOR_OF_VECTOR
205#ifdef USE_MAP_ARRAY
206#ifdef USE_FLOAT
92f5a8d4
TL
207 std::cout << "mp_test_type, generalized_vector_of_vector map_array" << std::endl;
208 test_my_matrix_vector<ublas::mapped_vector<mp_test_type, ublas::map_array<std::size_t, mp_test_type> >,
209 ublas::generalized_vector_of_vector<mp_test_type, ublas::row_major, ublas::vector<ublas::mapped_vector<mp_test_type, ublas::map_array<std::size_t, mp_test_type> > > >, 3>()();
210 test_my_matrix_vector<ublas::mapped_vector<mp_test_type, ublas::map_array<std::size_t, mp_test_type> >,
211 ublas::generalized_vector_of_vector<mp_test_type, ublas::row_major, ublas::mapped_vector<ublas::mapped_vector<mp_test_type, ublas::map_array<std::size_t, mp_test_type> >, ublas::map_array<std::size_t, ublas::mapped_vector<mp_test_type, ublas::map_array<std::size_t, mp_test_type> > > > >, 3>()();
7c673cae
FG
212#endif
213
214#ifdef USE_DOUBLE
92f5a8d4
TL
215 std::cout << "double, generalized_vector_of_vector map_array" << std::endl;
216 test_my_matrix_vector<ublas::mapped_vector<double, ublas::map_array<std::size_t, double> >,
217 ublas::generalized_vector_of_vector<double, ublas::row_major, ublas::vector<ublas::mapped_vector<double, ublas::map_array<std::size_t, double> > > >, 3>()();
218 test_my_matrix_vector<ublas::mapped_vector<double, ublas::map_array<std::size_t, double> >,
219 ublas::generalized_vector_of_vector<double, ublas::row_major, ublas::mapped_vector<ublas::mapped_vector<double, ublas::map_array<std::size_t, double> >, ublas::map_array<std::size_t, ublas::mapped_vector<double, ublas::map_array<std::size_t, double> > > > >, 3>()();
7c673cae
FG
220#endif
221
222#ifdef USE_STD_COMPLEX
223#ifdef USE_FLOAT
92f5a8d4
TL
224 std::cout << "std::complex<mp_test_type>, generalized_vector_of_vector map_array" << std::endl;
225 test_my_matrix_vector<ublas::mapped_vector<std::complex<mp_test_type>, ublas::map_array<std::size_t, std::complex<mp_test_type> > >,
226 ublas::generalized_vector_of_vector<std::complex<mp_test_type>, ublas::row_major, ublas::vector<ublas::mapped_vector<std::complex<mp_test_type>, ublas::map_array<std::size_t, std::complex<mp_test_type> > > > >, 3>()();
227 test_my_matrix_vector<ublas::mapped_vector<std::complex<mp_test_type>, ublas::map_array<std::size_t, std::complex<mp_test_type> > >,
228 ublas::generalized_vector_of_vector<std::complex<mp_test_type>, ublas::row_major, ublas::mapped_vector<ublas::mapped_vector<std::complex<mp_test_type>, ublas::map_array<std::size_t, std::complex<mp_test_type> > >, ublas::map_array<std::size_t, ublas::mapped_vector<std::complex<mp_test_type>, ublas::map_array<std::size_t, std::complex<mp_test_type> > > > > >, 3>()();
7c673cae
FG
229#endif
230
231#ifdef USE_DOUBLE
92f5a8d4
TL
232 std::cout << "std::complex<double>, generalized_vector_of_vector map_array" << std::endl;
233 test_my_matrix_vector<ublas::mapped_vector<std::complex<double>, ublas::map_array<std::size_t, std::complex<double> > >,
234 ublas::generalized_vector_of_vector<std::complex<double>, ublas::row_major, ublas::vector<ublas::mapped_vector<std::complex<double>, ublas::map_array<std::size_t, std::complex<double> > > > >, 3>()();
235 test_my_matrix_vector<ublas::mapped_vector<std::complex<double>, ublas::map_array<std::size_t, std::complex<double> > >,
236 ublas::generalized_vector_of_vector<std::complex<double>, ublas::row_major, ublas::mapped_vector<ublas::mapped_vector<std::complex<double>, ublas::map_array<std::size_t, std::complex<double> > >, ublas::map_array<std::size_t, ublas::mapped_vector<std::complex<double>, ublas::map_array<std::size_t, std::complex<double> > > > > >, 3>()();
7c673cae
FG
237#endif
238#endif
239#endif
240
241#ifdef USE_STD_MAP
242#ifdef USE_FLOAT
92f5a8d4
TL
243 std::cout << "mp_test_type, generalized_vector_of_vector std::map" << std::endl;
244 test_my_matrix_vector<ublas::mapped_vector<mp_test_type, std::map<std::size_t, mp_test_type> >,
245 ublas::generalized_vector_of_vector<mp_test_type, ublas::row_major, ublas::vector<ublas::mapped_vector<mp_test_type, std::map<std::size_t, mp_test_type> > > >, 3>()();
246 test_my_matrix_vector<ublas::mapped_vector<mp_test_type, std::map<std::size_t, mp_test_type> >,
247 ublas::generalized_vector_of_vector<mp_test_type, ublas::row_major, ublas::mapped_vector<ublas::mapped_vector<mp_test_type, std::map<std::size_t, mp_test_type> >, std::map<std::size_t, ublas::mapped_vector<mp_test_type, std::map<std::size_t, mp_test_type> > > > >, 3>()();
7c673cae
FG
248#endif
249
250#ifdef USE_DOUBLE
92f5a8d4
TL
251 std::cout << "double, generalized_vector_of_vector std::map" << std::endl;
252 test_my_matrix_vector<ublas::mapped_vector<double, std::map<std::size_t, double> >,
253 ublas::generalized_vector_of_vector<double, ublas::row_major, ublas::vector<ublas::mapped_vector<double, std::map<std::size_t, double> > > >, 3>()();
254 test_my_matrix_vector<ublas::mapped_vector<double, std::map<std::size_t, double> >,
255 ublas::generalized_vector_of_vector<double, ublas::row_major, ublas::mapped_vector<ublas::mapped_vector<double, std::map<std::size_t, double> >, std::map<std::size_t, ublas::mapped_vector<double, std::map<std::size_t, double> > > > >, 3>()();
7c673cae
FG
256#endif
257
258#ifdef USE_STD_COMPLEX
259#ifdef USE_FLOAT
92f5a8d4
TL
260 std::cout << "std::complex<mp_test_type>, generalized_vector_of_vector std::map" << std::endl;
261 test_my_matrix_vector<ublas::mapped_vector<std::complex<mp_test_type>, std::map<std::size_t, std::complex<mp_test_type> > >,
262 ublas::generalized_vector_of_vector<std::complex<mp_test_type>, ublas::row_major, ublas::vector<ublas::mapped_vector<std::complex<mp_test_type>, std::map<std::size_t, std::complex<mp_test_type> > > > >, 3>()();
263 test_my_matrix_vector<ublas::mapped_vector<std::complex<mp_test_type>, std::map<std::size_t, std::complex<mp_test_type> > >,
264 ublas::generalized_vector_of_vector<std::complex<mp_test_type>, ublas::row_major, ublas::mapped_vector<ublas::mapped_vector<std::complex<mp_test_type>, std::map<std::size_t, std::complex<mp_test_type> > >, std::map<std::size_t, ublas::mapped_vector<std::complex<mp_test_type>, std::map<std::size_t, std::complex<mp_test_type> > > > > >, 3>()();
7c673cae
FG
265#endif
266
267#ifdef USE_DOUBLE
92f5a8d4
TL
268 std::cout << "std::complex<double>, generalized_vector_of_vector std::map" << std::endl;
269 test_my_matrix_vector<ublas::mapped_vector<std::complex<double>, std::map<std::size_t, std::complex<double> > >,
270 ublas::generalized_vector_of_vector<std::complex<double>, ublas::row_major, ublas::vector<ublas::mapped_vector<std::complex<double>, std::map<std::size_t, std::complex<double> > > > >, 3>()();
271 test_my_matrix_vector<ublas::mapped_vector<std::complex<double>, std::map<std::size_t, std::complex<double> > >,
272 ublas::generalized_vector_of_vector<std::complex<double>, ublas::row_major, ublas::mapped_vector<ublas::mapped_vector<std::complex<double>, std::map<std::size_t, std::complex<double> > >, std::map<std::size_t, ublas::mapped_vector<std::complex<double>, std::map<std::size_t, std::complex<double> > > > > >, 3>()();
7c673cae
FG
273#endif
274#endif
275#endif
276#endif
277
278#ifdef USE_COMPRESSED_MATRIX
279#ifdef USE_FLOAT
92f5a8d4
TL
280 std::cout << "mp_test_type compressed" << std::endl;
281 test_my_matrix_vector<ublas::compressed_vector<mp_test_type>,
282 ublas::compressed_matrix<mp_test_type>, 3>()();
7c673cae
FG
283#endif
284
285#ifdef USE_DOUBLE
92f5a8d4
TL
286 std::cout << "double compressed" << std::endl;
287 test_my_matrix_vector<ublas::compressed_vector<double>,
288 ublas::compressed_matrix<double>, 3>()();
7c673cae
FG
289#endif
290
291#ifdef USE_STD_COMPLEX
292#ifdef USE_FLOAT
92f5a8d4
TL
293 std::cout << "std::complex<mp_test_type> compressed" << std::endl;
294 test_my_matrix_vector<ublas::compressed_vector<std::complex<mp_test_type> >,
295 ublas::compressed_matrix<std::complex<mp_test_type> >, 3>()();
7c673cae
FG
296#endif
297
298#ifdef USE_DOUBLE
92f5a8d4
TL
299 std::cout << "std::complex<double> compressed" << std::endl;
300 test_my_matrix_vector<ublas::compressed_vector<std::complex<double> >,
301 ublas::compressed_matrix<std::complex<double> >, 3>()();
7c673cae
FG
302#endif
303#endif
304#endif
305
306#ifdef USE_COORDINATE_MATRIX
307#ifdef USE_FLOAT
92f5a8d4
TL
308 std::cout << "mp_test_type coordinate" << std::endl;
309 test_my_matrix_vector<ublas::coordinate_vector<mp_test_type>,
310 ublas::coordinate_matrix<mp_test_type>, 3>()();
7c673cae
FG
311#endif
312
313#ifdef USE_DOUBLE
92f5a8d4
TL
314 std::cout << "double coordinate" << std::endl;
315 test_my_matrix_vector<ublas::coordinate_vector<double>,
316 ublas::coordinate_matrix<double>, 3>()();
7c673cae
FG
317#endif
318
319#ifdef USE_STD_COMPLEX
320#ifdef USE_FLOAT
92f5a8d4
TL
321 std::cout << "std::complex<mp_test_type> coordinate" << std::endl;
322 test_my_matrix_vector<ublas::coordinate_vector<std::complex<mp_test_type> >,
323 ublas::coordinate_matrix<std::complex<mp_test_type> >, 3>()();
7c673cae
FG
324#endif
325
326#ifdef USE_DOUBLE
92f5a8d4
TL
327 std::cout << "std::complex<double> coordinate" << std::endl;
328 test_my_matrix_vector<ublas::coordinate_vector<std::complex<double> >,
329 ublas::coordinate_matrix<std::complex<double> >, 3>()();
7c673cae
FG
330#endif
331#endif
332#endif
333}