MRPT logo

mrpt::math::CMatrixTemplate< T > Class Template Reference

This template class provides the basic functionality for a general 2D any-size, resizable container of numerical or non-numerical elements. More...

#include <mrpt/math/CMatrixTemplate.h>

Inheritance diagram for mrpt::math::CMatrixTemplate< T >:

mrpt::math::CMatrixTemplateNumeric< float > mrpt::math::CMatrixTemplateNumeric< T > mrpt::math::CMatrix

List of all members.

Public Types

typedef T value_type
 The type of the matrix elements.

Public Member Functions

void extractCol (size_t nCol, std::vector< T > &out, int startingRow=0) const
 Returns a given column to a vector (without modifying the matrix)
Exceptions:
std::exception On index out of bounds.

void extractCol (size_t nCol, CMatrixTemplate< T > &out, int startingRow=0) const
 Gets a given column to a vector (without modifying the matrix)
Exceptions:
std::exception On index out of bounds.

void swapCols (size_t nCol1, size_t nCol2)
 Swap two columns
Exceptions:
std::exception On index out of bounds.

void swapRows (size_t nRow1, size_t nRow2)
 Swap two rows
Exceptions:
std::exception On index out of bounds.

template<class F >
void extractRow (size_t nRow, std::vector< F > &out, size_t startingCol=0) const
 Gets a given row to a vector (without modifying the matrix)
Exceptions:
std::exception On index out of bounds.

template<class F >
void extractRow (size_t nRow, CMatrixTemplate< F > &out, size_t startingCol=0) const
 Gets a given row to a vector (without modifying the matrix)
Exceptions:
std::exception On index out of bounds.

 CMatrixTemplate (const CMatrixTemplate &m)
 Constructors.
 CMatrixTemplate (size_t row=3, size_t col=3)
 CMatrixTemplate (const CMatrixTemplate &m, const size_t cropRowCount, const size_t cropColCount)
 Copy constructor & crop from another matrix.
template<typename V , size_t N>
 CMatrixTemplate (size_t row, size_t col, V(&theArray)[N])
 Constructor from a given size and a C array.
template<typename V >
 CMatrixTemplate (size_t row, size_t col, const V &theVector)
 Constructor from a given size and a STL container (std::vector, std::list,.
virtual ~CMatrixTemplate ()
 Destructor.
CMatrixTemplateoperator= (const CMatrixTemplate &m)
 Assignment operator from another matrix.
template<typename V , size_t N>
CMatrixTemplateoperator= (V(&theArray)[N])
 Assignment operator for initializing from a C array (The matrix must be set to the correct size before invoking this asignament).
size_t getRowCount () const
 Number of rows in the matrix.
size_t getColCount () const
 Number of columns in the matrix.
void setSize (size_t row, size_t col)
 Changes the size of matrix, maintaining the previous contents.
bool IsSquare () const
 Check for type of matrix.
T & operator() (size_t row, size_t col)
 Subscript operator to get/set individual elements.
operator() (size_t row, size_t col) const
 Subscript operator to get/set individual elements.
T & operator() (size_t ith)
 Subscript operator to get/set an individual element from a row or column matrix.
operator() (size_t ith) const
 Subscript operator to get/set an individual element from a row or column matrix.
void set_unsafe (size_t row, size_t col, const T &v)
 Fast but unsafe method to write a value in the matrix.
get_unsafe (size_t row, size_t col) const
 Fast but unsafe method to read a value from the matrix.
T & get_unsafe (size_t row, size_t col)
 Fast but unsafe method to get a reference from the matrix.
T * 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 time critical applications).
void extractRows (size_t firstRow, size_t lastRow, CMatrixTemplate< T > &out) const
 Gets a series of contiguous rows.
void extractColumns (size_t firstCol, size_t lastCol, CMatrixTemplate< T > &out) const
 Gets a series of contiguous columns.
void insertRow (size_t nRow, const std::vector< T > &in)
 Inserts a row from a vector, replacing the current contents of that row.
void appendRow (const std::vector< T > &in)
 Appends a new row to the MxN matrix from a 1xN vector.
void appendCol (const std::vector< T > &in)
 Appends a new column to the matrix from a vector.
