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-2018, 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 "math-precomp.h" // Precompiled headers
11 
12 #include <mrpt/math/CMatrix.h>
15 
16 using namespace mrpt;
17 using namespace mrpt::math;
18 using namespace mrpt::serialization;
19 
20 // This must be added to any CSerializable class implementation file.
22 
23 uint8_t CMatrix::serializeGetVersion() const { return 0; }
25 {
26  // First, write the number of rows and columns:
27  out << (uint32_t)rows() << (uint32_t)cols();
28 
29  if (rows() > 0 && cols() > 0)
30  for (Index i = 0; i < rows(); i++)
31  out.WriteBufferFixEndianness<Scalar>(&coeff(i, 0), cols());
32 }
33 
35 {
36  switch (version)
37  {
38  case 0:
39  {
40  uint32_t nRows, nCols;
41 
42  // First, write the number of rows and columns:
43  in >> nRows >> nCols;
44 
45  setSize(nRows, nCols);
46 
47  if (nRows > 0 && nCols > 0)
48  for (Index i = 0; i < rows(); i++)
49  in.ReadBufferFixEndianness<Scalar>(&coeffRef(i, 0), nCols);
50  }
51  break;
52  default:
54  };
55 }
math-precomp.h
CMatrix.h
mrpt::math::CMatrix::serializeFrom
void serializeFrom(mrpt::serialization::CArchive &in, uint8_t serial_version) override
Pure virtual method for reading (deserializing) from an abstract archive.
Definition: CMatrix.cpp:34
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
uint8_t
unsigned char uint8_t
Definition: rptypes.h:41
Scalar
double Scalar
Definition: KmUtils.h:44
mrpt::serialization::CArchive
Virtual base class for "archives": classes abstracting I/O streams.
Definition: CArchive.h:48
lightweight_geom_data.h
mrpt::math::CMatrix
This class is a "CSerializable" wrapper for "CMatrixFloat".
Definition: CMatrix.h:24
mrpt::serialization::CSerializable
The virtual base class which provides a unified interface for all persistent objects in MRPT.
Definition: CSerializable.h:32
IMPLEMENTS_SERIALIZABLE
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
This must be inserted in all CSerializable classes implementation files.
Definition: CSerializable.h:114
setSize
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...
Definition: eigen_plugins.h:343
mrpt::serialization
Definition: aligned_serialization.h:14
mrpt::math::CMatrix::serializeTo
void serializeTo(mrpt::serialization::CArchive &out) const override
Pure virtual method for writing (serializing) to an abstract archive.
Definition: CMatrix.cpp:24
mrpt::math
This base provides a set of functions for maths stuff.
Definition: math/include/mrpt/math/bits_math.h:13
in
GLuint in
Definition: glext.h:7274
CArchive.h
MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
Definition: exceptions.h:90
mrpt::serialization::CArchive::WriteBufferFixEndianness
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: CArchive.h:123
uint32_t
unsigned __int32 uint32_t
Definition: rptypes.h:47



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST