blob: 62437435efc25a090809b3caeb147e51aa0080ab [file] [log] [blame]
Brian Silverman72890c22015-09-19 14:37:37 -04001// g++ -O3 -DNDEBUG benchmarkX.cpp -o benchmarkX && time ./benchmarkX
2
3#include <iostream>
4#include <Eigen/Core>
5
6using namespace std;
7using namespace Eigen;
8
9#ifndef VECTYPE
10#define VECTYPE VectorXLd
11#endif
12
13#ifndef VECSIZE
14#define VECSIZE 1000000
15#endif
16
17#ifndef REPEAT
18#define REPEAT 1000
19#endif
20
21int main(int argc, char *argv[])
22{
23 VECTYPE I = VECTYPE::Ones(VECSIZE);
24 VECTYPE m(VECSIZE,1);
25 for(int i = 0; i < VECSIZE; i++)
26 {
27 m[i] = 0.1 * i/VECSIZE;
28 }
29 for(int a = 0; a < REPEAT; a++)
30 {
31 m = VECTYPE::Ones(VECSIZE) + 0.00005 * (m.cwise().square() + m/4);
32 }
33 cout << m[0] << endl;
34 return 0;
35}