mirror of
https://gitlab.com/libeigen/eigen.git
synced 2024-12-15 07:10:37 +08:00
35 lines
617 B
C++
35 lines
617 B
C++
// g++ -O3 -DNDEBUG benchmarkX.cpp -o benchmarkX && time ./benchmarkX
|
|
|
|
#include <Eigen/Core>
|
|
|
|
using namespace std;
|
|
USING_PART_OF_NAMESPACE_EIGEN
|
|
|
|
#ifndef MATTYPE
|
|
#define MATTYPE MatrixXd
|
|
#endif
|
|
|
|
#ifndef MATSIZE
|
|
#define MATSIZE 20
|
|
#endif
|
|
|
|
#ifndef REPEAT
|
|
#define REPEAT 100000
|
|
#endif
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
MATTYPE I = MATTYPE::identity(MATSIZE,MATSIZE);
|
|
MATTYPE m(MATSIZE,MATSIZE);
|
|
for(int i = 0; i < MATSIZE; i++) for(int j = 0; j < MATSIZE; j++)
|
|
{
|
|
m(i,j) = 0.1 * (i+MATSIZE*j)/MATSIZE;
|
|
}
|
|
for(int a = 0; a < REPEAT; a++)
|
|
{
|
|
m = I + 0.00005 * (m + m*m);
|
|
}
|
|
cout << m(0,0) << endl;
|
|
return 0;
|
|
}
|