Templates -- Meow  204.13.18
A C++ template contains kinds of interesting classes and functions
Transformation.h
Go to the documentation of this file.
1 #ifndef math_Transformation_H__
2 #define math_Transformation_H__
3 
4 #include "Matrix.h"
5 #include "../Self.h"
6 
7 #include <list>
8 #include <cstdlib>
9 
10 namespace meow {
11 
20 template<class Scalar>
22 private:
23  struct Myself {
24  size_t inputRows_;
25  size_t inputCols_;
26  size_t outputRows_;
27  size_t outputCols_;
28  size_t psize_;
29 
30  Myself(Myself const& b):
31  inputRows_(b.inputRows_), inputCols_(b.inputCols_),
32  outputRows_(b.outputRows_), outputCols_(b.outputCols_),
33  psize_(b.psize_) {
34  }
35 
36  Myself(size_t ir, size_t ic, size_t or_, size_t oc, size_t ps):
37  inputRows_(ir), inputCols_(ic), outputRows_(or_), outputCols_(oc),
38  psize_(ps) {
39  }
40 
41  ~Myself() {
42  }
43  };
44 
45  Self<Myself> const self;
46 protected:
56  size_t outputRows, size_t outputCols,
57  size_t psize):
58  self(Myself(inputRows, inputCols, outputRows, outputCols, psize)) {
59  }
60 
66  self(b.self, Self<Myself>::COPY_FROM) {
67  }
68 
76  self().copyFrom(b.self);
77  return *this;
78  }
79 
87  self().referenceFrom(b.self);
88  return *this;
89  }
90 public:
94  virtual ~Transformation() {
95  }
96 
102  size_t inputRows() const {
103  return self->inputRows_;
104  }
105 
111  size_t inputCols() const {
112  return self->inputCols_;
113  }
114 
120  size_t outputRows() const {
121  return self->outputRows_;
122  }
123 
129  size_t outputCols() const {
130  return self->outputCols_;
131  }
132 
138  size_t parameterSize() const {
139  return self->psize_;
140  }
141 
148  virtual Scalar parameter(size_t i) const = 0;
149 
157  virtual Scalar parameter(size_t i, Scalar const& s) = 0;
158 
165  virtual Matrix<Scalar> transformate(Matrix<Scalar> const& x) const = 0;
166 
177  virtual Matrix<Scalar> jacobian(Matrix<Scalar> const& x) const {
178  return Matrix<Scalar>();
179  }
180 
192  virtual Matrix<Scalar> jacobian(Matrix<Scalar> const& x, size_t i) const {
193  return Matrix<Scalar>();
194  }
195 
201  virtual bool inversable() const { return false; }
202 
210  return Matrix<Scalar>();
211  }
212 
219  virtual Matrix<Scalar> jacobianInv(Matrix<Scalar> const& x) const {
220  return Matrix<Scalar>();
221  }
222 
230  virtual Matrix<Scalar> jacobianInv(Matrix<Scalar> const& x, size_t i) const {
231  return Matrix<Scalar>();
232  }
233 };
234 
235 } // meow
236 
237 #endif // math_Transformation_H__
virtual Matrix< Scalar > jacobian(Matrix< Scalar > const &x) const
Calculate the jacobian matrix (derivate by the input matrix) of the transformation.
virtual Matrix< Scalar > jacobian(Matrix< Scalar > const &x, size_t i) const
Calculate the jacobian matrix (derivate by the i -th parameter) of the transformation.
size_t parameterSize() const
Return the number of parameters.
size_t outputRows() const
Return the number of rows of the output matrix.
Transformation(size_t inputRows, size_t inputCols, size_t outputRows, size_t outputCols, size_t psize)
virtual Matrix< Scalar > transformateInv(Matrix< Scalar > const &x) const
Do the inverse transformation.
virtual Matrix< Scalar > transformate(Matrix< Scalar > const &x) const =0
Do transformate.
virtual Scalar parameter(size_t i) const =0
Get the i -th parameter.
size_t inputRows() const
Return the number of rows of the input matrix.
virtual Matrix< Scalar > jacobianInv(Matrix< Scalar > const &x) const
Return the jacobian matrix of the inverse transformation.
Transformation & copyFrom(Transformation const &b)
Copy from the specified one.
Transformation(Transformation const &b)
size_t inputCols() const
Return the number of columns of the input matrix.
virtual Matrix< Scalar > jacobianInv(Matrix< Scalar > const &x, size_t i) const
Return the jacobian matrix of the inverse transformation.
Transformation & referenceFrom(Transformation const &b)
reference from the specified one
A base class for implementing kinds of transformations.
size_t outputCols() const
Return the number of columns of the output matrix.
virtual bool inversable() const
Return whether this transformation is inversable or not.