OpenMS
Loading...
Searching...
No Matches
Weights.h
Go to the documentation of this file.
1// Copyright (c) 2002-present, OpenMS Inc. -- 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
17namespace OpenMS
18{
19 namespace ims
20 {
43 class OPENMS_DLLAPI Weights
44 {
45public:
47 typedef long unsigned int weight_type;
48
50 typedef double alphabet_mass_type;
51
53 typedef std::vector<weight_type> weights_type;
54
56 typedef std::vector<alphabet_mass_type> alphabet_masses_type;
57
59 typedef weights_type::size_type size_type;
60
68
81 Weights(const alphabet_masses_type & masses, alphabet_mass_type precision) :
82 alphabet_masses_(masses),
83 precision_(precision)
84 {
85 setPrecision(precision);
86 }
87
93 Weights(const Weights & other) :
94 alphabet_masses_(other.alphabet_masses_),
95 precision_(other.precision_),
96 weights_(other.weights_) {}
97
104 Weights & operator=(const Weights & other);
105
112 {
113 return weights_.size();
114 }
115
123 {
124 return weights_[i];
125 }
126
135
142 {
143 return precision_;
144 }
145
155 {
156 return weights_[i];
157 }
158
165 {
166 return weights_.back();
167 }
168
176 {
177 return alphabet_masses_[i];
178 }
179
191 alphabet_mass_type getParentMass(const std::vector<unsigned int> & decomposition) const;
192
203 void swap(size_type index1, size_type index2);
204
219
228
237private:
242
247
252 };
253
261 OPENMS_DLLAPI std::ostream & operator<<(std::ostream & os, const Weights & weights);
262
263 } // namespace ims
264} // namespace OpenMS
265
Pairs an alphabet of double-valued masses with the scaled integer weights derived from them.
Definition Weights.h:44
void swap(size_type index1, size_type index2)
Exchange the alphabet mass and the integer weight at index1 with those at index2.
alphabet_mass_type getMinRoundingError() const
Largest negative relative rounding error introduced by the current precision.
weights_type weights_
Definition Weights.h:251
alphabet_masses_type alphabet_masses_
Definition Weights.h:241
alphabet_mass_type precision_
Definition Weights.h:246
void setPrecision(alphabet_mass_type precision)
Replace the precision and recompute the integer weights from the stored alphabet masses.
alphabet_mass_type getMaxRoundingError() const
Largest positive relative rounding error introduced by the current precision.
Weights(const Weights &other)
Definition Weights.h:93
size_type size() const
Definition Weights.h:111
Weights(const alphabet_masses_type &masses, alphabet_mass_type precision)
Construct from a set of masses and a precision.
Definition Weights.h:81
weight_type back() const
Definition Weights.h:164
alphabet_mass_type getParentMass(const std::vector< unsigned int > &decomposition) const
Reconstruct a parent mass from a decomposition expressed as multiplicities of the alphabet.
weight_type operator[](size_type i) const
Definition Weights.h:154
Weights & operator=(const Weights &other)
double alphabet_mass_type
Type of double values to be used.
Definition Weights.h:50
bool divideByGCD()
Divide every integer weight by the greatest common divisor of all weights and scale the precision acc...
weight_type getWeight(size_type i) const
Definition Weights.h:122
std::vector< alphabet_mass_type > alphabet_masses_type
Type of container to store double values.
Definition Weights.h:56
long unsigned int weight_type
Type of integer values to be used.
Definition Weights.h:47
std::vector< weight_type > weights_type
Type of container to store integer values.
Definition Weights.h:53
Weights()
Default constructor.
Definition Weights.h:67
weights_type::size_type size_type
Type of container's size.
Definition Weights.h:59
alphabet_mass_type getPrecision() const
Definition Weights.h:141
alphabet_mass_type getAlphabetMass(size_type i) const
Definition Weights.h:175
std::ostream & operator<<(std::ostream &os, const IMSAlphabet &alphabet)
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19