Main MRPT website
>
C++ reference
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
mrpt
math
CMatrixD.h
Go to the documentation of this file.
1
/* +---------------------------------------------------------------------------+
2
| The Mobile Robot Programming Toolkit (MRPT) C++ library |
3
| |
4
| http://www.mrpt.org/ |
5
| |
6
| Copyright (C) 2005-2012 University of Malaga |
7
| |
8
| This software was written by the Machine Perception and Intelligent |
9
| Robotics Lab, University of Malaga (Spain). |
10
| Contact: Jose-Luis Blanco <jlblanco@ctima.uma.es> |
11
| |
12
| This file is part of the MRPT project. |
13
| |
14
| MRPT is free software: you can redistribute it and/or modify |
15
| it under the terms of the GNU General Public License as published by |
16
| the Free Software Foundation, either version 3 of the License, or |
17
| (at your option) any later version. |
18
| |
19
| MRPT is distributed in the hope that it will be useful, |
20
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
21
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
22
| GNU General Public License for more details. |
23
| |
24
| You should have received a copy of the GNU General Public License |
25
| along with MRPT. If not, see <http://www.gnu.org/licenses/>. |
26
| |
27
+---------------------------------------------------------------------------+ */
28
#ifndef CMATRIXD_H
29
#define CMATRIXD_H
30
31
#include <
mrpt/utils/CSerializable.h
>
32
#include <
mrpt/math/CMatrixTemplateNumeric.h
>
33
#include <
mrpt/utils/CStream.h
>
34
#include <
mrpt/utils/utils_defs.h
>
35
36
37
namespace
mrpt
38
{
39
namespace
math
40
{
41
// This must be added to any CSerializable derived class:
42
// Note: instead of the standard "DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE", classes inheriting
43
// from templates need special nasty handling for MSVC DLL exports...
44
DEFINE_MRPT_OBJECT_PRE_CUSTOM_BASE_LINKAGE2
(
CMatrixD
,
mrpt::utils::CSerializable
,
CMatrixD
)
45
BASE_IMPEXP
::mrpt::utils::
CStream
& operator>>(mrpt::utils::
CStream
& in,
CMatrixDPtr
&pObj);
46
47
48
/** This class is a "CSerializable" wrapper for "CMatrixTemplateNumeric<double>".
49
* \note For a complete introduction to Matrices and vectors in MRPT, see: http://www.mrpt.org/Matrices_vectors_arrays_and_Linear_Algebra_MRPT_and_Eigen_classes
50
* \ingroup mrpt_base_grp
51
*/
52
class
BASE_IMPEXP_TEMPL
CMatrixD
: public mrpt::utils::
CSerializable
, public
CMatrixTemplateNumeric
<
double
>
53
{
54
// This must be added to any CSerializable derived class:
55
//DEFINE_SERIALIZABLE( CMatrixD )
56
//DEFINE_MRPT_OBJECT(CMatrixD)
57
protected
:
58
static
const
mrpt::utils::TRuntimeClassId
* _GetBaseClass();
59
static
mrpt::utils::CLASSINIT
_init_CMatrixD
;
60
public
:
61
/*! A typedef for the associated smart pointer */
62
typedef
CMatrixDPtr
SmartPtr
;
63
static
BASE_IMPEXP
mrpt::utils::TRuntimeClassId
classCMatrixD
;
64
static
BASE_IMPEXP
const
mrpt::utils::TRuntimeClassId
*
classinfo
;
65
virtual
BASE_IMPEXP
const
mrpt::utils::TRuntimeClassId
* GetRuntimeClass()
const
;
66
static
BASE_IMPEXP
mrpt::utils::CObject
* CreateObject();
67
static
BASE_IMPEXP
CMatrixDPtr
Create();
68
virtual
BASE_IMPEXP
mrpt::utils::CObject
*duplicate()
const
;
69
protected
:
70
/*! @name CSerializable virtual methods */
71
/*! @{ */
72
BASE_IMPEXP
void
writeToStream(
mrpt::utils::CStream
&out,
int
*getVersion)
const
;
73
BASE_IMPEXP
void
readFromStream(
mrpt::utils::CStream
&in,
int
version);
74
/*! @} */
75
76
public
:
77
/** Constructor */
78
CMatrixD
() :
CMatrixTemplateNumeric
<double>(1,1)
79
{ }
80
81
/** Constructor */
82
CMatrixD
(
size_t
row,
size_t
col) :
CMatrixTemplateNumeric
<double>(row,col)
83
{ }
84
85
/** Copy constructor */
86
CMatrixD
(
const
CMatrixTemplateNumeric<double>
&m ) :
CMatrixTemplateNumeric
<double>(m)
87
{ }
88
89
/** Copy constructor
90
*/
91
CMatrixD
(
const
CMatrixFloat
&m ) :
CMatrixTemplateNumeric
<double>(0,0)
92
{
93
*
this
= m.eval().cast<
double
>();
94
}
95
96
/*! Assignment operator from any other Eigen class */
97
template
<
typename
OtherDerived>
98
inline
CMatrixD
& operator= (
const
Eigen::MatrixBase <OtherDerived>& other) {
99
CMatrixTemplateNumeric<double>::operator=
(other);
100
return
*
this
;
101
}
102
/*! Constructor from any other Eigen class */
103
template
<
typename
OtherDerived>
104
inline
CMatrixD
(
const
Eigen::MatrixBase <OtherDerived>& other) :
CMatrixTemplateNumeric
<double>(other) { }
105
106
/** Constructor from a TPose2D, which generates a 3x1 matrix \f$ [x y \phi]^T \f$
107
*/
108
explicit
CMatrixD
(
const
TPose2D
&p) :
CMatrixDouble
(p) {}
109
110
/** Constructor from a TPose3D, which generates a 6x1 matrix \f$ [x y z yaw pitch roll]^T \f$
111
*/
112
explicit
CMatrixD
(
const
TPose3D
&p) :
CMatrixDouble
(p) {}
113
114
/** Constructor from a TPoint2D, which generates a 2x1 matrix \f$ [x y]^T \f$
115
*/
116
explicit
CMatrixD
(
const
TPoint2D
&p) :
CMatrixDouble
(p) {}
117
118
/** Constructor from a mrpt::poses::CPoint3D, which generates a 3x1 matrix \f$ [x y z]^T \f$
119
*/
120
explicit
CMatrixD
(
const
TPoint3D
&p) :
CMatrixDouble
(p) {}
121
122
123
/** Assignment operator for float matrixes
124
*/
125
template
<
class
OTHERMAT>
126
inline
CMatrixD
& operator = (
const
OTHERMAT& m)
127
{
128
CMatrixDouble::operator =(m);
129
return
*
this
;
130
}
131
132
};
// end of class definition
133
134
}
// End of namespace
135
}
// End of namespace
136
137
#endif
Page generated by
Doxygen 1.8.3
for MRPT 0.9.6 SVN: at Fri Feb 15 22:05:02 EST 2013