44 #include "../Alphabet/AlphabetTools.h" 45 #include <Bpp/Numeric/NumTools.h> 54 distanceMatrix_(20, 20),
60 #include "__GranthamMatrixCode" 67 size_t stateIndex1 = alpha_->getStateIndex(state1);
68 size_t stateIndex2 = alpha_->getStateIndex(state2);
69 double d = distanceMatrix_(stateIndex1, stateIndex2);
70 if (sign_ == SIGN_NONE)
71 return NumTools::abs<double>(d);
72 if (sign_ == SIGN_PC1)
73 return signMatrix_(stateIndex1, stateIndex2) * NumTools::abs<double>(d);
80 return getIndex(alpha_->charToInt(state1), alpha_->charToInt(state2));
88 for (
size_t i = 0; i < 20; ++i)
90 for (
size_t j = 0; j < 20; ++j)
92 (*m)(i, j) = NumTools::abs<double>((*m)(i, j));
98 for (
size_t i = 0; i < 20; ++i)
100 for (
size_t j = 0; j < 20; ++j)
102 (*m)(i, j) =
signMatrix_(i, j) * NumTools::abs<double>((*m)(i, j));
static short int SIGN_ARBITRARY
An alphabet exception thrown when trying to specify a bad char to the alphabet.
This alphabet is used to deal NumericAlphabet.
static short int SIGN_NONE
LinearMatrix< double > distanceMatrix_
Matrix< double > * getIndexMatrix() const
An alphabet exception thrown when trying to specify a bad int to the alphabet.
GranthamAAChemicalDistance()
static short int SIGN_PC1
virtual ~GranthamAAChemicalDistance()
double getIndex(int state1, int state2) const
Get the index associated to a pair of states.
LinearMatrix< double > signMatrix_