1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
|
//
// 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 BENCH1_H
#define BENCH1_H
#include <iostream>
#include <string>
#include <valarray>
#include <boost/numeric/ublas/vector.hpp>
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/timer.hpp>
namespace ublas = boost::numeric::ublas;
void header (std::string text);
template<class T>
struct footer {
void operator () (int multiplies, int plus, int runs, double elapsed) {
std::cout << "elapsed: " << elapsed << " s, "
<< (multiplies * ublas::type_traits<T>::multiplies_complexity +
plus * ublas::type_traits<T>::plus_complexity) * runs /
(1024 * 1024 * elapsed) << " Mflops" << std::endl;
}
};
template<class T, int N>
struct c_vector_traits {
typedef T type [N];
};
template<class T, int N, int M>
struct c_matrix_traits {
typedef T type [N] [M];
};
template<class T, int N>
struct initialize_c_vector {
void operator () (typename c_vector_traits<T, N>::type &v) {
for (int i = 0; i < N; ++ i)
v [i] = std::rand () * 1.f;
// v [i] = 0.f;
}
};
template<class V>
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<class T, int N, int M>
struct initialize_c_matrix {
void operator () (typename c_matrix_traits<T, N, M>::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<class M>
BOOST_UBLAS_INLINE
void initialize_matrix (M &m) {
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<class T>
BOOST_UBLAS_INLINE
void sink_scalar (const T &s) {
static T g_s = s;
}
template<class T, int N>
struct sink_c_vector {
void operator () (const typename c_vector_traits<T, N>::type &v) {
static typename c_vector_traits<T, N>::type g_v;
for (int i = 0; i < N; ++ i)
g_v [i] = v [i];
}
};
template<class V>
BOOST_UBLAS_INLINE
void sink_vector (const V &v) {
static V g_v (v);
}
template<class T, int N, int M>
struct sink_c_matrix {
void operator () (const typename c_matrix_traits<T, N, M>::type &m) {
static typename c_matrix_traits<T, N, M>::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<class M>
BOOST_UBLAS_INLINE
void sink_matrix (const M &m) {
static M g_m (m);
}
template<class T>
struct peak {
void operator () (int runs);
};
template<class T, int N>
struct bench_1 {
void operator () (int runs);
};
template<class T, int N>
struct bench_2 {
void operator () (int runs);
};
template<class T, int N>
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_C_ARRAY
// #define USE_BOUNDED_ARRAY
#define USE_UNBOUNDED_ARRAY
// #define USE_STD_VALARRAY
//#define USE_STD_VECTOR
#endif
|