18 for (
auto i = 0; i < Eigen::Index(size_); i++)
20 double* Pi_i = &Pi_(i);
21 for (
auto j = 0; j < Eigen::Index(size_); j++)
25 *Pi_i += counts(j) *
std::log((*Pij_t)(
size_t(i),
size_t(j)));
30 Pi_.array() = (Pi_.array() + getFact_(counts)).
exp();
35 Pi_.array() = 0; dPi_.array() = 0;
37 for (
size_t i = 0; i < size_; i++)
39 double* Pi_i(&Pi_(Eigen::Index(i))), *dPi_i(&dPi_(Eigen::Index(i)));
41 for (
size_t j = 0; j < size_; j++)
43 if (counts(Eigen::Index(j)) != 0)
45 *Pi_i += counts(Eigen::Index(j)) *
std::log((*Pij_t)(i, j));
46 *dPi_i += counts(Eigen::Index(j)) * (*dPij_dt)(i, j) / (*Pij_t)(i, j);
51 dPi_.array() *= (Pi_.array() + getFact_(counts)).
exp();
56 Pi_.array() = 0; d2Pi_.array() = 0;
58 for (
size_t i = 0; i < size_; i++)
60 double* Pi_i(&Pi_(Eigen::Index(i))), *d2Pi_i(&d2Pi_(Eigen::Index(i)));
62 for (
size_t j = 0; j < size_; j++)
64 if (counts(Eigen::Index(j)) != 0)
66 *Pi_i += counts(Eigen::Index(j)) *
std::log((*Pij_t)(i, j));
67 *d2Pi_i += counts(Eigen::Index(j)) * (*d2Pij_dt2)(i, j) / (*Pij_t)(i, j);
72 d2Pi_.array() *= (Pi_.array() + getFact_(counts)).
exp();
81 Pij_t = &transitionModel().getPij_t(t);
82 dPij_dt = 0; d2Pij_dt2 = 0;
85 compute_Multinomial_(
to);
94 Pij_t = &transitionModel().getPij_t(t);
95 dPij_dt = &transitionModel().getdPij_dt(t);
98 else if (dPij_dt == 0)
99 dPij_dt = &transitionModel().getdPij_dt(t);
101 compute_dMultinomial_dt_(
to);
111 Pij_t = &transitionModel().getPij_t(t);
113 d2Pij_dt2 = &transitionModel().getd2Pij_dt2(t);
115 else if (d2Pij_dt2 == 0)
116 d2Pij_dt2 = &transitionModel().getd2Pij_dt2(t);
118 compute_d2Multinomial_dt2_(
to);
const Eigen::VectorXd & d2Lik_dt2(const Eigen::VectorXd &from, double t) const override
const Eigen::VectorXd & Lik_t(const Eigen::VectorXd &from, double t) const override
void compute_Multinomial_(const Eigen::VectorXd &counts) const
Fills the res vector of the likelihoods of the counts given ancestral states & transition matrix.
const Eigen::VectorXd & dLik_dt(const Eigen::VectorXd &from, double t) const override
void compute_d2Multinomial_dt2_(const Eigen::VectorXd &counts) const
void compute_dMultinomial_dt_(const Eigen::VectorXd &counts) const
T to(const std::string &s)
Defines the basic types of data flow nodes.
ExtendedFloat exp(const ExtendedFloat &ef)