bpp-core3  3.0.0
bpp::RowMatrix< Scalar > Class Template Reference

Matrix storage by row. More...

#include <Bpp/Numeric/Matrix/Matrix.h>

+ Inheritance diagram for bpp::RowMatrix< Scalar >:
+ Collaboration diagram for bpp::RowMatrix< Scalar >:

Public Member Functions

 RowMatrix ()
 
 RowMatrix (size_t nRow, size_t nCol)
 
 RowMatrix (const Matrix< Scalar > &m)
 
RowMatrixoperator= (const Matrix< Scalar > &m)
 
RowMatrixclone () 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
 
const std::vector< Scalar > & getRow (size_t i) const
 
std::vector< Scalar > & getRow (size_t i)
 
std::vector< Scalar > col (size_t j) const
 
void resize (size_t nRows, size_t nCols)
 Resize the matrix. More...
 
void addRow (const std::vector< Scalar > &newRow)
 
virtual bool equals (const Matrix &m, double threshold=NumConstants::TINY())
 

Protected Attributes

std::vector< std::vector< Scalar > > m_
 

Detailed Description

template<class Scalar>
class bpp::RowMatrix< Scalar >

Matrix storage by row.

This matrix is a vector of vector of Scalar. Row access is in $O(1)$ while column access is in $O(nRow)$.

Definition at line 129 of file Matrix.h.

Constructor & Destructor Documentation

◆ RowMatrix() [1/3]

template<class Scalar >
bpp::RowMatrix< Scalar >::RowMatrix ( )
inline

Definition at line 136 of file Matrix.h.

Referenced by bpp::RowMatrix< Scalar >::clone().

◆ RowMatrix() [2/3]

template<class Scalar >
bpp::RowMatrix< Scalar >::RowMatrix ( size_t  nRow,
size_t  nCol 
)
inline

Definition at line 138 of file Matrix.h.

References bpp::RowMatrix< Scalar >::m_.

◆ RowMatrix() [3/3]

template<class Scalar >
bpp::RowMatrix< Scalar >::RowMatrix ( const Matrix< Scalar > &  m)
inline

Member Function Documentation

◆ addRow()

template<class Scalar >
void bpp::RowMatrix< Scalar >::addRow ( const std::vector< Scalar > &  newRow)
inline

◆ clone()

template<class Scalar >
RowMatrix* bpp::RowMatrix< Scalar >::clone ( ) const
inlinevirtual

Create a copy of this object and send a pointer to it.

Returns
A pointer toward the copy object.

Implements bpp::Clonable.

Definition at line 179 of file Matrix.h.

References bpp::RowMatrix< Scalar >::RowMatrix().

◆ col()

template<class Scalar >
std::vector<Scalar> bpp::RowMatrix< Scalar >::col ( size_t  j) const
inlinevirtual
Returns
the column at position j as a vector.
Parameters
jThe index of the column.

Implements bpp::Matrix< Scalar >.

Definition at line 206 of file Matrix.h.

References bpp::RowMatrix< Scalar >::getNumberOfRows(), and bpp::RowMatrix< Scalar >::operator()().

◆ equals()

template<class Scalar >
virtual bool bpp::Matrix< Scalar >::equals ( const Matrix< Scalar > &  m,
double  threshold = NumConstants::TINY() 
)
inlinevirtualinherited

◆ getNumberOfColumns()

template<class Scalar >
size_t bpp::RowMatrix< Scalar >::getNumberOfColumns ( ) const
inlinevirtual
Returns
The number of columns.

Implements bpp::Matrix< Scalar >.

Definition at line 187 of file Matrix.h.

References bpp::RowMatrix< Scalar >::m_.

Referenced by bpp::RowMatrix< Scalar >::addRow(), bpp::DualityDiagram::compute_(), and bpp::RowMatrix< Scalar >::row().

◆ getNumberOfRows()

template<class Scalar >
size_t bpp::RowMatrix< Scalar >::getNumberOfRows ( ) const
inlinevirtual
Returns
The number of rows.

Implements bpp::Matrix< Scalar >.

Definition at line 185 of file Matrix.h.

References bpp::RowMatrix< Scalar >::m_.

Referenced by bpp::RowMatrix< Scalar >::col(), and bpp::DualityDiagram::compute_().

◆ getRow() [1/2]

template<class Scalar >
std::vector<Scalar>& bpp::RowMatrix< Scalar >::getRow ( size_t  i)
inline

Definition at line 201 of file Matrix.h.

References bpp::RowMatrix< Scalar >::m_.

◆ getRow() [2/2]

template<class Scalar >
const std::vector<Scalar>& bpp::RowMatrix< Scalar >::getRow ( size_t  i) const
inline

Definition at line 196 of file Matrix.h.

References bpp::RowMatrix< Scalar >::m_.

Referenced by bpp::AbstractHmmTransitionMatrix::sample().

◆ operator()() [1/2]

template<class Scalar >
Scalar& bpp::RowMatrix< Scalar >::operator() ( size_t  i,
size_t  j 
)
inlinevirtual
Returns
$m_{i,j}$.
Parameters
irow index.
jcolumn index.

Implements bpp::Matrix< Scalar >.

Definition at line 183 of file Matrix.h.

References bpp::RowMatrix< Scalar >::m_.

◆ operator()() [2/2]

template<class Scalar >
const Scalar& bpp::RowMatrix< Scalar >::operator() ( size_t  i,
size_t  j 
) const
inlinevirtual
Returns
$m_{i,j}$.
Parameters
irow index.
jcolumn index.

Implements bpp::Matrix< Scalar >.

Definition at line 181 of file Matrix.h.

References bpp::RowMatrix< Scalar >::m_.

Referenced by bpp::RowMatrix< Scalar >::col(), and bpp::RowMatrix< Scalar >::row().

◆ operator=()

template<class Scalar >
RowMatrix& bpp::RowMatrix< Scalar >::operator= ( const Matrix< Scalar > &  m)
inline

◆ resize()

template<class Scalar >
void bpp::RowMatrix< Scalar >::resize ( size_t  nRows,
size_t  nCols 
)
inlinevirtual

Resize the matrix.

Parameters
nRowsThe new number of rows.
nColsThe new number of columns.

Implements bpp::Matrix< Scalar >.

Definition at line 213 of file Matrix.h.

References bpp::RowMatrix< Scalar >::m_.

Referenced by bpp::DualityDiagram::compute_(), bpp::EigenValue< Real >::EigenValue(), and bpp::AbstractNumericalDerivative::setParametersToDerivate().

◆ row()

template<class Scalar >
std::vector<Scalar> bpp::RowMatrix< Scalar >::row ( size_t  i) const
inlinevirtual
Returns
the row at position i as a vector.
Parameters
iThe index of the row.

Implements bpp::Matrix< Scalar >.

Definition at line 189 of file Matrix.h.

References bpp::RowMatrix< Scalar >::getNumberOfColumns(), and bpp::RowMatrix< Scalar >::operator()().

Member Data Documentation

◆ m_


The documentation for this class was generated from the following file: