bpp-phyl3 3.0.0
TransitionFromTransitionModel.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: The Bio++ Development Group
2//
3// SPDX-License-Identifier: CECILL-2.1
4
6
8
9using namespace bpp;
10using namespace std;
11
12/******************************************************************************/
13
14const Eigen::VectorXd& TransitionFromTransitionModel::Lik_t(const Eigen::VectorXd& to, double t) const
15{
16 if (t != tref_)
17 {
18 tref_ = t;
19 dPij_dt = 0; d2Pij_dt2 = 0;
21 }
22 else if (Pij_t == 0)
24
25 for (Eigen::Index i = 0; i < Eigen::Index(size_); ++i)
26 {
27 Pi_(i) = 0;
28 for (Eigen::Index j = 0; j < Eigen::Index(size_); ++j)
29 {
30 Pi_(i) += (*Pij_t)(size_t(i), size_t(j)) * to[j];
31 }
32 }
33
34 return Pi_;
35}
36
37const Eigen::VectorXd& TransitionFromTransitionModel::dLik_dt(const Eigen::VectorXd& to, double t) const
38{
39 if (t != tref_)
40 {
41 tref_ = t;
42 Pij_t = 0; d2Pij_dt2 = 0;
44 }
45 else if (dPij_dt == 0)
47
48 for (Eigen::Index i = 0; i < Eigen::Index(size_); ++i)
49 {
50 dPi_(i) = 0;
51 for (auto j = 0; j < Eigen::Index(size_); ++j)
52 {
53 dPi_(i) += (*dPij_dt)(size_t(i), size_t(j)) * to[j];
54 }
55 }
56 return dPi_;
57}
58
59const Eigen::VectorXd& TransitionFromTransitionModel::d2Lik_dt2(const Eigen::VectorXd& to, double t) const
60{
61 if (t != tref_)
62 {
63 tref_ = t;
64 Pij_t = 0; dPij_dt = 0;
66 }
67 else if (d2Pij_dt2 == 0)
69
70 for (Eigen::Index i = 0; i < Eigen::Index(size_); ++i)
71 {
72 d2Pi_(i) = 0;
73 for (auto j = 0; j < Eigen::Index(size_); ++j)
74 {
75 d2Pi_(i) += (*d2Pij_dt2)(size_t(i), size_t(j)) * to[j];
76 }
77 }
78 return d2Pi_;
79}
double tref_
Reference time to avoid recomuputation of transition matrix when time has not changed....
const TransitionModelInterface & transitionModel() const
const Eigen::VectorXd & d2Lik_dt2(const Eigen::VectorXd &from, double t) const override
const Eigen::VectorXd & dLik_dt(const Eigen::VectorXd &from, double t) const override
const Matrix< double > * Pij_t
Transition Matrices owned by the submodel.
Eigen::VectorXd Pi_
Used return vectors.
virtual const Matrix< double > & getPij_t(double t) const =0
virtual const Matrix< double > & getdPij_dt(double t) const =0
virtual const Matrix< double > & getd2Pij_dt2(double t) const =0
T to(const std::string &s)
Defines the basic types of data flow nodes.