MRPT  1.9.9
CMatrixB.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/CMatrixB.h>
14 
15 using namespace mrpt;
16 using namespace mrpt::math;
17 
18 // This must be added to any CSerializable class implementation file.
20 
21 uint8_t CMatrixB::serializeGetVersion() const { return 0; }
23 {
24  out << (uint32_t)sizeof(m_Val[0][0]);
25 
26  // First, write the number of rows and columns:
27  out << (uint32_t)m_Rows << (uint32_t)m_Cols;
28 
29  if (m_Rows > 0 && m_Cols > 0)
30  for (unsigned int i = 0; i < m_Rows; i++)
31  out.WriteBuffer(m_Val[i], sizeof(m_Val[0][0]) * m_Cols);
32 }
33 
35 {
36  switch (version)
37  {
38  case 0:
39  {
40  uint32_t size_bool;
41  in >> size_bool;
42  if (size_bool != sizeof(m_Val[0][0]))
44  "Error: size of 'bool' is different in serialized data!")
45 
46  uint32_t nRows, nCols;
47 
48  // First, write the number of rows and columns:
49  in >> nRows >> nCols;
50 
51  setSize(nRows, nCols);
52 
53  if (nRows > 0 && nCols > 0)
54  for (unsigned int i = 0; i < nRows; i++)
55  in.ReadBuffer(m_Val[i], sizeof(m_Val[0][0]) * m_Cols);
56  }
57  break;
58  default:
60  };
61 }
62 
63 // Implementation of CMatrixBool
64 CMatrixBool::CMatrixBool(size_t row, size_t col)
65  : CMatrixTemplate<bool>(row, col)
66 {
67 }
69  : CMatrixTemplate<bool>(m)
70 {
71 }
73 {
75  return *this;
76 }
Declares a matrix of booleans (non serializable).
CMatrixBool & operator=(const CMatrixTemplate< bool > &m)
Assignment operator for float matrixes.
Definition: CMatrixB.cpp:72
#define THROW_EXCEPTION(msg)
Definition: exceptions.h:41
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
This must be inserted in all CSerializable classes implementation files.
void WriteBuffer(const void *Buffer, size_t Count)
Writes a block of bytes to the stream from Buffer.
Definition: CArchive.cpp:48
unsigned char uint8_t
Definition: rptypes.h:41
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
Definition: exceptions.h:90
This base provides a set of functions for maths stuff.
CMatrixBool(size_t row=1, size_t col=1)
Constructor.
Definition: CMatrixB.cpp:64
This template class provides the basic functionality for a general 2D any-size, resizable container o...
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Virtual base class for "archives": classes abstracting I/O streams.
Definition: CArchive.h:52
GLenum GLenum GLvoid * row
Definition: glext.h:3576
GLuint in
Definition: glext.h:7274
This class is a "CSerializable" wrapper for "CMatrixBool".
Definition: CMatrixB.h:21
void setSize(size_t row, size_t col, bool zeroNewElements=false)
Changes the size of matrix, maintaining the previous contents.
void serializeFrom(mrpt::serialization::CArchive &in, uint8_t serial_version) override
Pure virtual method for reading (deserializing) from an abstract archive.
Definition: CMatrixB.cpp:34
CMatrixTemplate & operator=(const CMatrixTemplate &m)
Assignment operator from another matrix.
unsigned __int32 uint32_t
Definition: rptypes.h:47
void serializeTo(mrpt::serialization::CArchive &out) const override
Pure virtual method for writing (serializing) to an abstract archive.
Definition: CMatrixB.cpp:22



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020