bpp-phyl3  3.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
DecompositionMethods.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: The Bio++ Development Group
2 //
3 // SPDX-License-Identifier: CECILL-2.1
4 
5 #ifndef BPP_PHYL_MAPPING_DECOMPOSITIONMETHODS_H
6 #define BPP_PHYL_MAPPING_DECOMPOSITIONMETHODS_H
7 
10 
11 #include "../Model/SubstitutionModel.h"
12 #include "SubstitutionRegister.h"
13 
14 namespace bpp
15 {
27 {
28 protected:
29  std::shared_ptr<const SubstitutionModelInterface> model_;
30  size_t nbStates_;
31  size_t nbTypes_;
33 
40 
44  std::vector< RowMatrix<double>> bMatrices_, insideProducts_, insideIProducts_;
45 
46 public:
48  std::shared_ptr<const SubstitutionModelInterface> model,
49  std::shared_ptr<const SubstitutionRegisterInterface> reg);
50 
51  DecompositionMethods(std::shared_ptr<const SubstitutionRegisterInterface> reg);
52 
53  DecompositionMethods(std::shared_ptr<const SubstitutionModelInterface> model);
54 
55  DecompositionMethods(const StateMapInterface& stateMap);
56 
58  model_(dm.model_),
59  nbStates_(dm.nbStates_),
60  nbTypes_(dm.nbTypes_),
61  jMat_(dm.jMat_),
62  jIMat_(dm.jIMat_),
70  {}
71 
73  {
74  model_ = dm.model_;
75  nbStates_ = dm.nbStates_;
76  nbTypes_ = dm.nbTypes_;
77  jMat_ = dm.jMat_;
78  jIMat_ = dm.jIMat_;
79 
87 
88  return *this;
89  }
90 
91  DecompositionMethods* clone() const { return new DecompositionMethods(*this); }
92 
93  virtual ~DecompositionMethods() {}
94 
95 
101  void setSubstitutionModel(std::shared_ptr<const SubstitutionModelInterface> model);
102 
103 protected:
104  void initStates_();
105 
106  void initBMatrices_();
107 
108  void computeProducts_();
109 
110  /*
111  * @brief Perform the computation of the conditional expectations
112  *
113  */
114 
115  void computeExpectations(RowMatrix<double>& mapping, double length) const;
116 
117  void computeExpectations(std::vector< RowMatrix<double>>& mappings, double length) const;
118 
124  void jFunction_(const std::vector<double>& lambda, double t, RowMatrix<double>& result) const;
125 
131  void jFunction_(const std::vector<double>& lambda, const std::vector<double>& ilambda, double t, RowMatrix<double>& result, RowMatrix<double>& iresult) const;
132 };
133 } // end of namespace bpp.
134 #endif // BPP_PHYL_MAPPING_DECOMPOSITIONMETHODS_H
Methods useful for analytical substitution count and rewards using the eigen decomposition method.
ColMatrix< double > rightEigenVectors_
Real and imaginary eigenvectors, for non-reversible computation.
RowMatrix< double > leftIEigenVectors_
void computeExpectations(RowMatrix< double > &mapping, double length) const
RowMatrix< double > leftEigenVectors_
std::vector< RowMatrix< double > > insideIProducts_
void jFunction_(const std::vector< double > &lambda, double t, RowMatrix< double > &result) const
Compute the integral part of the computation.
ColMatrix< double > rightIEigenVectors_
DecompositionMethods & operator=(const DecompositionMethods &dm)
std::vector< RowMatrix< double > > insideProducts_
DecompositionMethods(std::shared_ptr< const SubstitutionModelInterface > model, std::shared_ptr< const SubstitutionRegisterInterface > reg)
DecompositionMethods * clone() const
void setSubstitutionModel(std::shared_ptr< const SubstitutionModelInterface > model)
Set the substitution model.
DecompositionMethods(const DecompositionMethods &dm)
std::shared_ptr< const SubstitutionModelInterface > model_
std::vector< RowMatrix< double > > bMatrices_
computation matrices
Map the states of a given alphabet which have a model state.
Definition: StateMap.h:25
Defines the basic types of data flow nodes.