OpenMS
Weights.h
Go to the documentation of this file.
1 // Copyright (c) 2002-2023, The OpenMS Team -- EKU Tuebingen, ETH Zurich, and FU Berlin
2 // SPDX-License-Identifier: BSD-3-Clause
3 //
4 // --------------------------------------------------------------------------
5 // $Maintainer: Timo Sachsenberg $
6 // $Authors: Anton Pervukhin <Anton.Pervukhin@CeBiTec.Uni-Bielefeld.DE> $
7 // --------------------------------------------------------------------------
8 //
9 
10 #pragma once
11 
12 #include <vector>
13 #include <iosfwd>
14 
15 #include <OpenMS/config.h>
16 
17 namespace OpenMS
18 {
19  namespace ims
20  {
41  class OPENMS_DLLAPI Weights
42  {
43 public:
45  typedef long unsigned int weight_type;
46 
48  typedef double alphabet_mass_type;
49 
51  typedef std::vector<weight_type> weights_type;
52 
54  typedef std::vector<alphabet_mass_type> alphabet_masses_type;
55 
57  typedef weights_type::size_type size_type;
58 
60  Weights() {}
61 
68  Weights(const alphabet_masses_type & masses, alphabet_mass_type precision) :
69  alphabet_masses_(masses),
70  precision_(precision)
71  {
72  setPrecision(precision);
73  }
74 
80  Weights(const Weights & other) :
81  alphabet_masses_(other.alphabet_masses_),
82  precision_(other.precision_),
83  weights_(other.weights_) {}
84 
91  Weights & operator=(const Weights & other);
92 
98  size_type size() const
99  {
100  return weights_.size();
101  }
102 
110  {
111  return weights_[i];
112  }
113 
120 
127  {
128  return precision_;
129  }
130 
140  {
141  return weights_[i];
142  }
143 
150  {
151  return weights_.back();
152  }
153 
161  {
162  return alphabet_masses_[i];
163  }
164 
168  alphabet_mass_type getParentMass(const std::vector<unsigned int> & decomposition) const;
169 
176  void swap(size_type index1, size_type index2);
177 
190  bool divideByGCD();
191 
193 
195 private:
200 
205 
210  };
211 
218  OPENMS_DLLAPI std::ostream & operator<<(std::ostream & os, const Weights & weights);
219 
220  } // namespace ims
221 } // namespace OpenMS
222 
Represents a set of weights (double values and scaled with a certain precision their integer counterp...
Definition: Weights.h:42
void swap(size_type index1, size_type index2)
alphabet_mass_type getMinRoundingError() const
weights_type weights_
Definition: Weights.h:209
alphabet_masses_type alphabet_masses_
Definition: Weights.h:199
alphabet_mass_type precision_
Definition: Weights.h:204
void setPrecision(alphabet_mass_type precision)
alphabet_mass_type getMaxRoundingError() const
Weights(const Weights &other)
Definition: Weights.h:80
size_type size() const
Definition: Weights.h:98
Weights(const alphabet_masses_type &masses, alphabet_mass_type precision)
Definition: Weights.h:68
weight_type back() const
Definition: Weights.h:149
alphabet_mass_type getParentMass(const std::vector< unsigned int > &decomposition) const
weight_type operator[](size_type i) const
Definition: Weights.h:139
double alphabet_mass_type
Type of double values to be used.
Definition: Weights.h:48
weight_type getWeight(size_type i) const
Definition: Weights.h:109
Weights & operator=(const Weights &other)
std::vector< alphabet_mass_type > alphabet_masses_type
Type of container to store double values.
Definition: Weights.h:54
long unsigned int weight_type
Type of integer values to be used.
Definition: Weights.h:45
std::vector< weight_type > weights_type
Type of container to store integer values.
Definition: Weights.h:51
Weights()
Empty constructor.
Definition: Weights.h:60
weights_type::size_type size_type
Type of container's size.
Definition: Weights.h:57
alphabet_mass_type getPrecision() const
Definition: Weights.h:126
alphabet_mass_type getAlphabetMass(size_type i) const
Definition: Weights.h:160
std::ostream & operator<<(std::ostream &os, const IMSAlphabet &alphabet)
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:22