| 1 | // |
|---|
| 2 | // Copyright (c) 2000-2002 |
|---|
| 3 | // Joerg Walter, Mathias Koch |
|---|
| 4 | // |
|---|
| 5 | // Permission to use, copy, modify, distribute and sell this software |
|---|
| 6 | // and its documentation for any purpose is hereby granted without fee, |
|---|
| 7 | // provided that the above copyright notice appear in all copies and |
|---|
| 8 | // that both that copyright notice and this permission notice appear |
|---|
| 9 | // in supporting documentation. The authors make no representations |
|---|
| 10 | // about the suitability of this software for any purpose. |
|---|
| 11 | // It is provided "as is" without express or implied warranty. |
|---|
| 12 | // |
|---|
| 13 | // The authors gratefully acknowledge the support of |
|---|
| 14 | // GeNeSys mbH & Co. KG in producing this work. |
|---|
| 15 | // |
|---|
| 16 | |
|---|
| 17 | #include "bench1.hpp" |
|---|
| 18 | |
|---|
| 19 | template<class T, int N> |
|---|
| 20 | struct bench_c_outer_prod { |
|---|
| 21 | typedef T value_type; |
|---|
| 22 | |
|---|
| 23 | void operator () (int runs) const { |
|---|
| 24 | try { |
|---|
| 25 | static typename c_matrix_traits<T, N, N>::type m; |
|---|
| 26 | static typename c_vector_traits<T, N>::type v1, v2; |
|---|
| 27 | initialize_c_vector<T, N> () (v1); |
|---|
| 28 | initialize_c_vector<T, N> () (v2); |
|---|
| 29 | boost::timer t; |
|---|
| 30 | for (int i = 0; i < runs; ++ i) { |
|---|
| 31 | for (int j = 0; j < N; ++ j) { |
|---|
| 32 | for (int k = 0; k < N; ++ k) { |
|---|
| 33 | m [j] [k] = - v1 [j] * v2 [k]; |
|---|
| 34 | } |
|---|
| 35 | } |
|---|
| 36 | // sink_c_matrix<T, N, N> () (m); |
|---|
| 37 | } |
|---|
| 38 | footer<value_type> () (N * N, N * N, runs, t.elapsed ()); |
|---|
| 39 | } |
|---|
| 40 | catch (std::exception &e) { |
|---|
| 41 | std::cout << e.what () << std::endl; |
|---|
| 42 | } |
|---|
| 43 | } |
|---|
| 44 | }; |
|---|
| 45 | template<class M, class V, int N> |
|---|
| 46 | struct bench_my_outer_prod { |
|---|
| 47 | typedef typename M::value_type value_type; |
|---|
| 48 | |
|---|
| 49 | void operator () (int runs, safe_tag) const { |
|---|
| 50 | try { |
|---|
| 51 | static M m (N, N); |
|---|
| 52 | static V v1 (N), v2 (N); |
|---|
| 53 | initialize_vector (v1); |
|---|
| 54 | initialize_vector (v2); |
|---|
| 55 | boost::timer t; |
|---|
| 56 | for (int i = 0; i < runs; ++ i) { |
|---|
| 57 | m = - ublas::outer_prod (v1, v2); |
|---|
| 58 | // sink_matrix (m); |
|---|
| 59 | } |
|---|
| 60 | footer<value_type> () (N * N, N * N, runs, t.elapsed ()); |
|---|
| 61 | } |
|---|
| 62 | catch (std::exception &e) { |
|---|
| 63 | std::cout << e.what () << std::endl; |
|---|
| 64 | } |
|---|
| 65 | } |
|---|
| 66 | void operator () (int runs, fast_tag) const { |
|---|
| 67 | try { |
|---|
| 68 | static M m (N, N); |
|---|
| 69 | static V v1 (N), v2 (N); |
|---|
| 70 | initialize_vector (v1); |
|---|
| 71 | initialize_vector (v2); |
|---|
| 72 | boost::timer t; |
|---|
| 73 | for (int i = 0; i < runs; ++ i) { |
|---|
| 74 | m.assign (- ublas::outer_prod (v1, v2)); |
|---|
| 75 | // sink_matrix (m); |
|---|
| 76 | } |
|---|
| 77 | footer<value_type> () (N * N, N * N, runs, t.elapsed ()); |
|---|
| 78 | } |
|---|
| 79 | catch (std::exception &e) { |
|---|
| 80 | std::cout << e.what () << std::endl; |
|---|
| 81 | } |
|---|
| 82 | } |
|---|
| 83 | }; |
|---|
| 84 | template<class M, class V, int N> |
|---|
| 85 | struct bench_cpp_outer_prod { |
|---|
| 86 | typedef typename M::value_type value_type; |
|---|
| 87 | |
|---|
| 88 | void operator () (int runs) const { |
|---|
| 89 | try { |
|---|
| 90 | static M m (N * N); |
|---|
| 91 | static V v1 (N), v2 (N); |
|---|
| 92 | initialize_vector (v1); |
|---|
| 93 | initialize_vector (v2); |
|---|
| 94 | boost::timer t; |
|---|
| 95 | for (int i = 0; i < runs; ++ i) { |
|---|
| 96 | for (int j = 0; j < N; ++ j) { |
|---|
| 97 | for (int k = 0; k < N; ++ k) { |
|---|
| 98 | m [N * j + k] = - v1 [j] * v2 [k]; |
|---|
| 99 | } |
|---|
| 100 | } |
|---|
| 101 | // sink_vector (m); |
|---|
| 102 | } |
|---|
| 103 | footer<value_type> () (N * N, N * N, runs, t.elapsed ()); |
|---|
| 104 | } |
|---|
| 105 | catch (std::exception &e) { |
|---|
| 106 | std::cout << e.what () << std::endl; |
|---|
| 107 | } |
|---|
| 108 | } |
|---|
| 109 | }; |
|---|
| 110 | |
|---|
| 111 | template<class T, int N> |
|---|
| 112 | struct bench_c_matrix_vector_prod { |
|---|
| 113 | typedef T value_type; |
|---|
| 114 | |
|---|
| 115 | void operator () (int runs) const { |
|---|
| 116 | try { |
|---|
| 117 | static typename c_matrix_traits<T, N, N>::type m; |
|---|
| 118 | static typename c_vector_traits<T, N>::type v1, v2; |
|---|
| 119 | initialize_c_matrix<T, N, N> () (m); |
|---|
| 120 | initialize_c_vector<T, N> () (v1); |
|---|
| 121 | boost::timer t; |
|---|
| 122 | for (int i = 0; i < runs; ++ i) { |
|---|
| 123 | for (int j = 0; j < N; ++ j) { |
|---|
| 124 | v2 [j] = 0; |
|---|
| 125 | for (int k = 0; k < N; ++ k) { |
|---|
| 126 | v2 [j] += m [j] [k] * v1 [k]; |
|---|
| 127 | } |
|---|
| 128 | } |
|---|
| 129 | // sink_c_vector<T, N> () (v2); |
|---|
| 130 | } |
|---|
| 131 | footer<value_type> () (N * N, N * (N - 1), runs, t.elapsed ()); |
|---|
| 132 | } |
|---|
| 133 | catch (std::exception &e) { |
|---|
| 134 | std::cout << e.what () << std::endl; |
|---|
| 135 | } |
|---|
| 136 | } |
|---|
| 137 | }; |
|---|
| 138 | template<class M, class V, int N> |
|---|
| 139 | struct bench_my_matrix_vector_prod { |
|---|
| 140 | typedef typename M::value_type value_type; |
|---|
| 141 | |
|---|
| 142 | void operator () (int runs, safe_tag) const { |
|---|
| 143 | try { |
|---|
| 144 | static M m (N, N); |
|---|
| 145 | static V v1 (N), v2 (N); |
|---|
| 146 | initialize_matrix (m); |
|---|
| 147 | initialize_vector (v1); |
|---|
| 148 | boost::timer t; |
|---|
| 149 | for (int i = 0; i < runs; ++ i) { |
|---|
| 150 | v2 = ublas::prod (m, v1); |
|---|
| 151 | // sink_vector (v2); |
|---|
| 152 | } |
|---|
| 153 | footer<value_type> () (N * N, N * (N - 1), runs, t.elapsed ()); |
|---|
| 154 | } |
|---|
| 155 | catch (std::exception &e) { |
|---|
| 156 | std::cout << e.what () << std::endl; |
|---|
| 157 | } |
|---|
| 158 | } |
|---|
| 159 | void operator () (int runs, fast_tag) const { |
|---|
| 160 | try { |
|---|
| 161 | static M m (N, N); |
|---|
| 162 | static V v1 (N), v2 (N); |
|---|
| 163 | initialize_matrix (m); |
|---|
| 164 | initialize_vector (v1); |
|---|
| 165 | boost::timer t; |
|---|
| 166 | for (int i = 0; i < runs; ++ i) { |
|---|
| 167 | v2.assign (ublas::prod (m, v1)); |
|---|
| 168 | // sink_vector (v2); |
|---|
| 169 | } |
|---|
| 170 | footer<value_type> () (N * N, N * (N - 1), runs, t.elapsed ()); |
|---|
| 171 | } |
|---|
| 172 | catch (std::exception &e) { |
|---|
| 173 | std::cout << e.what () << std::endl; |
|---|
| 174 | } |
|---|
| 175 | } |
|---|
| 176 | }; |
|---|
| 177 | template<class M, class V, int N> |
|---|
| 178 | struct bench_cpp_matrix_vector_prod { |
|---|
| 179 | typedef typename M::value_type value_type; |
|---|
| 180 | |
|---|
| 181 | void operator () (int runs) const { |
|---|
| 182 | try { |
|---|
| 183 | static M m (N * N); |
|---|
| 184 | static V v1 (N), v2 (N); |
|---|
| 185 | initialize_vector (m); |
|---|
| 186 | initialize_vector (v1); |
|---|
| 187 | boost::timer t; |
|---|
| 188 | for (int i = 0; i < runs; ++ i) { |
|---|
| 189 | for (int j = 0; j < N; ++ j) { |
|---|
| 190 | std::valarray<value_type> row (m [std::slice (N * j, N, 1)]); |
|---|
| 191 | v2 [j] = (row * v1).sum (); |
|---|
| 192 | } |
|---|
| 193 | // sink_vector (v2); |
|---|
| 194 | } |
|---|
| 195 | footer<value_type> () (N * N, N * (N - 1), runs, t.elapsed ()); |
|---|
| 196 | } |
|---|
| 197 | catch (std::exception &e) { |
|---|
| 198 | std::cout << e.what () << std::endl; |
|---|
| 199 | } |
|---|
| 200 | } |
|---|
| 201 | }; |
|---|
| 202 | |
|---|
| 203 | template<class T, int N> |
|---|
| 204 | struct bench_c_matrix_add { |
|---|
| 205 | typedef T value_type; |
|---|
| 206 | |
|---|
| 207 | void operator () (int runs) const { |
|---|
| 208 | try { |
|---|
| 209 | static typename c_matrix_traits<T, N, N>::type m1, m2, m3; |
|---|
| 210 | initialize_c_matrix<T, N, N> () (m1); |
|---|
| 211 | initialize_c_matrix<T, N, N> () (m2); |
|---|
| 212 | boost::timer t; |
|---|
| 213 | for (int i = 0; i < runs; ++ i) { |
|---|
| 214 | for (int j = 0; j < N; ++ j) { |
|---|
| 215 | for (int k = 0; k < N; ++ k) { |
|---|
| 216 | m3 [j] [k] = - (m1 [j] [k] + m2 [j] [k]); |
|---|
| 217 | } |
|---|
| 218 | } |
|---|
| 219 | // sink_c_matrix<T, N, N> () (m3); |
|---|
| 220 | } |
|---|
| 221 | footer<value_type> () (0, 2 * N * N, runs, t.elapsed ()); |
|---|
| 222 | } |
|---|
| 223 | catch (std::exception &e) { |
|---|
| 224 | std::cout << e.what () << std::endl; |
|---|
| 225 | } |
|---|
| 226 | } |
|---|
| 227 | }; |
|---|
| 228 | template<class M, int N> |
|---|
| 229 | struct bench_my_matrix_add { |
|---|
| 230 | typedef typename M::value_type value_type; |
|---|
| 231 | |
|---|
| 232 | void operator () (int runs, safe_tag) const { |
|---|
| 233 | try { |
|---|
| 234 | static M m1 (N, N), m2 (N, N), m3 (N, N); |
|---|
| 235 | initialize_matrix (m1); |
|---|
| 236 | initialize_matrix (m2); |
|---|
| 237 | boost::timer t; |
|---|
| 238 | for (int i = 0; i < runs; ++ i) { |
|---|
| 239 | m3 = - (m1 + m2); |
|---|
| 240 | // sink_matrix (m3); |
|---|
| 241 | } |
|---|
| 242 | footer<value_type> () (0, 2 * N * N, runs, t.elapsed ()); |
|---|
| 243 | } |
|---|
| 244 | catch (std::exception &e) { |
|---|
| 245 | std::cout << e.what () << std::endl; |
|---|
| 246 | } |
|---|
| 247 | } |
|---|
| 248 | void operator () (int runs, fast_tag) const { |
|---|
| 249 | try { |
|---|
| 250 | static M m1 (N, N), m2 (N, N), m3 (N, N); |
|---|
| 251 | initialize_matrix (m1); |
|---|
| 252 | initialize_matrix (m2); |
|---|
| 253 | boost::timer t; |
|---|
| 254 | for (int i = 0; i < runs; ++ i) { |
|---|
| 255 | m3.assign (- (m1 + m2)); |
|---|
| 256 | // sink_matrix (m3); |
|---|
| 257 | } |
|---|
| 258 | footer<value_type> () (0, 2 * N * N, runs, t.elapsed ()); |
|---|
| 259 | } |
|---|
| 260 | catch (std::exception &e) { |
|---|
| 261 | std::cout << e.what () << std::endl; |
|---|
| 262 | } |
|---|
| 263 | } |
|---|
| 264 | }; |
|---|
| 265 | template<class M, int N> |
|---|
| 266 | struct bench_cpp_matrix_add { |
|---|
| 267 | typedef typename M::value_type value_type; |
|---|
| 268 | |
|---|
| 269 | void operator () (int runs) const { |
|---|
| 270 | try { |
|---|
| 271 | static M m1 (N * N), m2 (N * N), m3 (N * N); |
|---|
| 272 | initialize_vector (m1); |
|---|
| 273 | initialize_vector (m2); |
|---|
| 274 | boost::timer t; |
|---|
| 275 | for (int i = 0; i < runs; ++ i) { |
|---|
| 276 | m3 = - (m1 + m2); |
|---|
| 277 | // sink_vector (m3); |
|---|
| 278 | } |
|---|
| 279 | footer<value_type> () (0, 2 * N * N, runs, t.elapsed ()); |
|---|
| 280 | } |
|---|
| 281 | catch (std::exception &e) { |
|---|
| 282 | std::cout << e.what () << std::endl; |
|---|
| 283 | } |
|---|
| 284 | } |
|---|
| 285 | }; |
|---|
| 286 | |
|---|
| 287 | // Benchmark O (n ^ 2) |
|---|
| 288 | template<class T, int N> |
|---|
| 289 | void bench_2<T, N>::operator () (int runs) { |
|---|
| 290 | header ("bench_2"); |
|---|
| 291 | |
|---|
| 292 | header ("outer_prod"); |
|---|
| 293 | |
|---|
| 294 | header ("C array"); |
|---|
| 295 | bench_c_outer_prod<T, N> () (runs); |
|---|
| 296 | |
|---|
| 297 | #ifdef USE_C_ARRAY |
|---|
| 298 | header ("c_matrix, c_vector safe"); |
|---|
| 299 | bench_my_outer_prod<ublas::c_matrix<T, N, N>, |
|---|
| 300 | ublas::c_vector<T, N>, N> () (runs, safe_tag ()); |
|---|
| 301 | |
|---|
| 302 | header ("c_matrix, c_vector fast"); |
|---|
| 303 | bench_my_outer_prod<ublas::c_matrix<T, N, N>, |
|---|
| 304 | ublas::c_vector<T, N>, N> () (runs, fast_tag ()); |
|---|
| 305 | #endif |
|---|
| 306 | |
|---|
| 307 | #ifdef USE_BOUNDED_ARRAY |
|---|
| 308 | header ("matrix<bounded_array>, vector<bounded_array> safe"); |
|---|
| 309 | bench_my_outer_prod<ublas::matrix<T, ublas::row_major, ublas::bounded_array<T, N * N> >, |
|---|
| 310 | ublas::vector<T, ublas::bounded_array<T, N> >, N> () (runs, safe_tag ()); |
|---|
| 311 | |
|---|
| 312 | header ("matrix<bounded_array>, vector<bounded_array> fast"); |
|---|
| 313 | bench_my_outer_prod<ublas::matrix<T, ublas::row_major, ublas::bounded_array<T, N * N> >, |
|---|
| 314 | ublas::vector<T, ublas::bounded_array<T, N> >, N> () (runs, fast_tag ()); |
|---|
| 315 | #endif |
|---|
| 316 | |
|---|
| 317 | #ifdef USE_UNBOUNDED_ARRAY |
|---|
| 318 | header ("matrix<unbounded_array>, vector<unbounded_array> safe"); |
|---|
| 319 | bench_my_outer_prod<ublas::matrix<T, ublas::row_major, ublas::unbounded_array<T> >, |
|---|
| 320 | ublas::vector<T, ublas::unbounded_array<T> >, N> () (runs, safe_tag ()); |
|---|
| 321 | |
|---|
| 322 | header ("matrix<unbounded_array>, vector<unbounded_array> fast"); |
|---|
| 323 | bench_my_outer_prod<ublas::matrix<T, ublas::row_major, ublas::unbounded_array<T> >, |
|---|
| 324 | ublas::vector<T, ublas::unbounded_array<T> >, N> () (runs, fast_tag ()); |
|---|
| 325 | #endif |
|---|
| 326 | |
|---|
| 327 | #ifdef USE_STD_VALARRAY |
|---|
| 328 | header ("matrix<std::valarray>, vector<std::valarray> safe"); |
|---|
| 329 | bench_my_outer_prod<ublas::matrix<T, ublas::row_major, std::valarray<T> >, |
|---|
| 330 | ublas::vector<T, std::valarray<T> >, N> () (runs, safe_tag ()); |
|---|
| 331 | |
|---|
| 332 | header ("matrix<std::valarray>, vector<std::valarray> fast"); |
|---|
| 333 | bench_my_outer_prod<ublas::matrix<T, ublas::row_major, std::valarray<T> >, |
|---|
| 334 | ublas::vector<T, std::valarray<T> >, N> () (runs, fast_tag ()); |
|---|
| 335 | #endif |
|---|
| 336 | |
|---|
| 337 | #ifdef USE_STD_VECTOR |
|---|
| 338 | header ("matrix<std::vector>, vector<std::vector> safe"); |
|---|
| 339 | bench_my_outer_prod<ublas::matrix<T, ublas::row_major, std::vector<T> >, |
|---|
| 340 | ublas::vector<T, std::vector<T> >, N> () (runs, safe_tag ()); |
|---|
| 341 | |
|---|
| 342 | header ("matrix<std::vector>, vector<std::vector> fast"); |
|---|
| 343 | bench_my_outer_prod<ublas::matrix<T, ublas::row_major, std::vector<T> >, |
|---|
| 344 | ublas::vector<T, std::vector<T> >, N> () (runs, fast_tag ()); |
|---|
| 345 | #endif |
|---|
| 346 | |
|---|
| 347 | #ifdef USE_STD_VALARRAY |
|---|
| 348 | header ("std::valarray"); |
|---|
| 349 | bench_cpp_outer_prod<std::valarray<T>, std::valarray<T>, N> () (runs); |
|---|
| 350 | #endif |
|---|
| 351 | |
|---|
| 352 | header ("prod (matrix, vector)"); |
|---|
| 353 | |
|---|
| 354 | header ("C array"); |
|---|
| 355 | bench_c_matrix_vector_prod<T, N> () (runs); |
|---|
| 356 | |
|---|
| 357 | #ifdef USE_C_ARRAY |
|---|
| 358 | header ("c_matrix, c_vector safe"); |
|---|
| 359 | bench_my_matrix_vector_prod<ublas::c_matrix<T, N, N>, |
|---|
| 360 | ublas::c_vector<T, N>, N> () (runs, safe_tag ()); |
|---|
| 361 | |
|---|
| 362 | header ("c_matrix, c_vector fast"); |
|---|
| 363 | bench_my_matrix_vector_prod<ublas::c_matrix<T, N, N>, |
|---|
| 364 | ublas::c_vector<T, N>, N> () (runs, fast_tag ()); |
|---|
| 365 | #endif |
|---|
| 366 | |
|---|
| 367 | #ifdef USE_BOUNDED_ARRAY |
|---|
| 368 | header ("matrix<bounded_array>, vector<bounded_array> safe"); |
|---|
| 369 | bench_my_matrix_vector_prod<ublas::matrix<T, ublas::row_major, ublas::bounded_array<T, N * N> >, |
|---|
| 370 | ublas::vector<T, ublas::bounded_array<T, N> >, N> () (runs, safe_tag ()); |
|---|
| 371 | |
|---|
| 372 | header ("matrix<bounded_array>, vector<bounded_array> fast"); |
|---|
| 373 | bench_my_matrix_vector_prod<ublas::matrix<T, ublas::row_major, ublas::bounded_array<T, N * N> >, |
|---|
| 374 | ublas::vector<T, ublas::bounded_array<T, N> >, N> () (runs, fast_tag ()); |
|---|
| 375 | #endif |
|---|
| 376 | |
|---|
| 377 | #ifdef USE_UNBOUNDED_ARRAY |
|---|
| 378 | header ("matrix<unbounded_array>, vector<unbounded_array> safe"); |
|---|
| 379 | bench_my_matrix_vector_prod<ublas::matrix<T, ublas::row_major, ublas::unbounded_array<T> >, |
|---|
| 380 | ublas::vector<T, ublas::unbounded_array<T> >, N> () (runs, safe_tag ()); |
|---|
| 381 | |
|---|
| 382 | header ("matrix<unbounded_array>, vector<unbounded_array> fast"); |
|---|
| 383 | bench_my_matrix_vector_prod<ublas::matrix<T, ublas::row_major, ublas::unbounded_array<T> >, |
|---|
| 384 | ublas::vector<T, ublas::unbounded_array<T> >, N> () (runs, fast_tag ()); |
|---|
| 385 | #endif |
|---|
| 386 | |
|---|
| 387 | #ifdef USE_STD_VALARRAY |
|---|
| 388 | header ("matrix<std::valarray>, vector<std::valarray> safe"); |
|---|
| 389 | bench_my_matrix_vector_prod<ublas::matrix<T, ublas::row_major, std::valarray<T> >, |
|---|
| 390 | ublas::vector<T, std::valarray<T> >, N> () (runs, safe_tag ()); |
|---|
| 391 | |
|---|
| 392 | header ("matrix<std::valarray>, vector<std::valarray> fast"); |
|---|
| 393 | bench_my_matrix_vector_prod<ublas::matrix<T, ublas::row_major, std::valarray<T> >, |
|---|
| 394 | ublas::vector<T, std::valarray<T> >, N> () (runs, fast_tag ()); |
|---|
| 395 | #endif |
|---|
| 396 | |
|---|
| 397 | #ifdef USE_STD_VECTOR |
|---|
| 398 | header ("matrix<std::vector>, vector<std::vector> safe"); |
|---|
| 399 | bench_my_matrix_vector_prod<ublas::matrix<T, ublas::row_major, std::vector<T> >, |
|---|
| 400 | ublas::vector<T, std::vector<T> >, N> () (runs, safe_tag ()); |
|---|
| 401 | |
|---|
| 402 | header ("matrix<std::vector>, vector<std::vector> fast"); |
|---|
| 403 | bench_my_matrix_vector_prod<ublas::matrix<T, ublas::row_major, std::vector<T> >, |
|---|
| 404 | ublas::vector<T, std::vector<T> >, N> () (runs, fast_tag ()); |
|---|
| 405 | #endif |
|---|
| 406 | |
|---|
| 407 | #ifdef USE_STD_VALARRAY |
|---|
| 408 | header ("std::valarray"); |
|---|
| 409 | bench_cpp_matrix_vector_prod<std::valarray<T>, std::valarray<T>, N> () (runs); |
|---|
| 410 | #endif |
|---|
| 411 | |
|---|
| 412 | header ("matrix + matrix"); |
|---|
| 413 | |
|---|
| 414 | header ("C array"); |
|---|
| 415 | bench_c_matrix_add<T, N> () (runs); |
|---|
| 416 | |
|---|
| 417 | #ifdef USE_C_ARRAY |
|---|
| 418 | header ("c_matrix safe"); |
|---|
| 419 | bench_my_matrix_add<ublas::c_matrix<T, N, N>, N> () (runs, safe_tag ()); |
|---|
| 420 | |
|---|
| 421 | header ("c_matrix fast"); |
|---|
| 422 | bench_my_matrix_add<ublas::c_matrix<T, N, N>, N> () (runs, fast_tag ()); |
|---|
| 423 | #endif |
|---|
| 424 | |
|---|
| 425 | #ifdef USE_BOUNDED_ARRAY |
|---|
| 426 | header ("matrix<bounded_array> safe"); |
|---|
| 427 | bench_my_matrix_add<ublas::matrix<T, ublas::row_major, ublas::bounded_array<T, N * N> >, N> () (runs, safe_tag ()); |
|---|
| 428 | |
|---|
| 429 | header ("matrix<bounded_array> fast"); |
|---|
| 430 | bench_my_matrix_add<ublas::matrix<T, ublas::row_major, ublas::bounded_array<T, N * N> >, N> () (runs, fast_tag ()); |
|---|
| 431 | #endif |
|---|
| 432 | |
|---|
| 433 | #ifdef USE_UNBOUNDED_ARRAY |
|---|
| 434 | header ("matrix<unbounded_array> safe"); |
|---|
| 435 | bench_my_matrix_add<ublas::matrix<T, ublas::row_major, ublas::unbounded_array<T> >, N> () (runs, safe_tag ()); |
|---|
| 436 | |
|---|
| 437 | header ("matrix<unbounded_array> fast"); |
|---|
| 438 | bench_my_matrix_add<ublas::matrix<T, ublas::row_major, ublas::unbounded_array<T> >, N> () (runs, fast_tag ()); |
|---|
| 439 | #endif |
|---|
| 440 | |
|---|
| 441 | #ifdef USE_STD_VALARRAY |
|---|
| 442 | header ("matrix<std::valarray> safe"); |
|---|
| 443 | bench_my_matrix_add<ublas::matrix<T, ublas::row_major, std::valarray<T> >, N> () (runs, safe_tag ()); |
|---|
| 444 | |
|---|
| 445 | header ("matrix<std::valarray> fast"); |
|---|
| 446 | bench_my_matrix_add<ublas::matrix<T, ublas::row_major, std::valarray<T> >, N> () (runs, fast_tag ()); |
|---|
| 447 | #endif |
|---|
| 448 | |
|---|
| 449 | #ifdef USE_STD_VECTOR |
|---|
| 450 | header ("matrix<std::vector> safe"); |
|---|
| 451 | bench_my_matrix_add<ublas::matrix<T, ublas::row_major, std::vector<T> >, N> () (runs, safe_tag ()); |
|---|
| 452 | |
|---|
| 453 | header ("matrix<std::vector> fast"); |
|---|
| 454 | bench_my_matrix_add<ublas::matrix<T, ublas::row_major, std::vector<T> >, N> () (runs, fast_tag ()); |
|---|
| 455 | #endif |
|---|
| 456 | |
|---|
| 457 | #ifdef USE_STD_VALARRAY |
|---|
| 458 | header ("std::valarray"); |
|---|
| 459 | bench_cpp_matrix_add<std::valarray<T>, N> () (runs); |
|---|
| 460 | #endif |
|---|
| 461 | } |
|---|
| 462 | |
|---|
| 463 | #ifdef USE_FLOAT |
|---|
| 464 | template struct bench_2<float, 3>; |
|---|
| 465 | template struct bench_2<float, 10>; |
|---|
| 466 | template struct bench_2<float, 30>; |
|---|
| 467 | template struct bench_2<float, 100>; |
|---|
| 468 | #endif |
|---|
| 469 | |
|---|
| 470 | #ifdef USE_DOUBLE |
|---|
| 471 | template struct bench_2<double, 3>; |
|---|
| 472 | template struct bench_2<double, 10>; |
|---|
| 473 | template struct bench_2<double, 30>; |
|---|
| 474 | template struct bench_2<double, 100>; |
|---|
| 475 | #endif |
|---|
| 476 | |
|---|
| 477 | #ifdef USE_STD_COMPLEX |
|---|
| 478 | #ifdef USE_FLOAT |
|---|
| 479 | template struct bench_2<std::complex<float>, 3>; |
|---|
| 480 | template struct bench_2<std::complex<float>, 10>; |
|---|
| 481 | template struct bench_2<std::complex<float>, 30>; |
|---|
| 482 | template struct bench_2<std::complex<float>, 100>; |
|---|
| 483 | #endif |
|---|
| 484 | |
|---|
| 485 | #ifdef USE_DOUBLE |
|---|
| 486 | template struct bench_2<std::complex<double>, 3>; |
|---|
| 487 | template struct bench_2<std::complex<double>, 10>; |
|---|
| 488 | template struct bench_2<std::complex<double>, 30>; |
|---|
| 489 | template struct bench_2<std::complex<double>, 100>; |
|---|
| 490 | #endif |
|---|
| 491 | #endif |
|---|