Tjcampdx Spectrometer::getBlackBodySpec(double max, double T){ QVector<double> lambda = pixToWavelength(pixNum); QVector<double> intens; intens.resize(lambda.size()); for(int i=0;i<lambda.size();i++){ intens[i]=blackBodyIntensNorm(lambda[i]*1e-9,T)*max; } Tjcampdx spectrum; spectrum.LoadData(lambda.toStdVector(),intens.toStdVector()); return spectrum; }
void IqtFit::plotGuess(QtProperty *) { // Do nothing if there is no sample data curve if (!m_uiForm.ppPlot->hasCurve("Sample")) return; CompositeFunction_sptr function = createFunction(true); // Create the double* array from the input workspace const size_t binIndxLow = m_ffInputWS->binIndexOf(m_ffRangeManager->value(m_properties["StartX"])); const size_t binIndxHigh = m_ffInputWS->binIndexOf(m_ffRangeManager->value(m_properties["EndX"])); const size_t nData = binIndxHigh - binIndxLow; std::vector<double> inputXData(nData); const Mantid::MantidVec &XValues = m_ffInputWS->readX(0); const bool isHistogram = m_ffInputWS->isHistogramData(); for (size_t i = 0; i < nData; i++) { if (isHistogram) inputXData[i] = 0.5 * (XValues[binIndxLow + i] + XValues[binIndxLow + i + 1]); else inputXData[i] = XValues[binIndxLow + i]; } FunctionDomain1DVector domain(inputXData); FunctionValues outputData(domain); function->function(domain, outputData); QVector<double> dataX; QVector<double> dataY; for (size_t i = 0; i < nData; i++) { dataX.append(inputXData[i]); dataY.append(outputData.getCalculated(i)); } IAlgorithm_sptr createWsAlg = AlgorithmManager::Instance().create("CreateWorkspace"); createWsAlg->initialize(); createWsAlg->setChild(true); createWsAlg->setLogging(false); createWsAlg->setProperty("OutputWorkspace", "__GuessAnon"); createWsAlg->setProperty("NSpec", 1); createWsAlg->setProperty("DataX", dataX.toStdVector()); createWsAlg->setProperty("DataY", dataY.toStdVector()); createWsAlg->execute(); MatrixWorkspace_sptr guessWs = createWsAlg->getProperty("OutputWorkspace"); m_uiForm.ppPlot->addSpectrum("Guess", guessWs, 0, Qt::green); }
void Model::setSegmentDefinition(int id, const QVector<int>& markerIds, const QVector<Pair>& links, const QVector<Triad>& faces) { QMap<int,Segment*>::iterator it = this->m_Segments.find(id); if (it != this->m_Segments.end()) { (*it)->markerIds = markerIds; (*it)->links = links; (*it)->faces = faces; (*it)->mesh->SetDefinition(markerIds.toStdVector(),links.toStdVector(),faces.toStdVector()); emit segmentDefinitionChanged(id); } };
void Viewport::setAppliedIlluminant(QVector<multi_img_base::Value> illum) { //bool change = (applied != illuminant_apply); illuminantAppl = illum.toStdVector(); /* if (change) TODO: I assume this is already triggered by invalidated ROI rebuild();*/ }
bool QvernoteStorage::listNotebooks(std::vector<Notebook>& notebookList) { QVector<Notebook> qNotebooklist; QNotebook::loadList(getDB(), qNotebooklist); notebookList = qNotebooklist.toStdVector(); return true; }
bool QvernoteStorage::listTagsByNotebook(std::vector<Tag>& tagList, Guid notebookGuid) { QVector<Tag> qTaglist; QTag::loadForNotebook(getDB(), notebookGuid, qTaglist); tagList = qTaglist.toStdVector(); return true; }
bool EditableDenseThreeDimensionalModel::shouldUseLogValueScale() const { QReadLocker locker(&m_lock); QVector<float> sample; QVector<int> n; for (int i = 0; i < 10; ++i) { size_t index = i * 10; if (index < m_data.size()) { const Column &c = m_data.at(index); while (c.size() > sample.size()) { sample.push_back(0.f); n.push_back(0); } for (int j = 0; j < c.size(); ++j) { sample[j] += c.at(j); ++n[j]; } } } if (sample.empty()) return false; for (int j = 0; j < sample.size(); ++j) { if (n[j]) sample[j] /= n[j]; } return LogRange::useLogScale(sample.toStdVector()); }
bool QvernoteStorage::getFavoriteNotes(vector<Note>& noteList) { QVector<Note> qNoteList; QNote::getFavorites(getDB(), qNoteList); noteList = qNoteList.toStdVector(); return true; }
vector<QAction*> ToolBarImp::getItems() const { QList<QAction*> actionList = actions(); QVector<QAction*> actionVector = actionList.toVector(); vector<QAction*> items = actionVector.toStdVector(); return items; }
bool QvernoteStorage::listTags(vector<Tag>& tagList) { QVector<Tag> qTagList; QTag::loadList(getDB(), qTagList); tagList = qTagList.toStdVector(); return true; }
// This test case is based on the example presented on page 725 of the // paper: "Three dimensional triganulations from local transformations" // by Barry Joe (Siam J. Sci. Stat. Comput. Vol 10, No 4, 1989). void DelaunayTriangulationTest::joe89() { std::vector<chemkit::Point3> points; points.push_back(chemkit::Point3(0.054f, 0.099f, 0.993f)); points.push_back(chemkit::Point3(0.066f, 0.756f, 0.910f)); points.push_back(chemkit::Point3(0.076f, 0.578f, 0.408f)); points.push_back(chemkit::Point3(0.081f, 0.036f, 0.954f)); points.push_back(chemkit::Point3(0.082f, 0.600f, 0.726f)); points.push_back(chemkit::Point3(0.085f, 0.327f, 0.731f)); points.push_back(chemkit::Point3(0.123f, 0.666f, 0.842f)); points.push_back(chemkit::Point3(0.161f, 0.303f, 0.975f)); chemkit::DelaunayTriangulation triangulation(points); QCOMPARE(triangulation.vertexCount(), 8); QCOMPARE(triangulation.tetrahedronCount(), 13); QList<QVector<int> > expectedTetrahedra; expectedTetrahedra.append(QVector<int>() << 0 << 1 << 2 << 4); expectedTetrahedra.append(QVector<int>() << 0 << 1 << 4 << 5); expectedTetrahedra.append(QVector<int>() << 0 << 1 << 5 << 7); expectedTetrahedra.append(QVector<int>() << 0 << 2 << 3 << 5); expectedTetrahedra.append(QVector<int>() << 0 << 2 << 4 << 5); expectedTetrahedra.append(QVector<int>() << 0 << 3 << 5 << 7); expectedTetrahedra.append(QVector<int>() << 1 << 2 << 4 << 6); expectedTetrahedra.append(QVector<int>() << 1 << 4 << 5 << 7); expectedTetrahedra.append(QVector<int>() << 1 << 4 << 6 << 7); expectedTetrahedra.append(QVector<int>() << 2 << 3 << 5 << 7); expectedTetrahedra.append(QVector<int>() << 2 << 4 << 5 << 6); expectedTetrahedra.append(QVector<int>() << 2 << 5 << 6 << 7); expectedTetrahedra.append(QVector<int>() << 4 << 5 << 6 << 7); std::vector<std::vector<int> > tetrahedra = triangulation.tetrahedra(); QCOMPARE(tetrahedra.size(), size_t(expectedTetrahedra.size())); for(unsigned int i = 0; i < tetrahedra.size(); i++){ std::vector<int> tetrahedron = tetrahedra[i]; std::sort(tetrahedron.begin(), tetrahedron.end()); int foundCount = 0; for(int j = 0; j < expectedTetrahedra.size(); j++){ QVector<int> expectedTetrahedron = expectedTetrahedra[j]; if(tetrahedron == expectedTetrahedron.toStdVector()){ foundCount++; } } if(foundCount != 1){ qDebug() << "tetrahedron (index " << i << ") was not found. verticies: " << QVector<int>::fromStdVector(tetrahedron); } QCOMPARE(foundCount, 1); } }
/********************************************//** \brief Discrete Wavelet Transform including Daubechies and Biorthogonal \param array : input array (1D) \param filter : name of the filter to use (from TransformationType enum) \param dir : direction (1:forward, -1:backward) \param transformedArray : resulting transformed array \param stop : flag indicating if we need to stop the process or not \param origLength : original Length useful when dir is -1 to cut result \return boolean true if the execution is finished, false if the process has been stopped during the execution ***********************************************/ bool FWT::getDWT(const QVector<float>& array, const TransformationType filter, const int dir, QVector<float>& transformedArray, bool* stop, const int origLength) { std::vector<float> result; if(filter == DB4_TRANSFORMATION || filter == DB6_TRANSFORMATION || filter == DB8_TRANSFORMATION) { if(dir == 1) return fastWaveletTransf(array.toStdVector(), filter, result, stop); else return iFastWaveletTransf(array.toStdVector(), filter, origLength, result, stop); } else if(filter == BIOR_5_3_TRANSFORMATION || filter == BIOR_9_7_TRANSFORMATION) { return perform_wavelet_transform(array.toStdVector(), filter, dir, origLength, result, stop); } transformedArray.fromStdVector(result); return true; }
void NScriptEngine::execute_line( const QString & line , int fragment_number, QVector<int> break_points){ if (connected){ const common::URI script_engine_path("//Tools/Python/ScriptEngine", common::URI::Scheme::CPATH); SignalOptions options; QString repl=QString(line); repl.replace(QString("\t"),QString(";")); repl.replace(QString("\n"),QString("?")); options.add("script", repl.toStdString()); options.add("fragment",fragment_number); options.add("breakpoints",break_points.toStdVector()); SignalFrame frame = options.create_frame("execute_script", uri(), script_engine_path); NetworkQueue::global()->send( frame, NetworkQueue::IMMEDIATE ); } }
bool DefectsModel::setData(const QModelIndex& index, const QVariant& value, int role) { if (index.isValid() && role == Qt::EditRole) { switch (index.column()) { case (0): defectsList[index.row()].centre.x = value.toDouble(); break; case (1): defectsList[index.row()].centre.y = value.toDouble(); break; case (2): defectsList[index.row()].radius = value.toDouble(); break; case (3): { QString s = value.toString().replace("[", "").replace("]", "").trimmed(); QStringList sl = s.split(","); QVector<double> vec; for (int i = 0; i < sl.size(); ++i) { vec << sl.at(i).toDouble(); } GeneralComponentSystem g = GeneralComponentSystem(vec.toStdVector()); defectsList[index.row()].value.resize(g.components.size()); defectsList[index.row()].value = g; break; } case (4): defectsList[index.row()].boundaryCondition = static_cast<BoundaryCondition>(value.toInt()); break; } emit dataChanged(index, index); return true; } return false; }
Aquila::SignalSource * procHighpassFilter(Aquila::SignalSource * source) { QVector<Aquila::SampleType> data; const int step = 16; int size = source->getSamplesCount(); for (int i=0; i<size; i++) { double res = 0.0; for(int j=0; j<step; j++){ if(i-j < 0) res += source->sample(0); else res += source->sample(i-j); if(i+j >= size) res += source->sample(size-1); else res += source->sample(i+j); } Aquila::SampleType val = source->sample(i) - (res / (step * 2)); if(val > 32767.0) val = 32767.0; if(val< -32767.0) val =-32767.0; data.append(val); } return new Aquila::SignalSource(data.toStdVector(), source->getSampleFrequency()); }
/** * Main function: runs plugin based on its ID * @param plugin ID * @param image to be processed **/ QSharedPointer<nmc::DkImageContainer> WriterIdentificationPlugin::runPlugin( const QString &runID, QSharedPointer<nmc::DkImageContainer> imgC, const nmc::DkSaveInfo& saveInfo, QSharedPointer<nmc::DkBatchInfo>& info) const { if (!imgC) return imgC; if(runID == mRunIDs[id_calcuate_features]) { qInfo() << "calculating features for writer identification"; WriterIdentification wi = WriterIdentification(); cv::Mat imgCv = nmc::DkImage::qImage2Mat(imgC->image()); wi.setImage(imgCv); wi.calculateFeatures(); cv::cvtColor(imgCv, imgCv, CV_RGB2GRAY); QVector<cv::KeyPoint> kp = wi.keyPoints(); //QVector<cv::KeyPoint>::iterator kpItr = kp.begin(); //cv::Mat desc = wi.descriptors(); //cv::Mat newDesc = cv::Mat(0, desc.cols, desc.type()); //int r = 0; //rdf::Image::imageInfo(desc, "desc"); //for(auto kpItr = kp.begin(); kpItr != kp.end(); r++) { // kpItr->size *= 1.5 * 4; // if(kpItr->size > 70) { // kpItr = kp.erase(kpItr); // } else if(kpItr->size < 20) { // kpItr = kp.erase(kpItr); // } else { // kpItr++; // newDesc.push_back(desc.row(r).clone()); // } //} //rdf::Image::imageInfo(newDesc, "newDesc"); //wi.setDescriptors(newDesc); //wi.setKeyPoints(kp); cv::drawKeypoints(imgCv, kp.toStdVector(), imgCv, cv::Scalar::all(-1), cv::DrawMatchesFlags::DRAW_RICH_KEYPOINTS); ////cv::drawKeypoints(imgCv, wi.getKeyPoints().toStdVector(), imgCv, cv::Scalar::all(-1)); // ////QString fFilePath = featureFilePath(imgC->filePath(), true); wi.saveFeatures(featureFilePath(imgC->filePath(), true)); //QImage img = nmc::DkImage::mat2QImage(imgCv); //img = img.convertToFormat(QImage::Format_ARGB32); //imgC->setImage(img, tr("SIFT keypoints")); } else if(runID == mRunIDs[id_generate_vocabulary]) { qInfo() << "collecting files for vocabulary generation"; QString ffPath = featureFilePath(imgC->filePath()); int idxOfMinus = QFileInfo(imgC->filePath()).baseName().indexOf("-"); int idxOfUScore = QFileInfo(imgC->filePath()).baseName().indexOf("_"); int idx = -1; if(idxOfMinus == -1 && idxOfUScore > 0) idx = idxOfUScore; else if(idxOfUScore == -1 && idxOfMinus > 0) idx = idxOfMinus; else if(idxOfMinus > 0 && idxOfUScore > 0) idx = idxOfMinus > idxOfUScore ? idxOfMinus : idxOfUScore; QString label = QFileInfo(imgC->filePath()).baseName().left(idx); QSharedPointer<WIInfo> wInfo(new WIInfo(runID, imgC->filePath())); wInfo->setWriter(label); wInfo->setFeatureFilePath(ffPath); info = wInfo; } else if(runID == mRunIDs[id_identify_writer]) { qInfo() << "identifying writer"; } else if(runID == mRunIDs[id_evaluate_database]) { qInfo() << "collecting files evaluation"; if(mVocabulary.isEmpty()) { qWarning() << "batchProcess: vocabulary is empty ... not evaluating"; return imgC; } QString fFilePath = featureFilePath(imgC->filePath()); if(QFileInfo(fFilePath).exists()) { int idxOfMinus = QFileInfo(imgC->filePath()).baseName().indexOf("-"); int idxOfUScore = QFileInfo(imgC->filePath()).baseName().indexOf("_"); int idx = -1; if(idxOfMinus == -1 && idxOfUScore > 0) idx = idxOfUScore; else if(idxOfUScore == -1 && idxOfMinus > 0) idx = idxOfMinus; else if(idxOfMinus > 0 && idxOfUScore > 0) idx = idxOfMinus < idxOfUScore ? idxOfMinus : idxOfUScore; QString label = QFileInfo(imgC->filePath()).baseName().left(idx); qDebug() << "label: " << label << "\t\tbaseName:" << QFileInfo(imgC->filePath()).baseName(); cv::FileStorage fs(fFilePath.toStdString(), cv::FileStorage::READ); if(!fs.isOpened()) { qWarning() << " unable to read file " << fFilePath; return imgC; } std::vector<cv::KeyPoint> kp; fs["keypoints"] >> kp; cv::Mat descriptors; fs["descriptors"] >> descriptors; fs.release(); if(mVocabulary.minimumSIFTSize() > 0 || mVocabulary.maximumSIFTSize() > 0) { cv::Mat filteredDesc = cv::Mat(0, descriptors.cols, descriptors.type()); int r = 0; for(auto kpItr = kp.begin(); kpItr != kp.end(); r++) { if(kpItr->size*1.5 * 4 > mVocabulary.maximumSIFTSize() && mVocabulary.maximumSIFTSize() > 0) { kpItr = kp.erase(kpItr); } else if(kpItr->size * 1.5 * 4 < mVocabulary.minimumSIFTSize()) { kpItr = kp.erase(kpItr); } else { kpItr++; filteredDesc.push_back(descriptors.row(r).clone()); } } qDebug() << "filtered " << descriptors.rows - filteredDesc.rows << " SIFT features (maxSize:" << mVocabulary.maximumSIFTSize() << " minSize:" << mVocabulary.minimumSIFTSize() << ")"; descriptors = filteredDesc; } else qDebug() << "not filtering SIFT features, min or max size not set"; cv::Mat feature = mVocabulary.generateHist(descriptors); rdf::Image::imageInfo(descriptors, "descriptors"); rdf::Image::imageInfo(feature, "feature"); QSharedPointer<WIInfo> wInfo(new WIInfo(runID, imgC->filePath())); wInfo->setWriter(label); wInfo->setFeatureFilePath(fFilePath); wInfo->setFeatureVector(feature); info = wInfo; } else {
void DistViewModel::setIlluminant(QVector<multi_img::Value> illum) { // no recalculation as is triggered elsewhere illuminant = illum.toStdVector(); }
for (set <int>::const_iterator it = s.begin(); it != s.end(); it++) { _l.push_back(v[*it - 1]); } } QString Paper::getTitle() const { return _title; } vector <Problem> &Paper::getProb() { return _l; } const std::vector <Problem> &Paper::getProb() const { return _l; } QDataStream & operator << (QDataStream &stream, const Paper &p) { stream << p._title << QVector <Problem>::fromStdVector(p._l); return stream; } QDataStream & operator >> (QDataStream &stream, Paper &p) { QString title; QVector <Problem> prob; stream >> title; stream >> prob; p = Paper(title, prob.toStdVector()); return stream; }
void MainWindow::on_startSimulationPushButton_clicked() { QTime timer; timer.start(); qDebug() << "loading parameters..."; double alpha = ui->alpha_lineedit->text().toDouble(); int minNumberOfBusStopsInRegion = ui->minbusstopsinregion->text().toInt(); int maxNumberOfBusStopsInRegion = ui->maxbusstopsinregion->text().toInt(); int minBuslineLength = ui->minlinelength->text().toInt(); int maxBuslineLength = ui->maxlinelength->text().toInt(); int populationMultiplier = ui->multiplier_lineedit->text().toInt(); int percentageOfCrossedSolution = ui->crossed_lineedit->text().toInt(); int iterationsForDifferentBaseSolutions = ui->iterations_for_diff->text().toInt(); QVector<Parameters::MutationType> mutations; if ( ui->mutationType_simple->isChecked() ) mutations.push_front(Parameters::SIMPLE_MUTATION); if ( ui->mutationType_random->isChecked() ) mutations.push_front(Parameters::RANDOM_MUTATION); if ( ui->mutationType_moreRandom->isChecked() ) mutations.push_front(Parameters::MORE_RANDOM_MUTATION); if ( ui->mutationType_evenMoreRandom->isChecked() ) mutations.push_front(Parameters::EVEN_MORE_RANDOM_MUTATION); long numberOfIterations = ui->numofiterations->text().toInt(); qDebug() << "Parameters loaded"; qDebug() << "alpha" << alpha << endl << "minNumberOfBusStopsInRegion" << minNumberOfBusStopsInRegion << endl << "maxNumberOfBusStopsInRegion" << maxNumberOfBusStopsInRegion << endl << "minBuslineLength" << minBuslineLength << endl << "maxBuslineLength" << maxBuslineLength << endl << "numberOfIterations" << numberOfIterations << endl << "populationSizeMultiplier" << populationMultiplier << endl; Parameters::setAlpha(alpha); Parameters::setMinNumberOfBusStopsInRegion(minNumberOfBusStopsInRegion); Parameters::setMaxNumberOfBusStopsInRegion(maxNumberOfBusStopsInRegion); Parameters::setMinNumberOfBusStopsInBusline(minBuslineLength); Parameters::setMaxNumberOfBusStopsInBusLine(maxBuslineLength); Parameters::setPopulationSizeMultiplier(populationMultiplier); Parameters::setPercentageOfCrossedSolutions(percentageOfCrossedSolution); Parameters::setMutationOperators(mutations.toStdVector()); // TODO : set the lambda parameter algorithm->setNumberOfIterations(numberOfIterations); if ( ! dataLoaded ) { loadBusStops(); } if ( ! dataLoaded ) return; Solution optimalSolution; Solution tempSolution; QVector<double> vectorOfValuesFromDifferentBaseSolutions; try { model->loadBusStopsFromFile(dataFileName.toStdString()); qDebug() << "Before optimization"; optimalSolution = algorithm->performOptimization(); vectorOfValuesFromDifferentBaseSolutions.push_back(model->objectiveFunction(optimalSolution)); for(int i = 1; i < iterationsForDifferentBaseSolutions; i++) { tempSolution = algorithm->performOptimization(); if(model->objectiveFunction(tempSolution) > model->objectiveFunction(optimalSolution)) optimalSolution = tempSolution; vectorOfValuesFromDifferentBaseSolutions.push_back(model->objectiveFunction(tempSolution)); } } catch ( InvalidBoundsException * exc ) { QMessageBox::warning(NULL, "Error", "Ograniczenia są nieprawidłowe. Przerwano optymalizację", QMessageBox::Ok); qDebug() << QString::fromStdString(exc->getMessage()); qDebug() << "Skipping optimization due to invalid bounds" << endl; return; } saveResultsAndInvokeGnuplotIfRequested(QVector<double>::fromStdVector(algorithm->getValuesOfObjectiveFunction()), QVector<int>::fromStdVector(optimalSolution.toStdVector())); drawSolution(optimalSolution); ui->objectiveValueLabel->setText(QString::number(model->objectiveFunction(optimalSolution))); saveResultsFromDifferentBaseSolutions(vectorOfValuesFromDifferentBaseSolutions); qDebug() << "Przeprowadzenie optymalizacji zajęło " << timer.elapsed() << " ms." << endl; QApplication::beep(); QThread::sleep(1); QApplication::beep(); QThread::sleep(1); QApplication::beep(); QThread::sleep(1); QApplication::beep(); }
void QmlFeatureBattery::handleEventRecv(const QVector<uint8_t> data) { if (notification::is_hidpp20_notification(data.toStdVector(), (Hidpp20Device*)_device->backendDevice(), 0x00, feature::FEATURE_BATTERY)) { feature::BatteryLevel level = notification::get_battery_notification(data.toStdVector()); updateBatteryLevel(level); } }
void core::DotMatrix::setInputs(const QVector<double> &inputs) { setInputs(inputs.toStdVector()); }
void core::DotMatrix::setInputs(const QVector<double> &inputs, int rows, int cols) { setInputs(inputs.toStdVector(), rows, cols); }
void core::DotMatrix::setInputs(const QVector<int> &inputs, int rows, int cols) { vector<int> intInputs = inputs.toStdVector(); setInputs(vector<double>(intInputs.begin(), intInputs.end()), rows, cols); }
qreal MonoChannelFrame::compressChannel(const QVector<qreal>& aValues) { Mean mean(aValues.size()); std::vector<qreal> values = aValues.toStdVector(); return accumulate(values.begin(), values.end(), 0.0, mean); }