diff options
author | cathook <b01902109@csie.ntu.edu.tw> | 2014-06-01 13:56:57 +0800 |
---|---|---|
committer | cathook <b01902109@csie.ntu.edu.tw> | 2014-06-01 13:56:57 +0800 |
commit | d5052f1c296dddf51b3e83d59bf3e3c1952cb2d0 (patch) | |
tree | 16f7920c5079e0aefcf9509d2dbab59c464d42bd /meowpp/math/LinearTransformation.h | |
parent | bd58f63900410ec4764031f2e6de2d75e91434b3 (diff) | |
download | meow-d5052f1c296dddf51b3e83d59bf3e3c1952cb2d0.tar meow-d5052f1c296dddf51b3e83d59bf3e3c1952cb2d0.tar.gz meow-d5052f1c296dddf51b3e83d59bf3e3c1952cb2d0.tar.bz2 meow-d5052f1c296dddf51b3e83d59bf3e3c1952cb2d0.tar.lz meow-d5052f1c296dddf51b3e83d59bf3e3c1952cb2d0.tar.xz meow-d5052f1c296dddf51b3e83d59bf3e3c1952cb2d0.tar.zst meow-d5052f1c296dddf51b3e83d59bf3e3c1952cb2d0.zip |
big chnage
Diffstat (limited to 'meowpp/math/LinearTransformation.h')
-rw-r--r-- | meowpp/math/LinearTransformation.h | 116 |
1 files changed, 100 insertions, 16 deletions
diff --git a/meowpp/math/LinearTransformation.h b/meowpp/math/LinearTransformation.h index f856f08..86724b7 100644 --- a/meowpp/math/LinearTransformation.h +++ b/meowpp/math/LinearTransformation.h @@ -6,22 +6,106 @@ #include <cstdlib> -namespace meow{ - template<class Scalar> - class LinearTransformation: public Transformation<Scalar>{ - protected: - Matrix<Scalar> _matrix; - - LinearTransformation(size_t __inputRows, size_t __outputRows, - size_t __psize): - Transformation(__inputRows, 1u, __outputRows, 1u, __psize), - _matrix(__outputRows, __inputCols, Scalar(0.0)){ - } - public: - virtual LinearTransformation(){ } - virtual Matrix<Scalar> const& matrix() const{ return _matrix; } - virtual Matrix<Scalar> invMatrix() const = 0; - }; +namespace meow { + +/*! + * @brief A base class for implementing kinds of linear transformations. + * + * Because all linear transformations belong to transformations, + * this class inherit to Transformation. + * + * @author cat_leopard + */ +template<class Scalar> +class LinearTransformation: public Transformation<Scalar> { +private: + Matrix<Scalar> matrix_; +protected: + /*! + * Constructor with input/output size gived + */ + LinearTransformation(size_t inputRows, size_t outputRows, size_t psize): + Transformation<Scalar>(inputRows, 1u, outputRows, 1u, psize), + matrix_(outputRows, inputRows, Scalar(0.0)) { + } + + /*! + * Constructor with input/output size gived and a inital matrix + */ + LinearTransformation(size_t inputRows, size_t outputRows, size_t psize, + Matrix<Scalar> const& m): + Transformation<Scalar>(inputRows, 1u, outputRows, 1u, psize), + matrix_(m) { + } + + /*! + * Constructor with another LinearTransformation + * + * @param [in] b another LinearTransformation + */ + LinearTransformation(LinearTransformation const& b): + Transformation<Scalar>(b), + matrix_(b.matrix_) { + } + + /*! + * @brief Copy settings, matrix from another LinearTransformation + * + * @param [in] b another LinearTransformation + */ + LinearTransformation& copyFrom(LinearTransformation const& b) { + Transformation<Scalar>::copyFrom(b); + matrix_.copyFrom(b.matrix_); + return *this; + } + + /*! + * @brief Reference settings, matrix from another LinearTransformation + * + * @param [in] b another LinearTransformation + */ + LinearTransformation& referenceFrom(LinearTransformation const& b) { + Transformation<Scalar>::referenceFrom(b); + matrix_.referenceFrom(b.matrix_); + return *this; + } + + /*! + * @brief Setup the matrix + * + * @param [in] m matrix + * @return new matrix + */ + Matrix<Scalar> const& matrix(Matrix<Scalar> const& m) { + matrix_.copyFrom(m); + return matrix_; + } +public: + /*! + * Destructor + */ + virtual ~LinearTransformation() { + } + + /*! + * @brief Return the matrix form of this transformation + * + * @return A matrix + */ + virtual Matrix<Scalar> const& matrix() const { + return matrix_; + } + + /*! + * @brief Return the inverse of the matrix form of this transformate + * + * @return A matrix (may be invalid) + */ + virtual Matrix<Scalar> matrixInv() const { + return matrix_.inverse(); + } +}; + } #endif // math_LinearTransformation_H__ |