本文整理汇总了C++中Alphabet::getMasses方法的典型用法代码示例。如果您正苦于以下问题:C++ Alphabet::getMasses方法的具体用法?C++ Alphabet::getMasses怎么用?C++ Alphabet::getMasses使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Alphabet
的用法示例。
在下文中一共展示了Alphabet::getMasses方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char **argv) {
Options options;
try {
options.parse(argc, argv);
} catch (TCLAP::ArgException &e) {
throw ims::Exception("Error while parsing command line: " + e.error() + " for argument " + e.argId());
}
Alphabet alphabet;
try {
alphabet.load(options.getAlphabetFileName());
} catch (IOException& ioe) {
cerr << "can not read alphabet: " << ioe.what() << endl;
return 1;
}
Weights weights(alphabet.getMasses(), 1 /*precision*/);
// optimize alphabet by dividing by gcd
weights.divideByGCD();
// get masses from -m options and/or from a file
vector<double> masses = options.getMasses();
if (options.hasMassFile()) {
MassesTextParser parser;
try {
parser.load(options.getMassFile());
} catch (IOException& ioe) {
cerr << "can not read masses file: " << ioe.what() << endl;
return 1;
}
vector<double> filemasses = parser.getElements();
// append to masses
copy(filemasses.begin(), filemasses.end(), back_inserter(masses));
}
if (masses.empty()) {
cerr << "No input masses given to decompose (use -m or -f option)!\n";
return 1;
}
// maximal number of decompositions to show
unsigned int maxNumber = options.getMaxNumberDecompositions();
printHeader(alphabet, weights, options.getMode());
if (options.getMode() == Options::GETNUMBER) {
ClassicalDPMassDecomposer<> decomposer(weights);
// loop through masses
for (vector<double>::const_iterator it = masses.begin(); it != masses.end(); ++it) {
value_type mass = static_cast<value_type>(*it);
decomposition_value_t number = decomposer.getNumberOfDecompositions(mass);
cout << "# mass " << mass << " has " << number << " decompositions" << endl;
}
} else { // if any other tasks defined
// use decomposer with residues
IntegerMassDecomposer<> decomposer(weights);
if (options.getMode() == Options::FINDALL) {
// loop through masses
for (vector<double>::const_iterator it = masses.begin(); it != masses.end(); ++it) {
value_type mass = static_cast<value_type>(*it);
outputDecompositions(decomposer.getAllDecompositions(mass), alphabet, mass, maxNumber);
cout << '\n';
}
}
else if (options.getMode() == Options::FINDONE) {
// loop through masses
for (vector<double>::const_iterator it = masses.begin(); it != masses.end(); ++it) {
value_type mass = static_cast<value_type>(*it);
decomposition_t decomposition = decomposer.getDecomposition(mass);
if (decomposition.size() == 0) {
cout << "# mass " << mass << " has 0 decompositions\n\n";
} else {
cout << "# mass " << mass << " has at least this decomposition:\n";
printDecomposition(alphabet, decomposition);
cout << "\n\n";
}
}
}
else if (options.getMode() == Options::ISDECOMPOSABLE) {
// loop through masses
for (vector<double>::const_iterator it = masses.begin(); it != masses.end(); ++it) {
value_type mass = static_cast<value_type>(*it);
if (decomposer.exist(mass)) {
cout << "# mass " << mass << " has at least one decomposition\n";
} else {
cout << "# mass " << mass << " has no decompositions\n";
}
}
}
}
cout << "# done\n";
return 0;
}