36 #ifndef OPENMS_CHEMISTRY_MASSDECOMPOSITION_IMS_INTEGERMASSDECOMPOSER_H 37 #define OPENMS_CHEMISTRY_MASSDECOMPOSITION_IMS_INTEGERMASSDECOMPOSER_H 69 template <
typename ValueType =
long unsigned int,
70 typename DecompositionValueType =
unsigned int>
88 typedef typename decomposition_type::size_type
size_type;
103 virtual bool exist(value_type mass);
188 residues_table_row_type & _mass_in_lcms,
const value_type _infty,
189 witness_vector_type & _witness_vector, residues_table_type & _ertable);
200 decomposition_type decomposition, decompositions_type & decompositionsStore);
204 template <
typename ValueType,
typename DecompositionValueType>
219 template <
typename ValueType,
typename DecompositionValueType>
225 if (_alphabet.
size() < 2)
233 _ertable.reserve(_alphabet.
size());
234 _ertable.assign(_alphabet.
size(), std::vector<value_type>(smallestMass, _infty));
242 _witnessVector.resize(smallestMass);
245 size_type it_inc = secondMass % smallestMass, witness = 1;
253 _ertable[1][it_i] = mass;
256 _witnessVector[it_i] = std::make_pair(witness, counter);
259 if (it_i >= _ertable[1].size())
261 it_i -= _ertable[1].size();
266 _lcms[1] = secondMass * smallestMass / tmp_d;
267 _mass_in_lcms[1] = smallestMass / tmp_d;
279 _lcms[i] = currentMass * smallestMass / d;
280 _mass_in_lcms[i] = smallestMass / d;
283 if (currentMass >= _ertable[i - 1][currentMass % smallestMass])
285 _ertable[i] = _ertable[i - 1];
298 size_type p_inc = currentMass % smallestMass;
307 for (
size_type m = smallestMass; m > 0; --m)
312 if (p >= smallestMass)
316 if (n > prev_column[p])
323 _witnessVector[p] = std::make_pair(i, local_counter);
335 size_type cur = currentMass % smallestMass;
339 std::vector<decomposition_value_type> counters(smallestMass);
344 cur_column[j] = prev_column[j];
348 for (
size_type m = smallestMass / d; m > 1; m--)
355 if (cur_column[prev] + currentMass > prev_column[cur])
357 cur_column[cur] = prev_column[cur];
362 cur_column[cur] = cur_column[prev] + currentMass;
363 _witnessVector[cur] = std::make_pair(i, counters[cur]);
374 if (cur >= smallestMass)
390 if (cur_column[prev] + currentMass < cur_column[cur])
392 cur_column[cur] = cur_column[prev] + currentMass;
394 _witnessVector[cur] = std::make_pair(i, counters[cur]);
407 if (cur >= smallestMass)
417 template <
typename ValueType,
typename DecompositionValueType>
423 return residue !=
infty_ && mass >= residue;
426 template <
typename ValueType,
typename DecompositionValueType>
432 if (!this->
exist(mass))
434 return decomposition;
451 decomposition.at(i) += j;
459 return decomposition;
462 template <
typename ValueType,
typename DecompositionValueType>
469 return decompositionsStore;
472 template <
typename ValueType,
typename DecompositionValueType>
477 if (alphabetMassIndex == 0)
483 decompositionsStore.push_back(decomposition);
520 decomposition[alphabetMassIndex] += mass_in_lcm;
530 if (mass_mod_alphabet0 < mass_mod_decrement)
536 mass_mod_alphabet0 -= mass_mod_decrement;
550 template <
typename ValueType,
typename DecompositionValueType>
560 #endif // OPENMS_CHEMISTRY_MASSDECOMPOSITION_IMS_INTEGERMASSDECOMPOSER_H
IntegerMassDecomposer(const Weights &alphabet)
Definition: IntegerMassDecomposer.h:205
std::vector< residues_table_row_type > residues_table_type
Definition: IntegerMassDecomposer.h:146
value_type infty_
Definition: IntegerMassDecomposer.h:176
ValueType value_type
Definition: MassDecomposer.h:74
Represents a set of weights (double values and scaled with a certain precision their integer counterp...
Definition: Weights.h:68
std::vector< decomposition_value_type > decomposition_type
Definition: MassDecomposer.h:84
residues_table_row_type lcms_
Definition: IntegerMassDecomposer.h:164
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
std::vector< std::pair< size_type, decomposition_value_type > > witness_vector_type
Definition: IntegerMassDecomposer.h:136
Implements MassDecomposer interface using algorithm and data structures described in paper "Efficient...
Definition: IntegerMassDecomposer.h:71
virtual decomposition_value_type getNumberOfDecompositions(value_type mass)
Definition: IntegerMassDecomposer.h:552
decomposition_type::size_type size_type
Type of decomposition's size.
Definition: IntegerMassDecomposer.h:88
std::vector< decomposition_type > decompositions_type
Definition: MassDecomposer.h:89
void fillExtendedResidueTable_(const Weights &_alphabet, residues_table_row_type &_lcms, residues_table_row_type &_mass_in_lcms, const value_type _infty, witness_vector_type &_witness_vector, residues_table_type &_ertable)
Definition: IntegerMassDecomposer.h:220
MassDecomposer< ValueType, DecompositionValueType >::decomposition_value_type decomposition_value_type
Type of decomposition value.
Definition: IntegerMassDecomposer.h:79
weight_type getWeight(size_type i) const
Definition: Weights.h:136
T gcd(T a, T b)
Returns the greatest common divisor (gcd) of two numbers by applying the Euclidean algorithm...
Definition: MathFunctions.h:169
std::vector< value_type > residues_table_row_type
Definition: IntegerMassDecomposer.h:141
void collectDecompositionsRecursively_(value_type mass, size_type alphabetMassIndex, decomposition_type decomposition, decompositions_type &decompositionsStore)
Definition: IntegerMassDecomposer.h:474
virtual bool exist(value_type mass)
Definition: IntegerMassDecomposer.h:419
An interface to handle decomposing of integer values/masses over a set of integer weights (alphabet)...
Definition: MassDecomposer.h:68
residues_table_type ertable_
Definition: IntegerMassDecomposer.h:158
virtual decompositions_type getAllDecompositions(value_type mass)
Definition: IntegerMassDecomposer.h:464
residues_table_row_type mass_in_lcms_
Definition: IntegerMassDecomposer.h:171
virtual decomposition_type getDecomposition(value_type mass)
Definition: IntegerMassDecomposer.h:428
size_type size() const
Definition: Weights.h:125
DecompositionValueType decomposition_value_type
Definition: MassDecomposer.h:79
Weights alphabet_
Definition: IntegerMassDecomposer.h:151
MassDecomposer< ValueType, DecompositionValueType >::decomposition_type decomposition_type
Type of decomposition.
Definition: IntegerMassDecomposer.h:82
MassDecomposer< ValueType, DecompositionValueType >::decompositions_type decompositions_type
Type of container for many decompositions.
Definition: IntegerMassDecomposer.h:85
witness_vector_type witness_vector_
Definition: IntegerMassDecomposer.h:182
MassDecomposer< ValueType, DecompositionValueType >::value_type value_type
Type of value to be decomposed.
Definition: IntegerMassDecomposer.h:76