void insertCol (size_t nCol, const std::vector< T > &in)
 Inserts a column from a vector, replacing the current contents of that column.
template<class R >
void insertMatrix (const size_t nRow, const size_t nCol, const CMatrixTemplate< R > &in)
 Inserts a matrix into this matrix Notice that the matrix must "fit" into the existing size of this matrix.
void insertMatrixTranspose (const size_t nRow, const size_t nCol, const CMatrixTemplate< T > &in)
 Inserts the transpose of a given matrix into this matrix Notice that the matrix must "fit" into the existing size of this matrix.
template<size_t NROWS, size_t NCOLS>
void insertMatrix (const size_t nRow, const size_t nCol, const CMatrixFixedNumeric< T, NROWS, NCOLS > &in)
 Inserts a fixed-size matrix into this matrix Notice that the matrix must "fit" into the existing size of this matrix.
template<size_t NROWS, size_t NCOLS>
void insertMatrixTranspose (const size_t nRow, const size_t nCol, const CMatrixFixedNumeric< T, NROWS, NCOLS > &in)
 Inserts the transpose of a given fixed-size matrix into this matrix Notice that the matrix must "fit" into the existing size of this matrix.
void insertMatrix (size_t nRow, size_t nCol, const std::vector< T > &in)
 Inserts a matrix line (vector) into this matrix Notice that the matrix must "fit" into the existing size of this matrix.
void joinMatrix (const CMatrixTemplate< T > &left_up, const CMatrixTemplate< T > &right_up, const CMatrixTemplate< T > &left_down, const CMatrixTemplate< T > &right_down)
 Inserts 4 matrixes corresponding to the "four corners" into this matrix.
void fill (const T &val)
 Fill the matrix with a given value:.
void extractSubmatrix (const size_t row1, const size_t row2, const size_t col1, const size_t col2, CMatrixTemplate< T > &out) const
 Get a submatrix, given its bounds.
CMatrixTemplate< T > operator() (const size_t row1, const size_t row2, const size_t col1, const size_t col2) const
 Subscript operator to get a submatrix.
void exchangeColumns (size_t col1, size_t col2)
 Interchanges two columns of the matrix.
void exchangeRows (size_t row1, size_t row2)
 Interchanges two rows of the matrix.
void deleteRow (size_t row)
 Deletes a row of the matrix.
void deleteColumn (size_t col)
 Deletes a column of the matrix.
template<class R >
void extractMatrix (size_t nRow, size_t nCol, CMatrixTemplate< R > &in) const
 Extract a sub matrix from a matrix:
Exceptions:
std::exception On index out of bounds The output matrix must have been previously set to the desired size.

void extractMatrix (size_t nRow, size_t nCol, size_t nrows, size_t ncols, CMatrixTemplate< T > &outMat) const
 Extract a sub matrix from a matrix:
Exceptions:
std::exception On index out of bounds The output matrix must have been previously set to the desired size.

void extractMatrix (size_t nRow, size_t nCol, std::vector< T > &in) const
 Extract a sub matrix (vector) from a matrix:
Exceptions:
std::exception On index out of bounds The output matrix must have been previously set to the desired size.

template<size_t NROWS, size_t NCOLS>
void extractMatrix (const size_t nRow, const size_t nCol, CMatrixFixedNumeric< T, NROWS, NCOLS > &outMat) const
 Extract a sub matrix from a matrix (in the form of a fixed-size matrix)
Exceptions:
std::exception On index out of bounds The output matrix settles the size of the submatrix to extract, and (nRow,nCol) are the indices of the first element in the submatrix: e.g.

std::vector< T > extractMatrix (size_t nRow, size_t nCol, size_t ncols) const
 Extract a sub matrix (vector) from a matrix:
Exceptions:
std::exception On index out of bounds The output matrix must have been previously set to the desired size.

std::string inMatlabFormat () const
 Dump matrix in matlab format.
bool fromMatlabStringFormat (const std::string &s)
 Read a matrix from a string in Matlab-like format, for example "[1 0 2; 0 4 -1]" The string must start with '[' and end with ']'.
