Main MRPT website > C++ reference
MRPT logo

CMatrix.h

Go to the documentation of this file.
00001 /* +---------------------------------------------------------------------------+
00002    |          The Mobile Robot Programming Toolkit (MRPT) C++ library          |
00003    |                                                                           |
00004    |                   http://mrpt.sourceforge.net/                            |
00005    |                                                                           |
00006    |   Copyright (C) 2005-2011  University of Malaga                           |
00007    |                                                                           |
00008    |    This software was written by the Machine Perception and Intelligent    |
00009    |      Robotics Lab, University of Malaga (Spain).                          |
00010    |    Contact: Jose-Luis Blanco  <jlblanco@ctima.uma.es>                     |
00011    |                                                                           |
00012    |  This file is part of the MRPT project.                                   |
00013    |                                                                           |
00014    |     MRPT is free software: you can redistribute it and/or modify          |
00015    |     it under the terms of the GNU General Public License as published by  |
00016    |     the Free Software Foundation, either version 3 of the License, or     |
00017    |     (at your option) any later version.                                   |
00018    |                                                                           |
00019    |   MRPT is distributed in the hope that it will be useful,                 |
00020    |     but WITHOUT ANY WARRANTY; without even the implied warranty of        |
00021    |     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         |
00022    |     GNU General Public License for more details.                          |
00023    |                                                                           |
00024    |     You should have received a copy of the GNU General Public License     |
00025    |     along with MRPT.  If not, see <http://www.gnu.org/licenses/>.         |
00026    |                                                                           |
00027    +---------------------------------------------------------------------------+ */
00028 #ifndef CMATRIX_H
00029 #define CMATRIX_H
00030 
00031 #include <mrpt/utils/CSerializable.h>
00032 #include <mrpt/math/CMatrixTemplateNumeric.h>
00033 #include <mrpt/math/CMatrixFixedNumeric.h>
00034 #include <mrpt/utils/CStream.h>
00035 
00036 namespace mrpt
00037 {
00038         namespace math
00039         {
00040                 // This must be added to any CSerializable derived class:
00041                 //DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE( CMatrix, mrpt::utils::CSerializable )
00042                 //DEFINE_MRPT_OBJECT_PRE_CUSTOM_BASE_LINKAGE(class_name, base_name, BASE_IMPEXP )
00043                 DEFINE_MRPT_OBJECT_PRE_CUSTOM_BASE_LINKAGE2(CMatrix, mrpt::utils::CSerializable, CMatrix)
00044                 BASE_IMPEXP ::mrpt::utils::CStream& operator>>(mrpt::utils::CStream& in, CMatrixPtr &pObj);
00045 
00046                 /**  This class is a "CSerializable" wrapper for "CMatrixFloat".
00047                  */
00048                 class CMatrix : public mrpt::utils::CSerializable, public CMatrixFloat
00049                 {
00050                         // This must be added to any CSerializable derived class:
00051                         //DEFINE_SERIALIZABLE( CMatrix )
00052                         //DEFINE_MRPT_OBJECT(CMatrix)
00053                 protected:
00054                         static  const mrpt::utils::TRuntimeClassId* _GetBaseClass();
00055                         static mrpt::utils::CLASSINIT _init_CMatrix;
00056                 public: 
00057                         /*! A typedef for the associated smart pointer */ 
00058                         typedef CMatrixPtr SmartPtr; 
00059                         static BASE_IMPEXP  mrpt::utils::TRuntimeClassId  classCMatrix; 
00060                         static BASE_IMPEXP  const mrpt::utils::TRuntimeClassId *classinfo; 
00061                         virtual BASE_IMPEXP  const mrpt::utils::TRuntimeClassId* GetRuntimeClass() const; 
00062                         static  BASE_IMPEXP mrpt::utils::CObject* CreateObject(); 
00063                         static BASE_IMPEXP CMatrixPtr Create(); 
00064                         virtual BASE_IMPEXP mrpt::utils::CObject *duplicate() const; 
00065                 protected:
00066                         /*! @name CSerializable virtual methods */
00067                         /*! @{ */
00068                         BASE_IMPEXP void writeToStream(mrpt::utils::CStream &out, int *getVersion) const;
00069                         BASE_IMPEXP void readFromStream(mrpt::utils::CStream &in, int version);
00070                         /*! @} */
00071 
00072                 public:
00073                         /** Constructor  */
00074                         CMatrix() : CMatrixFloat(1,1)
00075                         { }
00076 
00077                         /** Constructor  */
00078                         CMatrix(size_t row, size_t col) : CMatrixFloat(row,col)
00079                         { }
00080 
00081                         /** Copy constructor
00082                           */
00083                         CMatrix( const CMatrixFloat &m ) : CMatrixFloat(m)
00084                         { }
00085 
00086                         /** Copy constructor
00087                           */
00088                         CMatrix( const CMatrixTemplateNumeric<double> &m ) : CMatrixFloat(0,0)
00089                         {
00090                                 *this = m.eval().cast<float>();
00091                         }
00092 
00093                         /** Constructor from a TPose2D, which generates a 3x1 matrix \f$ [x y \phi]^T \f$
00094                            */
00095                         explicit CMatrix( const TPose2D &p) : CMatrixFloat(p) {}
00096 
00097                         /** Constructor from a mrpt::poses::CPose6D, which generates a 6x1 matrix \f$ [x y z yaw pitch roll]^T \f$
00098                            */
00099                         explicit CMatrix( const TPose3D &p) : CMatrixFloat(p) {}
00100 
00101                         /** Constructor from a TPoint2D, which generates a 2x1 matrix \f$ [x y]^T \f$
00102                            */
00103                         explicit CMatrix( const TPoint2D &p) : CMatrixFloat(p) {}
00104 
00105                         /** Constructor from a TPoint3D, which generates a 3x1 matrix \f$ [x y z]^T \f$
00106                            */
00107                         explicit CMatrix( const TPoint3D &p) : CMatrixFloat(p) {}
00108 
00109                         /** Assignment operator for float matrixes
00110                         */
00111                         template <class OTHERMAT>
00112                         inline CMatrix & operator = (const OTHERMAT& m)
00113                         {
00114                                 CMatrixFloat::operator =(m);
00115                                 return *this;
00116                         }
00117 
00118                         /*! Assignment operator from any other Eigen class */
00119                         template<typename OtherDerived>
00120                         inline CMatrix & operator= (const Eigen::MatrixBase <OtherDerived>& other) {
00121                                 CMatrixTemplateNumeric<float>::operator=(other);
00122                                 return *this;
00123                         }
00124                         /*! Constructor from any other Eigen class */
00125                         template<typename OtherDerived>
00126                         inline CMatrix(const Eigen::MatrixBase <OtherDerived>& other) : CMatrixTemplateNumeric<float>(other) { }
00127 
00128                 }; // end of class definition
00129 
00130         } // End of namespace
00131 } // End of namespace
00132 
00133 #endif



Page generated by Doxygen 1.7.3 for MRPT 0.9.4 SVN:exported at Tue Jan 25 21:56:31 UTC 2011