26 const std::string& prefix) :
30 (prefix ==
"") ?
"Word." : prefix)
35 for (i = 0; i < nbmod - 1; i++)
48 std::shared_ptr<const Alphabet> alph,
49 std::shared_ptr<const StateMapInterface> stateMap,
50 const string& prefix) :
60 std::unique_ptr<SubstitutionModelInterface> pmodel,
62 const std::string& prefix) :
66 (prefix ==
"") ?
"Word." : prefix)
71 for (i = 0; i < num - 1; i++)
88 for (i = 0; i < nbmod - 1; i++)
107 for (i = 0; i < salph; i++)
111 for (p = nbmod; p > 0; p--)
113 m =
VSubMod_[p - 1]->getNumberOfStates();
122 vector<const Matrix<double>*> vM;
126 for (i = 0; i < nbmod; i++)
137 for (i = 0; i < nbStates; i++)
139 for (j = 0; j < nbStates; j++)
144 for (p = nbmod; p > 0; p--)
146 t =
VSubMod_[p - 1]->getNumberOfStates();
147 x *= (*vM[p - 1])(i2 % t, j2 % t);
160 vector<const Matrix<double>*> vM, vdM;
164 for (i = 0; i < nbmod; i++)
176 for (i = 0; i < nbStates; i++)
178 for (j = 0; j < nbStates; j++)
181 for (q = 0; q < nbmod; q++)
186 for (p = nbmod; p > 0; p--)
188 t =
VSubMod_[p - 1]->getNumberOfStates();
190 x *= (*vM[p - 1])(i2 % t, j2 % t);
192 x *=
rate_ *
Vrate_[p - 1] * (*vdM[p - 1])(i2 % t, j2 % t);
207 vector<const Matrix<double>*> vM, vdM, vd2M;
211 for (i = 0; i < nbmod; i++)
226 for (i = 0; i < nbStates; i++)
228 for (j = 0; j < nbStates; j++)
231 for (q = 1; q < nbmod; q++)
233 for (b = 0; b < q; b++)
238 for (p = nbmod; p > 0; p--)
240 t =
VSubMod_[p - 1]->getNumberOfStates();
241 if ((p - 1 == q) || (p - 1 == b))
242 x *=
rate_ *
Vrate_[p - 1] * (*vdM[p - 1])(i2 % t, j2 % t);
244 x *= (*vM[p - 1])(i2 % t, j2 % t);
255 for (q = 0; q < nbmod; q++)
260 for (p = nbmod; p > 0; p--)
262 t =
VSubMod_[p - 1]->getNumberOfStates();
264 x *= (*vM[p - 1])(i2 % t, j2 % t);
void addParameter_(Parameter *parameter)
double getParameterValue(const std::string &name) const override
bool computeFrequencies() const
bool enableEigenDecomposition()
Tell if eigenValues and Vectors must be computed.
RowMatrix< double > d2pijt_
std::shared_ptr< const Alphabet > getAlphabet() const override
RowMatrix< double > pijt_
These ones are for bookkeeping:
Vdouble freq_
The vector of equilibrium frequencies.
RowMatrix< double > dpijt_
double rate_
The rate of the model (default: 1). The generator (and all its vectorial components) is independent o...
size_t getNumberOfStates() const override
Get the number of states.
Abstract Basal class for words of substitution models.
void updateMatrices_()
Diagonalize the matrix, and fill the eigenValues_, iEigenValues_, leftEigenVectors_ and rightEigenVe...
std::vector< double > Vrate_
std::vector< std::shared_ptr< SubstitutionModelInterface > > VSubMod_
A list of models, for building a WordSubstitutionModel.
static const std::shared_ptr< IntervalConstraint > PROP_CONSTRAINT_EX
virtual void updateMatrices_() override
Diagonalize the matrix, and fill the eigenValues_, iEigenValues_, leftEigenVectors_ and rightEigenVe...
virtual void completeMatrices_() override
Called by updateMatrices to handle specific modifications for inheriting classes.
WordSubstitutionModel(ModelList &modelList, const std::string &prefix="")
Build a new WordSubstitutionModel object from a Vector of pointers to SubstitutionModels.
virtual const RowMatrix< double > & getdPij_dt(double d) const override
virtual const RowMatrix< double > & getd2Pij_dt2(double d) const override
virtual const RowMatrix< double > & getPij_t(double d) const override
virtual std::string getName() const override
Get the name of the model.
std::string toString(T t)
Defines the basic types of data flow nodes.