bpp-core3
3.0.0
|
Matrix storage in one vector. More...
#include <Bpp/Numeric/Matrix/Matrix.h>
Public Member Functions | |
LinearMatrix () | |
Build a 0 x 0 matrix. More... | |
LinearMatrix (size_t nRow, size_t nCol) | |
build a nRow x nCol matrix. More... | |
LinearMatrix (const Matrix< Scalar > &m) | |
LinearMatrix & | operator= (const Matrix< Scalar > &m) |
virtual | ~LinearMatrix () |
Destructor. More... | |
LinearMatrix * | clone () const |
Create a copy of this object and send a pointer to it. More... | |
const Scalar & | operator() (size_t i, size_t j) const |
Scalar & | operator() (size_t i, size_t j) |
size_t | getNumberOfRows () const |
size_t | getNumberOfColumns () const |
std::vector< Scalar > | row (size_t i) const |
std::vector< Scalar > | col (size_t j) const |
void | resize (size_t nRows, size_t nCols) |
Resize the matrix. More... | |
void | resize (size_t nRows, size_t nCols, bool keepValues) |
Resize the matrix. More... | |
virtual bool | equals (const Matrix &m, double threshold=NumConstants::TINY()) |
Private Member Functions | |
void | resize_ (size_t nRows, size_t nCols) |
Internal basic resize fonctionnalities. More... | |
Private Attributes | |
std::vector< Scalar > | m_ |
size_t | rows_ |
size_t | cols_ |
Matrix storage in one vector.
This Matrix is a simple vector of Scalar of size n x m. Element access is in but resizing the matrix while keeping the old values is in .
Basic usage:
|
inline |
|
inline |
|
inline |
|
inlinevirtual |
|
inlinevirtual |
Create a copy of this object and send a pointer to it.
Implements bpp::Clonable.
|
inlinevirtual |
j | The index of the column. |
Implements bpp::Matrix< Scalar >.
Definition at line 394 of file Matrix.h.
References bpp::Matrix< Scalar >::getNumberOfRows(), and bpp::Matrix< Scalar >::operator()().
|
inlinevirtualinherited |
Definition at line 44 of file Matrix.h.
References bpp::Matrix< Scalar >::col(), bpp::Matrix< Scalar >::getNumberOfColumns(), bpp::Matrix< Scalar >::getNumberOfRows(), bpp::Matrix< Scalar >::resize(), and bpp::Matrix< Scalar >::row().
|
inlinevirtual |
Implements bpp::Matrix< Scalar >.
Definition at line 382 of file Matrix.h.
Referenced by bpp::LinearMatrix< Scalar >::resize().
|
inlinevirtual |
Implements bpp::Matrix< Scalar >.
Definition at line 380 of file Matrix.h.
Referenced by bpp::LinearMatrix< Scalar >::resize().
|
inlinevirtual |
|
inlinevirtual |
|
inline |
Definition at line 352 of file Matrix.h.
References bpp::Matrix< Scalar >::getNumberOfColumns(), and bpp::Matrix< Scalar >::getNumberOfRows().
|
inlinevirtual |
Resize the matrix.
nRows | The new number of rows. |
nCols | The new number of columns. |
This method resize the matrix keeping old data in place.
Implements bpp::Matrix< Scalar >.
Definition at line 410 of file Matrix.h.
References bpp::Matrix< Scalar >::resize().
|
inline |
Resize the matrix.
This task may be memory consumming if keepValues is true because it use a copy of the input matrix to keep trace of the values.
nRows | the new number of rows |
nCols | the new number of columns |
keepValues | if old values must be kept in the resized matrix. If keepValues = false, old values are still in the matrix but not at the same positions. For instance: LinearMatrix<int> m(3, 2); for (size_t i = 0 ; i < m.getNumberOfRows() ; i++) { for (size_t j = 0 ; j < m.getNumberOfColumns() ; j++) { m(i, j) = i * m.nCols() + j + 1; } } // 3x2 // [ // [1, 2] // [3, 4] // [5, 6] // ] LinearMatrix<int> m2 = m; m2.resize(2, 4, false); // resize the matrix with keepValues = false MatrixTools::print(m2); // 2x4 // [ // [1, 2, 3, 4] // [5, 6, 0, 0] // ] LinearMatrix<int> m3 = m; m3.resize(2, 4, true); // resize the matrix with keepValues = true MatrixTools::print(m3); // 2x4 // [ // [1, 2, 0, 0] // [3, 4, 0, 0] // ] |
Definition at line 458 of file Matrix.h.
References bpp::LinearMatrix< Scalar >::getNumberOfColumns(), bpp::LinearMatrix< Scalar >::getNumberOfRows(), and bpp::Matrix< Scalar >::operator()().
|
inlineprivate |
|
inlinevirtual |
i | The index of the row. |
Implements bpp::Matrix< Scalar >.
Definition at line 384 of file Matrix.h.
References bpp::Matrix< Scalar >::getNumberOfColumns(), and bpp::Matrix< Scalar >::operator()().
|
private |
|
private |
|
private |