23 std::shared_ptr<const RNY> alph,
24 std::unique_ptr<NucleotideSubstitutionModelInterface> pm,
25 const string& prefix) :
29 nestedPrefix_(pm->getNamespace())
32 pmodel_->enableEigenDecomposition(0);
33 pmodel_->computeFrequencies(
false);
42 pmodel_(ypr.pmodel_->clone()),
43 nestedPrefix_(ypr.getNestedPrefix())
54 double TgC,
double tGA,
55 double CaT,
double cAG,
56 double TaC,
double tAC)
61 unsigned int i, j, i1, i2, i3, j1, j2, j3;
63 std::vector<double> a(4);
64 std::vector<double> b(4);
126 for (i1 = 0; i1 < 3; i1++)
128 for (i2 = 0; i2 < 4; i2++)
130 for (i3 = 0; i3 < 3; i3++)
132 i = 12 * i1 + 3 * i2 + i3;
133 for (j1 = 0; j1 < 3; j1++)
135 for (j2 = 0; j2 < 4; j2++)
137 for (j3 = 0; j3 < 3; j3++)
139 j = 12 * j1 + 3 * j2 + j3;
140 if ((i1 == j1) && (i2 == j2))
142 else if ((i1 == j1) && (i3 == j3))
144 else if ((i2 == j2) && (i3 == j3))
157 for (i3 = 0; i3 < 3; i3++)
160 generator_(12 * i3 + 7, 12 * i3 + 6) += cGA * a[0];
163 generator_(12 * i3 + 7, 12 * i3 + 10) += CgT * a[3];
166 generator_(12 * i3 + 10, 12 * i3 + 9) += tGA * a[0];
169 generator_(12 * i3 + 10, 12 * i3 + 7) += TgC * a[2];
172 generator_(12 * i3 + 6, 12 * i3 + 9) += CaT * a[3];
175 generator_(12 * i3 + 6, 12 * i3 + 7) += cAG * a[1];
178 generator_(12 * i3 + 9, 12 * i3 + 10) += tAC * a[1];
181 generator_(12 * i3 + 9, 12 * i3 + 6) += TaC * a[2];
186 for (i = 0; i < 36; ++i)
189 for (j = 0; j < 36; ++j)
211 for (i = 0; i <
size_; i++)
229 for (i = 0; i < 36; i++)
238 for (i = 0; i < 36; i++)
253 for (i = 1; i < 36; i++)
266 for (i = 0; i < 36; i++)
277 for (i1 = 0; i1 < 3; i1++)
279 for (i2 = 0; i2 < 4; i2++)
281 for (i3 = 0; i3 < 3; i3++)
283 i = 12 * i1 + 3 * i2 + i3;
284 for (j2 = 0; j2 < 4; j2++)
288 j = 12 * i1 + 3 * j2 + i3;
300 for (i = 0; i < 36; i++)
311 for (i = 0; i <
size_; i++)
313 for (j = 0; j <
size_; j++)
329 if ((pm.
Qij(0, 1) != pm.
Qij(2, 1)) || (pm.
Qij(0, 3) != pm.
Qij(2, 3))
330 || (pm.
Qij(1, 0) != pm.
Qij(3, 0)) || (pm.
Qij(1, 2) != pm.
Qij(3, 2)))
349 std::shared_ptr<const RNY> alph,
350 std::unique_ptr<NucleotideSubstitutionModelInterface> pm,
351 double CgT,
double TgC,
352 double CaT,
double TaC) :
354 YpR(alph, std::move(pm),
"YpR_Sym.")
393 std::shared_ptr<const RNY> alph,
394 std::unique_ptr<NucleotideSubstitutionModelInterface> pm,
395 double CgT,
double cGA,
396 double TgC,
double tGA,
397 double CaT,
double cAG,
398 double TaC,
double tAG) :
400 YpR(alph, std::move(pm),
"YpR_Gen.")
void addParameters_(const ParameterList ¶meters)
void addParameter_(Parameter *parameter)
void setNamespace(const std::string &prefix)
double getParameterValue(const std::string &name) const override
RowMatrix< double > generator_
The generator matrix of the model.
bool isDiagonalizable_
boolean value for diagonalizability in R of the generator_
bool isNonSingular_
boolean value for non-singularity of rightEigenVectors_
std::vector< RowMatrix< double > > vPowGen_
vector of the powers of generator_ for Taylor development (if rightEigenVectors_ is singular).
Vdouble eigenValues_
The vector of eigen values.
bool computeFrequencies() const
RowMatrix< double > exchangeability_
The exchangeability matrix of the model, defined as . When the model is reversible,...
Vdouble iEigenValues_
The vector of the imaginary part of the eigen values.
RowMatrix< double > leftEigenVectors_
The matrix made of left eigen vectors (by row) if rightEigenVectors_ is non-singular.
virtual bool isScalable() const
returns if model is scalable
RowMatrix< double > rightEigenVectors_
The matrix made of right eigen vectors (by column).
void setScale(double scale)
Multiplies the current generator by the given scale.
RowMatrix< double > tmpMat_
For computational issues.
size_t size_
The number of states.
Vdouble freq_
The vector of equilibrium frequencies.
virtual std::string getName() const =0
Get the name of the model.
virtual std::shared_ptr< const Alphabet > getAlphabet() const =0
This class implements a state map where all resolved states are modeled.
const RowMatrix< Real > & getV() const
const std::vector< Real > & getImagEigenValues() const
const std::vector< Real > & getRealEigenValues() const
static const std::shared_ptr< IntervalConstraint > R_PLUS
Interface for all substitution models.
virtual double Qij(size_t i, size_t j) const =0
A method for computing all necessary matrices.
void updateMatrices_() override
Diagonalize the matrix, and fill the eigenValues_, iEigenValues_, leftEigenVectors_ and rightEigenVe...
std::string getName() const override
Get the name of the model.
YpR_Gen(std::shared_ptr< const RNY > alph, std::unique_ptr< NucleotideSubstitutionModelInterface > pm, double CgT=0., double cGA=0., double TgC=0., double tGA=0., double CaT=0., double cAG=0., double TaC=0., double tAG=0.)
Build a new YpR_Gen substitution model.
std::string getName() const override
Get the name of the model.
YpR_Sym(std::shared_ptr< const RNY > alph, std::unique_ptr< NucleotideSubstitutionModelInterface > pm, double CgT=0., double TgC=0., double CaT=0., double TaC=0.)
Build a new YpR_Sym substitution model.
void updateMatrices_() override
Diagonalize the matrix, and fill the eigenValues_, iEigenValues_, leftEigenVectors_ and rightEigenVe...
std::string nestedPrefix_
void checkModel(const SubstitutionModelInterface &model) const
virtual void updateMatrices_() override
Diagonalize the matrix, and fill the eigenValues_, iEigenValues_, leftEigenVectors_ and rightEigenVe...
YpR(std::shared_ptr< const RNY >, std::unique_ptr< NucleotideSubstitutionModelInterface > const, const std::string &prefix)
Build a new YpR substitution model, with no dependency parameters.
std::unique_ptr< NucleotideSubstitutionModelInterface > pmodel_
virtual void setNamespace(const std::string &) override
Defines the basic types of data flow nodes.
ExtendedFloat abs(const ExtendedFloat &ef)