aboutsummaryrefslogtreecommitdiffstats
path: root/meowpp/math
diff options
context:
space:
mode:
Diffstat (limited to 'meowpp/math')
-rw-r--r--meowpp/math/!readme.asciidoc2
-rw-r--r--meowpp/math/LinearTransformation.h12
-rw-r--r--meowpp/math/LinearTransformations.h42
-rw-r--r--meowpp/math/Matrix.h9
-rw-r--r--meowpp/math/Transformation.h4
-rw-r--r--meowpp/math/Transformations.h66
-rw-r--r--meowpp/math/Vector.h20
-rw-r--r--meowpp/math/methods.h4
8 files changed, 82 insertions, 77 deletions
diff --git a/meowpp/math/!readme.asciidoc b/meowpp/math/!readme.asciidoc
index 5ae6b89..062b45d 100644
--- a/meowpp/math/!readme.asciidoc
+++ b/meowpp/math/!readme.asciidoc
@@ -33,7 +33,7 @@
===== Transformation.h
-各種轉換的 Base Class, 這裡所謂的 *Transformation* 形式上不一定要是 Linear,
+各種轉換的 Base Class, 這裡所謂的 *Transformation* 形式上不一定要是 Linear,
但原則上都是 *input a vector, output a vector* 其中input/output的dimension可以
不同.
diff --git a/meowpp/math/LinearTransformation.h b/meowpp/math/LinearTransformation.h
index f51630e..0dc3735 100644
--- a/meowpp/math/LinearTransformation.h
+++ b/meowpp/math/LinearTransformation.h
@@ -47,7 +47,7 @@ protected:
Transformation<Scalar>(b),
matrix_(b.matrix_) {
}
-
+
/*!
* @brief Copy settings, matrix from another LinearTransformation
*
@@ -58,7 +58,7 @@ protected:
matrix_.copyFrom(b.matrix_);
return *this;
}
-
+
/*!
* @brief Reference settings, matrix from another LinearTransformation
*
@@ -69,7 +69,7 @@ protected:
matrix_.referenceFrom(b.matrix_);
return *this;
}
-
+
/*!
* @brief setup the matrix
*/
@@ -77,14 +77,14 @@ protected:
matrix_.copyFrom(m);
return matrix();
}
-
+
public:
/*!
* Destructor
*/
virtual ~LinearTransformation() {
}
-
+
/*!
* @brief Return the matrix form of this transformation
*
@@ -93,7 +93,7 @@ public:
virtual Matrix<Scalar> const& matrix() const {
return matrix_;
}
-
+
/*!
* @brief Return the inverse of the matrix form of this transformate
*
diff --git a/meowpp/math/LinearTransformations.h b/meowpp/math/LinearTransformations.h
index e882a6c..4bf9a36 100644
--- a/meowpp/math/LinearTransformations.h
+++ b/meowpp/math/LinearTransformations.h
@@ -22,19 +22,19 @@ private:
struct Myself {
Vector3D<Scalar> theta_;
bool need_;
-
+
Myself(): theta_(0, 0, 0), need_(true) {
}
-
+
Myself(Myself const& b): theta_(b.theta_), need_(b.need_) {
}
-
+
~Myself() {
}
};
-
+
Self<Myself> const self;
-
+
void calcMatrix() const {
if (self->need_) {
Matrix<Scalar> tmp(3, 3, 0.0);
@@ -61,27 +61,27 @@ private:
self()->need_ = false;
}
}
-
+
public:
/*!
* Constructor with no rotation
*/
Rotation3D(): LinearTransformation<Scalar>(3u, 3u, 3u), self() {
}
-
+
/*!
* Constructor and copy data
*/
Rotation3D(Rotation3D const& b): LinearTransformation<Scalar>(b),
self(b.self, Self<Myself>::COPY_FROM) {
}
-
+
/*!
* Destructor
*/
~Rotation3D() {
}
-
+
/*!
* @brief Copy data
*
@@ -93,7 +93,7 @@ public:
self().copyFrom(b.self);
return *this;
}
-
+
/*!
* @brief Reference data
*
@@ -119,7 +119,7 @@ public:
Scalar parameter(size_t i, Scalar const& s) {
return theta(i, s);
}
-
+
/*!
* @brief Get the \c i -th theta
*
@@ -131,7 +131,7 @@ public:
Scalar const& theta(size_t i) const {
return self->theta_(i);
}
-
+
/*!
* @brief Set the \c i -th theta
*
@@ -163,7 +163,7 @@ public:
theta(i, n(i) * angle);
}
}
-
+
/*!
* @brief Concat another rotation transformation
* @param [in] r another rotation transformation
@@ -174,10 +174,10 @@ public:
}
return *this;
}
-
+
/*!
* @brief Do the transformate
-
+
* Assume:
* - The input vector is \f$ (x ,y ,z ) \f$
* - The output vector is \f$ (x',y',z') \f$
@@ -214,7 +214,7 @@ public:
calcMatrix();
return LinearTransformation<Scalar>::matrix() * x;
}
-
+
/*!
* @brief Return the jacobian matrix (derivate by the input vector)
* of this transformate
@@ -244,7 +244,7 @@ public:
calcMatrix();
return LinearTransformation<Scalar>::matrix();
}
-
+
/*!
* @brief Return the jacobian matrix of this transformate
*
@@ -344,7 +344,7 @@ public:
Matrix<Scalar> transformateInv(Matrix<Scalar> const& x) const {
return matrixInv() * x;
}
-
+
/*!
* @brief Return the jacobian matrix of the inverse form of this transformate
*
@@ -354,7 +354,7 @@ public:
Matrix<Scalar> jacobianInv(Matrix<Scalar> const& x) const {
return matrixInv();
}
-
+
/*!
* @brief Return the jacobian matrix of the inverse form of this transformate
*
@@ -392,13 +392,13 @@ public:
calcMatrix();
return LinearTransformation<Scalar>::matrix().transpose();
}
-
+
//! @brief same as \c copyFrom(b)
Rotation3D& operator=(Rotation3D const& b) {
return copyFrom(b);
}
};
-}
+} // meow
#endif // math_LinearTransformations_H__
diff --git a/meowpp/math/Matrix.h b/meowpp/math/Matrix.h
index 09832d8..94f23a3 100644
--- a/meowpp/math/Matrix.h
+++ b/meowpp/math/Matrix.h
@@ -28,12 +28,15 @@ private:
Myself():
rows_(0), cols_(0), entries_(0) {
}
+
Myself(Myself const& b):
rows_(b.rows_), cols_(b.cols_), entries_(b.entries_) {
}
+
Myself(size_t r, size_t c, Entry const& e):
rows_(r), cols_(c), entries_(r * c, e) {
}
+
~Myself() {
}
@@ -199,7 +202,7 @@ public:
self()->entries_[self->index(r, c)] = e;
return entry(r, c);
}
-
+
//! @brief Get the entry at \a r x \a c
EntryRef entryGet(size_t r, size_t c) {
return self()->entries_[self->index(r, c)];
@@ -351,7 +354,7 @@ public:
entry(r, c, (r == c ? Entry(1) : Entry(0)));
return *this;
}
-
+
/*!
* @brief Let itself be an diagonal form of original itself
*/
@@ -364,7 +367,7 @@ public:
}
return *this;
}
-
+
/*!
* @brief Return a matrix which is a diangonal form of me
*/
diff --git a/meowpp/math/Transformation.h b/meowpp/math/Transformation.h
index 011db8c..086cb03 100644
--- a/meowpp/math/Transformation.h
+++ b/meowpp/math/Transformation.h
@@ -27,17 +27,17 @@ private:
size_t outputCols_;
size_t psize_;
- Myself() {
- }
Myself(Myself const& b):
inputRows_(b.inputRows_), inputCols_(b.inputCols_),
outputRows_(b.outputRows_), outputCols_(b.outputCols_),
psize_(b.psize_) {
}
+
Myself(size_t ir, size_t ic, size_t or_, size_t oc, size_t ps):
inputRows_(ir), inputCols_(ic), outputRows_(or_), outputCols_(oc),
psize_(ps) {
}
+
~Myself() {
}
};
diff --git a/meowpp/math/Transformations.h b/meowpp/math/Transformations.h
index b9583f9..99d6483 100644
--- a/meowpp/math/Transformations.h
+++ b/meowpp/math/Transformations.h
@@ -55,12 +55,14 @@ private:
Myself(size_t d): dimension_(1), radius_(1) {
}
+
Myself(size_t d, Scalar const& r): dimension_(d), radius_(r) {
}
+
Myself(Myself const& m): dimension_(m.dimension_), radius_(m.radius_) {
}
};
-
+
Self<Myself> const self;
public:
/*!
@@ -70,7 +72,7 @@ public:
BallProjection(BallProjection const& b): Transformation<Scalar>(b),
self(b.self, Self<Myself>::COPY_FROM) {
}
-
+
/*!
* Constructor and setup, radius = 1
* @param [in] d Dimension of the input/output vector
@@ -79,7 +81,7 @@ public:
self(Myself(d)) {
radius(1);
}
-
+
/*!
* Constructor and setup
* @param [in] d Dimension of the input/output vector
@@ -89,7 +91,7 @@ public:
self(Myself(d, r)) {
radius(r);
}
-
+
/*!
* @brief Copy settings from another one
* @param [in] b Another one
@@ -100,7 +102,7 @@ public:
copyFrom(b);
return *this;
}
-
+
/*!
* @brief Reference settings from another one
* @param [in] b Another one
@@ -132,7 +134,7 @@ public:
Scalar radius() const {
return self->radius_;
}
-
+
/*!
* @brief Setup the radius
*
@@ -143,7 +145,7 @@ public:
self()->radius_ = r;
return radius();
}
-
+
/*!
* @brief Get the dimension of this projection
*/
@@ -151,7 +153,7 @@ public:
return self->dimension_;
}
-
+
/*!
* @brief Project the input vector(s) onto the hyper-sphere and return it.
*
@@ -159,7 +161,7 @@ public:
* method will think that you want to transform multiple vector once
* and the number of columns of the output matrix will be the same of
* the number of columns of the input one.
- *
+ *
* @param [in] x The input matrix.
* @return The output matrix.
* @note Take into account that too much safty checking will lead to
@@ -181,7 +183,7 @@ public:
}
return ret;
}
-
+
/*!
* @brief Return the jacobian matrix (derivate by the input vector)
* of this projection.
@@ -226,7 +228,7 @@ public:
}
return ret;
}
-
+
/*!
* @brief Return the jacobian matrix (derivate by radius) of this projection.
*
@@ -263,14 +265,14 @@ public:
}
return ret / Scalar(sqrt(double(sum)));
}
-
+
/*!
* @brief Same as \c copyFrom(b)
*/
BallProjection& operator=(BallProjection const& b) {
return copyFrom(b);
}
-
+
/*!
* @brief Same as \c transformate(v)
*/
@@ -325,30 +327,30 @@ private:
struct Myself {
Scalar focal_;
size_t dimension_;
-
+
Myself() {
}
-
+
Myself(size_t d, Scalar f): focal_(f), dimension_(d) {
}
-
+
Myself(Myself const& b): focal_(b.focal_), dimension_(b.dimension_) {
}
-
+
~Myself() {
}
};
-
+
Self<Myself> const self;
public:
/*!
* Constructor, focal = 1
*/
- PhotoProjection(size_t dimension):
+ PhotoProjection(size_t dimension):
Transformation<Scalar>(dimension, 1, dimension, 1, 1),
self(Myself(dimension, 1)) {
}
-
+
/*!
* Constructor
*/
@@ -356,14 +358,14 @@ public:
Transformation<Scalar>(dimension, 1, dimension, 1, 1),
self(Myself(dimension, f)) {
}
-
+
/*!
* Constructor, copy settings from another PhotoProjection.
*/
PhotoProjection(PhotoProjection const& p): Transformation<Scalar>(p),
self(p.self, Self<Myself>::COPY_FROM) {
}
-
+
/*!
* Copy settings from another one
* @param [in] b another one
@@ -374,7 +376,7 @@ public:
self().copyFrom(b.self);
return *this;
}
-
+
/*!
* Reference settings from another one
* @param [in] b another one
@@ -418,7 +420,7 @@ public:
self()->focal_ = f;
return focal();
}
-
+
/*!
* @brief Get the dimension of this projection
*/
@@ -429,13 +431,13 @@ public:
/*!
* @brief Project the input vector(s) onto the plane
*
- * The equation of the plane is \f$ x_N = -f \f$, where the \f$ N \f$
+ * The equation of the plane is \f$ x_N = -f \f$, where the \f$ N \f$
* is the dimension of this projection and f is the focal length. \n
* If the number of columns of the input matrix is larger than 1, this
* method will think that you want to transform multiple vector once
* and the number of columns of the output matrix will be the same of
* the number of columns of the input one.
- *
+ *
* @param [in] x The input matrix.
* @return The output matrix.
* @note Take into account that too much safty checking will lead to
@@ -452,9 +454,9 @@ public:
}
return ret;
}
-
+
/*!
- * @brief Return the jacobian matrix (derivate by the input vector)
+ * @brief Return the jacobian matrix (derivate by the input vector)
* of this projection.
*
* This method only allow a vector-like matrix be input.
@@ -490,7 +492,7 @@ public:
}
return ret;
}
-
+
/*!
* @brief Return the jacobian matrix (derivate by the focus length)
* of this projection.
@@ -527,14 +529,14 @@ public:
}
return ret;
}
-
+
/*!
* @brief Same as \c copyFrom(b)
*/
PhotoProjection& operator=(PhotoProjection const& b) {
return copyFrom(b);
}
-
+
/*!
* @brief Same as \c transformate(v)
*/
@@ -543,6 +545,6 @@ public:
}
};
-}
+} // meow
#endif // Transformations_H__
diff --git a/meowpp/math/Vector.h b/meowpp/math/Vector.h
index caa64fd..4dd95a5 100644
--- a/meowpp/math/Vector.h
+++ b/meowpp/math/Vector.h
@@ -92,7 +92,7 @@ public:
}
//! @brief Return a \a dimension x 1 matrix form of it
- Matrix<Scalar> const& matrix() const {
+ Matrix<Scalar> matrix() const {
return matrix_;
}
@@ -121,35 +121,35 @@ public:
return (dimension() > 0);
}
- //! @brief return \a i -th entry
- Scalar entry(size_t i) const {
+ //! @brief return \a i -th scalar
+ Scalar scalar(size_t i) const {
return matrix_.entry(i, 0);
}
/*!
- * @brief change \a i -th entry
+ * @brief change \a i -th scalar
*
* @param [in] i i-th
* @param [in] s new value
*/
- Scalar entry(size_t i, Scalar const& s) {
+ Scalar scalar(size_t i, Scalar const& s) {
matrix_.entry(i, 0, s);
return entry(i);
}
-
- //! @brief return \a i -th entry with non-constant type
- ScalarRef entryGet(size_t i) {
+
+ //! @brief return \a i -th scalar with non-constant type
+ ScalarRef scalarGet(size_t i) {
return matrix_.entryGet(i);
}
/*!
- * @brief change \a i -th to \a j -th entries
+ * @brief change \a i -th to \a j -th scalars
*
* @param [in] i i-th
* @param [in] j j-th
* @param [in] s new value
*/
- void entries(size_t i, size_t j, Scalar const& s) {
+ void scalars(size_t i, size_t j, Scalar const& s) {
for (size_t it = i; it <= j; ++it) {
matrix_.entry(it, 0, s);
}
diff --git a/meowpp/math/methods.h b/meowpp/math/methods.h
index 5b67594..c10a7d8 100644
--- a/meowpp/math/methods.h
+++ b/meowpp/math/methods.h
@@ -42,7 +42,7 @@ namespace meow {
*
* So in this function we choose
* \f$ M = \lceil \frac{\log(1 - P)}{\log(1 - p_0^N)} \rceil \f$
- *
+ *
* @param [in] data The whole data sett
* @param [in] w Weight function to give a floating number for a given
* parameters which means how best this solution is. Negitave
@@ -93,7 +93,7 @@ inline std::vector<Data> ransac(std::vector<Data> const& data,
/*
- * @brief Run the \b Levenberg-Marquardt method to solve a non-linear
+ * @brief Run the \b Levenberg-Marquardt method to solve a non-linear
* least squares problem.
*
* Assume: