You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
605 B

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