5 #ifndef BPP_SEQ_DISTANCEMATRIX_H
6 #define BPP_SEQ_DISTANCEMATRIX_H
56 std::size_t n = dist.
size();
58 for (std::size_t i = 0; i < n; ++i)
60 for (std::size_t j = 0; j < n; ++j)
77 std::size_t n =
size();
78 for (std::size_t i = 0; i < n; ++i)
80 for (std::size_t j = 0; j < n; ++j)
102 const std::string&
getName(std::size_t i)
const
116 void setName(std::size_t i,
const std::string& name)
129 void setNames(
const std::vector<std::string>& names)
131 if (names.size() !=
names_.size())
143 std::size_t
getNameIndex(
const std::string& name)
const;
155 for (std::size_t i = 0; i < n; ++i)
157 names_[i] =
"Taxon " + std::to_string(i);
170 virtual const double&
operator()(
const std::string& iName,
const std::string& jName)
const
186 virtual double&
operator()(
const std::string& iName,
const std::string& jName)
194 virtual const double&
operator()(std::size_t i, std::size_t j)
const
A Matrix class to store phylogenetic distances.
const std::string & getName(std::size_t i) const
std::size_t getNameIndex(const std::string &name) const
Get the index of a given name.
DistanceMatrix(std::size_t n)
Build a new distance matrix with specified size. Row names will be named 'Taxon 0',...
RowMatrix< double > distances_
DistanceMatrix * clone() const
virtual const Matrix< double > & asMatrix() const
virtual const double & operator()(std::size_t i, std::size_t j) const
void reset()
Reset the distance matrix: all distances are set to 0.
virtual const double & operator()(const std::string &iName, const std::string &jName) const
Access by name.
void setNames(const std::vector< std::string > &names)
Set the names associated to the matrix.
virtual double & operator()(std::size_t i, std::size_t j)
virtual Matrix< double > & asMatrix()
DistanceMatrix & operator=(const DistanceMatrix &dist)
void setName(std::size_t i, const std::string &name)
Set the ith name.
std::vector< std::string > names_
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 nu...
DistanceMatrix(const DistanceMatrix &dist)
const std::vector< std::string > & getNames() const
void resize(std::size_t n)
Change the dimension of the matrix.
virtual double & operator()(const std::string &iName, const std::string &jName)
Access by name.
void resize(size_t nRows, size_t nCols)
This alphabet is used to deal NumericAlphabet.