Main MRPT website > C++ reference for MRPT 1.5.7
List of all members | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes
mrpt::math::CMatrixB Class Reference

Detailed Description

This class is a "CSerializable" wrapper for "CMatrixBool".

Note
For a complete introduction to Matrices and vectors in MRPT, see: http://www.mrpt.org/Matrices_vectors_arrays_and_Linear_Algebra_MRPT_and_Eigen_classes

Definition at line 26 of file CMatrixB.h.

#include <mrpt/math/CMatrixB.h>

Inheritance diagram for mrpt::math::CMatrixB:
Inheritance graph

Public Types

typedef bool value_type
 The type of the matrix elements. More...
 
typedef bool & reference
 
typedef const bool & const_reference
 
typedef std::size_t size_type
 
typedef std::ptrdiff_t difference_type
 

Public Member Functions

voidoperator new (size_t size)
 
voidoperator new[] (size_t size)
 
void operator delete (void *ptr) throw ()
 
void operator delete[] (void *ptr) throw ()
 
void operator delete (void *memory, void *ptr) throw ()
 
voidoperator new (size_t size, const std::nothrow_t &) throw ()
 
void operator delete (void *ptr, const std::nothrow_t &) throw ()
 
 CMatrixB (size_t row=1, size_t col=1)
 Constructor. More...
 
 CMatrixB (const CMatrixBool &m)
 Copy constructor. More...
 
CMatrixBoperator= (const CMatrixBool &m)
 Assignment operator for float matrixes. More...
 
virtual mxArraywriteToMatlab () const
 Introduces a pure virtual method responsible for writing to a mxArray Matlab object, typically a MATLAB struct whose contents are documented in each derived class. More...
 
CObjectclone () const
 Cloning interface for smart pointers. More...
 
void ASSERT_ENOUGHROOM (size_t r, size_t c) const
 Checks whether the rows [r-N,r+N] and the columns [c-N,c+N] are present in the matrix. More...
 
void fillAll (const bool &val)
 
void swap (CMatrixTemplate< bool > &o)
 Swap with another matrix very efficiently (just swaps a pointer and two integer values). More...
 
size_t getRowCount () const
 Number of rows in the matrix. More...
 
size_t getColCount () const
 Number of columns in the matrix. More...
 
CMatrixTemplateSize size () const
 Get a 2-vector with [NROWS NCOLS] (as in MATLAB command size(x)) More...
 
void setSize (size_t row, size_t col, bool zeroNewElements=false)
 Changes the size of matrix, maintaining the previous contents. More...
 
void resize (const CMatrixTemplateSize &siz, bool zeroNewElements=false)
 This method just checks has no effects in this class, but raises an exception if the expected size does not match. More...
 
bool & operator() (size_t row, size_t col)
 Subscript operator to get/set individual elements. More...
 
const bool & operator() (size_t row, size_t col) const
 Subscript operator to get individual elements. More...
 
bool & operator() (size_t ith)
 Subscript operator to get/set an individual element from a row or column matrix. More...
 
bool operator() (size_t ith) const
 Subscript operator to get/set an individual element from a row or column matrix. More...
 
CMatrixTemplate< bool > operator() (const size_t row1, const size_t row2, const size_t col1, const size_t col2) const
 Subscript operator to get a submatrix. More...
 
void set_unsafe (size_t row, size_t col, const bool &v)
 Fast but unsafe method to write a value in the matrix. More...
 
const bool & get_unsafe (size_t row, size_t col) const
 Fast but unsafe method to read a value from the matrix. More...
 
bool & get_unsafe (size_t row, size_t col)
 Fast but unsafe method to get a reference from the matrix. More...
 
bool * get_unsafe_row (size_t row)
 Fast but unsafe method to obtain a pointer to a given row of the matrix (Use only in time critical applications) More...
 
const bool * get_unsafe_row (size_t row) const
 Fast but unsafe method to obtain a pointer to a given row of the matrix (Use only in critical applications) More...
 
void extractSubmatrix (const size_t row1, const size_t row2, const size_t col1, const size_t col2, CMatrixTemplate< bool > &out) const
 Get a submatrix, given its bounds. More...
 
