void NodalConstraintProcessor<SIM3D>::apply(SIM3D& sim, TopologySet& myEntitys, const ConstraintVec& vConstr) { for (const auto& it3 : vConstr) { TopologySet::const_iterator it = myEntitys.find(it3.topset); if (it != myEntitys.end()) { ASMs3D* pch = static_cast<ASMs3D*>(sim.getPatch(it3.patch)); if (!pch) continue; NodalConstraintASMs3DHelper helper(pch); int idx = helper.getCorner(it3.vertex, it3.basis); for (const auto& it2 : it->second) { // vertex constraints ASMs3D* pch2 = static_cast<ASMs3D*>(sim.getPatch(it2.patch)); if (!pch2) continue; NodalConstraintASMs3DHelper helper2(pch2); if (it2.idim == 3) helper2.constrainPatch(it3.comp, it3.basis, idx); else if (it2.idim == 2) // Face constraints helper2.constrainFace(it2.item, it3.comp, it3.basis, idx); else if (it2.idim == 1) // Edge constraints helper2.constrainEdge(it2.item, it3.comp, it3.basis, idx); else if (it2.idim == 0) // Vertex constraint helper2.constrainVertex(it2.item, it3.comp, it3.basis, idx); } } } }
void operator()(cocaine::framework::future<cocaine::framework::future<Args...>>& fut) { try { fut.get().then(executor_t(), helper2(m_new_state)); } catch (...) { m_new_state->set_exception(std::current_exception()); } }
vector<string> subset(string url){ if(url.empty()) return res; helper2(url, 0); if(!tmp.empty()){ for(int i = 0; i < tmp.size(); ++i) helper3(tmp[i], "", 0); } return res; }
void helper2(string url, int start){ if(start >= url.size()){ tmp.push_back(url); return; } for(int i = start; i < url.size(); ++i){ swap(url[start], url[i]); helper2(url, start+1); swap(url[start], url[i]); } }
int main() { std::cout << "starting first helper...\n"; std::thread helper1(foo); std::cout << "starting second helper...\n"; std::thread helper2(bar); std::cout << "waiting for helpers to finish..." << std::endl; helper1.join(); helper2.join(); std::cout << "done!\n"; }
int main( int argc, char **argv ) { (void) argc; (void) argv; #ifdef HAVE_LPSOLVE helper0("LP Solve", aa_opt_lpsolve_gmcreate); helper1("LP Solve", aa_opt_lpsolve_gmcreate); helper2("LP Solve", aa_opt_lpsolve_gmcreate); #endif #ifdef HAVE_GLPK helper0("GLPK", aa_opt_glpk_gmcreate); helper1("GLPK", aa_opt_glpk_gmcreate); helper2("GLPK", aa_opt_glpk_gmcreate); #endif #ifdef HAVE_CLP helper0("CLP", aa_opt_clp_gmcreate); helper1("CLP", aa_opt_clp_gmcreate); helper2("CLP", aa_opt_clp_gmcreate); #endif }
int main(int argc, char** argv) { std::cout << "starting first helper..." << std::endl; std::thread helper1(foo); std::cout << "starting second helper..." << std::endl; std::thread helper2(bar); std::cout << "waiting for helpers to finish..." << std::endl; helper1.join(); helper2.join(); std::cout << "done!" << std::endl; return 0; }
void NodalConstraintProcessor<SIM2D>::apply(SIM2D& sim, TopologySet& myEntitys, const ConstraintVec& vConstr) { for (const auto& it3 : vConstr) { TopologySet::const_iterator it = myEntitys.find(it3.topset); if (it != myEntitys.end()) { std::unique_ptr<NodalConstraintASMHelper> helper(get2DHelper(sim.getPatch(it3.patch))); int idx = helper->getCorner(it3.vertex, it3.basis); for (const auto& it2 : it->second) { std::unique_ptr<NodalConstraintASMHelper> helper2(get2DHelper(sim.getPatch(it2.patch))); if (it2.idim == 2) helper2->constrainPatch(it3.comp, it3.basis, idx); else if (it2.idim == 1) // Edge constraints helper2->constrainEdge(it2.item, it3.comp, it3.basis, idx); else if (it2.idim == 0) // Vertex constraint helper2->constrainVertex(it2.item, it3.comp, it3.basis, idx); } } } }
int main() { time_t t = time(0); struct tm * now = localtime(&t); std::cout << (now->tm_year + 1900) << '-' << (now->tm_mon + 1) << '-' << now->tm_mday << ' ' << now->tm_hour << ':' << now->tm_min << ':' << now->tm_sec << std::endl; std::cout << "starting first helper...\n"; std::thread helper1(foo); std::cout << "starting second helper...\n"; std::thread helper2(bar); std::cout << "waiting for helpers to finish..." << std::endl; helper1.join(); helper2.join(); std::cout << "done!\n"; }
void buildGraph(std::vector<std::pair<datadim_t, mdMap_t>> data, std::vector<std::pair<discretedim_t, discretedim_t>> dataDiscrete, std::shared_ptr<gc::Graph> graph, data_t threshold) { std::cout << "Build initial graph: " << std::flush; long edgeCount = 0; data_t xMax = std::numeric_limits<data_t>::lowest(); for (std::size_t i = 0; i < data.size(); i++) { std::list<std::size_t> refs; // reverse search existing vertices TBBSearchHelper helper1(i, graph); parallel_reduce(tbb::blocked_range<std::size_t>(0, i), helper1); refs.splice(refs.end(), helper1.refs); // do not add self reference (=i) // test edges too non exisiting vertices TBBEdgeHelper helper2(data[i].first, data[i].second, dataDiscrete[i].first, dataDiscrete[i].second, &data, &dataDiscrete, threshold); parallel_reduce(tbb::blocked_range<std::size_t>(i + 1, data.size()), helper2); xMax = std::max(xMax, helper2.xMax); refs.splice(refs.end(), helper2.refs); // store graph->add(refs); edgeCount += refs.size(); // report progress if (i % 100 == 0) { std::cout << i << std::flush; } else if (i % 10 == 0) { std::cout << "." << std::flush; } } std::cout << "done (" << (edgeCount / 2) << " edges, max="<< xMax << ")" << std::endl; }
// branch to different tasks void branching(char c) { switch (c) { case 'a': helper(c); break; case 'b': // add an actor/actress to a movie case 'c': // display a list of movies for an actor/actress case 'd': // delete all movies case 'e': // display all movies case 'f': // display a movie by index case 'g': // display a list of movies by genre helper2(c); break; case 'q': break; default: printf("Invalid input!\n"); } if (c == 'b' || c == 'c') { ungetc('\n', stdin); } }
static constexpr auto helper1(Xs const& xs, Ys const& ys, Pred const& pred, bool is_less) { return is_less ? true : helper2(xs, ys, pred, hana::if_(pred(hana::front(ys), hana::front(xs)), hana::true_c, hana::false_c)); }
static constexpr auto helper1(Xs const& xs, Ys const& ys, Pred const& pred, decltype(hana::false_c)) { return helper2(xs, ys, pred, hana::if_(pred(hana::front(ys), hana::front(xs)), hana::true_c, hana::false_c)); }