void removeColumns (const mrpt::vector_size_t &idxsToRemove, bool vectorIsAlreadySorted=false)
 Removes a set of columns by their indexes (0:first), given by the vector "idxsToRemove".
void getAsVector (std::vector< T > &out) const
 Returns a vector containing the matrix's values.
Import/export as text
void saveToTextFile (const std::string &file, TMatrixTextFileFormat fileFormat=MATRIX_FORMAT_ENG, bool appendMRPTHeader=false, const std::string &userHeader=std::string("")) const
 Save matrix to a text file, compatible with MATLAB text format.
void loadFromTextFile (const std::string &file)
 Load matrix from a text file, compatible with MATLAB text format.

Protected Member Functions

void realloc (size_t row, size_t col, bool newElementsToZero=false)
 Internal use only: It realloc the memory for the 2D matrix, maintaining the previous contents if posible.

Protected Attributes

T ** m_Val
size_t m_Rows
size_t m_Cols


Detailed Description

template<class T>
class mrpt::math::CMatrixTemplate< T >

This template class provides the basic functionality for a general 2D any-size, resizable container of numerical or non-numerical elements.

NOTES:

Note:
Memory blocks for each row are 16-bytes aligned (since MRPT 0.7.0).
See also:
CMatrixTemplateNumeric

Definition at line 74 of file CMatrixTemplate.h.


Member Typedef Documentation

template<class T >
typedef T mrpt::math::CMatrixTemplate< T >::value_type

The type of the matrix elements.

Definition at line 77 of file CMatrixTemplate.h.


Constructor & Destructor Documentation

template<class T >
mrpt::math::CMatrixTemplate< T >::CMatrixTemplate ( const CMatrixTemplate< T > &  m  )  [inline]

Constructors.

Definition at line 237 of file CMatrixTemplate.h.

template<class T >
mrpt::math::CMatrixTemplate< T >::CMatrixTemplate ( size_t  row = 3,
size_t  col = 3 
) [inline]

Definition at line 242 of file CMatrixTemplate.h.

template<class T >
mrpt::math::CMatrixTemplate< T >::CMatrixTemplate ( const CMatrixTemplate< T > &  m,
const size_t  cropRowCount,
const size_t  cropColCount 
) [inline]

Copy constructor & crop from another matrix.

Definition at line 249 of file CMatrixTemplate.h.

template<class T >
template<typename V , size_t N>
mrpt::math::CMatrixTemplate< T >::CMatrixTemplate ( size_t  row,
size_t  col,
V(&)  theArray[N] 
) [inline]

Constructor from a given size and a C array.

The array length must match cols x row.

  const double numbers[] = {
    1,2,3,
    4,5,6 };
         CMatrixDouble   M(3,2, numbers);

Definition at line 270 of file CMatrixTemplate.h.

template<class T >
template<typename V >
mrpt::math::CMatrixTemplate< T >::CMatrixTemplate ( size_t  row,
size_t  col,
const V &  theVector 
) [inline]

Constructor from a given size and a STL container (std::vector, std::list,.

..) with the initial values. The vector length must match cols x row.

Definition at line 289 of file CMatrixTemplate.h.

template<class T >
virtual mrpt::math::CMatrixTemplate< T >::~CMatrixTemplate (  )  [inline, virtual]

Destructor.

Definition at line 307 of file CMatrixTemplate.h.


Member Function Documentation

template<class T >
void mrpt::math::CMatrixTemplate< T >::appendCol ( const std::vector< T > &  in  )  [inline]

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::exception On size mismatch.
See also:
extractCol

appendRow

Definition at line 563 of file CMatrixTemplate.h.

template<class T >
void mrpt::math::CMatrixTemplate< T >::appendRow ( const std::vector< T > &  in  )  [inline]

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.

    CMatrixDouble  M(0,0);
    vector_double  v(7),w(7);
    // ...
    M.appendRow(v);
    M.appendRow(w);
Exceptions:
std::exception On incorrect vector length.
See also:
extractRow

appendCol

Definition at line 534 of file CMatrixTemplate.h.

template<class T >
void mrpt::math::CMatrixTemplate< T >::deleteColumn ( size_t  col  )  [inline]

Deletes a column of the matrix.