void extractSubmatrix (const size_t row1, const size_t row2, const size_t col1, const size_t col2, EIGEN_MATRIX &out) const
 
void extractRows (size_t firstRow, size_t lastRow, CMatrixTemplate< bool > &out) const
 Gets a series of contiguous rows. More...
 
void extractColumns (size_t firstCol, size_t lastCol, CMatrixTemplate< bool > &out) const
 Gets a series of contiguous columns. More...
 
void extractCol (size_t nCol, std::vector< bool > &out, int startingRow=0) const
 Returns a given column to a vector (without modifying the matrix) More...
 
void extractCol (size_t nCol, CMatrixTemplate< bool > &out, int startingRow=0) const
 Gets a given column to a vector (without modifying the matrix) More...
 
void appendRow (const std::vector< bool > &in)
 Appends a new row to the MxN matrix from a 1xN vector. More...
 
void appendCol (const std::vector< bool > &in)
 Appends a new column to the matrix from a vector. More...
 
void insertCol (size_t nCol, const std::vector< bool > &in)
 Inserts a column from a vector, replacing the current contents of that column. More...
 
void getAsVector (std::vector< bool > &out) const
 Returns a vector containing the matrix's values. More...
 
RTTI classes and functions
mrpt::utils::CObjectPtr duplicateGetSmartPtr () const
 Returns a copy of the object, indepently of its class, as a smart pointer (the newly created object will exist as long as any copy of this smart pointer). More...
 

Static Public Member Functions

static voidoperator new (size_t size, void *ptr)
 

Static Public Attributes

static const mrpt::utils::TRuntimeClassId classCObject
 
RTTI stuff
static const mrpt::utils::TRuntimeClassId classCSerializable
 

Protected Member Functions

void realloc (size_t row, size_t col, bool newElementsToZero=false)
 Internal use only: It reallocs the memory for the 2D matrix, maintaining the previous contents if posible. More...
 
CSerializable virtual methods
void writeToStream (mrpt::utils::CStream &out, int *getVersion) const
 Introduces a pure virtual method responsible for writing to a CStream. More...
 
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 be users, instead use "stream >> object;" for reading it from a stream or "stream >> object_ptr;" if the class is unknown apriori. More...
 

Protected Attributes

bool ** m_Val
 
size_t m_Rows
 
size_t m_Cols
 

RTTI stuff

typedef CMatrixBPtr Ptr
 
typedef CMatrixBPtr ConstPtr
 
static mrpt::utils::CLASSINIT _init_CMatrixB
 
static mrpt::utils::TRuntimeClassId classCMatrixB
 
static const mrpt::utils::TRuntimeClassIdclassinfo
 
static const mrpt::utils::TRuntimeClassId_GetBaseClass ()
 
virtual const mrpt::utils::TRuntimeClassIdGetRuntimeClass () const
 Returns information about the class of an object in runtime. More...
 
virtual mrpt::utils::CObjectduplicate () const
 Returns a copy of the object, indepently of its class. More...
 
static mrpt::utils::CObjectCreateObject ()
 
static CMatrixBPtr Create ()
 

Member Typedef Documentation

◆ const_reference

typedef const bool & mrpt::math::CMatrixTemplate< bool >::const_reference
inherited

Definition at line 60 of file CMatrixTemplate.h.

◆ ConstPtr

typedef CMatrixBPtr mrpt::math::CMatrixB::ConstPtr

Definition at line 29 of file CMatrixB.h.

◆ difference_type

Definition at line 62 of file CMatrixTemplate.h.

◆ Ptr

typedef CMatrixBPtr mrpt::math::CMatrixB::Ptr

A typedef for the associated smart pointer

Definition at line 29 of file CMatrixB.h.

◆ reference

typedef bool & mrpt::math::CMatrixTemplate< bool >::reference
inherited

Definition at line 59 of file CMatrixTemplate.h.

◆ size_type

typedef std::size_t mrpt::math::CMatrixTemplate< bool >::size_type
inherited

Definition at line 61 of file CMatrixTemplate.h.

◆ value_type

typedef bool mrpt::math::CMatrixTemplate< bool >::value_type
inherited

The type of the matrix elements.

Definition at line 58 of file CMatrixTemplate.h.

Constructor & Destructor Documentation

◆ CMatrixB() [1/2]

