void gn(ll n,int op=12323){ if(isp(n)) {s[l++]=n;return;} ll x=PB(n); while(x==n) x=PB(n,--op); gn(x); gn(n/x); }
/* ----------------------------------------------------------------------------- ----------------------------------------------------------------------------- */ void CForegroundObserver::RunL() { if (iStatus == KErrNone) { TWsEvent e; iWsSession.GetEvent(e); } if(iObserver && (iStatus != KErrCancel)) { TInt wgid = iWsSession.GetFocusWindowGroup(); CApaWindowGroupName* gn(NULL); gn = CApaWindowGroupName::NewL(iWsSession, wgid); if(gn) { CleanupStack::PushL(gn); // gn TUid TmpUID(gn->AppUid()); CleanupStack::PopAndDestroy(); // gn if(!iObserver->ForegroundChanged(TmpUID)) { Listen(); } } } }
int main() { using SolverType = invlib::ConjugateGradient<>; using MinimizerType = invlib::GaussNewton<double, SolverType>; using PrecisionMatrix = invlib::PrecisionMatrix<MatrixType>; using MAPType = invlib::MAP<LinearModel, MatrixType, PrecisionMatrix, PrecisionMatrix>; // Load data. MatrixType K = invlib::read_matrix_arts("STR_VALUE(MATS_DATA)/K.xml"); MatrixType SaInv = invlib::read_matrix_arts("STR_VALUE(MATS_DATA)/SaInv.xml"); MatrixType SeInv = invlib::read_matrix_arts("STR_VALUE(MATS_DATA)/SeInv.xml"); PrecisionMatrix Pa(SaInv); PrecisionMatrix Pe(SeInv); VectorType y = invlib::read_vector_arts("STR_VALUE(MATS_DATA)/y.vec"); VectorType xa = invlib::read_vector_arts("STR_VALUE(MATS_DATA)/xa.vec"); // Setup OEM. SolverType cg(1e-6, 1); MinimizerType gn(1e-6, 1, cg); LinearModel F(K, xa); MAPType oem(F, xa, Pa, Pe); // Run OEM. VectorType x; oem.compute(x, y, gn, 0); invlib::write_vector_arts("x.xml", (invlib::VectorData<double>) x, invlib::Format::ASCII); return 0.0; }
static int set_debug_option( char *caller_name, debug_option *options, char *value) { debug_option *op; int level; char *eq; if (NULL != (eq = ss(value,'='))) { /* There is an '='. */ *eq = 0; level = gn(eq+1); } else if (!('0' <= *value && *value <= '9')) { /* name with no '=', default to level 1. */ level = 1; } else { /* level with no name, set all options to level. */ level = gn(value); set_all_options(options,level); return(0); } op = find_debug_option(options,value); if (NULL != eq) { *eq = '='; } if (NULL != op) { /* Got a match. */ if (NULL != op->level) { *(op->level) = level; } else { /* Value matched an entire sub_table */ set_all_options(op,level); } return(0); } /* Unknown debug option. */ if (NULL == caller_name) { /* Silently ignore it. */ return(0); } printk(KERN_ERR "%s: unknown dbg option `%s', valid options are:\n", caller_name,value); print_all_options(caller_name,options); return(1); }
static PyObject* _gn(PyObject* self) { K kobj = gn(); if (!kobj) { PyErr_SetString(PyExc_RuntimeError, "gn returned NULL"); return NULL; } return _mk_K(kobj); }
void insert(node **h,char data,int pri) { node *t=*h,*x=gn(data,pri); if(*h==N || (*h)->p > pri) { x->n=*h; *h=x; } else { while(t->n!=N && t->n->p <= pri) t=t->n; x->n=t->n; t->n=x; } }
GeneralSubtree::GeneralSubtree(const std::string& v) : GeneralSubtree() { size_t p0, p1; size_t min = std::stoull(v, &p0, 10); size_t max = std::stoull(v.substr(p0 + 1), &p1, 10); GeneralName gn(v.substr(p0 + p1 + 2)); if(p0 > 0 && p1 > 0) { m_minimum = min; m_maximum = max; m_base = gn; } else { throw Invalid_Argument("Failed to decode Name Constraint"); } }
static int _K_init(_K *self, PyObject *args, PyObject *kwds) { PyObject* ko = NULL; if (PyArg_ParseTuple(args, "|O!", &_KType, &ko)) { K kobj; if (ko) { kobj = ((_K*)ko)->kobj; xci(kobj); } else { kobj = gn(); } self->kobj = kobj; return 0; } PyErr_SetString(PyExc_TypeError, "not k type"); return -1; }
void run_triangle_counting(char* filename, int nthreads) { Graph<TC> G; G.ReadMTX(filename, nthreads*16); //nthread pieces of matrix int numberOfVertices = G.getNumberOfVertices(); GetNeighbors gn(numberOfVertices); CountTriangles ct(numberOfVertices); auto gn_tmp = graph_program_init(gn, G); auto ct_tmp = graph_program_init(ct, G); struct timeval start, end; for (int i = 1; i <= numberOfVertices; i++) { TC vp = G.getVertexproperty(i); vp.id = i; G.setVertexproperty(i, vp); } gettimeofday(&start, 0); G.setAllActive(); run_graph_program(&gn, G, 1, &gn_tmp); G.setAllActive(); run_graph_program(&ct, G, 1, &ct_tmp); gettimeofday(&end, 0); printf("Time = %.3f ms \n", (end.tv_sec-start.tv_sec)*1e3+(end.tv_usec-start.tv_usec)*1e-3); graph_program_clear(gn_tmp); graph_program_clear(ct_tmp); unsigned long int ntriangles = 0; for (int i = 1; i <= numberOfVertices; i++) ntriangles += G.getVertexproperty(i).triangles; printf("Total triangles = %lu \n", ntriangles); for (int i = 1; i <= std::min(10, numberOfVertices); i++) { G.getVertexproperty(i).print(); } }
QuickLaunchAction::QuickLaunchAction(const XdgDesktopFile * xdg, QWidget * parent) : QAction(parent), m_valid(true) { m_type = ActionXdg; m_settingsMap["desktop"] = xdg->fileName(); QString title(xdg->localizedValue("Name").toString()); QString gn(xdg->localizedValue("GenericName").toString()); if (!gn.isEmpty()) title += " (" + gn + ")"; setText(title); setIcon(xdg->icon(XdgIcon::defaultApplicationIcon())); setData(xdg->fileName()); connect(this, SIGNAL(triggered()), this, SLOT(execAction())); }
KDModule::KDModule(QWidget *parent, const char *name, const QStringList &) : KCModule(KDMFactory::instance(), parent, name) , minshowuid(0) , maxshowuid(0) , updateOK(false) { KAboutData *about = new KAboutData(I18N_NOOP("kcmkdm"), I18N_NOOP("KDE Login Manager Config Module"), 0, 0, KAboutData::License_GPL, I18N_NOOP("(c) 1996 - 2005 The KDM Authors")); about->addAuthor("Thomas Tanghus", I18N_NOOP("Original author"), "*****@*****.**"); about->addAuthor("Steffen Hansen", 0, "*****@*****.**"); about->addAuthor("Oswald Buddenhagen", I18N_NOOP("Current maintainer"), "*****@*****.**"); setQuickHelp( i18n( "<h1>Login Manager</h1> In this module you can configure the " "various aspects of the KDE Login Manager. This includes " "the look and feel as well as the users that can be " "selected for login. Note that you can only make changes " "if you run the module with superuser rights. If you have not started the KDE " "Control Center with superuser rights (which is absolutely the right thing to " "do, by the way), click on the <em>Modify</em> button to acquire " "superuser rights. You will be asked for the superuser password." "<h2>Appearance</h2> On this tab page, you can configure how " "the Login Manager should look, which language it should use, and which " "GUI style it should use. The language settings made here have no influence on " "the user's language settings." "<h2>Font</h2>Here you can choose the fonts that the Login Manager should use " "for various purposes like greetings and user names. " "<h2>Background</h2>If you want to set a special background for the login " "screen, this is where to do it." "<h2>Shutdown</h2> Here you can specify who is allowed to shutdown/reboot the machine " "and whether a boot manager should be used." "<h2>Users</h2>On this tab page, you can select which users the Login Manager " "will offer you for logging in." "<h2>Convenience</h2> Here you can specify a user to be logged in automatically, " "users not needing to provide a password to log in, and other convenience features.<br>" "Note, that these settings are security holes by their nature, so use them very carefully.")); setAboutData( about ); setlocale( LC_COLLATE, "C" ); KGlobal::locale()->insertCatalogue("kcmbackground"); QStringList sl; QMap<gid_t,QStringList> tgmap; QMap<gid_t,QStringList>::Iterator tgmapi; QMap<gid_t,QStringList>::ConstIterator tgmapci; QMap<QString, QPair<int,QStringList> >::Iterator umapi; struct passwd *ps; for (setpwent(); (ps = getpwent()); ) { QString un( QFile::decodeName( ps->pw_name ) ); if (usermap.find( un ) == usermap.end()) { usermap.insert( un, QPair<int,QStringList>( ps->pw_uid, sl ) ); if ((tgmapi = tgmap.find( ps->pw_gid )) != tgmap.end()) (*tgmapi).append( un ); else tgmap[ps->pw_gid] = un; } } endpwent(); struct group *grp; for (setgrent(); (grp = getgrent()); ) { QString gn( QFile::decodeName( grp->gr_name ) ); bool delme = false; if ((tgmapi = tgmap.find( grp->gr_gid )) != tgmap.end()) { if ((*tgmapi).count() == 1 && (*tgmapi).first() == gn) delme = true; else for (QStringList::ConstIterator it = (*tgmapi).begin(); it != (*tgmapi).end(); ++it) usermap[*it].second.append( gn ); tgmap.remove( tgmapi ); } if (!*grp->gr_mem || (delme && !grp->gr_mem[1] && gn == QFile::decodeName( *grp->gr_mem ))) continue; do { QString un( QFile::decodeName( *grp->gr_mem ) ); if ((umapi = usermap.find( un )) != usermap.end()) { if ((*umapi).second.find( gn ) == (*umapi).second.end()) (*umapi).second.append( gn ); } else kdWarning() << "group '" << gn << "' contains unknown user '" << un << "'" << endl; } while (*++grp->gr_mem); } endgrent(); for (tgmapci = tgmap.begin(); tgmapci != tgmap.end(); ++tgmapci) kdWarning() << "user(s) '" << tgmapci.data().join(",") << "' have unknown GID " << tgmapci.key() << endl; config = new KSimpleConfig( QString::fromLatin1( KDE_CONFDIR "/kdm/kdmrc" )); QVBoxLayout *top = new QVBoxLayout(this); tab = new QTabWidget(this); // ***** // _don't_ add a theme configurator until the theming engine is _really_ done!! // ***** appearance = new KDMAppearanceWidget(this); tab->addTab(appearance, i18n("A&ppearance")); connect(appearance, SIGNAL(changed(bool)), SIGNAL( changed(bool))); font = new KDMFontWidget(this); tab->addTab(font, i18n("&Font")); connect(font, SIGNAL(changed(bool)), SIGNAL(changed(bool))); background = new KBackground(this); tab->addTab(background, i18n("&Background")); connect(background, SIGNAL(changed(bool)), SIGNAL(changed(bool))); sessions = new KDMSessionsWidget(this); tab->addTab(sessions, i18n("&Shutdown")); connect(sessions, SIGNAL(changed(bool)), SIGNAL(changed(bool))); users = new KDMUsersWidget(this, 0); tab->addTab(users, i18n("&Users")); connect(users, SIGNAL(changed(bool)), SIGNAL(changed(bool))); connect(users, SIGNAL(setMinMaxUID(int,int)), SLOT(slotMinMaxUID(int,int))); connect(this, SIGNAL(addUsers(const QMap<QString,int> &)), users, SLOT(slotAddUsers(const QMap<QString,int> &))); connect(this, SIGNAL(delUsers(const QMap<QString,int> &)), users, SLOT(slotDelUsers(const QMap<QString,int> &))); connect(this, SIGNAL(clearUsers()), users, SLOT(slotClearUsers())); convenience = new KDMConvenienceWidget(this, 0); tab->addTab(convenience, i18n("Con&venience")); connect(convenience, SIGNAL(changed(bool)), SIGNAL(changed(bool))); connect(this, SIGNAL(addUsers(const QMap<QString,int> &)), convenience, SLOT(slotAddUsers(const QMap<QString,int> &))); connect(this, SIGNAL(delUsers(const QMap<QString,int> &)), convenience, SLOT(slotDelUsers(const QMap<QString,int> &))); connect(this, SIGNAL(clearUsers()), convenience, SLOT(slotClearUsers())); load(); if (getuid() != 0 || !config->checkConfigFilesWritable( true )) { appearance->makeReadOnly(); font->makeReadOnly(); background->makeReadOnly(); users->makeReadOnly(); sessions->makeReadOnly(); convenience->makeReadOnly(); } top->addWidget(tab); }
void av::NetNode::join(const std::string& groupName) { #ifdef AVANGO_DEBUG logger.debug() << "av::NetNode::NetNode: joining group: " << groupName; #endif #ifdef ZMQ_DISTRIBUTION_SUPPORT bool isServer; std::string hostName; std::string port; uint64_t serverHWM = 2; { // from http://stackoverflow.com/questions/541561/using-boost-tokenizer-escaped-list-separator-with-different-parameters std::string gn(groupName); typedef boost::tokenizer< boost::escaped_list_separator<char> > Tokenizer; boost::escaped_list_separator<char> Separator( ' ', '|' ); Tokenizer tok( gn, Separator ); unsigned numTokens = 0; for (Tokenizer::iterator iter = tok.begin(); iter != tok.end(); ++iter) { ++numTokens; } if (3 == numTokens) { Tokenizer::iterator iter = tok.begin(); isServer = ("AVSERVER" == *iter); ++iter; hostName = *iter; ++iter; port = *iter; } else if (4 == numTokens) { Tokenizer::iterator iter = tok.begin(); isServer = ("AVSERVER" == *iter); ++iter; hostName = *iter; ++iter; port = *iter; serverHWM = atoi((*iter).c_str()); } else { std::stringstream msg; msg << "ERROR in av::NetNode::join(const std::string& groupName), could not join - invalid CONFIG"; throw (std::runtime_error(msg.str())); } } if (isServer) { gServer = new NetNodeServer(hostName,port, this, gClientEndpoint, gServerEndpoint, serverHWM); joined(gServerEndpoint); av::Msg av_msg; getStateFragment(gServerEndpoint,av_msg); setStateFragment(gClientEndpoint,av_msg); } else { gClient = new NetNodeClient(hostName,port, this, gClientEndpoint, gServerEndpoint); joined(gClientEndpoint); gClient->start(); } //handleNetworkSends(); //handleNetworkReceives(); mIdCounter = 0; #else leave(); Maestro_CSX_Options ops; // heartbeat is once per second ops.heartbeatRate = 1000; ops.groupName = (char*) groupName.c_str(); ops.transports = "DEERING"; ops.properties = "Gmp:Sync:Heal:Switch:Frag:Suspect:Flow:Total"; ops.params = "suspect_max_idle=3:int;suspect_sweep=1.000:time"; ops.mbrshipType = MAESTRO_SERVER; ops.xferType = MAESTRO_ATOMIC_XFER; // get the command-line options from the database ops.argv = getEnsOptionsArgv(); // check for usage of a groupd and set the corresponding maestro flag std::string dummy_value; if (getEnsOption("-groupd", dummy_value)) ops.groupdFlag = true; if (getEnsOption("-properties", dummy_value)) ops.properties = const_cast<char*> (dummy_value.c_str()); if (getEnsOption("-verbose", dummy_value)) { if (getEnsOption("-modes", dummy_value)) std::cout << " modes : " << dummy_value << std::endl; if (getEnsOption("-deering_port", dummy_value)) std::cout << " deering_port: " << dummy_value << std::endl; if (getEnsOption("-gossip_port", dummy_value)) std::cout << " gossip_port : " << dummy_value << std::endl; if (getEnsOption("-gossip_hosts", dummy_value)) std::cout << " gossip_hosts: " << dummy_value << std::endl; if (getEnsOption("-properties", dummy_value)) std::cout << " properties : " << dummy_value << std::endl; if (getEnsOption("-multiread", dummy_value)) std::cout << " multiread : " << (dummy_value.empty () ? "on" : dummy_value) << std::endl; } mMember = new NetGroup(this, ops); mMember->join(); mEID = mMember->eid().getHotEndpt().name; joined(mEID); handleNetworkSends(); handleNetworkReceives(); #ifdef AVANGO_DEBUG logger.debug() << "av::NetNode::NetNode: " << "joined group '" << groupName.c_str() << "', my eid: " << netEID(); #endif mIdCounter = 0; #ifdef AVANGO_DEBUG logger.debug() << "av::NetNode::join: was called from: " << " pid: " << getpid(); logger.debug() << "av::NetNode::join: completed."; #endif #endif // #ifdef ZMQ_DISTRIBUTION_SUPPORT }