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

Matrix storage by column. More...

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

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

Public Member Functions

 ColMatrix ()
 
 ColMatrix (size_t nRow, size_t nCol)
 
 ColMatrix (const Matrix< Scalar > &m)
 
ColMatrixoperator= (const Matrix< Scalar > &m)
 
virtual ~ColMatrix ()
 
ColMatrixclone () 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 getNumberOfColumns () const
 
size_t getNumberOfRows () const
 
std::vector< Scalar > row (size_t i) const
 
const std::vector< Scalar > & getCol (size_t i) const
 
std::vector< Scalar > & getCol (size_t i)
 
std::vector< Scalar > col (size_t j) const
 
void resize (size_t nRows, size_t nCols)
 Resize the matrix. More...
 
void addCol (const std::vector< Scalar > &newCol)
 
virtual bool equals (const Matrix &m, double threshold=NumConstants::TINY())
 

Private Attributes

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

Detailed Description

template<class Scalar>
class bpp::ColMatrix< Scalar >

Matrix storage by column.

This matrix is a vector of vector of Scalar. Column access is in $O(1)$ while row access is in $O(nCol)$.

Definition at line 200 of file Matrix.h.

Constructor & Destructor Documentation

◆ ColMatrix() [1/3]

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

Definition at line 207 of file Matrix.h.

◆ ColMatrix() [2/3]

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

Definition at line 209 of file Matrix.h.

◆ ColMatrix() [3/3]

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

◆ ~ColMatrix()

template<class Scalar>
virtual bpp::ColMatrix< Scalar >::~ColMatrix ( )
inlinevirtual

Definition at line 247 of file Matrix.h.

Member Function Documentation

◆ addCol()

template<class Scalar>
void bpp::ColMatrix< Scalar >::addCol ( const std::vector< Scalar > &  newCol)
inline

Definition at line 293 of file Matrix.h.

References bpp::Matrix< Scalar >::getNumberOfRows().

◆ clone()

template<class Scalar>
ColMatrix* bpp::ColMatrix< 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 250 of file Matrix.h.

◆ col()

template<class Scalar>
std::vector<Scalar> bpp::ColMatrix< 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 277 of file Matrix.h.

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

◆ equals()

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

◆ getCol() [1/2]

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

Definition at line 267 of file Matrix.h.

◆ getCol() [2/2]

template<class Scalar>
std::vector<Scalar>& bpp::ColMatrix< Scalar >::getCol ( size_t  i)
inline

Definition at line 272 of file Matrix.h.

◆ getNumberOfColumns()

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

Implements bpp::Matrix< Scalar >.

Definition at line 256 of file Matrix.h.

◆ getNumberOfRows()

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

Implements bpp::Matrix< Scalar >.

Definition at line 258 of file Matrix.h.

◆ operator()() [1/2]

template<class Scalar>
const Scalar& bpp::ColMatrix< 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 252 of file Matrix.h.

◆ operator()() [2/2]

template<class Scalar>
Scalar& bpp::ColMatrix< 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 254 of file Matrix.h.

◆ operator=()

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

◆ resize()

template<class Scalar>
void bpp::ColMatrix< 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 284 of file Matrix.h.

◆ row()

template<class Scalar>
std::vector<Scalar> bpp::ColMatrix< 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 260 of file Matrix.h.

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

Member Data Documentation

◆ m_

template<class Scalar>
std::vector< std::vector<Scalar> > bpp::ColMatrix< Scalar >::m_
private

Definition at line 204 of file Matrix.h.


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