void AudioInSettings::baseFreqChanged(int bFreq) { if (freqSpin->hasFocus()) { m_glParams->a440diff = getDiff(freqSpin->value()); intervalFromFreq(freqSpin->value()); getFreqStatusTip(); } }
void TAnimationCurve<T>::makeAdditive() { if (mKeyframes.size() < 2) return; const KeyFrame& refKey = mKeyframes[0]; UINT32 numKeys = (UINT32)mKeyframes.size(); for(UINT32 i = 1; i < numKeys; i++) mKeyframes[i].value = getDiff(mKeyframes[i].value, refKey.value); }
QByteArray LedFrameCompressor::toCompressedBinary() const { /* Compress Format: (DATA[size in bits]) "(total_bit_count[32]) (REPFRAME_COMPRESS[2])* (RLE_COMPRESS[2+(5+8)*(1..32)])* (INDEX_COMPRESS[2+5+(5+8)*(1..32)])* (PLAIN_COMPRESS[2+32*8])*" (REPFRAME_COMPRESS[2]) = (bits"00"{magic: repeat last frame}) (RLE_COMPRESS[2+(5+8)*(1..32)]) = (bits"01"{magic: RLE}) (RLE_BLOCK[5+8])*(1..32) (RLE_BLOCK[5+8]) = (bits"00000..11111"[5]{byte count (1..32) from (0..31)}) (byte"00..FF"[8]{repeatable byte}) (INDEX_COMPRESS[2+5+(5+8)*(1..32)]) = (bits"10"{magic: INDEX}) (bits"00000..11111"[5]{index count (1..32) from (0..31)}) (INDEX_BLOCK[5+8])*(1..32) (INDEX_BLOCK[5+8]) = (bits"00000..11111"[5]{index in frame = 0..31}) (byte"00..FF"[8]{byte for index}) (PLAIN_COMPRESS[2+32*8]) = (bits"11"{magic: PLAIN}) (byte"00..FF"[8]{plain byte})*32 */ BitStreamWriter bsw; const QByteArray nullFrame(frameSizeBytes(), '\x00'); QByteArray lastFrame = nullFrame; foreach (const LedFrame &lf, ledFrameList_) { const QByteArray curFrame = lf.toBinaryFrame(); if (curFrame.size() == frameSizeBytes()) { const QByteArray curDiff = getDiff(lastFrame, curFrame); if (bestCompress(curDiff, bsw)) { lastFrame = curFrame; } } } const quint32 total_bit_count = bsw.bitsCount(); QByteArray res; res.append(((quint8*)&total_bit_count)[0]); res.append(((quint8*)&total_bit_count)[1]); res.append(((quint8*)&total_bit_count)[2]); res.append(((quint8*)&total_bit_count)[3]); res.append(bsw.toByteArray()); return res; }
void AudioInSettings::grabParams(TaudioParams *params) { if (freqSpin->value() == 440 ) params->a440diff = 0.0; else params->a440diff = getDiff(freqSpin->value()); params->INdevName = m_inDeviceCombo->currentText(); params->INenabled = enableInBox->isChecked(); params->minimalVol = volumeSlider->value(); params->minDuration = (qreal)durationSpin->value() / 1000.0; params->intonation = m_intonationCombo->currentIndex(); #if !defined (Q_OS_ANDROID) && (defined (Q_OS_LINUX) || defined (Q_OS_WIN)) params->JACKorASIO = m_JACK_ASIO_ChB->isChecked(); #endif params->equalLoudness = m_noiseFilterChB->isChecked(); params->minSplitVol = m_splitVolChB->isChecked() ? (qreal)m_splitVolSpin->value() : 0.0; params->skipStillerVal = m_skipStillerChB->isChecked() ? (qreal)m_skipStillerSpin->value() : 0.0; params->detectMethod = m_methodCombo->currentIndex(); }
void split(Client* newClient) { NSecond start, end; pthread_attr_t attr; if (newClient == 0) return ; // 우선 만들어질 새 스레드를 설정함 pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); start = getNSecond(); // thread를 사용하는 서버 pthread_create(&newClient->tid, &attr, thread_run, (void*) newClient); end = getNSecond(); // server에서는 분기하는 데 걸린 시간을 구합니다. elapseTime += getDiff(end, start); }
void MergeBlockingTest::testRejectGetDiffReplyWhenBucketHasBecomeInconsistent() { TestFileStorComponents c(*this, "testRejectGetDiffReplyWhenBucketHasBecomeInconsistent"); createBucket(innerBucket); std::shared_ptr<api::GetBucketDiffCommand> getDiff( createGetDiff(innerBucket, getNodesWithForwarding())); c.top.sendDown(getDiff); c.top.waitForMessages(1, MSG_WAIT_TIME); api::StorageMessage::SP fwdDiff( c.top.getAndRemoveMessage(api::MessageType::GETBUCKETDIFF)); api::GetBucketDiffCommand& diffCmd( dynamic_cast<api::GetBucketDiffCommand&>(*fwdDiff)); api::GetBucketDiffReply::SP diffReply( new api::GetBucketDiffReply(diffCmd)); createBucket(innerBucket2); c.top.sendDown(diffReply); expectAbortedReply<api::GetBucketDiffReply>(c.top); }
int Brain::assessCube(int row,int column,CubeBox::Player player,CubeBox& box) const { int diff; if(row==0) // first row { if(column == 0) // upper left corner { diff=getDiff(0,1,player,box) ; int temp=getDiff(1,0,player,box); if(temp < diff) diff=temp; } else if(column == box.dim()-1) // upper right corner { diff=getDiff(0,column-1,player,box); int temp=getDiff(1,column,player,box); if(temp < diff) diff=temp; } else { diff=getDiff(row,column-1,player,box); int temp=getDiff(row,column+1,player,box); if(temp < diff) diff = temp; temp=getDiff(row+1,column,player,box); if(temp < diff) diff = temp; } } else if(row==box.dim()-1) // last row { if(column == 0) // lower left corner { diff=getDiff(row,1,player,box); int temp=getDiff(row-1,0,player,box); if(temp < diff) diff=temp; } else if(column == box.dim()-1) // lower right corner { diff=getDiff(row,column-1,player,box); int temp=getDiff(row-1,column,player,box); if(temp < diff) diff=temp; } else { diff=getDiff(row,column-1,player,box); int temp=getDiff(row,column+1,player,box); if(temp < diff) diff = temp; temp=getDiff(row-1,column,player,box); if(temp < diff) diff = temp; } } else if(column == 0) // first column { diff = getDiff(row,1,player,box); int temp = getDiff(row-1,0,player,box); if(temp < diff) diff = temp; temp = getDiff(row+1,0,player,box); if(temp < diff) diff = temp; } else if(column == box.dim()-1) // last column { diff = getDiff(row,column-1,player,box); int temp = getDiff(row-1,column,player,box); if(temp < diff) diff = temp; temp = getDiff(row+1,column,player,box); if(temp < diff) diff = temp; } else { diff=getDiff(row-1,column,player,box); int temp=getDiff(row+1,column,player,box); if(temp < diff) diff = temp; temp=getDiff(row,column-1,player,box); if(temp < diff) diff = temp; temp=getDiff(row,column+1,player,box); if(temp < diff) diff = temp; } int temp; temp=( box[row][column]->max()-box[row][column]->value() ); int val; val=diff-temp+1; val=val*(temp+1); return val; }
/* MAIN */ int main(){ //Pseudo random valued array double ablock[COL][ROW] = { {140,144,147,140,140,155,179,175}, {144,152,140,147,140,148,167,179}, {152,155,136,167,163,162,152,172}, {168,145,156,160,152,155,136,160}, {162,148,156,148,140,136,147,162}, {147,167,140,155,155,140,136,162}, {136,156,123,167,162,144,140,147}, {148,155,136,155,152,147,147,136} }; //Pseudo random valued array double bblock[COL][ROW] = { {16,11,10,16,24,40,51,61}, {12,12,14,19,26,58,60,55}, {14,13,16,24,40,57,69,56}, {14,17,22,29,51,87,80,62}, {18,22,37,56,68,109,103,77}, {24,35,55,64,81,104,113,92}, {49,64,78,87,103,121,120,101}, {72,92,95,98,112,100,103,90} }; //All zero array double cblock[COL][ROW] = { {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0} }; //All 255 array double dblock[COL][ROW] = { {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255} }; //Array with +255 values double eblock[COL][ROW] = { {289,345,269,453,299,645,334,356}, {889,945,669,853,399,945,534,956}, {489,845,769,653,599,445,534,956}, {689,745,369,353,999,545,734,856}, {389,545,469,953,299,345,834,356}, {389,945,869,853,599,545,934,756}, {289,545,969,653,499,845,334,756}, {189,445,369,553,799,745,434,756} }; //Unsigned char array unsigned char carray[COL][ROW] = { {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255} }; //Initializes the starting array init_rand(); //Calculates the basis 4x4 array values basis(); //Prints out the starting block that will be used printf("Starting Block:\n"); print_uc_block(); //Calculate DCT and store value into the GLOBAL dc_block[][] for(int u=0;u<8;u++) { for(int v=0;v<8;v++) { double temp = 0.0; for(int x=0;x<8;x++) { for(int y=0;y<8;y++) { temp += (uc_block[x][y] - 128) * result[u][v][x][y]; } } dc_block[u][v] = temp * (c(u)) * (c(v)) * .25; } } //Print the DCT BLOCK printf("DCT Block:\n"); print_dc_block(); //Caculate the IDCT and write values back into idct_block[][] for(int x=0;x<8;x++) { for(int y=0;y<8;y++) { double temp = 0.0; for(int u=0;u<8;u++) { for(int v=0;v<8;v++) { temp += (c(u)) * (c(v)) * dc_block[u][v] * cos(PI * (2 * x + 1) * u / 16) * cos(PI * (2 * y + 1) * v / 16); } } //This round function is what makes the //Differnece matrix output perfectly matching //values, if not used there will be at most (1) //value of difference. idct_block[x][y] = round((.25 * temp) + 128); //This assignment's difference matrix will output //at most (1) at about 50% of the matrix's values //idct_block[x][y] = ((temp * .25) + 128); } } //Print out original from IDCT printf("IDCT Block:\n"); print_idct_block(); //Do conversions and compute the difference matrix printf("Difference Matrix:\n"); getDiff(uc_block, idct_block); /* //basis() calculates base values that will be used in idct function //to caluclate the inverse of our dctblock array basis(); //Standard array print function for output printf("Starting block:\n"); printblock(ablock); //dct(block) calculates dct and then outputs to global array dctblock dct(ablock); //Print output of array printf("DCT block:\n"); printblock(dctblock); //takes the dctblock from the previous function and calculates //the inverse and uses the values stored in result[][][][] //then output result for idct into the global idctblock idct(dctblock); //Print output, should be the same as initial block on first print printf("IDCT block:\n"); printblock(idctblock); printf("Difference of Starting and IDCT\n"); diffMtx(ablock, idctblock); */ return 0; }
void ThreadList::updateTimes() { wxLongLong now = wxGetLocalTimeMillis(); int sampleTimeDiff = (now - lastTime).ToLong(); lastTime = now; for(int i=0; i<(int)this->threads.size(); ++i) { this->threads[i].cpuUsage = -1; this->threads[i].setLocation("-"); HANDLE thread_handle = this->threads[i].getThreadHandle(); if (thread_handle == NULL) continue; PROFILER_ADDR profaddr = 0; FILETIME CreationTime, ExitTime, KernelTime, UserTime; if ( GetThreadTimes( thread_handle, &CreationTime, &ExitTime, &KernelTime, &UserTime ) ) { __int64 kernel_diff = getDiff(this->threads[i].prevKernelTime, KernelTime); __int64 user_diff = getDiff(this->threads[i].prevUserTime, UserTime); this->threads[i].prevKernelTime = KernelTime; this->threads[i].prevUserTime = UserTime; if (sampleTimeDiff > 0){ this->threads[i].cpuUsage = ((kernel_diff + user_diff) / 10000) * 100 / sampleTimeDiff; } } try { std::map<CallStack, SAMPLE_TYPE> callstacks; std::map<PROFILER_ADDR, SAMPLE_TYPE> flatcounts; Profiler profiler(process_handle, thread_handle, callstacks, flatcounts); bool ok = profiler.sampleTarget(0); if (ok && !profiler.targetExited() && callstacks.size() > 0) { const CallStack &stack = callstacks.begin()->first; profaddr = stack.addr[0]; // Collapse functions down if (syminfo && stack.depth > 0) { for (size_t n=0;n<stack.depth;n++) { PROFILER_ADDR addr = stack.addr[n]; std::string mod = syminfo->getModuleNameForAddr(addr); if (IsOsModule(mod)) { profaddr = addr; } else { break; } } for (int n=(int)stack.depth-1;n>=0;n--) { std::string file; int line; PROFILER_ADDR addr = stack.addr[n]; std::string loc = syminfo->getProcForAddr(addr, file, line); if (IsOsFunction(loc)) { profaddr = addr; break; } } } } } catch( ProfilerExcep &) { } if (profaddr && syminfo) { std::string file; int line; // Grab the name of the current IP location. std::string loc = syminfo->getProcForAddr(profaddr, file, line); this->threads[i].setLocation(loc); } } fillList(); }
void AudioInSettings::testSlot() { bool tempTestState = m_testDisabled; if (sender() == testButt) setTestDisabled(!m_testDisabled); #if defined (Q_OS_ANDROID) else if (sender() == m_topList) { if (m_topList->currentRow() == 3) // 4. test settings page #else else if (sender() == m_toolBox) { if (m_toolBox->currentIndex() == 3) // 4. test settings page #endif setTestDisabled(false); else setTestDisabled(true); } else { #if defined (Q_OS_ANDROID) if (enableInBox->isChecked() && m_topList->isVisible()) { if (m_topList->currentRow() == 3) // 4. test settings page #else if (enableInBox->isChecked() && m_toolBox->isVisible()) { if (m_toolBox->currentIndex() == 3) // 4. test settings page #endif setTestDisabled(false); else setTestDisabled(true); } else setTestDisabled(true); } if (tempTestState != m_testDisabled) { if (!m_testDisabled) { // start a test grabParams(m_glParams); m_paramsWereChanged = true; if (!m_audioIn) { // create new audio-in device if (TaudioIN::instance()) { m_audioIn = TaudioIN::instance(); m_audioIn->updateAudioParams(); } else { m_audioIn = new TaudioIN(m_glParams); } pitchView->setAudioInput(m_audioIn); connect(m_audioIn, &TaudioIN::noteStarted, this, &AudioInSettings::noteSlot); } else { // set parameters to existing device m_audioIn->updateAudioParams(); } // ambitus is lowest note of instrument scale dropped on 2 major and highest Tartini note (140 in MIDI) m_audioIn->setAmbitus(Tnote(m_tune->str(m_tune->stringNr()).chromatic() - 2), Tnote(93)); testButt->setText(stopTxt); testButt->setIcon(QIcon(style()->standardIcon(QStyle::SP_MediaPause))); m_audioIn->startListening(); pitchView->watchInput(); pitchView->setIntonationAccuracy(m_glParams->intonation); } else { // stop a test if (m_audioIn) { pitchView->stopWatching(); m_audioIn->stopListening(); m_intonationCombo->setCurrentIndex(m_audioIn->intonationAccuracy()); } testButt->setText(testTxt); testButt->setIcon(QIcon(style()->standardIcon(QStyle::SP_MediaPlay))); setTestDisabled(true); } } } void AudioInSettings::noteSlot(const TnoteStruct& ns) { Tnote n = ns.pitch; pitchLab->setText("<b>" + n.toRichText() + "</b>"); freqLab->setText(QString("%1 Hz").arg(ns.freq, 0, 'f', 1, '0')); } void AudioInSettings::upDownIntervalSlot() { int upDown = 1; if (m_downsSemitoneRadio->isChecked()) upDown = -1; setTransposeInterval(m_intervalSpin->value() * upDown); freqFromInterval(m_intervalSpin->value() * upDown); m_glParams->a440diff = getDiff(freqSpin->value()); getFreqStatusTip(); }
inline unsigned int FMPWPartTmpl<GainTmpl>:: doPartitionInternal(vector<unsigned char>& part) { typedef FMPartTmpl<FMBiPartCore, GainTmpl> PWPartMgrType; typedef FMPartTmpl4<FMKWayPartCore4, FMKWayGainMgr2> RefineType; unsigned int cost1 = _initCost; unsigned int cost = _initCost; RefineType rfMgr(getParam()); rfMgr.setBalanceTol(getBalanceTol()); rfMgr.setPValue(1); rfMgr.setQValue(10); rfMgr.setVerbosity(getVerbosity()); rfMgr.setBoundType(getBoundType()); rfMgr.noNeedSetHighFanoutNets(); while (1) { initGrouping2(); getNetlist().pairWisePhase1(part, _groupMap, _sGVec); //xxx int cost3 = cost; cost = cost1; for (unsigned int j=0; j<_numGroups; ++j) { const FMParam param(*_sGVec[j]); PWPartMgrType PWMgr(param); //xxx PWMgr.setBalanceTol(getBalanceTol()); PWMgr.setUpperBound(getUpperBound()); PWMgr.setLowerBound(getLowerBound()); // PWMgr.setPValue(_pvalue); // PWMgr.setQValue(_qvalue); PWMgr.setVerbosity(getVerbosity()); //xxx PWMgr.setBoundType(getBoundType()); PWMgr.noNeedSetHighFanoutNets(); PWMgr.setNoInit(cost); vector<unsigned char> pw_part; projectUp(part, pw_part, j); // cost = PWMgr.doPartitionOne(pw_part); boost::array<int, 64>& diff = getDiff(); const unsigned int part0 = _groupInvMap[j]; const unsigned int part1 = _moveTo[part0]; int diff2[2]; diff2[0] = diff[part0]; diff2[1] = diff[part1]; PWMgr.setDiff(diff2); cost = PWMgr.doPartitionOne4(pw_part); // PWMgr.doPartition(pw_part, 1); // cost = PWMgr.getBestCost(); projectDown(part, pw_part, j); int* diff3 = PWMgr.getDiff(); diff[part0] = diff3[0]; diff[part1] = diff3[1]; delete _sGVec[j]; } // printDiff(); // std::cout << "cost = " << cost << std::endl; assert(cost == getNetlist().cutCost(part, getNumPartitions())); //xxx initDiff(part); rfMgr.setNoInit(cost); // only refine the solution rfMgr.setDiff(getDiff()); cost1 = rfMgr.doPartitionOne4(part); // rfMgr.doPartition(part, 1); // cost1 = rfMgr.getBestCost(); assert(cost1 == getNetlist().cutCost(part, getNumPartitions())); setDiff(rfMgr.getDiff()); // printDiff(); // std::cout << "cost1 = " << cost1 << std::endl; if (cost1 >= cost) break; } return cost1; }
void Ccode::getAverageQuery (vector<SeqDist> ref, Sequence* query) { try { vector< vector<int> > diffs; //diffs[1][2] is the number of differences between querySeqs[query] and ref seq 1 at window 2. //initialize diffs vector diffs.resize(ref.size()); for (int j = 0; j < diffs.size(); j++) { diffs[j].resize(windows.size(), 0); } it = trim.begin(); string refQuery = query->getAligned(); //j<i, so you don't find distances from i to j and then j to i. for (int j = 0; j < ref.size(); j++) { string refJ = ref[j].seq->getAligned(); for (int k = 0; k < windows.size(); k++) { string QueryWindowk, refJWindowk; if (k < windows.size()-1) { //get window strings QueryWindowk = refQuery.substr(windows[k], windowSizes); refJWindowk = refJ.substr(windows[k], windowSizes); }else { //last window may be smaller than rest - see findwindows //get window strings QueryWindowk = refQuery.substr(windows[k], (it->second-windows[k])); refJWindowk = refJ.substr(windows[k], (it->second-windows[k])); } //find differences int diff = getDiff(QueryWindowk, refJWindowk); //save differences diffs[j][k] = diff; }//k }//j //initialize sumRef for this query sumQuery.resize(windows.size(), 0); sumSquaredQuery.resize(windows.size(), 0); averageQuery.resize(windows.size(), 0); //find the sum of the differences for (int j = 0; j < diffs.size(); j++) { for (int k = 0; k < diffs[j].size(); k++) { sumQuery[k] += diffs[j][k]; sumSquaredQuery[k] += (diffs[j][k]*diffs[j][k]); }//k }//j //find the average of the differences for the references for each window for (int i = 0; i < windows.size(); i++) { averageQuery[i] = sumQuery[i] / (float) ref.size(); } } catch(exception& e) { m->errorOut(e, "Ccode", "getAverageQuery"); exit(1); } }
//find the distances from each reference sequence to every other reference sequence for each window for this query void Ccode::getAverageRef(vector<SeqDist> ref) { try { vector< vector< vector<int> > > diffs; //diffs[0][1][2] is the number of differences between ref seq 0 and ref seq 1 at window 2. //initialize diffs vector diffs.resize(ref.size()); for (int i = 0; i < diffs.size(); i++) { diffs[i].resize(ref.size()); for (int j = 0; j < diffs[i].size(); j++) { diffs[i][j].resize(windows.size(), 0); } } it = trim.begin(); //find the distances from each reference sequence to every other reference sequence for each window for this query for (int i = 0; i < ref.size(); i++) { string refI = ref[i].seq->getAligned(); //j<i, so you don't find distances from i to j and then j to i. for (int j = 0; j < i; j++) { string refJ = ref[j].seq->getAligned(); for (int k = 0; k < windows.size(); k++) { string refIWindowk, refJWindowk; if (k < windows.size()-1) { //get window strings refIWindowk = refI.substr(windows[k], windowSizes); refJWindowk = refJ.substr(windows[k], windowSizes); }else { //last window may be smaller than rest - see findwindows //get window strings refIWindowk = refI.substr(windows[k], (it->second-windows[k])); refJWindowk = refJ.substr(windows[k], (it->second-windows[k])); } //find differences int diff = getDiff(refIWindowk, refJWindowk); //save differences in [i][j][k] and [j][i][k] since they are the same diffs[i][j][k] = diff; diffs[j][i][k] = diff; }//k }//j }//i //initialize sumRef for this query sumRef.resize(windows.size(), 0); sumSquaredRef.resize(windows.size(), 0); averageRef.resize(windows.size(), 0); //find the sum of the differences for hte reference sequences for (int i = 0; i < diffs.size(); i++) { for (int j = 0; j < i; j++) { //increment this querys reference sequences combos refCombo++; for (int k = 0; k < diffs[i][j].size(); k++) { sumRef[k] += diffs[i][j][k]; sumSquaredRef[k] += (diffs[i][j][k]*diffs[i][j][k]); }//k }//j }//i //find the average of the differences for the references for each window for (int i = 0; i < windows.size(); i++) { averageRef[i] = sumRef[i] / (float) refCombo; } } catch(exception& e) { m->errorOut(e, "Ccode", "getAverageRef"); exit(1); } }
//*************************************************************************************************************** //tried to make this look most like ccode original implementation void Ccode::removeBadReferenceSeqs(vector<SeqDist>& seqs) { try { vector< vector<int> > numDiffBases; numDiffBases.resize(seqs.size()); //initialize to 0 for (int i = 0; i < numDiffBases.size(); i++) { numDiffBases[i].resize(seqs.size(),0); } it = trim.begin(); int length = it->second - it->first; //calc differences from each sequence to everyother seq in the set for (int i = 0; i < seqs.size(); i++) { string seqA = seqs[i].seq->getAligned().substr(it->first, length); //so you don't calc i to j and j to i since they are the same for (int j = 0; j < i; j++) { string seqB = seqs[j].seq->getAligned().substr(it->first, length); //compare strings int numDiff = getDiff(seqA, seqB); numDiffBases[i][j] = numDiff; numDiffBases[j][i] = numDiff; } } //initailize remove to 0 vector<int> remove; remove.resize(seqs.size(), 0); float top = ((20*length) / (float) 100); float bottom = ((0.5*length) / (float) 100); //check each numDiffBases and if any are higher than threshold set remove to 1 so you can remove those seqs from the closest set for (int i = 0; i < numDiffBases.size(); i++) { for (int j = 0; j < i; j++) { //are you more than 20% different if (numDiffBases[i][j] > top) { remove[j] = 1; } //are you less than 0.5% different if (numDiffBases[i][j] < bottom) { remove[j] = 1; } } } int numSeqsLeft = 0; //count seqs that are not going to be removed for (int i = 0; i < remove.size(); i++) { if (remove[i] == 0) { numSeqsLeft++; } } //if you have enough then remove bad ones if (numSeqsLeft >= 3) { vector<SeqDist> goodSeqs; //remove bad seqs for (int i = 0; i < remove.size(); i++) { if (remove[i] == 0) { goodSeqs.push_back(seqs[i]); } } seqs = goodSeqs; }else { //warn, but dont remove any m->mothurOut(querySeq->getName() + " does not have an adaquate number of reference sequences that are within 20% and 0.5% similarity. I will continue, but please check."); m->mothurOutEndLine(); } } catch(exception& e) { m->errorOut(e, "Ccode", "removeBadReferenceSeqs"); exit(1); } }
void WaitTimeBar::readXML() { // <?xml version="1.0" encoding="UTF-8"?> // <WaitTime> // <status>OK</status> // <module show="1" locationId="04"> // <totalCustomersInQueue>0</totalCustomersInQueue> // <customerNumberByService> // <service name="Auto">3</service> // </customerNumberByService> // <estimatedStartTimeByService> // <service name="Auto">July-25-13 4:46:20 PM</service> // </estimatedStartTimeByService> // </module> // </WaitTime> XML.pushTag("estimatedStartTimeByService", 0); int numTags = XML.getNumTags("service"); // ofLog() << "Num of service tags: " << numTags; for(int i=0;i<numTags;i++) { if(XML.getAttribute("service","name", "", 0) == "Auto") { carTime = getDiff(XML.getValue("service", "", i)); //ofLog() << "Car time: " << carTime; } else if(XML.getAttribute("service","name", "", 0) == "Home") { houseTime = XML.getValue("service", 0, i); //ofLog() << "Home time: " << houseTime; } else if(XML.getAttribute("service","name", "", 0) == "Travel") { travelTime = XML.getValue("service", 0, i); //ofLog() << "Travel time: " << travelTime; } else if(XML.getAttribute("service","name", "", 0) == "Member") { memberTime = XML.getValue("service", 0, i); //ofLog() << "Member service time: " << memberTime; } } XML.popTag(); XML.pushTag("customerNumberByService", 0); numTags = XML.getNumTags("service"); // ofLog() << "Num of service tags: " << numTags; for(int i=0;i<numTags;i++) { if(XML.getAttribute("service","name", "", 0) == "Auto") { carNum = XML.getValue("service", 0, i); //ofLog() << "Car queue: " << carNum; } else if(XML.getAttribute("service","name", "", 0) == "Home") { houseNum = XML.getValue("service", 0, i); //ofLog() << "Home queue: " << houseNum; } else if(XML.getAttribute("service","name", "", 0) == "Travel") { travelNum = XML.getValue("service", 0, i); //ofLog() << "Travel queue: " << travelNum; } else if(XML.getAttribute("service","name", "", 0) == "Member") { memberNum = XML.getValue("service", 0, i); //ofLog() << "Member service queue: " << memberNum; } } XML.popTag(); // // carTime = XML.getAttribute("WaitTime:module:customerNumberByService","Auto", ""); // carNum = XML.getAttribute("WaitTime:module:estimatedStartTimeByService","Auto", 0); // // houseTime = XML.getAttribute("WaitTime:module:customerNumberByService","Home", ""); // houseNum = XML.getAttribute("WaitTime:module:estimatedStartTimeByService","Home", 0); // // travelTime = XML.getAttribute("WaitTime:module:customerNumberByService","Travel", ""); // travelNum = XML.getAttribute("WaitTime:module:estimatedStartTimeByService","Travel", 0); // // memberTime = getDiff(XML.getAttribute("WaitTime:module:customerNumberByService","Member", "")); // memberNum = XML.getAttribute("WaitTime:module:estimatedStartTimeByService","Member", 0); }
void MainWindow::selectionChange(){ int s = mLeftPanel->selectedItems().at(0)->row(); mRightPanelCommit->setText(mList.at(s).at(5)); QString c = getDiff(mList.at(s+1).at(0),mList.at(s).at(0)); mRightPanelEdit->setHtml(formatChange(s,c)); }