int hpx_main() { // lets say we have two vectors that simulate.. 10007D std::vector<double> xvalues(10007); std::vector<double> yvalues(10007); std::fill(boost::begin(xvalues), boost::end(xvalues), 1.0); std::fill(boost::begin(yvalues), boost::end(yvalues), 1.0); double result = hpx::parallel::transform_reduce( hpx::parallel::par, boost::counting_iterator<size_t>(0), boost::counting_iterator<size_t>(10007), [&xvalues, &yvalues](size_t i) { return xvalues[i] * yvalues[i]; }, 0.0, std::plus<double>() ); // print the result hpx::cout << result << hpx::endl; return hpx::finalize(); }
int main(int argc, char **argv){ unsigned int runs = 400; seed_rand(); std::vector<double> xvalues(runs), yvalues(runs), zvalues(runs); for ( unsigned int i = 0; i < runs ; i++ ) { xvalues[i] = 1.0 * ((double) rand() - (double)RAND_MAX /2.0) /(double)RAND_MAX; yvalues[i] = 1.0 * ((double) rand() - (double)RAND_MAX /2.0) /(double)RAND_MAX; zvalues[i] = 1.0 * ((double) rand() - (double)RAND_MAX /2.0) /(double)RAND_MAX; } for ( unsigned int i = 0; i < runs ; i++ ) { btMatrix3x3 mat; btQuaternion q_baseline(xvalues[i],yvalues[i],zvalues[i]); mat.setRotation(q_baseline); btQuaternion q_from_m; mat.getRotation(q_from_m); std::printf("%f, angle between quaternions\n", q_from_m.angle(q_baseline)); } return 0; }
void all_of_tests(std::vector<hpx::id_type>& localities) { hpx::partitioned_vector<T> xvalues( SIZE, T(0), hpx::container_layout(localities)); initialize(xvalues); test_all(hpx::parallel::execution::seq, xvalues, op8(), false); test_all(hpx::parallel::execution::par, xvalues, op8(), false); test_all_async( hpx::parallel::execution::seq(hpx::parallel::execution::task), xvalues, op8(), false); test_all_async( hpx::parallel::execution::par(hpx::parallel::execution::task), xvalues, op8(), false); test_all(hpx::parallel::execution::seq, xvalues, op5(), false); test_all(hpx::parallel::execution::par, xvalues, op5(), false); test_all_async( hpx::parallel::execution::seq(hpx::parallel::execution::task), xvalues, op5(), false); test_all_async( hpx::parallel::execution::par(hpx::parallel::execution::task), xvalues, op5(), false); test_all(hpx::parallel::execution::seq, xvalues, op0(), true); test_all(hpx::parallel::execution::par, xvalues, op0(), true); test_all_async( hpx::parallel::execution::seq(hpx::parallel::execution::task), xvalues, op0(), true); test_all_async( hpx::parallel::execution::par(hpx::parallel::execution::task), xvalues, op0(), true); }
void adjacent_find_tests(std::vector<hpx::id_type>& localities) { hpx::partitioned_vector<T> xvalues( SIZE, T(0), hpx::container_layout(localities)); initialize(xvalues); test_adjacent_find(hpx::parallel::execution::seq, xvalues); test_adjacent_find(hpx::parallel::execution::par, xvalues); test_adjacent_find_async( hpx::parallel::execution::seq(hpx::parallel::execution::task), xvalues); test_adjacent_find_async( hpx::parallel::execution::par(hpx::parallel::execution::task), xvalues); }
int main(int argc, char *argv[]) { parameters p = readParams(argv[1]); p.xbinWidth = (p.xmax - p.xmin)/double(p.xbins); std::cout << "inbase " << p.inbase << "\n"; std::cout << "ext " << p.ext << "\n"; std::cout << "avgbase " << p.avgbase << "\n"; std::cout << "covbase " << p.covbase << "\n"; std::cout << "corbase " << p.corbase << "\n"; std::cout << "datapoints " << p.datapoints << "\n"; std::cout << "xvals " << p.xvals << "\n"; std::cout << "outformat " << p.outformat << "\n"; std::cout << "xmin " << p.xmin << "\n"; std::cout << "xbinWidth " << p.xbinWidth << "\n"; std::cout << "numMocks " << p.numMocks << "\n"; std::cout << "startNum " << p.startNum << "\n"; std::cout << "digits " << p.digits << "\n"; std::ifstream fin; std::ofstream fout; std::vector< double > mu(p.datapoints); std::vector< double > xvalues(p.datapoints); const int N = p.datapoints; double cov[N][N] = {0.0}; std::cout << "Finding the average values...\n"; for (int mock = p.startNum; mock <= p.numMocks; ++mock) { std::string infile = filename(p.inbase, mock, p.digits, p.ext); fin.open(infile.c_str(),std::ios::in); if (p.xvals == "true") { int i = 0; while (!fin.eof()) { double x, y; fin >> x >> y; if (x >= p.xmin && !fin.eof()) { mu[i] += y/p.numMocks; xvalues[i] = x; ++i; } } } else { for (int i = 0; i < N; ++i) {
int main(int argc, char **argv){ unsigned int runs = 400; seed_rand(); std::vector<double> xvalues(runs), yvalues(runs), zvalues(runs); for ( unsigned int i = 0; i < runs ; i++ ) { xvalues[i] = 1.0 * ((double) rand() - (double)RAND_MAX /2.0) /(double)RAND_MAX; yvalues[i] = 1.0 * ((double) rand() - (double)RAND_MAX /2.0) /(double)RAND_MAX; zvalues[i] = 1.0 * ((double) rand() - (double)RAND_MAX /2.0) /(double)RAND_MAX; } //Useful Operator Overload for ( unsigned int i = 0; i < runs ; i++ ) { btTransform transform(btQuaternion(0,0,0), btVector3(xvalues[i],yvalues[i],zvalues[i])); btQuaternion initial(xvalues[i],yvalues[i],zvalues[i]); btQuaternion final(xvalues[i],yvalues[i],zvalues[i]); final = transform * initial; std::printf("Useful Operator Overload: %f, angle between quaternions\n", initial.angle(final)); }