Main MRPT website > C++ reference for MRPT 1.5.9
CMatrixD.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/CMatrixD.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 \f$ */
25 /** Constructor from a TPose3D, which generates a 6x1 matrix \f$ [x y z yaw pitch roll]^T \f$ */
27 /** Constructor from a TPoint2D, which generates a 2x1 matrix \f$ [x y]^T \f$ */
29 /** Constructor from a TPoint3D, which generates a 3x1 matrix \f$ [x y z]^T \f$ */
31 
32 
33 /*---------------------------------------------------------------
34  writeToStream
35  ---------------------------------------------------------------*/
36 void CMatrixD::writeToStream(mrpt::utils::CStream &out, int *out_Version) const
37 {
38  if (out_Version)
39  *out_Version = 0;
40  else
41  {
42  // First, write the number of rows and columns:
43  out << (uint32_t)rows() << (uint32_t)cols();
44 
45  if (rows()>0 && cols()>0)
46  for (Index i=0;i<rows();i++)
47  out.WriteBufferFixEndianness<Scalar>(&coeff(i,0),cols());
48  }
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  } break;
72  default:
74 
75  };
76 }
77 
void readFromStream(mrpt::utils::CStream &in, int version)
Introduces a pure virtual method responsible for loading from a CStream This can not be used directly...
Definition: CMatrixD.cpp:55
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
Definition: zip.h:16
This class is a "CSerializable" wrapper for "CMatrixTemplateNumeric<double>".
Definition: CMatrixD.h:30
The virtual base class which provides a unified interface for all persistent objects in MRPT...
Definition: CSerializable.h:39
IMPLEMENTS_SERIALIZABLE(CLogFileRecord_FullEval, CHolonomicLogFileRecord, mrpt::nav) IMPLEMENTS_SERIALIZABLE(CHolonomicFullEval
void writeToStream(mrpt::utils::CStream &out, int *getVersion) const
Introduces a pure virtual method responsible for writing to a CStream.
Definition: CMatrixD.cpp:36
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:139
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:38
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...
int version
Definition: mrpt_jpeglib.h:898
CMatrixD()
Constructor.
Definition: CMatrixD.h:36
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:6301
Lightweight 2D pose.
Lightweight 3D point.
unsigned __int32 uint32_t
Definition: rptypes.h:49
Lightweight 2D point.
double Scalar
Definition: KmUtils.h:41
GLfloat GLfloat p
Definition: glext.h:5587



Page generated by Doxygen 1.8.14 for MRPT 1.5.9 Git: 690a4699f Wed Apr 15 19:29:53 2020 +0200 at miƩ abr 15 19:30:12 CEST 2020