Definition at line 768 of file CMatrixTemplate.h.

template<class T >
void mrpt::math::CMatrixTemplate< T >::deleteRow ( size_t  row  )  [inline]

Deletes a row of the matrix.

Definition at line 758 of file CMatrixTemplate.h.

template<class T >
void mrpt::math::CMatrixTemplate< T >::exchangeColumns ( size_t  col1,
size_t  col2 
) [inline]

Interchanges two columns of the matrix.

Definition at line 730 of file CMatrixTemplate.h.

template<class T >
void mrpt::math::CMatrixTemplate< T >::exchangeRows ( size_t  row1,
size_t  row2 
) [inline]

Interchanges two rows of the matrix.

Definition at line 744 of file CMatrixTemplate.h.

template<class T >
void mrpt::math::CMatrixTemplate< T >::extractCol ( size_t  nCol,
CMatrixTemplate< T > &  out,
int  startingRow = 0 
) const [inline]

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

Exceptions:
std::exception On index out of bounds.

Definition at line 156 of file CMatrixTemplate.h.

template<class T >
void mrpt::math::CMatrixTemplate< T >::extractCol ( size_t  nCol,
std::vector< T > &  out,
int  startingRow = 0 
) const [inline]

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

Exceptions:
std::exception On index out of bounds.

Definition at line 138 of file CMatrixTemplate.h.

template<class T >
void mrpt::math::CMatrixTemplate< T >::extractColumns ( size_t  firstCol,
size_t  lastCol,
CMatrixTemplate< T > &  out 
) const [inline]

Gets a series of contiguous columns.

Exceptions:
std::logic_error On index out of bounds
See also:
extractColumn

extractRows

Definition at line 502 of file CMatrixTemplate.h.

template<class T >
std::vector<T> mrpt::math::CMatrixTemplate< T >::extractMatrix ( size_t  nRow,
size_t  nCol,
size_t  ncols 
) const [inline]

Extract a sub matrix (vector) from a matrix:

Exceptions:
std::exception On index out of bounds The output matrix must have been previously set to the desired size.

(by AJOGD @ JAN-2007)

Definition at line 847 of file CMatrixTemplate.h.

template<class T >
template<size_t NROWS, size_t NCOLS>
void mrpt::math::CMatrixTemplate< T >::extractMatrix ( const size_t  nRow,
const size_t  nCol,
CMatrixFixedNumeric< T, NROWS, NCOLS > &  outMat 
) const [inline]

Extract a sub matrix from a matrix (in the form of a fixed-size matrix)

Exceptions:
std::exception On index out of bounds The output matrix settles the size of the submatrix to extract, and (nRow,nCol) are the indices of the first element in the submatrix: e.g.

(0,0) means extract a submatrix from the top-left corner

Definition at line 838 of file CMatrixTemplate.h.

template<class T >
void mrpt::math::CMatrixTemplate< T >::extractMatrix ( size_t  nRow,
size_t  nCol,
std::vector< T > &  in 
) const [inline]

Extract a sub matrix (vector) from a matrix:

Exceptions:
std::exception On index out of bounds The output matrix must have been previously set to the desired size.

(by AJOGD @ JAN-2007)

Definition at line 819 of file CMatrixTemplate.h.

template<class T >
void mrpt::math::CMatrixTemplate< T >::extractMatrix ( size_t  nRow,
size_t  nCol,
size_t  nrows,
size_t  ncols,
CMatrixTemplate< T > &  outMat 
) const [inline]

Extract a sub matrix from a matrix:

Exceptions:
std::exception On index out of bounds The output matrix must have been previously set to the desired size.

(by AJOGD @ JAN-2007)

Definition at line 801 of file CMatrixTemplate.h.

template<class T >
template<class R >
void mrpt::math::CMatrixTemplate< T >::extractMatrix ( size_t  nRow,
size_t  nCol,
CMatrixTemplate< R > &  in 
) const [inline]

Extract a sub matrix from a matrix:

Exceptions:
std::exception On index out of bounds The output matrix must have been previously set to the desired size.

(by AJOGD @ JAN-2007)

Definition at line 782 of file CMatrixTemplate.h.

Referenced by mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::extractColumns(), and mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::extractRows().

