bpp-phyl3 3.0.0
DecompositionSubstitutionCount.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_DECOMPOSITIONSUBSTITUTIONCOUNT_H
6#define BPP_PHYL_MAPPING_DECOMPOSITIONSUBSTITUTIONCOUNT_H
7
9
13
14namespace bpp
15{
29{
30private:
31 mutable std::vector< RowMatrix<double>> counts_;
32 mutable double currentLength_;
33
34public:
36 std::shared_ptr<const SubstitutionModelInterface> model,
37 std::shared_ptr<const SubstitutionRegisterInterface> reg,
38 std::shared_ptr<const AlphabetIndex2> weights = nullptr,
39 std::shared_ptr<const AlphabetIndex2> distances = nullptr);
40
42 std::shared_ptr<const SubstitutionRegisterInterface> reg,
43 std::shared_ptr<const AlphabetIndex2> weights = nullptr,
44 std::shared_ptr<const AlphabetIndex2> distances = nullptr);
45
51 counts_(dsc.counts_),
53 {}
54
56 {
57 AbstractSubstitutionCount::operator=(dsc);
61 counts_ = dsc.counts_;
63 return *this;
64 }
65
67
69
70public:
71 double getNumberOfSubstitutions(size_t initialState, size_t finalState, double length, size_t type = 1) const override;
72
73 std::unique_ptr< Matrix<double>> getAllNumbersOfSubstitutions(double length, size_t type = 1) const override;
74
75 void storeAllNumbersOfSubstitutions(double length, size_t type, Eigen::MatrixXd& mat) const override;
76
77 std::vector<double> getNumberOfSubstitutionsPerType(size_t initialState, size_t finalState, double length) const override;
78
84 void setSubstitutionModel(std::shared_ptr<const SubstitutionModelInterface> model) override;
85
86protected:
87 void initCounts_();
88
89 void computeCounts_(double length) const;
90
91 void substitutionRegisterHasChanged() override;
92
93 void weightsHaveChanged() override;
94
95 void distancesHaveChanged() override;
96
97private:
98 void fillBMatrices_();
99
101};
102} // end of namespace bpp.
103#endif // BPP_PHYL_MAPPING_DECOMPOSITIONSUBSTITUTIONCOUNT_H
Partial implementation of the SubstitutionCount interface.
Partial implementation of the SubstitutionDistance interface.
AbstractSubstitutionDistance & operator=(const AbstractSubstitutionDistance &index)
Partial implementation of the WeightedSubstitutionCount interface.
AbstractWeightedSubstitutionCount & operator=(const AbstractWeightedSubstitutionCount &index)
Methods useful for analytical substitution count and rewards using the eigen decomposition method.
DecompositionMethods & operator=(const DecompositionMethods &dm)
Analytical substitution count using the eigen decomposition method.
double getNumberOfSubstitutions(size_t initialState, size_t finalState, double length, size_t type=1) const override
Get the number of susbstitutions on a branch, given the initial and final states, and the branch leng...
DecompositionSubstitutionCount(std::shared_ptr< const SubstitutionModelInterface > model, std::shared_ptr< const SubstitutionRegisterInterface > reg, std::shared_ptr< const AlphabetIndex2 > weights=nullptr, std::shared_ptr< const AlphabetIndex2 > distances=nullptr)
std::vector< RowMatrix< double > > counts_
std::unique_ptr< Matrix< double > > getAllNumbersOfSubstitutions(double length, size_t type=1) const override
Get the numbers of susbstitutions on a branch, for each initial and final states, and given the branc...
std::vector< double > getNumberOfSubstitutionsPerType(size_t initialState, size_t finalState, double length) const override
Get the numbers of susbstitutions on a branch for all types, for an initial and final states,...
DecompositionSubstitutionCount & operator=(const DecompositionSubstitutionCount &dsc)
void storeAllNumbersOfSubstitutions(double length, size_t type, Eigen::MatrixXd &mat) const override
Stores the numbers of susbstitutions on a branch, for each initial and final states,...
DecompositionSubstitutionCount(const DecompositionSubstitutionCount &dsc)
DecompositionSubstitutionCount * clone() const override
void setSubstitutionModel(std::shared_ptr< const SubstitutionModelInterface > model) override
Set the substitution model.
Defines the basic types of data flow nodes.