2008-03-06 19:36:27 +08:00
|
|
|
// g++ -O3 -DNDEBUG -DMATSIZE=<x> benchmark.cpp -o benchmark && time ./benchmark
|
2007-12-29 00:20:00 +08:00
|
|
|
#include <Eigen/Core>
|
2007-12-21 05:11:05 +08:00
|
|
|
|
2008-03-06 19:36:27 +08:00
|
|
|
#ifndef MATSIZE
|
|
|
|
#define MATSIZE 3
|
|
|
|
#endif
|
|
|
|
|
|
|
|
using namespace std;
|
2007-12-24 19:14:25 +08:00
|
|
|
USING_PART_OF_NAMESPACE_EIGEN
|
2007-12-21 05:11:05 +08:00
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
2008-03-06 19:36:27 +08:00
|
|
|
Matrix<double,MATSIZE,MATSIZE> I;
|
|
|
|
Matrix<double,MATSIZE,MATSIZE> m;
|
|
|
|
for(int i = 0; i < MATSIZE; i++)
|
|
|
|
for(int j = 0; j < MATSIZE; j++)
|
|
|
|
{
|
|
|
|
I(i,j) = (i==j);
|
|
|
|
m(i,j) = (i+MATSIZE*j);
|
|
|
|
}
|
|
|
|
asm("#begin");
|
|
|
|
for(int a = 0; a < 40000000; a++)
|
|
|
|
{
|
|
|
|
m = I + 0.00005 * (m + m*m);
|
|
|
|
}
|
|
|
|
asm("#end");
|
|
|
|
cout << m << endl;
|
|
|
|
return 0;
|
2007-12-21 05:11:05 +08:00
|
|
|
}
|