template<class T >
template<class F >
void mrpt::math::CMatrixTemplate< T >::extractRow ( size_t  nRow,
CMatrixTemplate< F > &  out,
size_t  startingCol = 0 
) const [inline]

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

Exceptions:
std::exception On index out of bounds.

Definition at line 221 of file CMatrixTemplate.h.

template<class T >
template<class F >
void mrpt::math::CMatrixTemplate< T >::extractRow ( size_t  nRow,
std::vector< F > &  out,
size_t  startingCol = 0 
) const [inline]

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

Exceptions:
std::exception On index out of bounds.

Definition at line 203 of file CMatrixTemplate.h.

Referenced by mrpt::utils::CImage::rectifyImageInPlace().

template<class T >
void mrpt::math::CMatrixTemplate< T >::extractRows ( size_t  firstRow,
size_t  lastRow,
CMatrixTemplate< T > &  out 
) const [inline]

Gets a series of contiguous rows.

Exceptions:
std::logic_error On index out of bounds
See also:
extractRow

extractColumns

Definition at line 493 of file CMatrixTemplate.h.

template<class T >
void mrpt::math::CMatrixTemplate< T >::extractSubmatrix ( const size_t  row1,
const size_t  row2,
const size_t  col1,
const size_t  col2,
CMatrixTemplate< T > &  out 
) const [inline]

Get a submatrix, given its bounds.

Definition at line 706 of file CMatrixTemplate.h.

Referenced by mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::operator()().

template<class T >
void mrpt::math::CMatrixTemplate< T >::fill ( const T &  val  )  [inline]

Fill the matrix with a given value:.

Definition at line 697 of file CMatrixTemplate.h.

template<class T >
bool mrpt::math::CMatrixTemplate< T >::fromMatlabStringFormat ( const std::string &  s  )  [inline]

Read a matrix from a string in Matlab-like format, for example "[1 0 2; 0 4 -1]" The string must start with '[' and end with ']'.

Rows are separated by semicolons ';' and columns in each row by one or more whitespaces ' ' or tabs.

This format is also used for CConfigFile::read_matrix.

This template method can be instantiated for matrices of the types: int, long, unsinged int, unsigned long, float, double, long double

Returns:
true on success. false if the string is malformed, and then the matrix will be resized to 0x0.
See also:
inMatlabFormat, CConfigFile::read_matrix

Definition at line 896 of file CMatrixTemplate.h.

Referenced by mrpt::math::CMatrixFixedNumeric< float, 4, 4 >::fromMatlabStringFormat().

template<class T >
T& mrpt::math::CMatrixTemplate< T >::get_unsafe ( size_t  row,
size_t  col 
) [inline]

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

Definition at line 477 of file CMatrixTemplate.h.

template<class T >
T mrpt::math::CMatrixTemplate< T >::get_unsafe ( size_t  row,
size_t  col 
) const [inline]

template<class T >
T* mrpt::math::CMatrixTemplate< T >::get_unsafe_row ( size_t  row  )  const [inline]

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

Definition at line 483 of file CMatrixTemplate.h.

Referenced by mrpt::math::extractFixMatrixFromDynMatrix(), mrpt::math::fixedToDynMatrix(), mrpt::math::insertMatrixFixIntoDyn(), and mrpt::math::CMatrixFixedNumeric< float, 4, 4 >::operator=().

template<class T >
void mrpt::math::CMatrixTemplate< T >::getAsVector ( std::vector< T > &  out  )  const [inline]

Returns a vector containing the matrix's values.

Definition at line 1120 of file CMatrixTemplate.h.

template<class T >
size_t mrpt::math::CMatrixTemplate< T >::getColCount (  )  const [inline]

template<class T >
size_t mrpt::math::CMatrixTemplate< T >::getRowCount (  )  const [inline]

template<class T >
std::string mrpt::math::CMatrixTemplate< T >::inMatlabFormat (  )  const [inline]

Dump matrix in matlab format.

This template method can be instantiated for matrices of the types: int, long, unsinged int, unsigned long, float, double, long double

See also:
fromMatlabStringFormat

Definition at line 866 of file CMatrixTemplate.h.

