5 #ifndef BPP_SEQ_ALPHABETINDEX_SIMPLEINDEXDISTANCE_H 6 #define BPP_SEQ_ALPHABETINDEX_SIMPLEINDEXDISTANCE_H 14 #include "../Alphabet/AlphabetExceptions.h" 15 #include <Bpp/Exceptions.h> 16 #include <Bpp/Numeric/Matrix/Matrix.h> 31 std::shared_ptr<AlphabetIndex1>
index_;
49 indexMatrix_(sid.indexMatrix_),
65 double getIndex(
int state1,
int state2)
const override 70 double getIndex(
const std::string& state1,
const std::string& state2)
const override 75 std::shared_ptr<const Alphabet>
getAlphabet()
const override {
return index_->getAlphabet(); }
86 for (
size_t i = 0; i <
size_; ++i)
88 for (
size_t j = 0; j <
size_; ++j)
90 auto d = index_->getIndex(
getAlphabet()->getIntCodeAt(i + 1)) - index_->getIndex(
getAlphabet()->getIntCodeAt(j + 1));
91 if (sym_) d = NumTools::abs<double>(d);
112 #endif // BPP_SEQ_ALPHABETINDEX_SIMPLEINDEXDISTANCE_H SimpleIndexDistance * clone() const override
virtual ~SimpleIndexDistance()
RowMatrix< double > indexMatrix_
SimpleIndexDistance(const SimpleIndexDistance &sid)
This alphabet is used to deal NumericAlphabet.
bool isSymmetric() const override
SimpleIndexDistance & operator=(const SimpleIndexDistance &sid)
double getIndex(const std::string &state1, const std::string &state2) const override
Get the index associated to a pair of states.
const Alphabet & alphabet() const override
Get the alphabet associated to this index.
double getIndex(int state1, int state2) const override
Get the index associated to a pair of states.
void computeIndexMatrix_()
Two dimensionnal alphabet index interface.
Simple dissimilarity distance.
std::shared_ptr< const Alphabet > getAlphabet() const override
Get the alphabet associated to this index.
std::shared_ptr< const AlphabetIndex1 > getAlphabetIndex1() const
const Matrix< double > & getIndexMatrix() const override
SimpleIndexDistance(std::shared_ptr< AlphabetIndex1 > index)
std::shared_ptr< AlphabetIndex1 > index_
void setSymmetric(bool yn)