2008-04-11 22:28:42 +08:00
|
|
|
// g++ -fopenmp -I .. -O3 -DNDEBUG -finline-limit=1000 benchmarkX.cpp -o b && time ./b
|
2008-01-05 18:57:14 +08:00
|
|
|
#include <Eigen/Core>
|
|
|
|
|
|
|
|
using namespace std;
|
2010-04-23 06:27:13 +08:00
|
|
|
using namespace Eigen;
|
2008-01-05 18:57:14 +08:00
|
|
|
|
2008-04-11 16:18:47 +08:00
|
|
|
#ifndef MATTYPE
|
2008-04-11 22:28:42 +08:00
|
|
|
#define MATTYPE MatrixXLd
|
2008-04-11 16:18:47 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef MATSIZE
|
2008-04-11 22:28:42 +08:00
|
|
|
#define MATSIZE 400
|
2008-04-11 16:18:47 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef REPEAT
|
2008-04-11 22:28:42 +08:00
|
|
|
#define REPEAT 100
|
2008-04-11 16:18:47 +08:00
|
|
|
#endif
|
|
|
|
|
2008-01-05 18:57:14 +08:00
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
2008-07-27 19:39:47 +08:00
|
|
|
MATTYPE I = MATTYPE::Ones(MATSIZE,MATSIZE);
|
2008-04-11 16:18:47 +08:00
|
|
|
MATTYPE m(MATSIZE,MATSIZE);
|
|
|
|
for(int i = 0; i < MATSIZE; i++) for(int j = 0; j < MATSIZE; j++)
|
2008-01-05 18:57:14 +08:00
|
|
|
{
|
2008-04-11 22:28:42 +08:00
|
|
|
m(i,j) = (i+j+1)/(MATSIZE*MATSIZE);
|
2008-01-05 18:57:14 +08:00
|
|
|
}
|
2008-04-11 16:18:47 +08:00
|
|
|
for(int a = 0; a < REPEAT; a++)
|
2008-01-05 18:57:14 +08:00
|
|
|
{
|
2008-04-11 22:28:42 +08:00
|
|
|
m = I + 0.0001 * (m + m*m);
|
2008-01-05 18:57:14 +08:00
|
|
|
}
|
2008-04-11 16:18:47 +08:00
|
|
|
cout << m(0,0) << endl;
|
2008-01-05 18:57:14 +08:00
|
|
|
return 0;
|
|
|
|
}
|