bpp-seq  2.4.0
bpp::DistanceMatrix Class Referencefinal

A Matrix class to store phylogenetic distances. More...

#include <Bpp/Seq/DistanceMatrix.h>

+ Inheritance diagram for bpp::DistanceMatrix:
+ Collaboration diagram for bpp::DistanceMatrix:

Public Member Functions

 DistanceMatrix (const std::vector< std::string > &names)
 Build a new distance matrix with specified names. The dimension of the matrix will be equal to the number of names. More...
 
 DistanceMatrix (std::size_t n)
 Build a new distance matrix with specified size. Row names will be named 'Taxon 0', 'Taxon 1', and so on. More...
 
 DistanceMatrix (const DistanceMatrix &dist)
 
DistanceMatrixoperator= (const DistanceMatrix &dist)
 
DistanceMatrixclone () const
 
void reset ()
 Reset the distance matrix: all distances are set to 0. More...
 
std::size_t size () const
 
const std::vector< std::string > & getNames () const
 
const std::string & getName (std::size_t i) const
 
void setName (std::size_t i, const std::string &name)
 Set the ith name. More...
 
void setNames (const std::vector< std::string > &names)
 Set the names associated to the matrix. More...
 
std::size_t getNameIndex (const std::string &name) const
 Get the index of a given name. More...
 
void resize (std::size_t n)
 Change the dimension of the matrix. More...
 
virtual const double & operator() (const std::string &iName, const std::string &jName) const
 Access by name. More...
 
virtual double & operator() (const std::string &iName, const std::string &jName)
 Access by name. More...
 
virtual const double & operator() (std::size_t i, std::size_t j) const
 
virtual double & operator() (std::size_t i, std::size_t j)
 
virtual const Matrix< double > & asMatrix () const
 
virtual Matrix< double > & asMatrix ()
 

Private Attributes

RowMatrix< double > distances_
 
std::vector< std::string > names_
 

Detailed Description

A Matrix class to store phylogenetic distances.

Definition at line 55 of file DistanceMatrix.h.

Constructor & Destructor Documentation

bpp::DistanceMatrix::DistanceMatrix ( const std::vector< std::string > &  names)
inline

Build a new distance matrix with specified names. The dimension of the matrix will be equal to the number of names.

Parameters
namesThe names to use.

Definition at line 67 of file DistanceMatrix.h.

References reset().

Referenced by clone().

bpp::DistanceMatrix::DistanceMatrix ( std::size_t  n)
inline

Build a new distance matrix with specified size. Row names will be named 'Taxon 0', 'Taxon 1', and so on.

Parameters
nThe size of the matrix.

Definition at line 79 of file DistanceMatrix.h.

References resize().

bpp::DistanceMatrix::DistanceMatrix ( const DistanceMatrix dist)
inline

Definition at line 86 of file DistanceMatrix.h.

Member Function Documentation

virtual const Matrix<double>& bpp::DistanceMatrix::asMatrix ( ) const
inlinevirtual

Definition at line 241 of file DistanceMatrix.h.

References distances_.

virtual Matrix<double>& bpp::DistanceMatrix::asMatrix ( )
inlinevirtual

Definition at line 243 of file DistanceMatrix.h.

References distances_.

DistanceMatrix* bpp::DistanceMatrix::clone ( ) const
inlinevirtual

Implements bpp::Clonable.

Definition at line 107 of file DistanceMatrix.h.

References DistanceMatrix().

const std::string& bpp::DistanceMatrix::getName ( std::size_t  i) const
inline
Returns
The ith name.
Parameters
iName index.
Exceptions
IndexOutOfBoundsExceptionIf i is not a valid index.

Definition at line 140 of file DistanceMatrix.h.

References size().

size_t DistanceMatrix::getNameIndex ( const std::string &  name) const

Get the index of a given name.

Parameters
nameThe name to look for.
Returns
The position of the name.
Exceptions
ExceptionIf no names are attached to this matrix, or if the name was not found.

Definition at line 45 of file DistanceMatrix.cpp.

Referenced by operator()(), and setNames().

const std::vector<std::string>& bpp::DistanceMatrix::getNames ( ) const
inline
Returns
The names associated to the matrix.

Definition at line 133 of file DistanceMatrix.h.

References names_.

virtual const double& bpp::DistanceMatrix::operator() ( const std::string &  iName,
const std::string &  jName 
) const
inlinevirtual

Access by name.

Parameters
iNameName 1 (row)
jNameName 2 (column)
Returns
A reference toward the specified distance.
Exceptions
Exceptionif the matrix has no name of if one of the name do not match existing names.

Definition at line 206 of file DistanceMatrix.h.

References distances_, and getNameIndex().

virtual double& bpp::DistanceMatrix::operator() ( const std::string &  iName,
const std::string &  jName 
)
inlinevirtual

Access by name.

Parameters
iNameName 1 (row)
jNameName 2 (column)
Returns
A reference toward the specified distance.
Exceptions
Exceptionif the matrix has no name of if one of the name do not match existing names.

Definition at line 222 of file DistanceMatrix.h.

References distances_, and getNameIndex().

virtual const double& bpp::DistanceMatrix::operator() ( std::size_t  i,
std::size_t  j 
) const
inlinevirtual

Definition at line 230 of file DistanceMatrix.h.

References distances_.

virtual double& bpp::DistanceMatrix::operator() ( std::size_t  i,
std::size_t  j 
)
inlinevirtual

Definition at line 235 of file DistanceMatrix.h.

References distances_.

DistanceMatrix& bpp::DistanceMatrix::operator= ( const DistanceMatrix dist)
inline

Definition at line 92 of file DistanceMatrix.h.

References distances_, names_, resize(), and size().

void bpp::DistanceMatrix::reset ( )
inline

Reset the distance matrix: all distances are set to 0.

Definition at line 113 of file DistanceMatrix.h.

References distances_, and size().

Referenced by DistanceMatrix(), and resize().

void bpp::DistanceMatrix::resize ( std::size_t  n)
inline

Change the dimension of the matrix.

Parameters
nthe new dimension of the matrix.

Definition at line 188 of file DistanceMatrix.h.

References reset(), and bpp::RowMatrix< Scalar >::resize().

Referenced by DistanceMatrix(), and operator=().

void bpp::DistanceMatrix::setName ( std::size_t  i,
const std::string &  name 
)
inline

Set the ith name.

Parameters
iName index.
nameThe new name.
Exceptions
IndexOutOfBoundsExceptionIf i is not a valid index.

Definition at line 154 of file DistanceMatrix.h.

References size().

void bpp::DistanceMatrix::setNames ( const std::vector< std::string > &  names)
inline

Set the names associated to the matrix.

Parameters
namesMatrix names.
Exceptions
DimensionExceptionIf 'names' have not the same size as the matrix.

Definition at line 167 of file DistanceMatrix.h.

References getNameIndex().

std::size_t bpp::DistanceMatrix::size ( ) const
inline
Returns
The dimension of the matrix.

Definition at line 128 of file DistanceMatrix.h.

Referenced by getName(), operator=(), reset(), and setName().

Member Data Documentation

RowMatrix<double> bpp::DistanceMatrix::distances_
private

Definition at line 58 of file DistanceMatrix.h.

Referenced by asMatrix(), operator()(), operator=(), and reset().

std::vector<std::string> bpp::DistanceMatrix::names_
private

Definition at line 59 of file DistanceMatrix.h.

Referenced by getNames(), and operator=().


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