void DynSuffixArray::Delete(unsigned index, unsigned num2del) { int ltmp = m_L->at(m_ISA->at(index)); int true_pos = LastFirstFunc(m_ISA->at(index)); // track cycle shift (newIndex - 1) for(size_t q = 0; q < num2del; ++q) { int row = m_ISA->at(index); // gives the position of index in SA and m_F //std::cerr << "row = " << row << std::endl; //std::cerr << "SA[r]/index = " << m_SA->at(row) << "/" << index << std::endl; true_pos -= (row <= true_pos ? 1 : 0); // track changes m_L->erase(m_L->begin() + row); m_F->erase(m_F->begin() + row); m_ISA->erase(m_ISA->begin() + index); // order is important for (vuint_t::iterator itr = m_ISA->begin(); itr != m_ISA->end(); ++itr) { if((int)*itr > row) --(*itr); } m_SA->erase(m_SA->begin() + row); for (vuint_t::iterator itr = m_SA->begin(); itr != m_SA->end(); ++itr) { if(*itr > index) --(*itr); } } m_L->at(m_ISA->at(index))= ltmp; Reorder(LastFirstFunc(m_ISA->at(index)), true_pos); //PrintAuxArrays(); }
void ReorderOddEven(int *pData, unsigned int length) { if (pData == NULL || length == 0) return; Reorder(pData, length, isEven); }
/* Converts a multiple alignment (possibly with gaps) to a bunch of * aligned single-letter seqeunces. Also reorders aligned residues. */ SequenceAlignment *GetSequenceAlignment(MultipleAlignment *ma) { SequenceAlignment *out = (SequenceAlignment *) malloc(sizeof(SequenceAlignment)); int chain, block, chain2; int *indices = (int*) calloc(ma->numChains, sizeof(int)); out->numSeqs = ma->numChains; out->seqs = (Sequence**) malloc(sizeof(Sequence*) * ma->numChains); for (chain=0; chain<ma->numChains; chain++) { out->seqs[chain] = CreateSequence(ma->chains[chain]->pdb->idString); } for (block=0; block < ma->numBlocks; block++) { int first = ma->blocks[block].first; int last = ma->blocks[block].last; for (chain=0; chain<ma->numChains; chain++) { int find = first; int index; while (find <= last && !ma->residues[chain].res[find].exists) find++; if (find > last) break; index = ma->residues[chain].res[find].index; while (indices[chain] < index) { for (chain2=0; chain2<ma->numChains; chain2++) { if (chain2 != chain) { AddCharacter(out->seqs[chain2], '-'); } else { AddCharacter(out->seqs[chain2], ma->chains[chain2]->res[indices[chain2]++].residue); } } } } while (first <= last) { for (chain=0; chain<ma->numChains; chain++) { if (ma->residues[chain].res[first].exists) { AddCharacter(out->seqs[chain], ma->chains[chain]->res[indices[chain]++].residue); } else { AddCharacter(out->seqs[chain], '-'); } } first++; } } for (chain=0; chain<ma->numChains; chain++) { while (indices[chain] < ma->chains[chain]->length) { for (chain2=0; chain2<ma->numChains; chain2++) { if (chain2 != chain) { AddCharacter(out->seqs[chain2], '-'); } else { AddCharacter(out->seqs[chain2], ma->chains[chain2]->res[indices[chain2]++].residue); } } } } free(indices); Reorder(out); return out; }
void cDialogManager::DestroyDialog (cDialog* pDialog) { if (!pDialog) return; mlDialogs.remove(pDialog); std::list<cWidget*> mycopy(pDialog->mlRootWidget); // use a copy of the list to avoid breakting iterator by automatic unregistering for (std::list<cWidget*>::iterator itor=mycopy.begin();itor!=mycopy.end();++itor) pDialog->DestroyWidget(*itor); // this might trigger callbacks, must be outside dialog destructor delete pDialog; Reorder(); }
int FAMGMultiGrid::Deconstruct() { int i; #ifdef FAMG_REORDERCOLUMN if(Reorder()) RETURN(1); #endif for(i = n-1; i >= 0; i--) if(grid[i] != NULL) grid[i]->Deconstruct(i); FAMGReleaseHeap(FAMG_FROM_TOP); // mark in construct n = 1; return 0; }
void reorderList(ListNode* head) { if( !head || !head->next ) { return; } ListNode* mid = FindMid( head ); ListNode* second_head = mid->next; mid->next = NULL; second_head = ReverseLL(second_head); head = Reorder( head, second_head ); }
void DynSuffixArray::Insert(vuint_t* newSent, unsigned newIndex) { // for sentences //stages 1, 2, 4 stay same from 1char case //(use last word of new text in step 2 and save Ltmp until last insert?) //stage 3...all words of new sentence are inserted backwards // stage 2: k=ISA[newIndex], tmp= L[k], L[k] = newChar //PrintAuxArrays(); CHECK(newIndex <= m_SA->size()); int k(-1), kprime(-1); k = (newIndex < m_SA->size() ? m_ISA->at(newIndex) : m_ISA->at(0)); // k is now index of the cycle that starts at newindex int true_pos = LastFirstFunc(k); // track cycle shift (newIndex - 1) int Ltmp = m_L->at(k); m_L->at(k) = newSent->at(newSent->size()-1); // cycle k now ends with correct word for(int j = newSent->size()-1; j > -1; --j) { kprime = LastFirstFunc(k); // find cycle that starts with (newindex - 1) //kprime += ((m_L[k] == Ltmp) && (k > isa[k]) ? 1 : 0); // yada yada // only terminal char can be 0 so add new vocab at end kprime = (kprime > 0 ? kprime : m_SA->size()); true_pos += (kprime <= true_pos ? 1 : 0); // track changes // insert everything m_F->insert(m_F->begin() + kprime, newSent->at(j)); int theLWord = (j == 0 ? Ltmp : newSent->at(j-1)); m_L->insert(m_L->begin() + kprime, theLWord); for (vuint_t::iterator itr = m_SA->begin(); itr != m_SA->end(); ++itr) { if(*itr >= newIndex) ++(*itr); } m_SA->insert(m_SA->begin() + kprime, newIndex); for (vuint_t::iterator itr = m_ISA->begin(); itr != m_ISA->end(); ++itr) { if((int)*itr >= kprime) ++(*itr); } m_ISA->insert(m_ISA->begin() + newIndex, kprime); k = kprime; //PrintAuxArrays(); } // Begin stage 4 Reorder(true_pos, LastFirstFunc(kprime)); // actual position vs computed position of cycle (newIndex-1) }
void cDialogManager::SendToBack (cDialog* pDialog) { mlDialogs.remove(pDialog); mlDialogs.push_front(pDialog); Reorder(); }
void cDialogManager::BringToFront (cDialog* pDialog) { mlDialogs.remove(pDialog); mlDialogs.push_back(pDialog); Reorder(); }
void ALOperator::BuildALOperator() { TEUCHOS_ASSERT(blockedMapping_ != Teuchos::null); // Get an Epetra_CrsMatrix. const Teuchos::RCP<const Epetra_CrsMatrix> crsContent = Teuchos::rcp_dynamic_cast<const Epetra_CrsMatrix>(fullContent_); // Ask the strategy to build the Thyra operator for you. if(blockedOperator_ == Teuchos::null) { blockedOperator_ = blockedMapping_->buildBlockedThyraOp(crsContent, label_); } else { const Teuchos::RCP<Thyra::BlockedLinearOpBase<double> > blkOp = Teuchos::rcp_dynamic_cast<Thyra::BlockedLinearOpBase<double> > (blockedOperator_, true); blockedMapping_->rebuildBlockedThyraOp(crsContent, blkOp); } // Extract blocks. const Teuchos::RCP<Thyra::BlockedLinearOpBase<double> > blkOp = Teuchos::rcp_dynamic_cast<Thyra::BlockedLinearOpBase<double> > (blockedOperator_, true); numBlockRows_ = blkOp->productRange()->numBlocks(); Teuchos::RCP<const Thyra::LinearOpBase<double> > blockedOpBlocks[4][4]; for(int i = 0; i <= dim_; i++) { for(int j = 0; j <= dim_; j++) { blockedOpBlocks[i][j] = blkOp->getBlock(i, j); } } // Pressure mass matrix. if(pressureMassMatrix_ != Teuchos::null) { invPressureMassMatrix_ = getInvDiagonalOp(pressureMassMatrix_); } // We need the size of the sub-block to build the identity matrix. else { std::cout << "Pressure mass matrix is null. Use identity." << std::endl; pressureMassMatrix_ = Thyra::identity<double>(blockedOpBlocks[dim_][0]->range()); invPressureMassMatrix_ = Thyra::identity<double>(blockedOpBlocks[dim_][0]->range()); } // Build the AL operator. Teuchos::RCP<Thyra::DefaultBlockedLinearOp<double> > alOperator_ = Thyra::defaultBlockedLinearOp<double>(); alOperator_->beginBlockFill(dim_ + 1, dim_ + 1); // Set blocks for the velocity parts and gradient. for(int i = 0; i < dim_; i++) { for(int j = 0; j < dim_; j++) { // build the blocks and place it the right location alOperator_->setBlock(i, j, Thyra::add(blockedOpBlocks[i][j], Thyra::scale(gamma_, Thyra::multiply(blockedOpBlocks[i][dim_], invPressureMassMatrix_, blockedOpBlocks[dim_][j])))); } // end for j } // end for i // Last row. Divergence and (possible) stabilization matrix. for(int j = 0; j <= dim_; j++) { alOperator_->setBlock(dim_, j, blockedOpBlocks[dim_][j]); } // Last column. Gradient. for(int i = 0; i < dim_; i++) { alOperator_->setBlock(i, dim_, Thyra::add(blockedOpBlocks[i][dim_], Thyra::scale(gamma_, Thyra::multiply(blockedOpBlocks[i][dim_], invPressureMassMatrix_,blockedOpBlocks[dim_][dim_])))); } alOperator_->endBlockFill(); // Set whatever is returned. SetOperator(alOperator_, false); // Set operator for augmenting the right-hand side. Teuchos::RCP<Thyra::DefaultBlockedLinearOp<double> > alOpRhs_ = Thyra::defaultBlockedLinearOp<double>(); alOpRhs_->beginBlockFill(dim_ + 1, dim_ + 1); // Identity matrices on the main diagonal. for(int i = 0; i < dim_; i++) { // build the blocks and place it the right location alOpRhs_->setBlock(i, i, Thyra::identity<double>(blockedOpBlocks[0][0]->range())); } // end for i alOpRhs_->setBlock(dim_, dim_, Thyra::identity<double>(blockedOpBlocks[dim_][dim_]->range())); // Last column. for(int i = 0; i < dim_; i++) { alOpRhs_->setBlock(i, dim_, Thyra::scale(gamma_, Thyra::multiply(blockedOpBlocks[i][dim_], invPressureMassMatrix_))); } alOpRhs_->endBlockFill(); alOperatorRhs_ = alOpRhs_; // reorder if necessary if(reorderManager_ != Teuchos::null) Reorder(*reorderManager_); }
EXPORT_C void CHuiLayout::MoveVisualToBack(CHuiVisual& aVisual, TInt aLayoutTransitionTime) { Reorder(aVisual, 0, aLayoutTransitionTime); }
EXPORT_C void CHuiLayout::MoveVisualToFront(CHuiVisual& aVisual, TInt aLayoutTransitionTime) { Reorder(aVisual, Count() - 1, aLayoutTransitionTime); }
int main(int argc, char* argv[]) { programname = copystring(Basename(argv[0])); argc--, argv++; while (argc && argv[0][0] == '-') { while (*++*argv) switch(**argv) { case 'p': pflag++; break; case 'e': eflag++; epsfwidth = WidthInPoints(*argv + 1); goto nextarg; case 'd': dflag++; goto nextarg; case 'i': switch( *(*argv + 1) ) { case '-': iflag = -1; case '+': default: iflag = 1; } goto nextarg; case 'g': gflag++; goto nextarg; case 'y': yflag++; goto nextarg; case 'b': bflag++; goto nextarg; case 's': sflag++; goto nextarg; case 'm': mflag++; TWENTY = atoi(*argv + 1); if (TWENTY > DEFAULT_TWENTY) Usage(*argv-1); goto nextarg; case 't': tflag++; THRESHOLD_PERCENT = (floatish) atof(*argv + 1); if (THRESHOLD_PERCENT < 0 || THRESHOLD_PERCENT > 5) Usage(*argv-1); goto nextarg; case 'c': cflag++; goto nextarg; case '?': default: Usage(*argv-1); } nextarg: ; argc--, argv++; } hpfile = "stdin"; psfile = "stdout"; hpfp = stdin; psfp = stdout; filter = argc < 1; if (!filter) { pathName = copystring(argv[0]); DropSuffix(pathName, ".hp"); baseName = copystring(Basename(pathName)); hpfp = Fp(pathName, &hpfile, ".hp", "r"); // I changed these two lines to use 'pathName' instead of // 'baseName'. This means that the .ps and .aux files get put in // the same directory as the .hp file. This solved Valgrind bugt // #117686. --njn // psfp = Fp(baseName, &psfile, ".ps", "w"); psfp = Fp(pathName, &psfile, ".ps", "w"); // if (pflag) auxfp = Fp(baseName, &auxfile, ".aux", "r"); if (pflag) auxfp = Fp(pathName, &auxfile, ".aux", "r"); } GetHpFile(hpfp); if (!filter && pflag) GetAuxFile(auxfp); TraceElement(); /* Orders on total, Removes trace elements (tflag) */ if (dflag) Deviation(); /* ReOrders on deviation */ if (iflag) Identorder(iflag); /* ReOrders on identifier */ if (pflag) Reorder(); /* ReOrders on aux file */ if (TWENTY) TopTwenty(); /* Selects top twenty (mflag) */ Dimensions(); areabelow = AreaBelow(); Scale(); PutPsFile(); if (!filter) { auxfp = Fp(baseName, &auxfile, ".aux", "w"); PutAuxFile(auxfp); } return(0); }
int main(int argc, char *argv[]) { programname = copystring(Basename(argv[0])); argc--, argv++; while (argc && argv[0][0] == '-') { while (*++*argv) switch(**argv) { case 'p': pflag++; break; case 'e': eflag++; epsfwidth = WidthInPoints(*argv + 1); goto nextarg; case 'd': dflag++; goto nextarg; case 'i': switch( *(*argv + 1) ) { case '-': iflag = -1; break; case '+': default: iflag = 1; } goto nextarg; case 'g': gflag++; goto nextarg; case 'y': yflag++; goto nextarg; case 'b': bflag++; goto nextarg; case 's': sflag++; goto nextarg; case 'm': mflag++; TWENTY = atoi(*argv + 1); // only 20 keys fit on a page if (TWENTY > DEFAULT_TWENTY) multipageflag++; goto nextarg; case 'M': multipageflag++; goto nextarg; case 't': tflag++; THRESHOLD_PERCENT = (floatish) atof(*argv + 1); if (THRESHOLD_PERCENT < 0 || THRESHOLD_PERCENT > 5) Usage(*argv-1); goto nextarg; case 'c': cflag++; goto nextarg; case '?': default: Usage(*argv-1); } nextarg: ; argc--, argv++; } hpfile = "stdin"; psfile = "stdout"; hpfp = stdin; psfp = stdout; filter = argc < 1; if (!filter) { pathName = copystring(argv[0]); DropSuffix(pathName, ".hp"); #if defined(_WIN32) DropSuffix(pathName, ".exe"); #endif baseName = copystring(Basename(pathName)); hpfp = Fp(pathName, &hpfile, ".hp", "r"); psfp = Fp(baseName, &psfile, ".ps", "w"); if (pflag) auxfp = Fp(baseName, &auxfile, ".aux", "r"); } GetHpFile(hpfp); if (!filter && pflag) GetAuxFile(auxfp); TraceElement(); /* Orders on total, Removes trace elements (tflag) */ if (dflag) Deviation(); /* ReOrders on deviation */ if (iflag) Identorder(iflag); /* ReOrders on identifier */ if (pflag) Reorder(); /* ReOrders on aux file */ /* Selects top bands (mflag) - can be more than 20 now */ if (TWENTY != 0) TopTwenty(); Dimensions(); areabelow = AreaBelow(); Scale(); PutPsFile(); if (!filter) { auxfp = Fp(baseName, &auxfile, ".aux", "w"); PutAuxFile(auxfp); } return(0); }
void PackageList::SaveBin(Profile* profile,BOStream&file) { if (!profile->route) profile->wpsused=0; int numraids=0; if (profile->raidnumentries) { while (profile->raidnumentries[numraids].squadliststart!=Profile::RNEC_LISTVALISLASTREC) numraids++; numraids=profile->raidnumentries[numraids].raidnum; } file<<CSprintf(line1out, profile->attackmethod,profile->packagestatus,profile->squadlist.Max(),numraids,profile->flags, profile->packagetakeoff,Reorder(profile->packagetarget[0]),profile->doglegloc, profile->primarytargetETA,profile->playerETAdelta ); int targets[10]; int subtargets[10]; { for (int i=1;i<10;i++) { targets[i]=Reorder(profile->packagetarget[i].SGT); subtargets[i]=profile->packagetarget[i].band+profile->packagetarget[i].bandoff; } } file<<CSprintf(line2out, targets[1],subtargets[1], targets[2],subtargets[2], targets[3],subtargets[3], targets[4],subtargets[4], targets[5],subtargets[5], targets[6],subtargets[6], targets[7],subtargets[7], targets[8],subtargets[8], targets[9],subtargets[9]); //DeadCode JIM 20Oct00 int loopcount=0; //increase for any fixed fields.... int maxsq=profile->squadlist; { for (int i=0;i<maxsq;i++) { Profile::Squad squadbuff=profile->squadlist[i]; //JIM 29Oct00 if (profile->packagestatus!=Profile::PS_COMPLETE) squadbuff.instance=ReorderNoCheck(squadbuff.instance); else squadbuff.instance=UID_NULL; file<<"Sq: "; ULong* squadptr=(ULong*)&squadbuff; assert (sizeof(Profile::Squad)%4==0); for (int countdown=sizeof(Profile::Squad)/4;countdown;countdown--) { ULong p0=*squadptr++, p1=p0/90, p2=p1/90, p3=p2/90, p4=p3/90; char packstr[6]; packstr[0]=p0%90+34; packstr[1]=p1%90+34; packstr[2]=p2%90+34; packstr[3]=p3%90+34; packstr[4]=p4%90+34; packstr[5]=0; file<<packstr; } file<<'\n'; //DeadCode CRAIG 30Oct100 Profile::Squad& squad=profile->squadlist[i]; //DeadCode CRAIG 30Oct100 if (profile->packagestatus!=Profile::PS_COMPLETE) //DeadCode CRAIG 30Oct100 file<<CSprintf(linesqout, //DeadCode CRAIG 30Oct100 ReorderNoCheck(squad.instance), +squad.squadnum, +squad.formtype, squad.diaryentry, squad.numbers, squad.fightperiods, //DeadCode CRAIG 30Oct100 +squad.targetindex, squad.takeofftime, squad.lastwptime, //DeadCode CRAIG 30Oct100 +squad.method, +squad.submethod, +squad.status, squad.fuelleft //DeadCode CRAIG 30Oct100 //DeadCode CRAIG 30Oct100 ); //DeadCode CRAIG 30Oct100 else //DeadCode CRAIG 30Oct100 file<<CSprintf(linesqout, //DeadCode CRAIG 30Oct100 0, +squad.squadnum, +squad.formtype, squad.diaryentry, squad.numbers, //DeadCode CRAIG 30Oct100 +squad.targetindex, squad.takeofftime, squad.lastwptime, //DeadCode CRAIG 30Oct100 +squad.method, +squad.submethod, +squad.status, squad.fuelleft //DeadCode CRAIG 30Oct100 //DeadCode CRAIG 30Oct100 ); //DeadCode CRAIG 30Oct100 } } if (maxsq==1) { file<<CSprintf(lollyout,profile->squadlist.AcBitsFirstSquad()); } { for (int i=0;i<numraids;i++) { file<<"Rd: "; ULong* raidptr=(ULong*)&profile->raidnumentries[i]; //JIM 29Oct00 assert (sizeof(Profile::RaidNumEntry)%4==0); for (int countdown=sizeof(Profile::RaidNumEntry)/4;countdown;countdown--) { ULong p0=*raidptr++, p1=p0/90, p2=p1/90, p3=p2/90, p4=p3/90; char packstr[6]; packstr[0]=p0%90+34; packstr[1]=p1%90+34; packstr[2]=p2%90+34; packstr[3]=p3%90+34; packstr[4]=p4%90+34; packstr[5]=0; file<<packstr; } file<<'\n'; //DeadCode CRAIG 30Oct100 file<<CSprintf(linerout, //DeadCode C profile->raidnumentries[i].raidnum, profile->raidnumentries[i].squadliststart,profile->raidnumentries[i].detector,profile->raidnumentries[i].alertlevel,profile->raidnumentries[i].detectlatency,profile->raidnumentries[i].firstsquaddiaryentry, //DeadCode CRAIG 30Oct100 profile->raidnumentries[i].prevpositions[0].X,profile->raidnumentries[i].prevpositions[0].Y,profile->raidnumentries[i].prevpositions[0].Z, //DeadCode CRAIG 30Oct100 profile->raidnumentries[i].prevpositions[1].X,profile->raidnumentries[i].prevpositions[1].Y,profile->raidnumentries[i].prevpositions[1].Z, //DeadCode CRAIG 30Oct100 profile->raidnumentries[i].prevpositions[2].X,profile->raidnumentries[i].prevpositions[2].Y,profile->raidnumentries[i].prevpositions[2].Z, //DeadCode CRAIG 30Oct100 profile->raidnumentries[i].prevpositions[3].X,profile->raidnumentries[i].prevpositions[3].Y,profile->raidnumentries[i].prevpositions[3].Z); } } file<<C 26 <<C 0; if (profile->wpsused) { file <<C T_bfsave <<C T_linklist <<C maxsq; { Profile::Squad& squad=profile->squadlist[0]; //AirGroup // T_inform: // T_inwing: // T_duty: // T_form: // T_pos: // T_route: only leader // T_itemA: // T_leader: - new in this position! file<<C T_airgrp <<C T_linklist <<C 7; SaveRouteBin(profile->route,file); profile->SaveAirItemBin(&squad,profile->route,file); } for (int i=1;i<maxsq;i++) { Profile::Squad& squad=profile->squadlist[i]; //AirGroup // T_inform: // T_inwing: // T_duty: // T_form: // T_pos: // T_route: only leader // T_itemA: // T_leader: - new in this position! info_airgrp *a=*Persons2::ConvertPtrUID(squad.instance); if (a->leader.Evaluate()==ENABLE_COMPLEX_VAL || ReorderZero(UniqueID(a->leader.Evaluate()))) { file<<C T_airgrp <<C T_linklist <<C 7; file<<C T_leader; if (a->leader.Evaluate()!=ENABLE_COMPLEX_VAL) Expr::putint(ReorderZero(UniqueID(a->leader.Evaluate())),file); else Expr::putint(0,file); //NEED TO WORK ON THIS!!!!! } else file<<C T_airgrp <<C T_linklist <<C 6; profile->SaveAirItemBin(&squad,profile->route,file); } } }
void ReorderOddEven(int A[], int N) { Reorder(A, N, devideBy3); }