template<class T >
void mrpt::math::CMatrixTemplate< T >::insertCol ( size_t  nCol,
const std::vector< T > &  in 
) [inline]

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

Exceptions:
std::exception On index out of bounds
See also:
extractCol

Definition at line 578 of file CMatrixTemplate.h.

template<class T >
void mrpt::math::CMatrixTemplate< T >::insertMatrix ( size_t  nRow,
size_t  nCol,
const std::vector< T > &  in 
) [inline]

Inserts a matrix line (vector) into this matrix Notice that the matrix must "fit" into the existing size of this matrix.

Exceptions:
std::exception On index out of bounds
See also:
extractCol By AJOGD @ MAR-2007

Definition at line 666 of file CMatrixTemplate.h.

template<class T >
template<size_t NROWS, size_t NCOLS>
void mrpt::math::CMatrixTemplate< T >::insertMatrix ( const size_t  nRow,
const size_t  nCol,
const CMatrixFixedNumeric< T, NROWS, NCOLS > &  in 
) [inline]

Inserts a fixed-size matrix into this matrix Notice that the matrix must "fit" into the existing size of this matrix.

Parameters:
in The submatrix to insert into 'this' matrix.
nRow The row in 'this' matrix where the submatrix will be inserted (0:first).
nCol The column in 'this' matrix where the submatrix will be inserted (0:first).
Exceptions:
std::exception On index out of bounds
See also:
extractCol, insertMatrixTranspose

Definition at line 643 of file CMatrixTemplate.h.

template<class T >
template<class R >
void mrpt::math::CMatrixTemplate< T >::insertMatrix ( const size_t  nRow,
const size_t  nCol,
const CMatrixTemplate< R > &  in 
) [inline]

Inserts a matrix into this matrix Notice that the matrix must "fit" into the existing size of this matrix.

Parameters:
in The submatrix to insert into 'this' matrix.
nRow The row in 'this' matrix where the submatrix will be inserted (0:first).
nCol The column in 'this' matrix where the submatrix will be inserted (0:first).
Exceptions:
std::exception On index out of bounds
See also:
extractCol

Definition at line 598 of file CMatrixTemplate.h.

Referenced by mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::joinMatrix().

template<class T >
template<size_t NROWS, size_t NCOLS>
void mrpt::math::CMatrixTemplate< T >::insertMatrixTranspose ( const size_t  nRow,
const size_t  nCol,
const CMatrixFixedNumeric< T, NROWS, NCOLS > &  in 
) [inline]

Inserts the transpose of a given fixed-size matrix into this matrix Notice that the matrix must "fit" into the existing size of this matrix.

Parameters:
in The submatrix to insert into 'this' matrix.
nRow The row in 'this' matrix where the submatrix will be inserted (0:first).
nCol The column in 'this' matrix where the submatrix will be inserted (0:first).
Exceptions:
std::exception On index out of bounds
See also:
extractCol, insertMatrix

Definition at line 656 of file CMatrixTemplate.h.

template<class T >
void mrpt::math::CMatrixTemplate< T >::insertMatrixTranspose ( const size_t  nRow,
const size_t  nCol,
const CMatrixTemplate< T > &  in 
) [inline]

Inserts the transpose of a given matrix into this matrix Notice that the matrix must "fit" into the existing size of this matrix.

Parameters:
in The submatrix to insert into 'this' matrix.
nRow The row in 'this' matrix where the submatrix will be inserted (0:first).
nCol The column in 'this' matrix where the submatrix will be inserted (0:first).
Exceptions:
std::exception On index out of bounds
See also:
extractCol

Definition at line 620 of file CMatrixTemplate.h.

template<class T >
void mrpt::math::CMatrixTemplate< T >::insertRow ( size_t  nRow,
const std::vector< T > &  in 
) [inline]

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

Exceptions:
std::exception On index out of bounds
See also:
extractRow

Definition at line 510 of file CMatrixTemplate.h.

Referenced by mrpt::math::CLevenbergMarquardtTempl< NUMTYPE, USERPARAM >::execute().

template<class T >
bool mrpt::math::CMatrixTemplate< T >::IsSquare (  )  const [inline]

Check for type of matrix.