mrpt::math::CMatrixB::CMatrixB ( size_t  row = 1,
size_t  col = 1 
)
inline

Constructor.

Definition at line 32 of file CMatrixB.h.

◆ CMatrixB() [2/2]

mrpt::math::CMatrixB::CMatrixB ( const CMatrixBool m)
inline

Copy constructor.

Definition at line 34 of file CMatrixB.h.

Member Function Documentation

◆ _GetBaseClass()

static const mrpt::utils::TRuntimeClassId* mrpt::math::CMatrixB::_GetBaseClass ( )
staticprotected

◆ appendCol()

void mrpt::math::CMatrixTemplate< bool >::appendCol ( const std::vector< bool > &  in)
inlineinherited

Appends a new column to the matrix from a vector.

The length of the vector must match the number of rows of the matrix, unless it is (0,0).

Exceptions
std::exceptionOn size mismatch.
See also
extractCol
appendRow

Definition at line 532 of file CMatrixTemplate.h.

◆ appendRow()

void mrpt::math::CMatrixTemplate< bool >::appendRow ( const std::vector< bool > &  in)
inlineinherited

Appends a new row to the MxN matrix from a 1xN vector.

The lenght of the vector must match the width of the matrix, unless it's empty: in that case the matrix is resized to 1xN.

// ...
M.appendRow(v);
M.appendRow(w);
Exceptions
std::exceptionOn incorrect vector length.
See also
extractRow
appendCol

Definition at line 503 of file CMatrixTemplate.h.

◆ ASSERT_ENOUGHROOM()

void mrpt::math::CMatrixTemplate< bool >::ASSERT_ENOUGHROOM ( size_t  r,
size_t  c 
) const
inlineinherited

Checks whether the rows [r-N,r+N] and the columns [c-N,c+N] are present in the matrix.

Definition at line 121 of file CMatrixTemplate.h.

◆ clone()

CObject* mrpt::utils::CObject::clone ( ) const
inlineinherited

Cloning interface for smart pointers.

Definition at line 133 of file CObject.h.

◆ Create()

static CMatrixBPtr mrpt::math::CMatrixB::Create ( )
static

◆ CreateObject()

static mrpt::utils::CObject* mrpt::math::CMatrixB::CreateObject ( )
static

◆ duplicate()

virtual mrpt::utils::CObject* mrpt::math::CMatrixB::duplicate ( ) const
virtual

Returns a copy of the object, indepently of its class.

Implements mrpt::utils::CObject.

◆ duplicateGetSmartPtr()

mrpt::utils::CObjectPtr CObject::duplicateGetSmartPtr ( ) const
inlineinherited

Returns a copy of the object, indepently of its class, as a smart pointer (the newly created object will exist as long as any copy of this smart pointer).

Definition at line 162 of file CObject.h.

References mrpt::utils::CObjectPtr.

Referenced by mrpt::obs::CRawlog::addActions(), mrpt::slam::CIncrementalMapPartitioner::addMapFrame(), and mrpt::obs::CRawlog::addObservations().

◆ extractCol() [1/2]

void mrpt::math::CMatrixTemplate< bool >::extractCol ( size_t  nCol,
std::vector< bool > &  out,
int  startingRow = 0 
) const
inlineinherited

Returns a given column to a vector (without modifying the matrix)

Exceptions
std::exceptionOn index out of bounds

Definition at line 457 of file CMatrixTemplate.h.

◆ extractCol() [2/2]

void mrpt::math::CMatrixTemplate< bool >::extractCol ( size_t  nCol,
CMatrixTemplate< bool > &  out,
int  startingRow = 0 
) const
inlineinherited

Gets a given column to a vector (without modifying the matrix)

Exceptions
std::exceptionOn index out of bounds

Definition at line 475 of file CMatrixTemplate.h.

◆ extractColumns()

void mrpt::math::CMatrixTemplate< bool >::extractColumns ( size_t  firstCol,
size_t  lastCol,
CMatrixTemplate< bool > &  out 
) const
inlineinherited

Gets a series of contiguous columns.

Exceptions
std::logic_errorOn index out of bounds
See also
extractColumn
extractRows

Definition at line 449 of file CMatrixTemplate.h.

