40 #ifndef _SIMPLEINDEXDISTANCE_H_ 41 #define _SIMPLEINDEXDISTANCE_H_ 48 #include "../Alphabet/ProteicAlphabet.h" 49 #include "../Alphabet/AlphabetExceptions.h" 50 #include <Bpp/Exceptions.h> 51 #include <Bpp/Numeric/Matrix/Matrix.h> 65 std::auto_ptr<AlphabetIndex1>
index_;
81 index_.reset(dynamic_cast<AlphabetIndex1*>(sid.
index_->clone()));
91 double d =
index_->getIndex(state2) -
index_->getIndex(state1);
92 return sym_ ? NumTools::abs<double>(d) : d;
97 double d =
index_->getIndex(state2) -
index_->getIndex(state1);
98 return sym_ ? NumTools::abs<double>(d) : d;
107 size_t n =
index_->getAlphabet()->getSize();
108 RowMatrix<double>* m =
new RowMatrix<double>(n, n);
109 for (
size_t i = 0; i < n; ++i)
111 for (
size_t j = 0; j < n; ++j)
113 (*m)(i, j) =
getIndex(static_cast<int>(i),
static_cast<int>(j));
133 #endif // _SIMPLEINDEXDISTANCE_H_ AlphabetIndex1 & getAlphabetIndex1()
An alphabet exception thrown when trying to specify a bad char to the alphabet.
SimpleIndexDistance * clone() const
virtual ~SimpleIndexDistance()
SimpleIndexDistance(const SimpleIndexDistance &sid)
This alphabet is used to deal NumericAlphabet.
SimpleIndexDistance(AlphabetIndex1 *index)
std::auto_ptr< AlphabetIndex1 > index_
const Alphabet * getAlphabet() const
Get the alphabet associated to this index.
SimpleIndexDistance & operator=(const SimpleIndexDistance &sid)
const AlphabetIndex1 & getAlphabetIndex1() const
One dimensionnal alphabet index interface.
double getIndex(const std::string &state1, const std::string &state2) const
Get the index associated to a pair of states.
Two dimensionnal alphabet index interface.
Simple dissimilarity distance.
Matrix< double > * getIndexMatrix() const
An alphabet exception thrown when trying to specify a bad int to the alphabet.
double getIndex(int state1, int state2) const
Get the index associated to a pair of states.
void setSymmetric(bool yn)