bool read_clause (PrologElement * parameters, char * module_name, char * atom_name, int ordering) { AREA area; int module_id = find_module_id (area, module_name); if (module_id < 0) return false; int atom_id = find_atom_id (area, module_id, atom_name); if (atom_id < 0) return false; PrologAtom * atom = find_or_create_atom (module_name, atom_name); if (atom == NULL) return false; db_clause clause; if (! find_clause (area, module_id, atom_id, ordering, & clause)) return false; if (fast) { mysql_term_reader trd (root, area); PrologElement * trdx = trd . readElement (); if (trdx != 0) { root -> getValue (trdx, area, 0); parameters -> setPair (trdx, root -> earth ()); return true; } return false; } parameters -> setPair (); parameters = parameters -> getLeft (); parameters -> setPair (); PrologElement * head = parameters -> getLeft (); head -> setPair (); head -> getLeft () -> setAtom (atom); head = head -> getRight (); if (! find_element (area, module_name, head, clause . parameters)) return false; // head -> setInteger (clause . parameters); head = parameters -> getRight (); if (! find_element (area, module_name, head, clause . body)) return false; // head -> setInteger (clause . body); return true; }
/* Function: solve * * Computes eigenvectors of the standard eigenvalue problem Ax = l x. * * Parameters: * A - Left-hand side matrix. * ev - Array of eigenvectors. * work - Workspace array. * lwork - Size of the input workspace array. * communicator - MPI communicator for selecting the threshold criterion. */ void solve(K* const& A, K**& ev, K* const& work, int& lwork, const MPI_Comm& communicator) { int info; K* tau = work + lwork; underlying_type<K>* d = reinterpret_cast<underlying_type<K>*>(tau + Eigensolver<K>::_n); underlying_type<K>* e = d + Eigensolver<K>::_n; trd("L", &(Eigensolver<K>::_n), A, &(Eigensolver<K>::_n), d, e, tau, work, &lwork, &info); underlying_type<K> vl = -1.0 / HPDDM_EPS; underlying_type<K> vu = Eigensolver<K>::_threshold; int iu = Eigensolver<K>::_nu; int nsplit; underlying_type<K>* evr = e + Eigensolver<K>::_n - 1; int* iblock = new int[5 * Eigensolver<K>::_n]; int* isplit = iblock + Eigensolver<K>::_n; int* iwork = isplit + Eigensolver<K>::_n; char range = Eigensolver<K>::_threshold > 0.0 ? 'V' : 'I'; stebz(&range, "B", &(Eigensolver<K>::_n), &vl, &vu, &i__1, &iu, &(Eigensolver<K>::_tol), d, e, &(Eigensolver<K>::_nu), &nsplit, evr, iblock, isplit, reinterpret_cast<underlying_type<K>*>(work), iwork, &info); if(Eigensolver<K>::_nu) { ev = new K*[Eigensolver<K>::_nu]; *ev = new K[Eigensolver<K>::_n * Eigensolver<K>::_nu]; for(unsigned short i = 1; i < Eigensolver<K>::_nu; ++i) ev[i] = *ev + i * Eigensolver<K>::_n; int* ifailv = new int[Eigensolver<K>::_nu]; stein(&(Eigensolver<K>::_n), d, e, &(Eigensolver<K>::_nu), evr, iblock, isplit, *ev, &(Eigensolver<K>::_n), reinterpret_cast<underlying_type<K>*>(work), iwork, ifailv, &info); delete [] ifailv; mtr("L", "L", "N", &(Eigensolver<K>::_n), &(Eigensolver<K>::_nu), A, &(Eigensolver<K>::_n), tau, *ev, &(Eigensolver<K>::_n), work, &lwork, &info); if(!Wrapper<K>::is_complex) lwork += 3 * Eigensolver<K>::_n - 1; else lwork += 4 * Eigensolver<K>::_n - 1; } delete [] iblock; }
/* Function: workspace * Returns the optimal size of the workspace array. */ int workspace() const { int info; int lwork = -1; K wkopt; trd("L", &(Eigensolver<K>::_n), nullptr, &(Eigensolver<K>::_n), nullptr, nullptr, nullptr, &wkopt, &lwork, &info); return static_cast<int>(std::real(wkopt)); }
void CmdSandboxMeshTestRef::activated(int iMsg) { Gui::WaitCursor wc; std::vector< boost::shared_ptr<QThread> > threads; Base::Reference<Mesh::MeshObject> mesh(new Mesh::MeshObject); int num = mesh.getRefCount(); for (int i=0; i<10; i++) { boost::shared_ptr<QThread> trd(new MeshThread(mesh)); trd->start(); threads.push_back(trd); } QTimer timer; QEventLoop loop; QObject::connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit())); timer.start(2000); loop.exec(); threads.clear(); Mesh::MeshObject* ptr = (Mesh::MeshObject*)mesh; if (!ptr) Base::Console().Error("Object deleted\n"); if (num != mesh.getRefCount()) Base::Console().Error("Reference count is %d\n",mesh.getRefCount()); }
bool writeResumeData(const libed2k::save_resume_data_alert* p, const QString& path, bool onDisk, const QDateTime& ts) { qDebug() << Q_FUNC_INFO; try { QED2KHandle h(p->m_handle); qDebug() << "save fast resume data for " << h.hash(); if (h.is_valid() && p->resume_data) { QDir bkpDir(path); // Remove old fastresume file if it exists std::vector<char> out; libed2k::bencode(back_inserter(out), *p->resume_data); const QString filepath = bkpDir.absoluteFilePath(h.filename()); libed2k::transfer_resume_data trd(p->m_handle.hash(), p->m_handle.name(), p->m_handle.size(), h.is_seed(), out); // append additional tag about has transfer disk file trd.m_fast_resume_data.add_tag(libed2k::make_typed_tag(onDisk, libed2k::CT_EMULE_RESERVED1, true)); // append creation date trd.m_fast_resume_data.add_tag(libed2k::make_string_tag(ts.toString(Qt::ISODate).toUtf8().constData(), libed2k::CT_EMULE_RESERVED2, true)); std::ofstream fs(filepath.toLocal8Bit(), std::ios_base::out | std::ios_base::binary); if (fs) { libed2k::archive::ed2k_oarchive oa(fs); oa << trd; return true; } } } catch(const libed2k::libed2k_exception& e) { qDebug() << "error on write resume data " << misc::toQStringU(e.what()); } return false; }
/* ==================================================================== Get first value of 'name', translated to the current language in the context of the given domain, and return it _duplicated_. ==================================================================== */ int parser_get_localized_string ( PData *pd, const char *name, const char *domain, char **result ) { char *value; if ( !parser_get_value( pd, name, &value, 0 ) ) { sprintf( parser_sub_error, "parser_get_string:\n %s", parser_error ); strcpy( parser_error, parser_sub_error ); return 0; } *result = strdup( trd(domain, value) ); return 1; }
bool ResourceManager::UnloadResources() { if (loading_) { return false; } std::thread trd(thread_unloadResources, this, resourceList_); trd.detach(); loading_ = true; return true; }
//------------------------------- /// strURLをダウンロードする void CDownloadManager::DownloadStart(LPCTSTR strURL, LPCTSTR strDLFolder, HWND hWnd, DWORD dwDLOption) { if (CDLControlOption::s_bUseDLManager == false) return ; if (dwDLOption & DLO_SAVEIMAGE) { strDLFolder = static_cast<LPCTSTR>(CDLOptions::strImgDLFolderPath); dwDLOption |= CDLOptions::dwImgExStyle; //dwDLOption |= CDLOptions::bShowWindowOnDL ? DLO_SHOWWINDOW : 0; } if (dwDLOption & DLO_SHOWWINDOW || CDLOptions::bShowWindowOnDL) OnShowDLManager(0, 0, NULL); CCustomBindStatusCallBack* pCBSCB = _CreateCustomBindStatusCallBack(); pCBSCB->SetReferer(s_strReferer); s_strReferer.Empty(); pCBSCB->SetOption(strDLFolder, hWnd, dwDLOption); CString* pstrURL = new CString(strURL); boost::thread trd(boost::bind(&CDownloadManager::_DLStart, this, pstrURL, (IBindStatusCallback*)pCBSCB)); }
bool writeResumeDataOne(std::ofstream& fs, const libed2k::save_resume_data_alert* p) { try { QED2KHandle h(p->m_handle); if (h.is_valid() && p->resume_data) { std::vector<char> out; libed2k::bencode(back_inserter(out), *p->resume_data); libed2k::transfer_resume_data trd(p->m_handle.hash(), p->m_handle.name(), p->m_handle.size(), p->m_handle.is_seed(), out); libed2k::archive::ed2k_oarchive oa(fs); oa << trd; return true; } } catch(const libed2k::libed2k_exception& e) { qDebug() << "error on write resume data " << misc::toQStringU(e.what()); return false; } return false; }