#include #include #include #include #include #include #include const unsigned N = 100 * (1 << 20); template struct Sqrt { T operator()(const T &x) const { return std::sqrt(x); } }; int main (int argc, char * const argv[]) { // Number of threads is derived from environment // variable "OMP_NUM_THREADS" std::cout << "Threads: " << omp_get_max_threads() << std::endl; std::vector v1(N); omptl::generate(v1.begin(), v1.end(), std::rand); omptl::sort(v1.begin(), v1.end()); omptl::random_shuffle(v1.begin(), v1.end()); std::vector v2(N); omptl::transform(v1.begin(), v1.end(), v2.begin(), Sqrt()); std::cout << "Nr 3's: " << omptl::count(v2.begin(), v2.end(), 3) << std::endl; std::cout << "Sum: " << omptl::accumulate(v2.begin(), v2.end(), 0) << std::endl; std::cout << *v1.begin() << std::endl; return 0; }