int main( int argc, char* argv[] ) { // Open trajectory channel sns_chan_open( &traj_chan, "traj-left", NULL ); // Set path std::list<Eigen::VectorXd> path; Eigen::VectorXd po(num_joints); Eigen::VectorXd pf(num_joints); po(0) = 0.162630; po(1) = 0.098454; po(2) = 0.13533; po(3) = -0.002723; pf(0) = po(0) - 0.16; pf(1) = po(1) - 0.1; pf(2) = po(2) - 0.135; pf(3) = po(3) + 0.1; path.push_back( po ); path.push_back( pf ); // Build a message struct sns_msg_path_dense* msg = sns_msg_path_dense_alloc( path.size(), (*(path.begin())).size() ); msg->n_dof = (*(path.begin())).size(); msg->n_steps = path.size(); sns_msg_header_fill( &msg->header ); msg->header.n = (*(path.begin())).size(); // Fill path int counter = 0; std::list<Eigen::VectorXd>::iterator it; for( it = path.begin(); it != path.end(); ++it ) { for( int j = 0; j < (*it).size(); ++j ) { msg->x[counter] = (*it)(j); counter++; } } // Set message duration double tsec = 0.05; int64_t dt_nsec = tsec*1e9; struct timespec now; if( clock_gettime( ACH_DEFAULT_CLOCK, &now ) ) { SNS_LOG( LOG_ERR, "Clock_gettime failed: %s \n", strerror(errno) ); } sns_msg_set_time( &msg->header, &now, dt_nsec ); // Send message ach_status_t r; r = ach_put( &traj_chan, msg, sns_msg_path_dense_size(msg) ); if( r!= ACH_OK ) { printf("\t * [ERROR] Error sending path \n"); } else { printf("\t * [INFO] Path was sent all right\n"); } }
void run(ucam::util::RegistryPO const &rg) { ucam::util::PatternAddress<unsigned> pi (rg.get<std::string> (HifstConstants::kInput) ); ucam::util::PatternAddress<unsigned> po (rg.get<std::string> (HifstConstants::kOutput) ); for ( ucam::util::IntRangePtr ir (ucam::util::IntRangeFactory ( rg, HifstConstants::kRangeOne ) ); !ir->done(); ir->next() ) { fst::VectorFst<Arc> *mfst = fst::VectorFstRead<Arc> (pi ( ir->get() ) ); if (!mfst) { LERROR("Could not read file:" << ir->get()); exit(EXIT_FAILURE); } TopSort (mfst); boost::multiprecision::uint128_t j = countstrings<Arc, boost::multiprecision::uint128_t> (*mfst); std::stringstream ss; ss << j; ucam::util::oszfstream o (po (ir->get() ), true); o << ss.str() << std::endl; LINFO ( pi (ir->get() ) << ":" << ss.str() ) ; o.close(); delete mfst; } }
int main (int argc, const char* argv[] ) { ucam::util::initLogger ( argc, argv ); FORCELINFO ( argv[0] << " starts!" ); ucam::util::RegistryPO rg ( argc, argv ); FORCELINFO ( rg.dump ( "CONFIG parameters:\n=====================", "=====================" ) ) ; ucam::util::PatternAddress<unsigned> pi (rg.get<std::string> (HifstConstants::kInput) ); ucam::util::PatternAddress<unsigned> po (rg.get<std::string> (HifstConstants::kOutput) ); for ( ucam::util::IntRangePtr ir (ucam::util::IntRangeFactory ( rg, HifstConstants::kRangeOne ) ); !ir->done(); ir->next() ) { fst::VectorFst<fst::StdArc> *mfst = fst::VectorFstRead<fst::StdArc> (pi ( ir->get() ) ); if (!mfst) return 1; TopSort (mfst); boost::multiprecision::uint128_t j = countstrings<fst::StdArc, boost::multiprecision::uint128_t> (*mfst); std::stringstream ss; ss << j; ucam::util::oszfstream o (po (ir->get() ), true); o << ss.str() << std::endl; LINFO ( pi (ir->get() ) << ":" << ss.str() ) ; o.close(); delete mfst; } FORCELINFO ( argv[0] << " ends!" ); }
static void at91sam9x5_video_params(unsigned width, unsigned height, int rotation, u32 *xstride, u32 *pstride, u32 *tloffset) { /* offset of pixel at (x, y) in the buffer */ #define po(x, y) ((x) + width * (y)) /* offsets of the edges in counter-clockwise order */ const unsigned e[] = { po(0, 0), po(0, height - 1), po(width - 1, height - 1), po(width - 1, 0), }; /* * offsets of the pixels next to the corresponding edges * If edge[i] goes to the top left corner, edge_neighbour[i] is * located just below of edge[i]. */ const unsigned en[] = { po(0, 1), po(1, height - 1), po(width - 1, height - 2), po(width - 2, 0), }; #define ro(r) ((rotation + (r)) % 4) *xstride = en[ro(0)] - e[ro(3)]; *pstride = e[ro(3)] - en[ro(3)]; *tloffset = e[ro(0)]; }
void r_po(int argc, Rune **argv) { if(argc == 1){ po(getnr(L(".o0"))); return; } if(argv[1][0] == '+') po(getnr(L(".o"))+evalscale(argv[1]+1, 'v')); else if(argv[1][0] == '-') po(getnr(L(".o"))-evalscale(argv[1]+1, 'v')); else po(evalscale(argv[1], 'v')); }
void XmlWriter::writeFile(FILE *f, const NodePtr node) { if (!node) { po("XmlWriter: NULL document\n"); return; } indent = 0; //po("Document\n"); buf = ""; write(node); for (unsigned int i=0 ; i<buf.size() ; i++) { int ch = buf[i]; fputc(ch, f); } fflush(f); buf = ""; }
main (){ int j1 = 1; int k1 = 2; // Save integers to the file "int.dat" { // Open the stream to save to: ofstream f("int.dat"); RWpostream po(f); // Use overloaded insertion operator to save integers: po << j1; po << k1; } // Restore integers from the file "int.dat" int j2 = 0; int k2 = 0; { // Open a separate stream to restore from: ifstream f("int.dat"); RWpistream pi(f); // Use overloaded extraction operator to restore integers: pi >> j2; // j1 == j2 pi >> k2; // k1 == k2 } assert(j1 == j2); assert(k1 == k2); return 0; }
PingResult TransportObjectFactory::ping( TcpTransport& tcpTransport) { IntWrapper tid(std::numeric_limits<uint32_t>::max()); PingOperation po(codec, tid, tcpTransport); return po.execute(); }
PingResult TransportObjectFactory::ping( TcpTransport& tcpTransport) { Topology tid(-1); PingOperation po(codec, tid, tcpTransport); return po.execute(); }
int main() { long long int n,m,k; scanf("%lld%lld%lld",&n,&m,&k); bool min=0; long long int point=0; if(m>(n/k)*(k-1)+n%k) min = true; long long int excess = m - ((n/k)*(k-1)+n%k); if(min) { point = (k*(po(2,excess+1)%MOD-2))%MOD ; point = (point + m - (excess*k)%MOD)%MOD; } else { point = m; } printf("%lld\n",point); return 0; }
PodOutputAbs PodOutputSim::absolute(const PodState& pod) { Vector target = pod.pos + Vector::fromMagAngle(10000, pod.angle + angle); PodOutputAbs po(thrust, target); if(shieldEnabled) po.enableShield(); else if(boostEnabled) po.enableBoost(); return po; }
void GameScene::mouseLock() { QPoint po(gView->pos().x()+gView->width()/2,gView->pos().y()+gView->height()/2); gView->cursor().setPos(po); setCenterPoint(po); // gView->setCursor(Qt::BlankCursor); gView->viewport()->setCursor(Qt::BlankCursor); //使用父容器对鼠标进行改变 }
void MD_Runner::run() { fprintf(stderr, "V8 version %s [mordor shell]\n", v8::V8::GetVersion()); v8::Platform* v8_platform = v8::platform::CreateDefaultPlatform(1); v8::V8::InitializeICU(); v8::V8::InitializePlatform(v8_platform); v8::V8::Initialize(); int argc = g_argc; v8::V8::SetFlagsFromCommandLine(&argc, g_argv, true); v8::V8::SetFlagsFromString(MD_V8_OPTIONS, sizeof(MD_V8_OPTIONS) - 1); v8::V8::SetArrayBufferAllocator(&ArrayBufferAllocator::the_singleton); v8::Isolate* isolate = v8::Isolate::New(); { v8::Isolate::Scope isolate_scope(isolate); v8::Locker locker(isolate); v8::HandleScope handle_scope(isolate); v8::Local<v8::Context> context = v8::Context::New(isolate); v8::Context::Scope context_scope(context); Environment* env = Environment::New(context, Scheduler::getThis()); ProcessObject po(env); po.setup(); { Coroutine<const char*> coReadScript(&readScript); const char* script; bool running = true; do { script = coReadScript.call(); if (coReadScript.state() == Fiber::State::TERM) { break; } v8::HandleScope handle_scope(context->GetIsolate()); v8::Local<v8::String> script_str = Utf8String(isolate, script); ExecuteString(env, script_str, Utf8String(isolate, "md_shell")); running = env->running(); } while (running); std::cout << "bye." << std::endl; } Environment::environment.reset(); } isolate->Dispose(); LineEditor* line_editor = LineEditor::Get(); if (line_editor) line_editor->Close(); v8::V8::Dispose(); v8::V8::ShutdownPlatform(); delete v8_platform; this->over(); }
int main() { while(1) { char y[5]; fflush(stdin); scanf("%s",y); int n,z; n=(10*(y[0]-'0')+y[1]-'0')*po(10,y[3]-'0'); if(n==0) break; if((n&(n-1))==0) printf("1\n"); else { z=log2l(n); z=po(2,z); printf("%d\n",1+2*(n-z)); } } return 0; }
int po(int a, int k) { if(k == 0) return 1; if(k == 1) return a; int temp = po(a, k/2); temp *= temp; if(k & 1) temp *= a; return temp; }
int main(){ scanf("%d",&T); while(T--){ scanf("%lld%lld%lld%d",&e,&p,&q,&n); e=rev(e,(p-1)*(q-1)); P=p*q; for(i=1;i<=n;i++){ scanf("%lld",&x); printf("%lld%c",po(x,e),i<n?' ':'\n'); } } }
static base_t my_powr(const base_t&i, int p, unsigned q) { base_t po(Power(i, p)); if((q & 0x1) && my_inf(po) < 0) { if(my_sup(po) <= 0) return -Root(Abs(po), q); base_t r(Root(Abs(po), q)); r = base_t(-Sup(r), Sup(r)); return r; } return Root(po,q); }
bool ProcessingView::eventFilter(QObject *, QEvent *) { QPainter painter(ui->widget); QPoint po(0, 0); if (thumbnailImage != nullptr) { painter.drawImage(po, *thumbnailImage); } return true; }
int main(int argc, char** argv) { //Parse command-line args ProgramOptions po(argc, argv); //Initialize the AST SgProject* project = new SgProject(argc, argv); ROSE_ASSERT(project); AstTests::runAllTests(project); //TODO switch on/off with command-line args //Set the folder containing the features string featureFolder = ""; bool defaultFeatures = po.getFeaturesFolder(featureFolder); if(!defaultFeatures) CallScheduler::setFeaturesFolder(featureFolder); //Loop through all partitioned kernels and add scheduling calls Rose_STL_Container<SgNode*> pragmas = querySubTree(project, V_SgPragmaDeclaration); Rose_STL_Container<SgNode*>::const_iterator pragmaIt = pragmas.begin(); SgPragmaDeclaration* pragma = NULL; SgFunctionDeclaration* funcDecl = NULL; SgStatement* stmt = NULL; for(pragmaIt = pragmas.begin(); pragmaIt != pragmas.end(); pragmaIt++) { pragma = isSgPragmaDeclaration(*pragmaIt); ROSE_ASSERT(pragma); PragmaParser pp(pragma); if(pp.isPopcornPragma() && pp.getPragmaType() == PARTITIONED) { stmt = getNextStatement(pragma); while(!isSgFunctionDeclaration(stmt)) stmt = getNextStatement(pragma); funcDecl = isSgFunctionDeclaration(stmt); ROSE_ASSERT(funcDecl); Pragmas pragmas(funcDecl); //Add scheduling calls CallScheduler cs(funcDecl, pragmas); cs.addSchedulerCalls(); //Insert the header //TODO this won't insert the header into files insertHeader(po.getSchedulerHeaderLocation(), PreprocessingInfo::after, false, getGlobalScope(funcDecl)); } } return backend(project); }
void XmlWriter::write(const NodePtr nodeArg) { NodePtr node = nodeArg; indent+=2; NamedNodeMap attributes = node->getAttributes(); int nrAttrs = attributes.getLength(); //### Start open tag spaces(); po("<"); pos(node->getNodeName()); if (nrAttrs>0) po("\n"); //### Attributes for (int i=0 ; i<nrAttrs ; i++) { NodePtr attr = attributes.item(i); spaces(); pos(attr->getNodeName()); po("=\""); pos(attr->getNodeValue()); po("\"\n"); } //### Finish open tag if (nrAttrs>0) spaces(); po(">\n"); //### Contents spaces(); pos(node->getNodeValue()); //### Children for (NodePtr child = node->getFirstChild() ; child.get() ; child=child->getNextSibling()) { write(child); } //### Close tag spaces(); po("</"); pos(node->getNodeName()); po(">\n"); indent-=2; }
int main(int argc,char *argv[]) { int b1=atoi(argv[1]); int b2=atoi(argv[2]); int w=strlen(argv[3]); int ch[w],sum=0,i,fin[100],r,c=0; char k; for(i=0;i<w;i++) { k=argv[3][i]; if(k>=48 && k<=57) ch[i]=k-48; else if(k>=65 && k<=70) ch[i]=k-55; else ch[i]=999; if(ch[i]>=b1) { printf("%d",0); return 0; } } for(i=0;i<w;i++) { sum=sum+ch[i]*po(b1,w-i-1); } if(b2==10) printf("%d",sum); else { do { r=sum%b2; fin[c]=r; sum=sum/b2; c++; }while(sum>0); for(i=c-1;i>=0;i--) { if(fin[i]<10) k=fin[i]+48; else k=fin[i]+55; printf("%c",k); } } return 0; }
void SpectralMeterView::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { Q_UNUSED(option); Q_UNUSED(widget); // re-draw the background pixmap if (bgPixmap.width() != int(m_boundingRect.width()) || bgPixmap.height() != int(m_boundingRect.height())) { update_background(); } painter->drawPixmap(0, 0, bgPixmap); // draw the bars if (m_spectrum.size()) { QRect rect; painter->setClipRegion(m_rect); painter->setBrush(m_brushFg); painter->setPen(Qt::NoPen); int spc = 0; if (num_bands < 64) spc = 1; // draw the freq bands for (uint i = 0; i < (uint)m_spectrum.size(); ++i) { if (m_bands.at(i+1) < lower_db) { continue; } rect.setTopLeft(QPoint((int)freq2xpos(m_bands.at(i)) + spc, (int)db2ypos(m_spectrum.at(i)))); rect.setBottomRight(QPoint((int)freq2xpos(m_bands.at(i+1)) - spc, (int)db2ypos(DB_FLOOR))); painter->drawRect(rect); } // draw the average line if requested if (show_average) { painter->setPen(m_penAvgCurve); QPoint pt; QPoint po((int)m_map_idx2xpos.at(0), (int)db2ypos(m_avg_db.at(0))); for (uint i = 0; i < (uint)m_avg_db.size(); ++i) { pt.setX((int)m_map_idx2xpos.at(i)); pt.setY((int)db2ypos(m_avg_db.at(i))); painter->drawLine(po, pt); po = pt; } } } }
void Controller_Module::mode ( Mode m ) { if( mode() != CV && m == CV ) { if ( control_output[0].connected() ) { chain()->engine()->lock(); Port *p = control_output[0].connected_port(); JACK::Port po( chain()->engine(), JACK::Port::Input, p->name(), 0, "CV" ); if ( ! po.activate() ) { fl_alert( "Could not activate JACK port \"%s\"", po.name() ); chain()->engine()->unlock(); return; } if ( po.valid() ) { jack_input.push_back( po ); } chain()->engine()->unlock(); } } else if ( mode() == CV && m != CV ) { chain()->engine()->lock(); jack_input.back().shutdown(); jack_input.pop_back(); chain()->engine()->unlock(); } _mode = m ; }
int main(const bayolau::CommandLine& cl) { Options po(cl); if (not po.valid() or po.help()) { std::cout << po << std::endl; return 1; } std::cout << "faitest operating with " << po.input() << std::endl; bio::Fai lookup(po.input()); std::cout << "seqNameStore size " << lookup.size() << std::endl; for (auto itr = lookup.name_begin(); itr != lookup.name_end(); ++itr) { std::cout << *itr << " " << lookup.size(*itr) << "\n"; } const auto& first = *lookup.name_begin(); std::cout << "first entry " << first << " (" << lookup.size(first) << ")" << std::endl; std::cout << *lookup.get<seqan::Dna5String>(first, 100, 200) << std::endl; return 0; }
PetscErrorCode PISMIceModel::allocate_couplers() { PetscErrorCode ierr; // Initialize boundary models: PAFactory pa(grid, config); PSFactory ps(grid, config); POFactory po(grid, config); PISMAtmosphereModel *atmosphere; ierr = PetscOptionsBegin(grid.com, "", "Options choosing PISM boundary models", ""); CHKERRQ(ierr); #if 1 // GLINT2-modified version if (surface == NULL) { surface = new PSConstantGLINT2(grid, config); external_surface_model = false; pa.create(atmosphere); surface->attach_atmosphere_model(atmosphere); } #else // Original Version if (surface == NULL) { ps.create(surface); external_surface_model = false; pa.create(atmosphere); surface->attach_atmosphere_model(atmosphere); } #endif if (ocean == NULL) { po.create(ocean); external_ocean_model = false; } ierr = PetscOptionsEnd(); CHKERRQ(ierr); return 0; }
int main( int argc, char** argv) { //assign the filename std::string filename; bool write_tris = false; ProgOptions po("Graph_Obbs: a program for writing the OBBs of a mesh in a dot graph format"); po.addRequiredArg<std::string>("filename", "Mesh file", &filename); po.parseCommandLine( argc, argv ); //start a dagmc instance and load the modified cube file moab::DagMC *dag_inst = moab::DagMC::instance(); moab::ErrorCode result; result = dag_inst->load_file( filename.c_str() ); if( MB_SUCCESS != result) return MB_FAILURE; //generate the obb tree result = dag_inst->init_OBBTree(); if( MB_SUCCESS != result) return MB_FAILURE; moab::Range vols; result = get_volumes( dag_inst->moab_instance(), vols ); //now write the OBBs to a set of files based on depth in tree std::string base_name = "OBBS"; result = write_obb_mesh( dag_inst, vols[0], base_name, write_tris ); if( MB_SUCCESS != result) return MB_FAILURE; return 0; }
void OffsetWorker::offsetPolygon(Polygon_2 poly, double offset) { typedef CGAL::Gps_circle_segment_traits_2<SFCGAL::Kernel> Gps_traits_2; typedef Gps_traits_2::Polygon_2 Offset_polygon_2; if(!poly.is_simple()) { DM::Logger(DM::Warning) << "Can't perform offset polygon is not simple"; } CGAL::Orientation orient = poly.orientation(); if (orient == CGAL::CLOCKWISE) { poly.reverse_orientation(); } const double err_bound = 0.00001; std::list<Offset_polygon_2> inset_polygons; CGAL::approximated_inset_2 (poly, offset, err_bound, std::back_inserter (inset_polygons)); foreach (Offset_polygon_2 p, inset_polygons) { SFCGAL::Polygon po(this->approximate(p)); QString wkt = QString(po.asText(9).c_str()); module->addToSystem(wkt); //emit resultPolygon(wkt); }
QSharedPointer<PluginOptions> CustomWidgetPluginWizardPage::basicPluginOptions() const { QSharedPointer<PluginOptions> po(new PluginOptions); po->pluginName = pluginName(); po->resourceFile = m_ui->resourceFileEdit->text(); po->collectionClassName = collectionClassName(); po->collectionHeaderFile = m_ui->collectionHeaderEdit->text(); po->collectionSourceFile = m_ui->collectionSourceEdit->text(); return po; }
bool Render::dentroFace(HalfEdge* h, QPointF p) { HalfEdge::iterator it; QVector<QPointF> list; list.push_back(h->getOrigem()->getPoint()); for(it = h->f_begin(); it != h->f_end(); ++it) { list.push_back(it->getOrigem()->getPoint()); } QPolygonF po(list); return po.containsPoint(p, Qt::OddEvenFill); }
int main() { int t,n,a,b,i; long long int cnt; scanf("%d",&t); while(t--) { scanf("%d",&n);cnt=0; for(i=0;i<=n/2;i++) { a=n-2*i; b=i; if(b==0) { cnt=cnt+po(a-1);printf("%lld\n",cnt); } else { cnt=cnt+(fact(n-i)/(fact(a-1)*fact(b)))*po(a-1+b);printf("%lld\n",cnt); cnt=cnt+(fact(n-i)/(fact(a)*fact(b-1)))*po(a+b-1);printf("%lld\n",cnt); } } printf("%lld\n",cnt); } //printf("%d %d",fact(1),po(5)); return 0; }