S min(arbint a){ while(!v(ag(a))) a=ag(a); return r(a); }
arbint sup(arbint a,S x){ int chemin; arbin racine=a; arbin pere; while(x!=r(a)){ if (x>r(a)){ pere=a; a=ad(a); chemin=1; } else{ pere=a; a=ag(a); chemin=0; } nouv_racine=r(eg(ad(a))); otermin(ad(a)); if(chemin==0) pere->ag=e(ag(a),nouv_racine,ad(a)); else pere->ad=e(ag(a),nouv_racine,ad(a)); free(a); return racine; } }
Arbin union1(Arbin a1,Arbin a2)// Ici, la fonction copieArbre permet de rendre la methode fonctionnelle { if(a1==NULL) return copieArbre(a2); else if(a2==NULL) return copieArbre(a1); else { if(a1->v <= a2->v) return e(copieArbre(ag(a1)),a1->v,union1(ad(a1),a2)); else return e(union1(a1,ag(a2)),a2->v,copieArbre(ad(a2))); } }
arbin otermin(arbint a){ arbin racine=a; arbin tmp; while(!v(ag(ag(a)))) a=ag(a); tmp=ad(ag(a)); free(a->ag); a->ag=tmp; return racine; }
Gravity_t Base_t::writeGravity( const vector<float>& gvect ) { Array<float> ag(gvect); int ier = cg_gravity_write( getFileID(), getID(), ag ); check_error( "Base_t::writeGravity", "cg_gravity_write", ier ); return Gravity_t(push( "Gravity_t", 1 )); }
DSN_PY_API dsn_error_t dsn_app_bridge(int argc, const char** argv) { std::vector< std::string> args; for (int i = 0; i < argc; i++) { std::string ag(*argv++); args.push_back(ag); } new std::thread([=](){ Py_Initialize(); char* PyFileName = (char *)args[0].c_str(); char** PyParameterList = new char* [args.size()]; for (int i = 0;i < args.size(); ++i) { PyParameterList[i] = new char[args[i].size()+1]; strcpy(PyParameterList[i], args[i].c_str()); } PySys_SetArgv((int)args.size(), PyParameterList); PyObject* PyFileObject = PyFile_FromString(PyFileName, "r"); PyRun_SimpleFile(PyFile_AsFile(PyFileObject), PyFileName); Py_Finalize(); for (int i = 0; i < args.size(); ++i) { delete [] PyParameterList[i]; } delete [] PyParameterList; }); dsn_app_loader_wait(); return dsn::ERR_OK; }
int main() { AndGate2 ag(true, false); AndGate2 ag2(false); AndGate2 ag3(); //not working for some misterious reason AndGate2 ag4(true,false); AndGate2 ag5(false,true); AndGate2 ag6(true); std::cout << ag.toString() << std::endl; std::cout <<"Output: " << std::boolalpha << ag.getOutput() << std::endl; std::cout <<"Comparing with 'ag4'(" << ag4.toString() << "). " << "Result: " << std::boolalpha << (ag==ag4) << std::endl; //(ag==ag4) needs the parentesis in order to compile std::cout << "==============================================================" << std::endl; std::cout << ag5.toString() << std::endl; std::cout <<"Output: " << std::boolalpha << ag5.getOutput() << std::endl; std::cout <<"Comparing with 'ag2'(" << ag2.toString() << "). " << "Result: " << std::boolalpha << (ag5==ag2) << std::endl; std::cout << "==============================================================" << std::endl; std::cout << ag6.toString() << std::endl; std::cout <<"Output: " << std::boolalpha << ag6.getOutput() << std::endl; std::cout <<"Comparing with 'ag5'(" << ag5.toString() << "). " << "Result: " << std::boolalpha << (ag6==ag5) << std::endl; }
void DPolygon::writeGML(ostream &stream) const { Graph g; GraphAttributes ag(g); node u = NULL; node v = NULL; node first = 0; ListConstIterator<DPoint> iter; for (iter = begin(); iter.valid(); ++iter) { v = g.newNode(); if (u != NULL) g.newEdge(u, v); else first = v; u = v; ag.x(v) = (*iter).m_x; ag.y(v) = (*iter).m_y; } g.newEdge(v, first); ag.writeGML(stream); }
void Editor::rotationPivot() { KMenu menu(i18n("Rotation Pivot")); QAction *a1 = menu.addAction(i18n("Each parts")); QAction *a2 = menu.addAction(i18n("Center")); QAction *a3 = menu.addAction(i18n("Manual (if exists)")); a1->setCheckable(true); a2->setCheckable(true); a3->setCheckable(true); QActionGroup ag(&menu); ag.addAction(a1); ag.addAction(a2); ag.addAction(a3); ag.setExclusive(true); if (pivot_ == PivotEach) a1->setChecked(true); else if (pivot_ == PivotCenter) a2->setChecked(true); else if (pivot_ == PivotManual) a3->setChecked(true); a3->setEnabled(false); QAction *result = menu.exec(QCursor::pos()); if (result == a1) pivot_ = PivotEach; else if (result == a2) pivot_ = PivotCenter; else if (result == a3) pivot_ = PivotManual; }
void reset(void) { cur[0]=icur; dg=5; fmt=2; strcpy(buf,"0-99,0-99,0-99,0-99"); ag(buf,0); oper=0; }
arbin otermax(arbint a){ arbin racine=a; arbin tmp; while(!v(ad(ad(a)))) a=ad(a); tmp=ag(ad(a)); free(a->ad); a->ad=tmp; return racine; }
TEST(AlnGraphBoostTest, DanglingNodes) { log4cpp::Appender *fapp = new log4cpp::OstreamAppender("console", &std::cout); log4cpp::PatternLayout *layout = new log4cpp::PatternLayout(); layout->setConversionPattern("%d %p [%c] %m%n"); fapp->setLayout(layout); log4cpp::Category& root = log4cpp::Category::getRoot(); root.addAppender(fapp); AlnGraphBoost ag(12); dagcon::Alignment a; a.tstr = "C-GCGGA-T-G-"; a.qstr = "CCGCGG-G-A-T"; ag.addAln(a); EXPECT_FALSE(ag.danglingNodes()); }
Liste al(Arbin a)//Parcours infixe inverse : d r g { Liste l=listenouv(); Listea tmp=listenouv_a(); Arbin atmp; tmp=desd(a,tmp); while(tailleliste_a(tmp)>0) { atmp=tete_a(tmp); tmp=supt_a(tmp); l=adjt(l,rac(atmp)); tmp=desd(ag(atmp),tmp); } freeListe_a(tmp); return l; }
bool rech(arbint a,S x){ arbin racine=a; while(!v(a)){ if (x>r(a)){ a=ad(a); } else if (x<r(a)){ a=ag(a); } else return a; } return lambda(); }
void agg(char *l,unsigned char j) { unsigned char i; /*SN SN*/ icur=cur[j]; oper=0xff; /*SN SN*/ for(i=0;i<GS;i++) gi[j]=0; ag(l,j); cur[j]=(unsigned long)(g[j][0]*pow10[dg-2]); // printf("%lu",cur[j]); return; }
void Consensus(int id, TrgBuf& trgBuf, CnsBuf& cnsBuf) { TargetData td; trgBuf.pop(&td); std::vector<CnsResult> seqs; el::Loggers::getLogger("Consensus"); while (td.alns.size() > 0) { if (td.alns.size() < popts.minCov) { trgBuf.pop(&td); continue; } boost::format msg("(%d) calling: %s Alignments: %d"); CLOG(INFO, "Consensus") << msg % id % td.alns[0].id % td.alns.size(); AlnGraphBoost ag(td.targSeq); AlnVec alns = td.alns; for (auto it = alns.begin(); it != alns.end(); ++it) { if (it->qstr.length() < popts.minLen) continue; dagcon::Alignment aln = normalizeGaps(*it); // XXX: Shouldn't be needed for dazcon, but causes some infinite // loops in the current consensus code. trimAln(aln, popts.trim); ag.addAln(aln); } CVLOG(3, "Consensus") << "Merging nodes"; ag.mergeNodes(); CVLOG(3, "Consensus") << "Generating consensus"; ag.consensus(seqs, popts.minCov, popts.minLen); for (auto it = seqs.begin(); it != seqs.end(); ++it) { CnsResult result = *it; boost::format fasta(">%s/%d_%d\n%s\n"); fasta % alns[0].id % result.range[0] % result.range[1]; fasta % result.seq; cnsBuf.push(fasta.str()); } trgBuf.pop(&td); } boost::format msg("(%d) ending ..."); CLOG(INFO, "Consensus") << msg % id; // write out a sentinal cnsBuf.push(""); }
void SkTextUtils::GetPath(const void* text, size_t length, SkTextEncoding encoding, SkScalar x, SkScalar y, const SkFont& font, SkPath* path) { SkAutoToGlyphs ag(font, text, length, encoding); SkAutoTArray<SkPoint> pos(ag.count()); font.getPos(ag.glyphs(), ag.count(), pos.get(), {x, y}); struct Rec { SkPath* fDst; const SkPoint* fPos; } rec = { path, pos.get() }; path->reset(); font.getPaths(ag.glyphs(), ag.count(), [](const SkPath* src, const SkMatrix& mx, void* ctx) { Rec* rec = (Rec*)ctx; if (src) { SkMatrix m(mx); m.postTranslate(rec->fPos->fX, rec->fPos->fY); rec->fDst->addPath(*src, m); } rec->fPos += 1; }, &rec); }
TEST(AlnGraphBoostTest, RawConsensus) { std::string backbone = "ATATTAGGC"; AlnGraphBoost ag(backbone); dagcon::Alignment *algs = new dagcon::Alignment[5]; algs[0].tstr = "ATATTA---GGC"; algs[0].qstr = "ATAT-AGCCGGC"; algs[1].tstr = "ATATTA-GGC"; algs[1].qstr = "ATAT-ACGGC"; algs[2].tstr = "AT-ATTA--GGC"; algs[2].qstr = "ATCAT--CCGGC"; algs[3].tstr = "ATATTA--G-GC"; algs[3].qstr = "ATAT-ACCGAG-"; algs[4].tstr = "ATATTA---GGC"; algs[4].qstr = "ATAT-AGCCGGC"; for(int i=0; i < 5; i++) { dagcon::Alignment& ra = algs[i]; ra.id = "target"; ra.len = 9; ra.start = 1; } ag.addAln(algs[0]); ag.addAln(algs[1]); ag.addAln(algs[2]); ag.addAln(algs[3]); ag.addAln(algs[4]); ag.mergeNodes(); std::string expected = "ATATAGCCGGC"; const std::string actual = ag.consensus(); EXPECT_EQ(expected, actual); }
Arbin om(Arbin a) { Arbin atmp=union1(ag(a),ad(a)); return atmp; }
/*********************************************************** synopsis: do all of the initialisation for a new game: build the screen get a random word and generate anagrams (must get less than 66 anagrams to display on screen) initialise all the game control flags inputs: head - first node in the answers list (in/out) dblHead - first node in the dictionary list screen - the SDL_Surface to display the image letters - first node in the letter sprites (in/out) outputs: n/a ***********************************************************/ static void newGame(struct node** head, struct dlb_node* dlbHead, SDL_Surface* screen, struct sprite** letters) { char guess[9]; char remain[9]; int happy = 0; /* we don't want any more than ones with 66 answers */ /* - that's all we can show... */ int i; /* show background */ strcpy(txt, language); ShowBMP(strcat(txt,"images/background.bmp"),screen, 0,0); destroyLetters(letters); assert(*letters == NULL); while (!happy) { char buffer[9]; getRandomWord(buffer, sizeof(buffer)); strcpy(guess,""); strcpy(rootWord, buffer); bigWordLen = strlen(rootWord)-1; strcpy(remain, rootWord); rootWord[bigWordLen] = '\0'; /* destroy answers list */ destroyAnswers(head); /* generate anagrams from random word */ ag(head, dlbHead, guess, remain); answersSought = Length(*head); happy = ((answersSought <= 77) && (answersSought >= 6)); #ifdef DEBUG if (!happy) { Debug("Too Many Answers! word: %s, answers: %i", rootWord, answersSought); } #endif } #ifdef DEBUG Debug("Selected word: %s, answers: %i", rootWord, answersSought); #endif /* now we have a good set of words - sort them alphabetically */ sort(head); for (i = bigWordLen; i < 7; i++){ remain[i] = SPACE_CHAR; } remain[7] = '\0'; remain[bigWordLen]='\0'; shuffleWord(remain); strcpy(shuffle, remain); strcpy(answer, SPACE_FILLED_STRING); /* build up the letter sprites */ assert(*letters == NULL && screen != NULL); buildLetters(letters, screen); addClock(letters, screen); addScore(letters, screen); /* display all answer boxes */ displayAnswerBoxes(*head, screen); gotBigWord = 0; score = 0; updateTheScore = 1; gamePaused = 0; winGame = 0; answersGot = 0; gameStart = time(0); gameTime = 0; stopTheClock = 0; }
int EEBearing3d::update() { int rValue = 0; // get current time Domain *theDomain = this->getDomain(); (*t)(0) = theDomain->getCurrentTime(); // get global trial response int ndim = 0, i; Vector dg(12), vg(12), ag(12), dgDelta(12); for (i=0; i<2; i++) { Vector disp = theNodes[i]->getTrialDisp(); Vector vel = theNodes[i]->getTrialVel(); Vector accel = theNodes[i]->getTrialAccel(); Vector dispIncr = theNodes[i]->getIncrDeltaDisp(); dg.Assemble(disp, ndim); vg.Assemble(vel, ndim); ag.Assemble(accel, ndim); dgDelta.Assemble(dispIncr, ndim); ndim += 6; } // transform response from the global to the local system Vector vl(12), al(12), dlDelta(12); dl.addMatrixVector(0.0, Tgl, dg, 1.0); vl.addMatrixVector(0.0, Tgl, vg, 1.0); al.addMatrixVector(0.0, Tgl, ag, 1.0); dlDelta.addMatrixVector(0.0, Tgl, dgDelta, 1.0); // transform response from the local to the basic system Vector dbDelta(6); db->addMatrixVector(0.0, Tlb, dl, 1.0); vb->addMatrixVector(0.0, Tlb, vl, 1.0); ab->addMatrixVector(0.0, Tlb, al, 1.0); dbDelta.addMatrixVector(0.0, Tlb, dlDelta, 1.0); // 1) set axial deformations in basic x-direction theMaterials[0]->setTrialStrain((*db)(0), (*vb)(0)); if (pFrcCtrl == 1) (*qb)(0) = theMaterials[0]->getStress(); // 2) set shear deformations in basic y- and z-direction // do not check time for right now because of transformation constraint // handler calling update at beginning of new step when applying load // if (dbDelta.pNorm(0) > DBL_EPSILON || (*t)(0) > tLast) { if (dbDelta.pNorm(0) > DBL_EPSILON) { // set the trial response at the site if (theSite != 0) { theSite->setTrialResponse(db, vb, ab, qb, t); } else { sData[0] = OF_RemoteTest_setTrialResponse; rValue += theChannel->sendVector(0, 0, *sendData, 0); } } // 3) set rotations about basic x-direction theMaterials[1]->setTrialStrain((*db)(3), (*vb)(3)); // 4) set rotations about basic y-direction theMaterials[2]->setTrialStrain((*db)(4), (*vb)(4)); // 5) set rotations about basic z-direction theMaterials[3]->setTrialStrain((*db)(5), (*vb)(5)); // save the last time tLast = (*t)(0); return rValue; }