Image Component Library (ICL)
PolynomialRegression.h
Go to the documentation of this file.
1 /********************************************************************
2 ** Image Component Library (ICL) **
3 ** **
4 ** Copyright (C) 2006-2013 CITEC, University of Bielefeld **
5 ** Neuroinformatics Group **
6 ** Website: www.iclcv.org and **
7 ** http://opensource.cit-ec.de/projects/icl **
8 ** **
9 ** File : ICLMath/src/ICLMath/PolynomialRegression.h **
10 ** Module : ICLMath **
11 ** Authors: Christof Elbrechter **
12 ** **
13 ** **
14 ** GNU LESSER GENERAL PUBLIC LICENSE **
15 ** This file may be used under the terms of the GNU Lesser General **
16 ** Public License version 3.0 as published by the **
17 ** **
18 ** Free Software Foundation and appearing in the file LICENSE.LGPL **
19 ** included in the packaging of this file. Please review the **
20 ** following information to ensure the license requirements will **
21 ** be met: http://www.gnu.org/licenses/lgpl-3.0.txt **
22 ** **
23 ** The development of this software was supported by the **
24 ** Excellence Cluster EXC 277 Cognitive Interaction Technology. **
25 ** The Excellence Cluster EXC 277 is a grant of the Deutsche **
26 ** Forschungsgemeinschaft (DFG) in the context of the German **
27 ** Excellence Initiative. **
28 ** **
29 ********************************************************************/
30 
31 #pragma once
32 
33 #include <ICLUtils/CompatMacros.h>
34 #include <ICLMath/DynMatrix.h>
35 #include <vector>
36 #include <string>
37 
38 namespace icl{
39 
40  namespace math{
41 
44  template<class T>
46  struct PolynomialRegressionAttrib{
47  virtual ~PolynomialRegressionAttrib(){}
48  virtual T compute(const T *row) const = 0;
49  virtual std::string toString() const = 0;
50  virtual PolynomialRegressionAttrib<T> *copy() const = 0;
51  };
55 
84  template<class T>
86 
87  public:
88 
91 
93  typedef PolynomialRegressionAttrib<T> Attrib;
94 
95 
99  friend class PolynomialRegression;
100 
102  std::vector<const Attrib*> m_attribs;
103 
105  std::string m_function;
106 
108  mutable Matrix m_params;
109 
111  mutable Matrix m_xbuf, m_resultBuf;
112 
114  mutable int m_attribMaxIndex;
115 
117  void setup(const std::string &function);
118 
119  public:
120 
122  inline Result(){}
123 
125  Result(const std::string &xmlfilename);
126 
128  Result(const Result &r);
129 
131  Result &operator=(const Result &r);
132 
134  const Matrix &getParams() const { return m_params; }
135 
137 
147  const Matrix &operator()(const Matrix &xs) const;
148 
150  std::vector<const Attrib*> getAttribs() const { return m_attribs; }
151 
153  std::string toString(const std::vector<std::string> &rowLabels=std::vector<std::string> ()) const;
154 
156  void save(const std::string &xmlFileName) const;
157  };
158 
159  protected:
160 
162  mutable Matrix m_buf;
163 
166 
167 
168  public:
169 
171  PolynomialRegression(const std::string &function);
172 
173 
175 
186  const Result &apply(const Matrix &xs, const Matrix &ys, bool useSVD=false);
187 
189  std::string getFunctionString() const;
190  };
191 
192  }
193 }
int m_attribMaxIndex
maximum x-row index used in the attribute list
Definition: PolynomialRegression.h:114
ICLQt_API void save(const core::ImgBase &image, const std::string &filename)
write an image to HD
result type
Definition: PolynomialRegression.h:97
undocument this line if you encounter any issues!
Definition: Any.h:37
std::string m_function
function definition given
Definition: PolynomialRegression.h:105
#define ICLMath_API
Definition: CompatMacros.h:173
DynMatrix< T > Matrix
internally used matrxi type
Definition: PolynomialRegression.h:90
Result m_result
internal result buffer (always returned as const-reference)
Definition: PolynomialRegression.h:165
Result()
empty default constructor
Definition: PolynomialRegression.h:122
Highly flexible and optimized matrix class implementation.
Definition: DynMatrix.h:81
PolynomialRegressionAttrib< T > Attrib
internally used type
Definition: PolynomialRegression.h:93
const Matrix & getParams() const
set of parameters (on row for each output dimension)
Definition: PolynomialRegression.h:134
Generic Implementation of the Polynomial Regression algorithm.
Definition: PolynomialRegression.h:85
Matrix m_buf
internal buffer
Definition: PolynomialRegression.h:162
std::vector< const Attrib * > m_attribs
list of attribute functions
Definition: PolynomialRegression.h:102
#define ICLMath_IMP
Definition: CompatMacros.h:172
Matrix m_xbuf
internal buffers
Definition: PolynomialRegression.h:111
Matrix m_params
set of estimated parameters
Definition: PolynomialRegression.h:108
void copy(const T *src, const T *srcEnd, T *dst)
moves data from source to destination array (no casting possible)
Definition: CoreFunctions.h:216
std::vector< const Attrib * > getAttribs() const
returns the dummy attrib instances
Definition: PolynomialRegression.h:150