Definition at line 378 of file CMatrixTemplate.h.

template<class T >
void mrpt::math::CMatrixTemplate< T >::joinMatrix ( const CMatrixTemplate< T > &  left_up,
const CMatrixTemplate< T > &  right_up,
const CMatrixTemplate< T > &  left_down,
const CMatrixTemplate< T > &  right_down 
) [inline]

Inserts 4 matrixes corresponding to the "four corners" into this matrix.

Exceptions:
std::exception On index out of bounds
See also:
insertMatrix

Definition at line 682 of file CMatrixTemplate.h.

template<class T >
void mrpt::math::CMatrixTemplate< T >::loadFromTextFile ( const std::string &  file  )  [inline]

Load matrix from a text file, compatible with MATLAB text format.

Lines starting with '' or '#' are interpreted as comments and ignored.

See also:
saveToTextFile, CMatrixTemplate::fromMatlabStringFormat

Definition at line 986 of file CMatrixTemplate.h.

Referenced by mrpt::math::CVectorTemplate< double >::loadFromTextFile().

template<class T >
CMatrixTemplate<T> mrpt::math::CMatrixTemplate< T >::operator() ( const size_t  row1,
const size_t  row2,
const size_t  col1,
const size_t  col2 
) const [inline]

Subscript operator to get a submatrix.

Definition at line 722 of file CMatrixTemplate.h.

template<class T >
T mrpt::math::CMatrixTemplate< T >::operator() ( size_t  ith  )  const [inline]

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

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

Definition at line 436 of file CMatrixTemplate.h.

template<class T >
T& mrpt::math::CMatrixTemplate< T >::operator() ( size_t  ith  )  [inline]

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

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

Definition at line 408 of file CMatrixTemplate.h.

template<class T >
T mrpt::math::CMatrixTemplate< T >::operator() ( size_t  row,
size_t  col 
) const [inline]

Subscript operator to get/set individual elements.

Definition at line 396 of file CMatrixTemplate.h.

template<class T >
T& mrpt::math::CMatrixTemplate< T >::operator() ( size_t  row,
size_t  col 
) [inline]

Subscript operator to get/set individual elements.

Definition at line 385 of file CMatrixTemplate.h.

template<class T >
template<typename V , size_t N>
CMatrixTemplate& mrpt::math::CMatrixTemplate< T >::operator= ( V(&)  theArray[N]  )  [inline]

Assignment operator for initializing from a C array (The matrix must be set to the correct size before invoking this asignament).

         CMatrixDouble   M(3,2);
  const double numbers[] = {
    1,2,3,
    4,5,6 };
  M = numbers;
Refer also to the constructor with initialization data CMatrixTemplate::CMatrixTemplate

Reimplemented in mrpt::math::CMatrixTemplateNumeric< T >, mrpt::math::CMatrixTemplateNumeric< NUMTYPE >, mrpt::math::CMatrixTemplateNumeric< double >, and mrpt::math::CMatrixTemplateNumeric< float >.

Definition at line 336 of file CMatrixTemplate.h.

template<class T >
CMatrixTemplate& mrpt::math::CMatrixTemplate< T >::operator= ( const CMatrixTemplate< T > &  m  )  [inline]

Assignment operator from another matrix.

Definition at line 314 of file CMatrixTemplate.h.

template<class T >
void mrpt::math::CMatrixTemplate< T >::realloc ( size_t  row,
size_t  col,
bool  newElementsToZero = false 
) [inline, protected]

template<class T >
void mrpt::math::CMatrixTemplate< T >::removeColumns ( const mrpt::vector_size_t idxsToRemove,
bool  vectorIsAlreadySorted = false 
) [inline]

Removes a set of columns by their indexes (0:first), given by the vector "idxsToRemove".

Parameters:
vectorIsAlreadySorted Can be set to true only when it can be assured that the vector of indices is sorted in ascending order. Otherwise, the method will sort it internally.
Note:
All the indices MUST BE UNIQUE. Behavior on duplicated indices is undefined.
Exceptions:
std::exception On index out of bounds

Definition at line 1075 of file CMatrixTemplate.h.

