Main MRPT website > C++ reference
MRPT logo

CMatrixD.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 CMATRIXD_H
00029 #define CMATRIXD_H
00030 
00031 #include <mrpt/utils/CSerializable.h>
00032 #include <mrpt/math/CMatrixTemplateNumeric.h>
00033 #include <mrpt/utils/CStream.h>
00034 #include <mrpt/utils/utils_defs.h>
00035 
00036 
00037 namespace mrpt
00038 {
00039         namespace math
00040         {
00041                 // This must be added to any CSerializable derived class:
00042                 //DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE( CMatrixD, mrpt::utils::CSerializable )
00043                 //DEFINE_MRPT_OBJECT_PRE_CUSTOM_BASE_LINKAGE(class_name, base_name, BASE_IMPEXP )
00044                 DEFINE_MRPT_OBJECT_PRE_CUSTOM_BASE_LINKAGE2(CMatrixD, mrpt::utils::CSerializable, CMatrixD)
00045                 BASE_IMPEXP ::mrpt::utils::CStream& operator>>(mrpt::utils::CStream& in, CMatrixDPtr &pObj);
00046 
00047 
00048                 /**  This class is a "CSerializable" wrapper for "CMatrixTemplateNumeric<double>".
00049                  */
00050                 class CMatrixD : public mrpt::utils::CSerializable, public CMatrixTemplateNumeric<double>
00051                 {
00052                         // This must be added to any CSerializable derived class:
00053                         //DEFINE_SERIALIZABLE( CMatrixD )
00054                         //DEFINE_MRPT_OBJECT(CMatrixD)
00055                 protected:
00056                         static  const mrpt::utils::TRuntimeClassId* _GetBaseClass();
00057                         static mrpt::utils::CLASSINIT _init_CMatrixD;
00058                 public: 
00059                         /*! A typedef for the associated smart pointer */ 
00060                         typedef CMatrixDPtr SmartPtr; 
00061                         static BASE_IMPEXP  mrpt::utils::TRuntimeClassId  classCMatrixD; 
00062                         static BASE_IMPEXP  const mrpt::utils::TRuntimeClassId *classinfo; 
00063                         virtual BASE_IMPEXP  const mrpt::utils::TRuntimeClassId* GetRuntimeClass() const; 
00064                         static  BASE_IMPEXP mrpt::utils::CObject* CreateObject(); 
00065                         static BASE_IMPEXP CMatrixDPtr Create(); 
00066                         virtual BASE_IMPEXP mrpt::utils::CObject *duplicate() const; 
00067                 protected:
00068                         /*! @name CSerializable virtual methods */
00069                         /*! @{ */
00070                         BASE_IMPEXP void writeToStream(mrpt::utils::CStream &out, int *getVersion) const;
00071                         BASE_IMPEXP void readFromStream(mrpt::utils::CStream &in, int version);
00072                         /*! @} */
00073 
00074                 public:
00075                         /** Constructor */
00076                         CMatrixD() : CMatrixTemplateNumeric<double>(1,1)
00077                         { }
00078 
00079                         /** Constructor */
00080                         CMatrixD(size_t row, size_t col) : CMatrixTemplateNumeric<double>(row,col)
00081                         { }
00082 
00083                         /** Copy constructor */
00084                         CMatrixD( const CMatrixTemplateNumeric<double> &m ) : CMatrixTemplateNumeric<double>(m)
00085                         { }
00086 
00087                         /** Copy constructor
00088                           */
00089                         CMatrixD( const CMatrixFloat &m ) : CMatrixTemplateNumeric<double>(0,0)
00090                         {
00091                                 *this = m.eval().cast<double>();
00092                         }
00093 
00094                         /*! Assignment operator from any other Eigen class */
00095                         template<typename OtherDerived>
00096                         inline CMatrixD & operator= (const Eigen::MatrixBase <OtherDerived>& other) {
00097                                 CMatrixTemplateNumeric<double>::operator=(other);
00098                                 return *this;
00099                         }
00100                         /*! Constructor from any other Eigen class */
00101                         template<typename OtherDerived>
00102                         inline CMatrixD(const Eigen::MatrixBase <OtherDerived>& other) : CMatrixTemplateNumeric<double>(other) { }
00103 
00104                         /** Constructor from a TPose2D, which generates a 3x1 matrix \f$ [x y \phi]^T \f$
00105                            */
00106                         explicit CMatrixD( const TPose2D &p) : CMatrixDouble(p) {}
00107 
00108                         /** Constructor from a TPose3D, which generates a 6x1 matrix \f$ [x y z yaw pitch roll]^T \f$
00109                            */
00110                         explicit CMatrixD( const TPose3D &p) : CMatrixDouble(p) {}
00111 
00112                         /** Constructor from a TPoint2D, which generates a 2x1 matrix \f$ [x y]^T \f$
00113                            */
00114                         explicit CMatrixD( const TPoint2D &p) : CMatrixDouble(p) {}
00115 
00116                         /** Constructor from a mrpt::poses::CPoint3D, which generates a 3x1 matrix \f$ [x y z]^T \f$
00117                            */
00118                         explicit CMatrixD( const TPoint3D &p) : CMatrixDouble(p) {}
00119 
00120 
00121                         /** Assignment operator for float matrixes
00122                         */
00123                         template <class OTHERMAT>
00124                         inline CMatrixD & operator = (const OTHERMAT& m)
00125                         {
00126                                 CMatrixDouble::operator =(m);
00127                                 return *this;
00128                         }
00129 
00130                 }; // end of class definition
00131 
00132         } // End of namespace
00133 } // End of namespace
00134 
00135 #endif



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