// // Copyright (c) 2000-2002 // Joerg Walter, Mathias Koch // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // // The authors gratefully acknowledge the support of // GeNeSys mbH & Co. KG in producing this work. // #ifndef BENCH2_H #define BENCH2_H #include #include #include #include #include #include #include #include #define BOOST_UBLAS_NOT_USED(x) (void)(x) namespace ublas = boost::numeric::ublas; void header (std::string text); template struct footer { void operator () (int multiplies, int plus, int runs, double elapsed) { std::cout << "elapsed: " << elapsed << " s, " << (multiplies * ublas::type_traits::multiplies_complexity + plus * ublas::type_traits::plus_complexity) * runs / (1024 * 1024 * elapsed) << " Mflops" << std::endl; } }; template struct c_vector_traits { typedef T type [N]; }; template struct c_matrix_traits { typedef T type [N] [M]; }; template struct initialize_c_vector { void operator () (typename c_vector_traits::type &v) { for (int i = 0; i < N; ++ i) v [i] = std::rand () * 1.f; // v [i] = 0.f; } }; template BOOST_UBLAS_INLINE void initialize_vector (V &v) { int size = v.size (); for (int i = 0; i < size; ++ i) v [i] = std::rand () * 1.f; // v [i] = 0.f; } template struct initialize_c_matrix { void operator () (typename c_matrix_traits::type &m) { for (int i = 0; i < N; ++ i) for (int j = 0; j < M; ++ j) m [i] [j] = std::rand () * 1.f; // m [i] [j] = 0.f; } }; template BOOST_UBLAS_INLINE void initialize_matrix (M &m, ublas::row_major_tag) { int size1 = m.size1 (); int size2 = m.size2 (); for (int i = 0; i < size1; ++ i) for (int j = 0; j < size2; ++ j) m (i, j) = std::rand () * 1.f; // m (i, j) = 0.f; } template BOOST_UBLAS_INLINE void initialize_matrix (M &m, ublas::column_major_tag) { int size1 = m.size1 (); int size2 = m.size2 (); for (int j = 0; j < size2; ++ j) for (int i = 0; i < size1; ++ i) m (i, j) = std::rand () * 1.f; // m (i, j) = 0.f; } template BOOST_UBLAS_INLINE void initialize_matrix (M &m) { typedef typename M::orientation_category orientation_category; initialize_matrix (m, orientation_category ()); } template BOOST_UBLAS_INLINE void sink_scalar (const T &s) { static T g_s = s; } template struct sink_c_vector { void operator () (const typename c_vector_traits::type &v) { static typename c_vector_traits::type g_v; for (int i = 0; i < N; ++ i) g_v [i] = v [i]; } }; template BOOST_UBLAS_INLINE void sink_vector (const V &v) { static V g_v (v); } template struct sink_c_matrix { void operator () (const typename c_matrix_traits::type &m) { static typename c_matrix_traits::type g_m; for (int i = 0; i < N; ++ i) for (int j = 0; j < M; ++ j) g_m [i] [j] = m [i] [j]; } }; template BOOST_UBLAS_INLINE void sink_matrix (const M &m) { static M g_m (m); } template struct peak { void operator () (int runs); }; template struct bench_1 { void operator () (int runs); }; template struct bench_2 { void operator () (int runs); }; template struct bench_3 { void operator () (int runs); }; struct safe_tag {}; struct fast_tag {}; // #define USE_FLOAT #define USE_DOUBLE // #define USE_STD_COMPLEX #define USE_MAP_ARRAY // #define USE_STD_MAP // #define USE_STD_VALARRAY #define USE_MAPPED_VECTOR #define USE_COMPRESSED_VECTOR #define USE_COORDINATE_VECTOR #define USE_MAPPED_MATRIX // #define USE_SPARSE_VECTOR_OF_SPARSE_VECTOR #define USE_COMPRESSED_MATRIX #define USE_COORDINATE_MATRIX #endif