void ResultViewPic::calculatePieces() { selectPicture(); mPieces.clear(); float aspectRatio = float( mFullPic.width() ) / float( mFullPic.height() ); kdDebug() << "AR: " << aspectRatio << endl; int y = sqrt( float( totalCount() ) / aspectRatio ); int x = y * aspectRatio; kdDebug() << "TOTAL: " << x << " " << y << endl; while( x * y < totalCount() ) { y += 1; x = y * aspectRatio; } kdDebug() << "TOTAL2: " << x << " " << y << endl; int row = 0; int col = 0; float x_size = float( mFullPic.width() ) / float( x ); float y_size = float( mFullPic.height() ) / float( y ); kdDebug() << "X_SIZE: " << x_size << " Y_SIZE: " << y_size << endl; for ( int i = 0; i < x * y; ++i ) { QRect piece; piece.setLeft( row * x_size ); piece.setTop( col * y_size ); piece.setWidth( ceil( x_size ) ); piece.setHeight( ceil( y_size ) ); mPieces.append( piece ); row++; if ( row >= x ) { col++; row = 0; } } // showPiece( mPieces.last() ); kdDebug() << "PIECES: " << mPieces.count() << endl; }
QList<QMap<QString, QString> > DatabaseManager::getSeries() { QList<QMap<QString, QString> > allSeries; if (m_db.isOpen()) { this->startTransaction(); QSqlQuery query(m_db); query.exec(QString("SELECT banner, poster, seriesName, status, id, overview, imdbID, rating, genre FROM Series ORDER BY seriesName;")); this->commit(); if (query.isSelect()) { while (query.next()) { QMap<QString, QString> temp; QString banner = query.value(0).toString(); temp["banner"] = banner; QString poster = query.value(1).toString(); temp["poster"] = poster; QString seriesName = query.value(2).toString(); temp["seriesName"] = seriesName; QString status = query.value(3).toString(); temp["status"] = status; int id = query.value(4).toInt(); QString idstring = QString::number(id); temp["id"] = idstring; QString overview = query.value(5).toString(); overview.replace("''","'"); temp["overview"] = overview; QString imdbId = query.value(6).toString(); temp["imdbId"] = imdbId; QString rating = query.value(7).toString(); temp["rating"] = rating; QString genre = query.value(8).toString(); temp["genre"] = genre; int watched = watchedCount(id); QString watchedCount = QString::number(watched); temp["watchedCount"] = watchedCount; int total = totalCount(id); QString totalCount = QString::number(total); temp["totalCount"] = totalCount; allSeries.append(temp); } } } return allSeries; }
InstanceCounter() : mDontIncludeInCounts(false) { AO_fetch_and_add_full(&mCounts, 1); LOG_DEBUG << "Create " << Ufora::debug::StackTrace::demangle(typeid(T).name()) << ". Total = " << totalCount(); }
void TextDocument::lowlight(int block) { if (block == -1) block = totalCount() - 1; if (d.lowlight != block) { d.lowlight = block; updateBlock(block); } }
virtual ~InstanceCounter() { if (!mDontIncludeInCounts) AO_fetch_and_add_full(&mCounts, -1); LOG_DEBUG << "Destroy " << Ufora::debug::StackTrace::demangle(typeid(T).name()) << ". Total = " << totalCount(); }
void expandQueryByMap(std::map<int,double>& fb, double origModCoeff) { if (!qm) { qm = new lemur::api::IndexedRealVector(); } else { qm->clear(); } cout << "stage 1" << endl; debug(); std::map<int,double>::iterator it; for(it=fb.begin();it!=fb.end();++it) { int termID = it->first; IndexedReal entry; if(!include(termID)) { entry.ind = termID; entry.val = 0; qm->push_back(entry); } } cout << "stage 2" << endl; debug(); // get original query term count double countSum = totalCount(); startIteration(); while (hasMore()) { lemur::api::QueryTerm *qt = nextTerm(); setCount(qt->id(), qt->weight()*origModCoeff/countSum); delete qt; } cout << "stage 3" << endl; debug(); for(it=fb.begin();it!=fb.end();++it) { int termID = it->first; double score = it->second; incCount(termID, score*(1.0-origModCoeff)); } cout << "stage 4" << endl; debug(); //Sum w in Q qtf * log(qtcf/termcount); colQLikelihood = 0; colQueryLikelihood(); colKLComputed = false; }
void TextDocument::addHighlight(int block) { const int max = totalCount() - 1; if (block == -1) block = max; if (block >= 0 && block <= max) { QList<int>::iterator it = qLowerBound(d.highlights.begin(), d.highlights.end(), block); d.highlights.insert(it, block); updateBlock(block); } }
static INT_PTR CALLBACK Dialog_GoToPage_Proc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) { HWND editPageNo; Dialog_GoToPage_Data * data; //[ ACCESSKEY_GROUP GoTo Page Dialog if (WM_INITDIALOG == msg) { data = (Dialog_GoToPage_Data*)lParam; assert(data); SetWindowLongPtr(hDlg, GWLP_USERDATA, (LONG_PTR)data); win::SetText(hDlg, _TR("Go to page")); editPageNo = GetDlgItem(hDlg, IDC_GOTO_PAGE_EDIT); if (!data->onlyNumeric) SetWindowLong(editPageNo, GWL_STYLE, GetWindowLong(editPageNo, GWL_STYLE) & ~ES_NUMBER); assert(data->currPageLabel); SetDlgItemText(hDlg, IDC_GOTO_PAGE_EDIT, data->currPageLabel); ScopedMem<WCHAR> totalCount(str::Format(_TR("(of %d)"), data->pageCount)); SetDlgItemText(hDlg, IDC_GOTO_PAGE_LABEL_OF, totalCount); Edit_SelectAll(editPageNo); SetDlgItemText(hDlg, IDC_STATIC, _TR("&Go to page:")); SetDlgItemText(hDlg, IDOK, _TR("Go to page")); SetDlgItemText(hDlg, IDCANCEL, _TR("Cancel")); CenterDialog(hDlg); SetFocus(editPageNo); return FALSE; } //] ACCESSKEY_GROUP GoTo Page Dialog switch (msg) { case WM_COMMAND: switch (LOWORD(wParam)) { case IDOK: data = (Dialog_GoToPage_Data*)GetWindowLongPtr(hDlg, GWLP_USERDATA); assert(data); editPageNo = GetDlgItem(hDlg, IDC_GOTO_PAGE_EDIT); data->newPageLabel = win::GetText(editPageNo); EndDialog(hDlg, IDOK); return TRUE; case IDCANCEL: EndDialog(hDlg, IDCANCEL); return TRUE; } break; } return FALSE; }
void expandQuery(MyQueryModel &exRep, double origModCoeff) { if (!qm) { qm = new lemur::api::IndexedRealVector(); } else { qm->clear(); } // get original query term count double countSum = totalCount(); // add expand query's term, init weight as zero exRep.startIteration(); while (exRep.hasMore()) { lemur::api::QueryTerm *qt = exRep.nextTerm(); IndexedReal entry; if(!include(qt->id())) { entry.ind = qt->id(); //entry.val = qt->weight(); entry.val = 0; qm->push_back(entry); } delete qt; } qm->Sort(); // cout << "after push words" << endl; // cout << "original total count = " << totalCount() << endl; // debug(); // discounting the original model startIteration(); while (hasMore()) { lemur::api::QueryTerm *qt = nextTerm(); setCount(qt->id(), qt->weight()*origModCoeff/countSum); delete qt; } // debug(); // now adding the new model double exCountSum = exRep.totalCount(); exRep.startIteration(); while (exRep.hasMore()) { lemur::api::QueryTerm *qt = exRep.nextTerm(); incCount(qt->id(), qt->weight()*(1.0-origModCoeff)/exCountSum); delete qt; } debug(); //Sum w in Q qtf * log(qtcf/termcount); colQLikelihood = 0; colQueryLikelihood(); colKLComputed = false; }
void interpolateWith(const lemur::langmod::UnigramLM &qModel, double origModCoeff, int howManyWord, double prSumThresh, double prThresh) { if (!qm) { qm = new lemur::api::IndexedRealVector(); } else { qm->clear(); } qModel.startIteration(); while (qModel.hasMore()) { IndexedReal entry; qModel.nextWordProb((TERMID_T &)entry.ind,entry.val); qm->push_back(entry); } qm->Sort(); double countSum = totalCount(); startIteration(); while (hasMore()) { QueryTerm *qt = nextTerm(); setCount(qt->id(), qt->weight()*origModCoeff/countSum); delete qt; } cout << "-------- FB terms --------" << endl; double prSum = 0; int wdCount = 0; IndexedRealVector::iterator it; it = qm->begin(); while (it != qm->end() && prSum < prSumThresh && wdCount < howManyWord && (*it).val >=prThresh) { incCount((*it).ind, (*it).val*(1-origModCoeff)); cout << ind.term(it->ind) << endl; prSum += (*it).val; it++; wdCount++; } cout << "--------------------------" << endl; colQLikelihood = 0; colQueryLikelihood(); colKLComputed = false; }
QVariant SpotItemModel::data(const QModelIndex &index, int role) const { if (!index.isValid() || m_items_reference.empty()) { return QVariant(QVariant::Invalid); } const auto item = m_items_reference.at(index.row()); if ((role == Qt::DisplayRole || role == Qt::UserRole) && index.column() == Name) { return item->name(); } if (role == Qt::ForegroundRole && index.column() == Name) { return QColor(0, 155, 60); } if ((role == Qt::CheckStateRole || role == Qt::UserRole) && index.column() == Show) { return item->visible() ? Qt::Checked : Qt::Unchecked; } if ((role == Qt::DisplayRole || role == Qt::UserRole) && index.column() == Count) { return item->totalCount(); } if (role == Qt::DecorationRole && index.column() == Color) { return item->color(); } if (role == Qt::TextAlignmentRole) { switch (index.column()) { case Show: return Qt::AlignCenter; case Color: return Qt::AlignCenter; case Count: return Qt::AlignCenter; case Name: return Qt::AlignLeft; default: return QVariant(QVariant::Invalid); } } return QVariant(QVariant::Invalid); }
static void CalcOnlineCTRSimple(const TTrainData& data, const TVector<ui64>& enumeratedCatFeatures, size_t leafCount, const TVector<int>& permutedTargetClass, const TVector<float>& priors, int ctrBorderCount, TArray2D<TVector<ui8>>* feature) { const auto docCount = enumeratedCatFeatures.ysize(); auto ctrArrSimple = TCtrCalcer::GetCtrHistoryArr(leafCount); TVector<float> shift; TVector<float> norm; CalcNormalization(priors, &shift, &norm); const int blockSize = 1000; TVector<int> totalCount(blockSize); TVector<int> goodCount(blockSize); for (int blockStart = 0; blockStart < docCount; blockStart += blockSize) { const int nextBlockStart = Min<int>(docCount, blockStart + blockSize); for (int docId = blockStart; docId < nextBlockStart; ++docId) { TCtrHistory& elem = ctrArrSimple[enumeratedCatFeatures[docId]]; goodCount[docId - blockStart] = elem.N[1]; totalCount[docId - blockStart] = elem.N[0] + elem.N[1]; if (docId < data.LearnSampleCount) { ++elem.N[permutedTargetClass[docId]]; } } for (int prior = 0; prior < priors.ysize(); ++prior) { const float priorX = priors[prior]; const float shiftX = shift[prior]; const float normX = norm[prior]; ui8* featureData = (*feature)[0][prior].data(); for (int docId = blockStart; docId < nextBlockStart; ++docId) { featureData[docId] = CalcCTR(goodCount[docId - blockStart], totalCount[docId - blockStart], priorX, shiftX, normX, ctrBorderCount); } } } }
void ResultViewPic::doSetCurrentCount( int c ) { Q_UNUSED( c ); if ( c > 0 ) { int select = KRandom::number( mPieces.count() ); Q_ASSERT( select < int( mPieces.count() ) ); QRect piece = mPieces[ select ]; QValueList<QRect>::Iterator it = mPieces.at( select ); mPieces.erase( it ); showPiece( piece ); } if ( c == totalCount() ) { for( unsigned int i = 0; i < mPieces.count(); ++i ) { showPiece( mPieces[ i ] ); } } setSummary(); }
size_t mystack::AnytimeContractSearchStack(gridSearch& GS) { //search in a round robin manner in this step as well if(level > 0) { size_t totalCount(0); for(size_t i = 0; i < numRange; i++) { size_t count = sArr[i]->AnytimeContractSearchStack(GS); expCount[i] += count; totalCount += count; if(expCount[i] >= lim[i]) { suspend[i] = true; } } return totalCount; } size_t count(0); do { bool exist(false); size_t lvl(0); openEntry qCur = SelectBestFromAllLevels(exist, lvl); if(!exist) { return count; } bool added = GS.CallBack(qCur, lvl); if(added) { expCount[lvl]++; count++; if(expCount[lvl] >= lim[lvl]) { suspend[lvl] = true; } } } while(true); return count; }
int main() { int i; int flag;//1应该出现offline, 0应该出现online int onpos;//记录最近有效的on-line记录位置,为了算出charge int sign;//0表示该客户名字和月份还没有输出,1表示已输出 while(scanf("%d", &rate[0]) != EOF) { for(i = 1; i < 24; i ++) { scanf("%d", &rate[i]); } scanf("%d", &n); rd = (record *)malloc(n * sizeof(record)); for(i = 0; i < n; i ++) { scanf("\n%s %d:%d:%d:%d %s", rd[i].name, &rd[i].month, &rd[i].day, &rd[i].hour, &rd[i].minute, rd[i].tag); } qsort(rd, n, sizeof(record), comp_name);//先将记录按字母表顺序分类 count = 1; start = 0; totalCount(); sign = 0; while(start < n)//整个记录表还没处理完 { qsort(rd + start, count, sizeof(record), comp_time); flag = 0; totalCharge = 0; for(i = start; i < start + count; i ++)//处理该客户 { if(flag == 0)//期待出现online,如果是offline跳过 { if(rd[i].tag[1] == 'f')//off-line { continue; } else//on-line { onpos = i; flag = 1; } } else//期待出现offline,如果是online则更新onpos { if(rd[i].tag[1] == 'n')//on-line { onpos = i; } else//off-line { if(sign == 0) { printf("%s %02d\n", rd[start].name, rd[start].month); sign = 1; } printf("%02d:%02d:%02d %02d:%02d:%02d ", rd[onpos].day, rd[onpos].hour, rd[onpos].minute, rd[i].day, rd[i].hour, rd[i].minute); totalCharge += charge(rd[onpos].day, rd[onpos].hour, rd[onpos].minute, rd[i].day, rd[i].hour, rd[i].minute); flag = 0; } } } if(sign == 1) { printf("Total amount: $%.2lf\n", totalCharge); } start += count; count = 1; totalCount(); sign = 0; } } return 0; }
void TextDocument::removeHighlight(int block) { if (d.highlights.removeOne(block) && block >= 0 && block < totalCount()) updateBlock(block); }
void BlinkParser::parseXml() { while (!m_reader->atEnd()) { switch(m_reader->readNext()) { case QXmlStreamReader::StartElement: if (m_reader->name().endsWith(QStringLiteral("db_id"))) { state = State::ID; } else if (m_reader->name() == QStringLiteral("series_image")) { state = State::ImgLink; } else if (m_reader->name() == QStringLiteral("myinfo")) { m_atUserInfo = true; } else if (m_atUserInfo) { // here we rip off the total progress that we need if (m_reader->name() == QStringLiteral("user_watching") || m_reader->name() == QStringLiteral("user_reading") || m_reader->name() == QStringLiteral("user_completed") || m_reader->name() == QStringLiteral("user_onhold") || m_reader->name() == QStringLiteral("user_dropped") || m_reader->name() == QStringLiteral("user_plantowatch") || m_reader->name() == QStringLiteral("user_plantoread")) { m_total += m_reader->readElementText().toInt(); } } else if (m_reader->name() == "error") { emit writingError(m_reader->readElementText()); return; } break; case QXmlStreamReader::Characters: if (state == State::ID) { m_currentId += m_reader->text(); } else if (state == State::ImgLink) { m_currentImgLink += m_reader->text(); } case QXmlStreamReader::EndElement: if (m_reader->name().endsWith(QStringLiteral("db_id")) || m_reader->name() == QStringLiteral("series_image")) { state = State::Nothing; } if (m_reader->name() == QStringLiteral("anime") || m_reader->name() == QStringLiteral("manga")) { emit write(m_currentId, m_currentImgLink); emit currentProgress(++m_current); m_currentId.clear(); m_currentImgLink.clear(); } if (m_reader->name() == QStringLiteral("myinfo")) { m_atUserInfo = false; emit totalCount(m_total); } break; case QXmlStreamReader::EndDocument: m_reply->deleteLater(); m_reply = nullptr; emit writingFinished(); default: break; } } if (Q_UNLIKELY(m_reader->hasError() && m_reader->error() != QXmlStreamReader::PrematureEndOfDocumentError)) { emit writingError(m_reader->errorString()); m_reply->abort(); m_reply->deleteLater(); m_reply = nullptr; } }
void RegressionAnalysis::RankFamilies() { printf("Family Informativeness\n" "======================\n" "%15s %15s %7s %7s %7s %7s %7s\n", "Family", "Trait", "People", "Phenos", "Pairs", "Info", "ELOD20"); IntArray totalCount(modelCount); totalCount.Zero(); IntArray totalPheno(modelCount); totalPheno.Zero(); IntArray totalPairs(modelCount); totalPairs.Zero(); for (int trait = 0; trait < modelCount; trait++) regress[trait].ResetMaxInfo(); for (int i = 0; i < ped.familyCount; i++) { Family * family = ped.families[i]; mantra.Prepare(ped, *family); if (mantra.bit_count > maxBits) { printf("%15s *** %d-bit family skipped ***\n", (const char *) family->famid, mantra.bit_count); continue; } mantra.PrepareIBD(); tree.MakeMinimalTree(1.0, mantra.bit_count); kinship.SelectFamily(&ped, family); kinship.Calculate(tree); for (int trait = 0; trait < modelCount; trait++) { regress[trait].SetupFamily(kinship); int phenotypes = 0; for (int j = family->first; j <= family->last; j++) if (ped[j].isPhenotyped(regress[trait].trait)) phenotypes++; totalCount[trait] += family->count; totalPheno[trait] += phenotypes; totalPairs[trait] += regress[trait].CountPairs(); printf("%15s %15s %7d %7d %7d %7.3f %7.3f\n", (const char *) family->famid, (const char *) regress[trait].shortLabel, family->count, phenotypes, regress[trait].CountPairs(), regress[trait].maxInfo, regress[trait].maxInfo * 0.04 * 0.2171472409516); } } for (int trait = 0; trait < modelCount; trait++) printf("%15s %15s %7d %7d %7d %7.3f %7.3f\n", "TOTAL", (const char *) regress[trait].shortLabel, totalCount[trait], totalPheno[trait], totalPairs[trait], regress[trait].sumMaxInfo, regress[trait].sumMaxInfo * 0.04 * 0.2171472409516); printf("\n"); }
void ResultViewPic::setSummary() { mSummaryLabel->setText( i18n("%1/%2 correct, %3 wrong").arg( currentCount() ) .arg( totalCount() ).arg( wrongCount() ) ); }
QList<QVariantMap> DatabaseManager::getSeries() { QList<QVariantMap> allSeries; if (m_db.isOpen()) { this->startTransaction(); QSqlQuery query(m_db); query.exec(QString("SELECT banner, poster, seriesName, status, id, overview, imdbID, rating, genre " "FROM Series " "ORDER BY seriesName;")); this->commit(); if (query.isSelect()) { while (query.next()) { QVariantMap temp; auto banner = query.value(0).toString(); temp["banner"] = banner; auto poster = query.value(1).toString(); temp["poster"] = poster; auto seriesName = query.value(2).toString(); seriesName.replace("''", "'"); temp["seriesName"] = seriesName; auto status = query.value(3).toString(); temp["status"] = status; auto id = query.value(4).toInt(); auto idString = QString::number(id); temp["id"] = idString; auto overview = query.value(5).toString(); overview.replace("''", "'"); temp["overview"] = overview; auto imdbId = query.value(6).toString(); temp["imdbId"] = imdbId; auto rating = query.value(7).toString(); temp["rating"] = rating; auto genre = query.value(8).toString(); temp["genre"] = genre; auto watched = watchedCount(id); auto watchedCount = QString::number(watched); temp["watchedCount"] = watchedCount; auto total = totalCount(id); auto totalCount = QString::number(total); temp["totalCount"] = totalCount; allSeries.append(temp); } } } return allSeries; }