◆ extractRows()

void mrpt::math::CMatrixTemplate< bool >::extractRows ( size_t  firstRow,
size_t  lastRow,
CMatrixTemplate< bool > &  out 
) const
inlineinherited

Gets a series of contiguous rows.

Exceptions
std::logic_errorOn index out of bounds
See also
extractRow
extractColumns

Definition at line 439 of file CMatrixTemplate.h.

◆ extractSubmatrix() [1/2]

void mrpt::math::CMatrixTemplate< bool >::extractSubmatrix ( const size_t  row1,
const size_t  row2,
const size_t  col1,
const size_t  col2,
CMatrixTemplate< bool > &  out 
) const
inlineinherited

Get a submatrix, given its bounds.

See also
extractSubmatrixSymmetricalBlocks

Definition at line 406 of file CMatrixTemplate.h.

◆ extractSubmatrix() [2/2]

void mrpt::math::CMatrixTemplate< bool >::extractSubmatrix ( const size_t  row1,
const size_t  row2,
const size_t  col1,
const size_t  col2,
EIGEN_MATRIX &  out 
) const
inlineinherited

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 420 of file CMatrixTemplate.h.

◆ fillAll()

void mrpt::math::CMatrixTemplate< bool >::fillAll ( const bool &  val)
inlineinherited

Fill all the elements with a given value (Note: named "fillAll" since "fill" will be used by child classes)

Definition at line 127 of file CMatrixTemplate.h.

◆ get_unsafe() [1/2]

const bool & mrpt::math::CMatrixTemplate< bool >::get_unsafe ( size_t  row,
size_t  col 
) const
inlineinherited

Fast but unsafe method to read a value from the matrix.

Definition at line 358 of file CMatrixTemplate.h.

◆ get_unsafe() [2/2]

bool & mrpt::math::CMatrixTemplate< bool >::get_unsafe ( size_t  row,
size_t  col 
)
inlineinherited

Fast but unsafe method to get a reference from the matrix.

Definition at line 369 of file CMatrixTemplate.h.

◆ get_unsafe_row() [1/2]

bool * mrpt::math::CMatrixTemplate< bool >::get_unsafe_row ( size_t  row)
inlineinherited

Fast but unsafe method to obtain a pointer to a given row of the matrix (Use only in time critical applications)

Definition at line 380 of file CMatrixTemplate.h.

◆ get_unsafe_row() [2/2]

const bool * mrpt::math::CMatrixTemplate< bool >::get_unsafe_row ( size_t  row) const
inlineinherited

Fast but unsafe method to obtain a pointer to a given row of the matrix (Use only in critical applications)

Definition at line 391 of file CMatrixTemplate.h.

◆ getAsVector()

void mrpt::math::CMatrixTemplate< bool >::getAsVector ( std::vector< bool > &  out) const
inlineinherited

Returns a vector containing the matrix's values.

Definition at line 560 of file CMatrixTemplate.h.

◆ getColCount()

size_t mrpt::math::CMatrixTemplate< bool >::getColCount ( ) const
inlineinherited

Number of columns in the matrix.

See also
getRowCount, getColCount, nr, nc

Definition at line 244 of file CMatrixTemplate.h.

◆ getRowCount()

size_t mrpt::math::CMatrixTemplate< bool >::getRowCount ( ) const
inlineinherited

Number of rows in the matrix.

See also
getRowCount, getColCount, nr, nc

Definition at line 239 of file CMatrixTemplate.h.

◆ GetRuntimeClass()

virtual const mrpt::utils::TRuntimeClassId* mrpt::math::CMatrixB::GetRuntimeClass ( ) const
virtual

Returns information about the class of an object in runtime.

Reimplemented from mrpt::utils::CSerializable.

◆ insertCol()

void mrpt::math::CMatrixTemplate< bool >::insertCol ( size_t  nCol,
const std::vector< bool > &  in 
)
inlineinherited

Inserts a column from a vector, replacing the current contents of that column.

Exceptions
std::exceptionOn index out of bounds
See also
extractCol

Definition at line 547 of file CMatrixTemplate.h.

◆ operator delete() [1/3]

void mrpt::math::CMatrixB::operator delete ( void ptr)
throw (
)
inline

