mirror of
https://gitlab.com/libeigen/eigen.git
synced 2024-12-15 07:10:37 +08:00
ab4046970b
* Use them to write an unrolled path in echelon.cpp, as an experiment before I do this LU module. * For floating-point types, make ei_random() use an amplitude of 1.
37 lines
773 B
C++
37 lines
773 B
C++
// g++ -O3 -DNDEBUG -DMATSIZE=<x> benchmark.cpp -o benchmark && time ./benchmark
|
|
#include <Eigen/Core>
|
|
|
|
#ifndef MATSIZE
|
|
#define MATSIZE 3
|
|
#endif
|
|
|
|
using namespace std;
|
|
USING_PART_OF_NAMESPACE_EIGEN
|
|
|
|
#ifndef REPEAT
|
|
#define REPEAT 40000000
|
|
#endif
|
|
|
|
#ifndef SCALAR
|
|
#define SCALAR double
|
|
#endif
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
Matrix<SCALAR,MATSIZE,MATSIZE> I = Matrix<SCALAR,MATSIZE,MATSIZE>::ones();
|
|
Matrix<SCALAR,MATSIZE,MATSIZE> m;
|
|
for(int i = 0; i < MATSIZE; i++)
|
|
for(int j = 0; j < MATSIZE; j++)
|
|
{
|
|
m(i,j) = (i+MATSIZE*j);
|
|
}
|
|
asm("#begin");
|
|
for(int a = 0; a < REPEAT; a++)
|
|
{
|
|
m = Matrix<SCALAR,MATSIZE,MATSIZE>::ones() + 0.00005 * (m + m*m);
|
|
}
|
|
asm("#end");
|
|
cout << m << endl;
|
|
return 0;
|
|
}
|