void Graph::printGraph() const { Converter c; for (auto &v : vertexes) { cout << "\t" << c.convert(v.getValue()) << ":\n"; for (auto &succ : v.getSuccessors()) { cout << "\t\t" << c.convert(succ.first->getValue()) << ": " << succ.second << "\n"; } } }
void conversionTest() { string randomSequence, processedSequence; for (int i = 0; i < 100; ++i) { randomSequence = generateRandomSequence(Options::getInstance().getBasePairsPerOligonucleotide()); processedSequence = c.convert(c.convert(randomSequence)); CPPUNIT_ASSERT_MESSAGE("Converter changed sequence during conversion!", randomSequence == processedSequence); } }
casa::Vector<double> ConverterChannel::convert( const casa::Vector<double>& oldValues, casa::SpectralCoordinate spectralCoordinate ) { std::vector<double> resultValues( oldValues.size()); for ( int i = 0; i < static_cast<int>(resultValues.size()); i++ ) { double result; bool correct = spectralCoordinate.toWorld( result, oldValues[i]); if ( correct ) { casa::Vector<casa::String> worldUnitsVector = spectralCoordinate.worldAxisUnits(); QString worldUnit(worldUnitsVector[0].c_str()); if ( worldUnit == newUnits ) { resultValues[i] = result; } else { qDebug() << "worldUnit="<<worldUnit<<" newUnit="<<newUnits; Converter* helper = Converter::getConverter( worldUnit, newUnits); if ( helper != nullptr ){ resultValues[i] = helper->convert( result, spectralCoordinate ); delete helper; } else { qDebug() << "Could not convert from "<<worldUnit<<" to "<<newUnits; } } } else { qDebug() << "Could not convert channel="<<oldValues[i]; } } return resultValues; }
int main(int argc, char *argv[]) { QString outputFileName; if (argc < 2) { printf("xbm-epd version " APPVERSION " (C) kimmoli 2014\n\n"); printf("xbm-epd inputfile {outputfile}\n"); return 0; } if (argc == 3) { outputFileName = QString(argv[2]); } else { outputFileName = QString("%1.xbm").arg(QString(argv[1]).split('.').at(0)); } printf("Writing output to %s\n", qPrintable(outputFileName)); Converter* converter = new(Converter); converter->convert(QString(argv[1]), outputFileName); delete converter; return 1; }
void profileIntegerConverter( Format format, const integer32 *source, void *destination, int count ) { printf( " truecolor -> %s", getFormatString(format) ); Converter * converter = requestConverter( Format::XRGB8888, format ); if ( !converter ) { printf( "\n failed: null converter\n" ); exit(1); } double startTime = timer.time(); double time = 0.0; int iterations = 0; while ( time < duration ) { converter->convert( source, destination, count ); time = timer.time() - startTime; iterations ++; } printf( " = %f ms\n", (double) time / iterations * 1000 ); }
void ClusterRepository::commit(std::vector<Pattern> pattern_list, double threshold){ Converter<Pattern> converter; std::for_each(pattern_list.begin(), pattern_list.end(), [&](Pattern pattern){ try{ std::vector<double> origin(pattern.size()); std::fill(origin.begin(), origin.end(), (double)1); double feature = Math::cosSimilarity(origin, converter.convert(pattern)); std::vector<Row> result; //しきい値以下のクラスタがあるか result = this->sqlite.execute(this->getSelectClusterQuery(feature,threshold)); if(result.empty()){ //なかったら新しく追加する this->sqlite.execute(this->getAddClusterQuery(feature)); }else{ int id; std::istringstream converter; converter.str(result[0]["label"]); converter >> id; //重要度を上げて、同じラベルで追加する this->sqlite.execute(this->getRaisePriorityQuery(result)); this->sqlite.execute(this->getAddClusterQuery(feature,id)); } }catch(std::exception e){ } });
Row ClusterRepository::search(Pattern pattern, double threshold){ std::vector<double> origin(pattern.size()); Converter<Pattern> converter; std::fill(origin.begin(), origin.end(), (double)1); double feature = Math::cosSimilarity(origin, converter.convert(pattern)); //しきい値以下のクラスタ std::vector<Row> result = this->sqlite.execute(this->getSelectClusterQuery(feature, threshold)); if(result.empty()) throw std::exception("not found"); return result[0]; }
int main(int argc, char const *argv[]) { Converter converter; { using namespace std; // get input from screen string input; cout << "Please enter the number to convert to words :" << endl << "Input : "; cin >> input; string output=converter.convert(input); cout << " The result is : "<< output << endl; } return 0; }
int main() { Converter converter; converter.calculate(1000000000000000LL); int numCases; cin >> numCases; while (numCases--) { long long miles; cin >> miles; cout << converter.convert(miles) << endl; } return 0; }
void Command::execute() const { std::stringstream ss(m_command); std::string help; ss >> help; Converter* first = ConverterFactory::_instance()->create(help); if(!first) { std::cout<< help <<" is no Converter!\n"; return; } Converter* temp = first; ss >> help; Converter* temp2; while(!isdigit(help.at(0))) { temp2 = ConverterFactory::_instance()->create(help); if(!temp2) { std::cout<< help <<" is no Converter!\n"; return; } temp->link(temp2); temp = temp2; if(!(ss >> help)) { std::cout<<"You need a conversionvalue!!!!\n"; return; } } std::cout<<"Using converter: "<< first->toString() <<" converted: " <<std::stod(help)<< " to: "<< first->convert(std::stod(help)) <<std::endl; }
/** This method processes the application's startup arguments and performs the conversion by means of a DocumentReader and Converter object. @author Bjoern */ void Console::_performInitialOperations(QStringList arguments, QStringList options) { /* arguments: 0 = source file path 1 = source file type 2 = input definition file path 3 = target file path 4 = target file type 5 = output definition file path */ if (arguments.count() == 6) { TranslationMapper* translationmapper = new TranslationMapper; QString sourcefilepath(arguments.at(0)); QString filetypestring(arguments.at(1)); QString inputdefinitionfilepath(arguments.at(2)); translationmapper->createDocumentReaderData(inputdefinitionfilepath); QFile file(sourcefilepath); Node* root = 0; if (file.exists()) { DocumentData::FileType filetype = DocumentData::Unknown; if (filetypestring.toLower() == "javadoc") filetype = DocumentData::JavaDocHTML; DocumentReader* reader = new DocumentReader(translationmapper); root = reader->read(sourcefilepath, filetype); delete reader; std::cout << tr("Read source file(s) --> success").toStdString() << std::endl; } else { file.close(); std::cout << tr("I/O error - the source file doesn't exit: ").toStdString() << sourcefilepath.toStdString() << std::endl; return; } file.close(); QString targetfilepath(arguments.at(3)); filetypestring = QString(arguments.at(4)); QString outputdefinitionfilepath(arguments.at(5)); translationmapper->createOutputElementMap(outputdefinitionfilepath); file.setFileName(targetfilepath); if (file.open(QFile::WriteOnly)) { DocumentData::FileType filetype = DocumentData::Unknown; if (filetypestring.toLower() == "tex") filetype = DocumentData::Tex; else if (filetypestring.toLower() == "pdf") filetype = DocumentData::PDF; // root - converting... Converter* converter = new Converter(this, translationmapper); converter->convert(targetfilepath, root, filetype); std::cout << tr("Perform conversion --> success").toStdString() << std::endl; delete converter; } else std::cout << tr("I/O error - can't write to file: ").toStdString() << targetfilepath.toStdString() << std::endl; delete translationmapper; } else { std::cout << tr("Error - unexpected number of arguments.").toStdString() << std::endl; std::cerr << "usage: htmlatex INPUTFILE FORMAT INPUTDEFINITION OUTPUTFILE FORMAT OUTPUTDEFINITION [-g|--gui]\n" << " e.g. htmlatex index.html javadoc input_javadoc.xml manual.tex tex output_tex.xml -g\n" << "\t-g, --gui \tLaunch the GUI\n" << "\t-h, --help \tShow some examples\n\n" << "\tSee the \"README\" file for further information." << std::endl; } };
int main(int argc, char* argv[]) { #if 1 PathName src = argv[1]; PathName dst = src.ChangeExtension("fxc"); #else PathName src = "C:/Proj/Lumino/src/Scene/Resource/SSBasic2D.fx"; PathName dst = src.ChangeExtension("fxc"); #endif Effect effect; Loader loader; loader.Load(&effect, src); Generator gen; gen.Generate(&effect, dst); #if 0 std::string shaderSource; std::ofstream ofs("shader.txt"); ofs << "test"; if (argc < 2) { return 1; } DXDevice device; if (!device.initlaize()) { printf("failed initialize DirectX.\n"); device.finalize(); return 1; } //Converter converter; //converter.convert( "D:/Proj/LightNote/Source/Core/Resource/Shader/SSBasic3D.fx", &device ); /*if ( Hlsl2Glsl_Initialize() == 0 ) { printf( "failed Hlsl2Glsl_Initialize.\n" ); return 1; }*/ //converter.convert( "SSBasic2D.fx", &device ); //converter.convert( "SSBasic3D.fx", &device ); //converter.convert( "MirrorWater_low.fxm", &device ); //converter.convert( "full.fx", &device ); for (int i = 1; i < argc; ++i) { Converter converter; converter.convert(argv[i], &device); } //Hlsl2Glsl_Shutdown(); device.finalize(); #endif return 0; }