Definition at line 29 of file CMatrixB.h.

◆ operator delete() [2/3]

void mrpt::math::CMatrixB::operator delete ( void memory,
void ptr 
)
throw (
)
inline

Definition at line 29 of file CMatrixB.h.

◆ operator delete() [3/3]

void mrpt::math::CMatrixB::operator delete ( void ptr,
const std::nothrow_t &   
)
throw (
)
inline

Definition at line 29 of file CMatrixB.h.

◆ operator delete[]()

void mrpt::math::CMatrixB::operator delete[] ( void ptr)
throw (
)
inline

Definition at line 29 of file CMatrixB.h.

◆ operator new() [1/3]

static void* mrpt::math::CMatrixB::operator new ( size_t  size,
void ptr 
)
inlinestatic

Definition at line 29 of file CMatrixB.h.

◆ operator new() [2/3]

void* mrpt::math::CMatrixB::operator new ( size_t  size,
const std::nothrow_t &   
)
throw (
)
inline

Definition at line 29 of file CMatrixB.h.

◆ operator new() [3/3]

void* mrpt::math::CMatrixB::operator new ( size_t  size)
inline

Definition at line 29 of file CMatrixB.h.

◆ operator new[]()

void* mrpt::math::CMatrixB::operator new[] ( size_t  size)
inline

Definition at line 29 of file CMatrixB.h.

◆ operator()() [1/5]

bool & mrpt::math::CMatrixTemplate< bool >::operator() ( size_t  row,
size_t  col 
)
inlineinherited

Subscript operator to get/set individual elements.

Definition at line 269 of file CMatrixTemplate.h.

◆ operator()() [2/5]

const bool & mrpt::math::CMatrixTemplate< bool >::operator() ( size_t  row,
size_t  col 
) const
inlineinherited

Subscript operator to get individual elements.

Definition at line 280 of file CMatrixTemplate.h.

◆ operator()() [3/5]

bool & mrpt::math::CMatrixTemplate< bool >::operator() ( size_t  ith)
inlineinherited

Subscript operator to get/set an individual element from a row or column matrix.

Exceptions
std::exceptionIf the object is not a column or row matrix.

Definition at line 292 of file CMatrixTemplate.h.

◆ operator()() [4/5]

bool mrpt::math::CMatrixTemplate< bool >::operator() ( size_t  ith) const
inlineinherited

Subscript operator to get/set an individual element from a row or column matrix.

Exceptions
std::exceptionIf the object is not a column or row matrix.

Definition at line 320 of file CMatrixTemplate.h.

◆ operator()() [5/5]

CMatrixTemplate<bool > mrpt::math::CMatrixTemplate< bool >::operator() ( const size_t  row1,
const size_t  row2,
const size_t  col1,
const size_t  col2 
) const
inlineinherited

Subscript operator to get a submatrix.

Definition at line 397 of file CMatrixTemplate.h.

◆ operator=()

CMatrixB& mrpt::math::CMatrixB::operator= ( const CMatrixBool m)
inline

Assignment operator for float matrixes.

Definition at line 36 of file CMatrixB.h.

References mrpt::math::CMatrixBool::operator=().

◆ readFromStream()

void CMatrixB::readFromStream ( mrpt::utils::CStream in,
int  version 
)
protectedvirtual

Introduces a pure virtual method responsible for loading from a CStream This can not be used directly be users, instead use "stream >> object;" for reading it from a stream or "stream >> object_ptr;" if the class is unknown apriori.

Parameters
inThe input binary stream where the object data must read from.
versionThe version of the object stored in the stream: use this version number in your code to know how to read the incoming data.
Exceptions
std::exceptionOn any error, see CStream::ReadBuffer
See also
CStream

Implements mrpt::utils::CSerializable.

Definition at line 47 of file CMatrixB.cpp.

References MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION, setSize(), THROW_EXCEPTION, and version.

◆ realloc()

void mrpt::math::CMatrixTemplate< bool >::realloc ( size_t  row,
size_t  col,
bool  newElementsToZero = false 
)
inlineprotectedinherited

Internal use only: It reallocs the memory for the 2D matrix, maintaining the previous contents if posible.

Definition at line 71 of file CMatrixTemplate.h.

◆ resize()

