Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <boost/random/mersenne_twister.hpp>
- #include <boost/random/uniform_int_distribution.hpp>
- #include <boost/timer/timer.hpp>
- #include "Eigen/Dense"
- #define LENGTH 3
- int main( int argc, char ** argv )
- { boost::random::mt19937 gen;
- boost::random::uniform_int_distribution<> dist(1, 10);
- typedef Eigen::Array<double,LENGTH,1> Arr;
- Arr five(5.0);
- Arr ten(10.0);
- Arr res(0.0);
- const int loops = 100000;
- { int j = LENGTH;
- while (j--)
- { ten(j) *= dist(gen);
- five(j) *= dist(gen);
- }
- }
- { boost::timer::auto_cpu_timer t;
- int i = loops;
- while (i--)
- { res += res.max(ten.min(five)); }
- }
- res=0.0;
- { boost::timer::auto_cpu_timer t;
- int i = loops;
- while (i--)
- { int j=LENGTH;
- while (j--)
- { res(j) += std::max ( res(j), std::min (ten(j),five(j))); }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement