39 #ifndef _DISTANCEMATRIX_H_ 40 #define _DISTANCEMATRIX_H_ 45 #include <Bpp/Exceptions.h> 46 #include <Bpp/Numeric/VectorExceptions.h> 47 #include <Bpp/Numeric/Matrix/Matrix.h> 56 public virtual Clonable
100 size_t n = dist.
size();
102 for(
size_t i = 0; i < n; ++i)
104 for(
size_t j = 0; j < n; ++j)
123 for (
size_t i = 0; i < n; ++i)
125 for (
size_t j = 0; j < n; ++j)
147 const std::string&
getName(
size_t i)
const throw (IndexOutOfBoundsException)
149 if (i >=
size())
throw IndexOutOfBoundsException(
"DistanceMatrix::getName. Invalid indice.", i, 0,
size());
160 void setName(
size_t i,
const std::string& name)
throw (IndexOutOfBoundsException)
162 if (i >=
size())
throw IndexOutOfBoundsException(
"DistanceMatrix::setName. Invalid indice.", i, 0,
size());
172 void setNames(
const std::vector<std::string>& names)
throw (DimensionException)
174 if (names.size() !=
names_.size())
throw DimensionException(
"DistanceMatrix::setNames. Invalid number of names.", names.size(),
names_.size());
185 size_t getNameIndex(
const std::string& name)
const throw (Exception);
196 for (
size_t i = 0; i < n; ++i)
197 names_[i] =
"Taxon " + TextTools::toString(i);
209 virtual const double&
operator()(
const std::string& iName,
const std::string& jName)
const throw (Exception)
225 virtual double&
operator()(
const std::string& iName,
const std::string& jName)
throw (Exception)
255 #endif //_DISTANCEMATRIX_H_ DistanceMatrix * clone() const
void resize(size_t n)
Change the dimension of the matrix.
DistanceMatrix(const std::vector< std::string > &names)
Build a new distance matrix with specified names.
DistanceMatrix(size_t n)
Build a new distance matrix with specified size.
This alphabet is used to deal NumericAlphabet.
const std::string & getName(size_t i) const
const std::vector< std::string > & getNames() const
void setNames(const std::vector< std::string > &names)
Set the names associated to the matrix.
virtual double & operator()(const std::string &iName, const std::string &jName)
Access by name.
size_t getNameIndex(const std::string &name) const
Get the index of a given name.
void setName(size_t i, const std::string &name)
Set the ith name.
DistanceMatrix(const DistanceMatrix &dist)
DistanceMatrix & operator=(const DistanceMatrix &dist)
virtual const double & operator()(size_t i, size_t j) const
virtual const Matrix< double > & asMatrix() const
std::vector< std::string > names_
virtual double & operator()(size_t i, size_t j)
virtual ~DistanceMatrix()
A Matrix class to store phylogenetic distances.
virtual Matrix< double > & asMatrix()
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.
RowMatrix< double > distances_