void mrpt::math::CMatrixTemplate< bool >::resize ( const CMatrixTemplateSize siz,
bool  zeroNewElements = false 
)
inlineinherited

This method just checks has no effects in this class, but raises an exception if the expected size does not match.

Definition at line 262 of file CMatrixTemplate.h.

◆ set_unsafe()

void mrpt::math::CMatrixTemplate< bool >::set_unsafe ( size_t  row,
size_t  col,
const bool &  v 
)
inlineinherited

Fast but unsafe method to write a value in the matrix.

Definition at line 347 of file CMatrixTemplate.h.

◆ setSize()

void mrpt::math::CMatrixTemplate< bool >::setSize ( size_t  row,
size_t  col,
bool  zeroNewElements = false 
)
inlineinherited

Changes the size of matrix, maintaining the previous contents.

Definition at line 256 of file CMatrixTemplate.h.

◆ size()

CMatrixTemplateSize mrpt::math::CMatrixTemplate< bool >::size ( ) const
inlineinherited

Get a 2-vector with [NROWS NCOLS] (as in MATLAB command size(x))

Definition at line 247 of file CMatrixTemplate.h.

◆ swap()

void mrpt::math::CMatrixTemplate< bool >::swap ( CMatrixTemplate< bool > &  o)
inlineinherited

Swap with another matrix very efficiently (just swaps a pointer and two integer values).

Definition at line 134 of file CMatrixTemplate.h.

◆ writeToMatlab()

virtual mxArray* mrpt::utils::CSerializable::writeToMatlab ( ) const
inlinevirtualinherited

Introduces a pure virtual method responsible for writing to a mxArray Matlab object, typically a MATLAB struct whose contents are documented in each derived class.

Returns
A new mxArray (caller is responsible of memory freeing) or NULL is class does not support conversion to MATLAB.

Definition at line 79 of file CSerializable.h.

◆ writeToStream()

void CMatrixB::writeToStream ( mrpt::utils::CStream out,
int *  getVersion 
) const
protectedvirtual

Introduces a pure virtual method responsible for writing to a CStream.

This can not be used directly be users, instead use "stream << object;" for writing it to a stream.

Parameters
outThe output binary stream where object must be dumped.
getVersionIf NULL, the object must be dumped. If not, only the version of the object dump must be returned in this pointer. This enables the versioning of objects dumping and backward compatibility with previously stored data.
Exceptions
std::exceptionOn any error, see CStream::WriteBuffer
See also
CStream

Implements mrpt::utils::CSerializable.

Definition at line 26 of file CMatrixB.cpp.

Member Data Documentation

◆ _init_CMatrixB

mrpt::utils::CLASSINIT mrpt::math::CMatrixB::_init_CMatrixB
staticprotected

Definition at line 29 of file CMatrixB.h.

◆ classCMatrixB

mrpt::utils::TRuntimeClassId mrpt::math::CMatrixB::classCMatrixB
static

Definition at line 29 of file CMatrixB.h.

◆ classCObject

const mrpt::utils::TRuntimeClassId mrpt::utils::CObject::classCObject
staticinherited

Definition at line 118 of file CObject.h.

◆ classCSerializable

const mrpt::utils::TRuntimeClassId mrpt::utils::CSerializable::classCSerializable
staticinherited

Definition at line 42 of file CSerializable.h.

◆ classinfo

const mrpt::utils::TRuntimeClassId* mrpt::math::CMatrixB::classinfo
static

Definition at line 29 of file CMatrixB.h.

◆ m_Cols

size_t mrpt::math::CMatrixTemplate< bool >::m_Cols
protectedinherited

Definition at line 67 of file CMatrixTemplate.h.

◆ m_Rows

size_t mrpt::math::CMatrixTemplate< bool >::m_Rows
protectedinherited

Definition at line 67 of file CMatrixTemplate.h.

◆ m_Val

bool ** mrpt::math::CMatrixTemplate< bool >::m_Val
protectedinherited

Definition at line 66 of file CMatrixTemplate.h.




Page generated by Doxygen 1.8.14 for MRPT 1.5.7 Git: 5902e14cc Wed Apr 24 15:04:01 2019 +0200 at lun oct 28 01:39:17 CET 2019