2008-07-10 00:43:11 +08:00
|
|
|
// g++ -O3 -DNDEBUG benchmarkX.cpp -o benchmarkX && time ./benchmarkX
|
|
|
|
|
2010-07-09 09:59:36 +08:00
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
#include <Eigen/Core>
|
2008-07-10 00:43:11 +08:00
|
|
|
|
|
|
|
using namespace std;
|
2010-04-23 06:27:13 +08:00
|
|
|
using namespace Eigen;
|
2008-07-10 00:43:11 +08:00
|
|
|
|
|
|
|
#ifndef REPEAT
|
|
|
|
#define REPEAT 10000
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef SCALAR
|
|
|
|
#define SCALAR float
|
|
|
|
#endif
|
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
typedef Matrix<SCALAR, Eigen::Dynamic, Eigen::Dynamic> Mat;
|
|
|
|
Mat m(100, 100);
|
|
|
|
m.setRandom();
|
|
|
|
|
|
|
|
for(int a = 0; a < REPEAT; a++)
|
|
|
|
{
|
|
|
|
int r, c, nr, nc;
|
|
|
|
r = Eigen::ei_random<int>(0,10);
|
|
|
|
c = Eigen::ei_random<int>(0,10);
|
|
|
|
nr = Eigen::ei_random<int>(50,80);
|
|
|
|
nc = Eigen::ei_random<int>(50,80);
|
2008-07-27 19:39:47 +08:00
|
|
|
m.block(r,c,nr,nc) += Mat::Ones(nr,nc);
|
2008-07-10 00:43:11 +08:00
|
|
|
m.block(r,c,nr,nc) *= SCALAR(10);
|
|
|
|
m.block(r,c,nr,nc) -= Mat::constant(nr,nc,10);
|
2008-07-10 00:46:26 +08:00
|
|
|
m.block(r,c,nr,nc) /= SCALAR(10);
|
2008-07-10 00:43:11 +08:00
|
|
|
}
|
|
|
|
cout << m[0] << endl;
|
|
|
|
return 0;
|
|
|
|
}
|