template<class T >
void mrpt::math::CMatrixTemplate< T >::saveToTextFile ( const std::string &  file,
TMatrixTextFileFormat  fileFormat = MATRIX_FORMAT_ENG,
bool  appendMRPTHeader = false,
const std::string &  userHeader = std::string("") 
) const [inline]

Save matrix to a text file, compatible with MATLAB text format.

Parameters:
file The target filename.
fileFormat See TMatrixTextFileFormat. The format of the numbers in the text file.
appendMRPTHeader Insert this header to the file "% File generated by MRPT. Load with MATLAB with: VAR=load(FILENAME);"
userHeader Additional text to be written at the head of the file. Typically MALAB comments "% This file blah blah". Final end-of-line is not needed.
See also:
loadFromTextFile, CMatrixTemplate::inMatlabFormat, DEBUG_SAVE_MATRIX

Definition at line 972 of file CMatrixTemplate.h.

Referenced by mrpt::math::CVectorTemplate< double >::saveToTextFile().

template<class T >
void mrpt::math::CMatrixTemplate< T >::set_unsafe ( size_t  row,
size_t  col,
const T &  v 
) [inline]

template<class T >
void mrpt::math::CMatrixTemplate< T >::setSize ( size_t  row,
size_t  col 
) [inline]

template<class T >
void mrpt::math::CMatrixTemplate< T >::swapCols ( size_t  nCol1,
size_t  nCol2 
) [inline]

Swap two columns

Exceptions:
std::exception On index out of bounds.

Definition at line 174 of file CMatrixTemplate.h.

template<class T >
void mrpt::math::CMatrixTemplate< T >::swapRows ( size_t  nRow1,
size_t  nRow2 
) [inline]

Swap two rows

Exceptions:
std::exception On index out of bounds.

Definition at line 188 of file CMatrixTemplate.h.


Member Data Documentation

template<class T >
size_t mrpt::math::CMatrixTemplate< T >::m_Cols [protected]

Definition at line 81 of file CMatrixTemplate.h.

Referenced by mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::appendCol(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::appendRow(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::CMatrixTemplate(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::deleteColumn(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::deleteRow(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::exchangeColumns(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::exchangeRows(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::extractCol(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::extractRow(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::extractRows(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::extractSubmatrix(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::fill(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::fromMatlabStringFormat(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::getAsVector(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::getColCount(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::inMatlabFormat(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::insertCol(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::insertMatrix(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::insertMatrixTranspose(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::insertRow(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::IsSquare(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::operator()(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::operator=(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::realloc(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::removeColumns(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::swapCols(), and mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::swapRows().

template<class T >
size_t mrpt::math::CMatrixTemplate< T >::m_Rows [protected]

Definition at line 81 of file CMatrixTemplate.h.

Referenced by mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::appendCol(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::appendRow(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::CMatrixTemplate(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::deleteColumn(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::deleteRow(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::exchangeColumns(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::exchangeRows(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::extractCol(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::extractColumns(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::extractRow(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::extractSubmatrix(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::fill(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::getAsVector(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::getRowCount(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::inMatlabFormat(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::insertCol(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::insertMatrix(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::insertMatrixTranspose(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::insertRow(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::IsSquare(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::operator()(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::operator=(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::realloc(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::removeColumns(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::swapCols(), and mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::swapRows().

template<class T >
T** mrpt::math::CMatrixTemplate< T >::m_Val [protected]

Definition at line 80 of file CMatrixTemplate.h.

Referenced by mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::appendCol(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::appendRow(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::CMatrixTemplate(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::deleteColumn(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::deleteRow(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::exchangeColumns(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::exchangeRows(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::extractCol(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::extractRow(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::extractSubmatrix(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::fill(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::fromMatlabStringFormat(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::get_unsafe(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::get_unsafe_row(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::getAsVector(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::inMatlabFormat(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::insertCol(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::insertRow(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::operator()(), mrpt::math::CMatrixTemplateObjects< T >::operator=(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::operator=(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::realloc(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::removeColumns(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::set_unsafe(), mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::swapCols(), and mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D >::swapRows().




Page generated by Doxygen 1.5.7.1 for MRPT 0.7.1 SVN: at Mon Aug 17 23:10:56 EDT 2009