ProjectTreePtr Project::AsTree() { ProjectItem item(GetName(), GetName(), GetFileName().GetFullPath(), ProjectItem::TypeProject); ProjectTreePtr ptp(new ProjectTree(item.Key(), item)); wxXmlNode *child = m_doc.GetRoot()->GetChildren(); while ( child ) { RecursiveAdd(child, ptp, ptp->GetRoot()); child = child->GetNext(); } return ptp; }
bool is_exist(HANDLE token, const LUID & priv) { DWORD size = 0; ::GetTokenInformation(token, TokenPrivileges, nullptr, 0, &size); CheckApi(::GetLastError() == ERROR_INSUFFICIENT_BUFFER); memory::auto_buf<PTOKEN_PRIVILEGES> ptp(size); CheckApi(::GetTokenInformation(token, TokenPrivileges, ptp, ptp.size(), &size)); for (DWORD i = 0; i < ptp->PrivilegeCount; ++i) { if (ptp->Privileges[i].Luid == priv) { return true; } } return false; }
void osmdata_t::stop() { /* Commit the transactions, so that multiple processes can * access the data simultanious to process the rest in parallel * as well as see the newly created tables. */ size_t pending_count = mid->pending_count(); mid->commit(); for (auto& out: outs) { //TODO: each of the outs can be in parallel out->commit(); pending_count += out->pending_count(); } // should be the same for all outputs const bool append = outs[0]->get_options()->append; //threaded pending processing pending_threaded_processor ptp(mid, outs, outs[0]->get_options()->num_procs, pending_count, append); if (!outs.empty()) { //This stage takes ways which were processed earlier, but might be //involved in a multipolygon relation. They could also be ways that //were modified in diff processing. mid->iterate_ways( ptp ); //This is like pending ways, except there aren't pending relations //on import, only on update. //TODO: Can we skip this on import? mid->iterate_relations( ptp ); } // Clustering, index creation, and cleanup. // All the intensive parts of this are long-running PostgreSQL commands std::vector<std::future<void>> futures; // XXX we might get too many parallel processes here // use osmium worker pool instead for (auto& out: outs) { futures.push_back(std::async(&output_t::stop, out.get())); } futures.push_back(std::async(&middle_t::stop, mid.get())); for (auto& f: futures) { f.get(); } }
cholmod_sparse * MultivariateFNormalSufficientSparse::evaluate_derivative_Sigma() const { //d(-log(p))/dSigma = 1/2 (N P - N P epsilon transpose(epsilon) P - P W P) IMP_LOG(TERSE, "MVNsparse: evaluate_derivative_Sigma() = " << std::endl); cholmod_sparse *ptp(compute_PTP()); cholmod_sparse *pwp(compute_PWP()); //std::cout << " ptp " << std::endl << ptp << std::endl << std::endl; //std::cout << " pwp " << std::endl << pwp << std::endl << std::endl; static double one[2]={1,0}; static double minusone[2]={-1,0}; cholmod_sparse *tmp = cholmod_add(P_, ptp, one, minusone, true, false, c_); double enn[2]={0.5*N_,0}; static double ptfive[2]={-0.5,0}; cholmod_sparse *R = cholmod_add(tmp, pwp, enn, ptfive, true, false, c_); cholmod_free_sparse(&ptp, c_); cholmod_free_sparse(&pwp, c_); cholmod_free_sparse(&tmp, c_); return R; }