Main MRPT website > C++ reference for MRPT 1.9.9
CMatrix.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2017, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #include "base-precomp.h" // Precompiled headers
11 
12 #include <mrpt/math/CMatrix.h>
14 #include <mrpt/utils/CStream.h>
15 
16 using namespace mrpt;
17 using namespace mrpt::math;
18 using namespace mrpt::utils;
19 
20 // This must be added to any CSerializable class implementation file.
22 
23 /** Constructor from a TPose2D, which generates a 3x1 matrix \f$ [x y \phi]^T
24  * \f$ */
26 /** Constructor from a mrpt::poses::CPose6D, which generates a 6x1 matrix \f$ [x
27  * y z yaw pitch roll]^T \f$ */
29 /** Constructor from a TPoint2D, which generates a 2x1 matrix \f$ [x y]^T \f$ */
31 /** Constructor from a TPoint3D, which generates a 3x1 matrix \f$ [x y z]^T \f$
32  */
34 /*---------------------------------------------------------------
35  writeToStream
36  ---------------------------------------------------------------*/
37 void CMatrix::writeToStream(mrpt::utils::CStream& out, int* out_Version) const
38 {
39  if (out_Version)
40  *out_Version = 0;
41  else
42  {
43  // First, write the number of rows and columns:
44  out << (uint32_t)rows() << (uint32_t)cols();
45 
46  if (rows() > 0 && cols() > 0)
47  for (Index i = 0; i < rows(); i++)
48  out.WriteBufferFixEndianness<Scalar>(&coeff(i, 0), cols());
49  }
50 }
51 
52 /*---------------------------------------------------------------
53  readFromStream
54  ---------------------------------------------------------------*/
56 {
57  switch (version)
58  {
59  case 0:
60  {
61  uint32_t nRows, nCols;
62 
63  // First, write the number of rows and columns:
64  in >> nRows >> nCols;
65 
66  setSize(nRows, nCols);
67 
68  if (nRows > 0 && nCols > 0)
69  for (Index i = 0; i < rows(); i++)
70  in.ReadBufferFixEndianness<Scalar>(&coeffRef(i, 0), nCols);
71  }
72  break;
73  default:
75  };
76 }
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
void writeToStream(mrpt::utils::CStream &out, int *getVersion) const override
Introduces a pure virtual method responsible for writing to a CStream.
Definition: CMatrix.cpp:37
The virtual base class which provides a unified interface for all persistent objects in MRPT...
Definition: CSerializable.h:44
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
This must be inserted in all CSerializable classes implementation files.
CMatrix()
Constructor.
Definition: CMatrix.h:31
void WriteBufferFixEndianness(const T *ptr, size_t ElementCount)
Writes a sequence of elemental datatypes, taking care of reordering their bytes from the running arch...
Definition: CStream.h:159
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:41
This base provides a set of functions for maths stuff.
Definition: CArrayNumeric.h:19
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
EIGEN_STRONG_INLINE void setSize(size_t row, size_t col)
Changes the size of matrix, maintaining its previous content as possible and padding with zeros where...
void readFromStream(mrpt::utils::CStream &in, int version) override
Introduces a pure virtual method responsible for loading from a CStream This can not be used directly...
Definition: CMatrix.cpp:55
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Lightweight 3D pose (three spatial coordinates, plus three angular coordinates).
GLuint in
Definition: glext.h:7274
Lightweight 2D pose.
Lightweight 3D point.
This class is a "CSerializable" wrapper for "CMatrixFloat".
Definition: CMatrix.h:25
unsigned __int32 uint32_t
Definition: rptypes.h:47
Lightweight 2D point.
double Scalar
Definition: KmUtils.h:44
GLfloat GLfloat p
Definition: glext.h:6305



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019