Main MRPT website > C++ reference for 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 }
mrpt::math::CMatrixTemplate::operator=
CMatrixTemplate & operator=(const CMatrixTemplate &m)
Assignment operator from another matrix.
Definition: CMatrixTemplate.h:256
mrpt::math::CMatrixTemplate< bool >::setSize
void setSize(size_t row, size_t col, bool zeroNewElements=false)
Changes the size of matrix, maintaining the previous contents.
Definition: CMatrixTemplate.h:313
mrpt::math::CMatrixTemplate< bool >::m_Val
bool ** m_Val
Definition: CMatrixTemplate.h:84
mrpt::math::CMatrixBool::operator=
CMatrixBool & operator=(const CMatrixTemplate< bool > &m)
Assignment operator for float matrixes.
Definition: CMatrixB.cpp:72
mrpt::math::CMatrixTemplate< bool >::m_Cols
size_t m_Cols
Definition: CMatrixTemplate.h:85
mrpt::math::CMatrixBool
Declares a matrix of booleans (non serializable).
Definition: CMatrixTemplate.h:696
mrpt::math::CMatrixBool::CMatrixBool
CMatrixBool(size_t row=1, size_t col=1)
Constructor.
Definition: CMatrixB.cpp:64
mrpt::math::CMatrixB::serializeFrom
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
math-precomp.h
mrpt::math::CMatrixTemplate
This template class provides the basic functionality for a general 2D any-size, resizable container o...
Definition: CMatrixTemplate.h:72
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
THROW_EXCEPTION
#define THROW_EXCEPTION(msg)
Definition: exceptions.h:41
mrpt::serialization::CArchive
Virtual base class for "archives": classes abstracting I/O streams.
Definition: CArchive.h:48
mrpt::serialization::CArchive::WriteBuffer
void WriteBuffer(const void *Buffer, size_t Count)
Writes a block of bytes to the stream from Buffer.
Definition: CArchive.cpp:48
mrpt::math::CMatrixB
This class is a "CSerializable" wrapper for "CMatrixBool".
Definition: CMatrixB.h:23
CMatrixB.h
IMPLEMENTS_SERIALIZABLE
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
This must be inserted in all CSerializable classes implementation files.
Definition: CSerializable.h:114
mrpt::math::CMatrixB::serializeTo
void serializeTo(mrpt::serialization::CArchive &out) const override
Pure virtual method for writing (serializing) to an abstract archive.
Definition: CMatrixB.cpp:22
mrpt::math::CMatrixTemplate< bool >::m_Rows
size_t m_Rows
Definition: CMatrixTemplate.h:85
row
GLenum GLenum GLvoid * row
Definition: glext.h:3576
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
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