OpenMS
RANSACModel.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: George Rosenberger $
6 // $Authors: George Rosenberger, Hannes Roest, Chris Bielow $
7 // --------------------------------------------------------------------------
8 
9 #pragma once
10 
11 #include <OpenMS/config.h>
12 
13 #include <cstddef> // for size_t & ptrdiff_t
14 #include <vector>
15 #include <string>
16 
17 namespace OpenMS
18 {
19 
20  namespace Math
21  {
22 
31  template<class ModelT = int> // dummy default to allow easy access to public typedefs
33  {
34  public:
35  typedef std::pair<double, double> DPair;
36  typedef std::vector<DPair> DVec;
37  typedef DVec::const_iterator DVecIt;
38  typedef std::vector<double> ModelParameters;
39 
40 
42  ModelParameters rm_fit(const DVecIt& begin, const DVecIt& end) const
43  {
44  return static_cast<const ModelT*>(this)->rm_fit_impl(begin, end);
45  }
46 
56  double rm_rsq(const DVecIt& begin, const DVecIt& end) const
57  {
58  return static_cast<const ModelT*>(this)->rm_rsq_impl(begin, end);
59  }
60 
62  double rm_rss(const DVecIt& begin, const DVecIt& end, const ModelParameters& coefficients) const
63  {
64  return static_cast<const ModelT*>(this)->rm_rss_impl(begin, end, coefficients);
65  }
66 
69  DVec rm_inliers(const DVecIt& begin, const DVecIt& end, const ModelParameters& coefficients, double max_threshold) const
70  {
71  return static_cast<const ModelT*>(this)->rm_inliers_impl(begin, end, coefficients, max_threshold);
72  }
73  };
74 
75  }
76 
77 
78 }
Generic plug-in template base class using 'Curiously recurring template pattern' (CRTP) to allow for ...
Definition: RANSACModel.h:33
ModelParameters rm_fit(const DVecIt &begin, const DVecIt &end) const
fit a model and return its parameters
Definition: RANSACModel.h:42
double rm_rss(const DVecIt &begin, const DVecIt &end, const ModelParameters &coefficients) const
calculates the residual sum of squares of the input points according to the model
Definition: RANSACModel.h:62
DVec::const_iterator DVecIt
Definition: RANSACModel.h:37
std::vector< double > ModelParameters
Definition: RANSACModel.h:38
DVec rm_inliers(const DVecIt &begin, const DVecIt &end, const ModelParameters &coefficients, double max_threshold) const
Definition: RANSACModel.h:69
std::pair< double, double > DPair
Definition: RANSACModel.h:35
std::vector< DPair > DVec
Definition: RANSACModel.h:36
double rm_rsq(const DVecIt &begin, const DVecIt &end) const
Returns the R-squared of the data applied to the model (computed on-the-fly).
Definition: RANSACModel.h:56
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:22