7 #define BOOST_TEST_DYN_LINK
8 #define BOOST_TEST_MODULE "Some benchmarkings for vector operations"
10 #include <boost/test/unit_test.hpp>
13 #include <Eigen/Dense>
19 using namespace Eigen;
36 BOOST_FIXTURE_TEST_SUITE( VectorBenchmarkSuite, TimedTestFixture )
42 std::vector< MatrixXd > ma;
44 for (
int i = 0; i <
MSIZE; ++i )
45 ma[i] = MatrixXd::Constant(
LSIZE,
LSIZE, 2.0);
47 std::vector< VectorXd > vb;
49 for (
int i = 0; i <
MSIZE; ++i )
50 vb[i] = VectorXd::Constant(
LSIZE, 5.0);
52 std::vector< VectorXd > vc;
54 for (
int i = 0; i <
MSIZE; ++i )
55 vc[i] = VectorXd::Constant(
LSIZE, 0.0);
59 for (
int i = 0; i <
MSIZE; ++i )
60 vc[i].noalias() = ma[i] * vb[i];
67 typedef Matrix< double, LSIZE, LSIZE > MatrixSd;
68 typedef Matrix< double, LSIZE, 1 > VectorSd;
70 std::vector< MatrixSd > ma;
72 for (
int i = 0; i <
MSIZE; ++i )
73 ma[i] = MatrixSd::Constant(
LSIZE,
LSIZE, 2.0);
75 std::vector< VectorSd > vb;
77 for (
int i = 0; i <
MSIZE; ++i )
78 vb[i] = VectorSd::Constant(
LSIZE, 5.0 );
80 std::vector< VectorSd > vc;
82 for (
int i = 0; i <
MSIZE; ++i )
83 vc[i] = VectorSd::Constant(
LSIZE, 0.0 );
87 for (
int i = 0; i <
MSIZE; ++i )
88 vc[i].noalias() = ma[i] * vb[i];
129 std::vector< nat > ma;
131 for (
int i = 0; i <
MSIZE; ++i )
134 for (
int j = 0; j <
LSIZE*
LSIZE; ++j ) ma[i].data[j] = 2.0;
137 std::vector< nat > vb;
139 for (
int i = 0; i <
MSIZE; ++i )
141 vb[i].data =
new double [
LSIZE ];
142 for (
int j = 0; j <
LSIZE; ++j ) vb[i].data[j] = 5.0;
145 std::vector< nat > vc;
147 for (
int i = 0; i <
MSIZE; ++i )
149 vc[i].data =
new double [
LSIZE ];
150 for (
int j = 0; j <
LSIZE; ++j ) vc[i].data[j] = 0.0;
156 for (
int i = 0; i <
LSIZE; ++i )
159 for (
Uint j = 0,
k = i*n; j <
n; ++j, ++
k)
160 vc[
e].data[i] += ma[
e].data[
k] * vb[
e].data[j];
168 std::vector< MatrixXd > ma;
170 for (
int i = 0; i <
MSIZE; ++i )
171 ma[i] = MatrixXd::Constant(
LSIZE,
LSIZE, 2.0);
173 std::vector< MatrixXd > mb;
175 for (
int i = 0; i <
MSIZE; ++i )
176 mb[i] = MatrixXd::Constant(
LSIZE,
LSIZE, 7.0);
178 std::vector< MatrixXd > mc;
180 for (
int i = 0; i <
MSIZE; ++i )
181 mc[i] = MatrixXd::Constant(
LSIZE,
LSIZE, 0.0);
185 for (
int i = 0; i <
MSIZE; ++i )
186 mc[i].noalias() = ma[i] * mb[i];
193 typedef Matrix< double, LSIZE, LSIZE > MatrixSd;
195 std::vector< MatrixSd > ma;
197 for (
int i = 0; i <
MSIZE; ++i )
198 ma[i] = MatrixSd::Constant(
LSIZE,
LSIZE, 2.0);
200 std::vector< MatrixSd > mb;
202 for (
int i = 0; i <
MSIZE; ++i )
203 mb[i] = MatrixSd::Constant(
LSIZE,
LSIZE, 7.0);
205 std::vector< MatrixSd > mc;
207 for (
int i = 0; i <
MSIZE; ++i )
208 mc[i] = MatrixSd::Constant(
LSIZE,
LSIZE, 0.0);
212 for (
int i = 0; i <
MSIZE; ++i )
213 mc[i].noalias() = ma[i] * mb[i];
254 std::vector< nat > ma;
256 for (
int i = 0; i <
MSIZE; ++i )
259 for (
int j = 0; j <
LSIZE*
LSIZE; ++j ) ma[i].data[j] = 2.0;
262 std::vector< nat > mb;
264 for (
int i = 0; i <
MSIZE; ++i )
267 for (
int j = 0; j <
LSIZE*
LSIZE; ++j ) mb[i].data[j] = 7.0;
270 std::vector< nat > mc;
272 for (
int i = 0; i <
MSIZE; ++i )
275 for (
int j = 0; j <
LSIZE*
LSIZE; ++j ) mc[i].data[j] = 0.0;
282 const size_t nc =
LSIZE;
283 const size_t m =
LSIZE;
286 const nat& A = ma[
e];
287 const nat& B = mb[
e];
290 for (
size_t i = 0; i < m; ++i)
292 const size_t jstart = i*
n;
293 const size_t jmax = jstart +
n;
294 const size_t kstart = i*nc;
300 for(
size_t j = jstart; j < jmax; ++j)
314 BOOST_AUTO_TEST_SUITE_END()
Real e()
Definition of the Unit charge [C].
BOOST_AUTO_TEST_CASE(dgemv_eigen_dynamic)
Top-level namespace for coolfluid.
unsigned int Uint
typedef for unsigned int
coolfluid3 header, included almost everywhere
Most basic kernel library.
Uint count(const RangeT &range)
Count the elements in a range.