bpp-phyl3 3.0.0
AlignedPhyloLikelihoodProduct.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
7using namespace bpp;
8using namespace std;
9
10AlignedPhyloLikelihoodProduct::AlignedPhyloLikelihoodProduct(
11 Context& context,
12 std::shared_ptr<PhyloLikelihoodContainer> pC,
13 bool inCollection) :
16 AbstractPhyloLikelihoodSet(context, pC, {}, inCollection),
18 AbstractAlignedPhyloLikelihoodSet(context, pC, inCollection)
19{
20 auto nPhylo = pC->getNumbersOfPhyloLikelihoods();
21
22 // get RowVectorXd for each single Calculation
23 std::vector<std::shared_ptr<Node_DF>> vSL;
24
25 for (auto np : nPhylo)
26 {
27 vSL.push_back(alignedPhyloLikelihood(np).alignedLikelihoodCalculation().getSiteLikelihoods(false));
28 }
29
30 auto sL = CWiseMul<RowLik, ReductionOf<RowLik>>::create(this->context(), std::move(vSL), RowVectorDimension (nbSites_));
31
32 likCal_->setSiteLikelihoods(sL);
33
34 auto su = SumOfLogarithms<RowLik>::create (this->context(), {sL}, RowVectorDimension (Eigen::Index (nbSites_)));
35
36 likCal_->setLikelihoodNode(su);
37}
38
40 Context& context,
41 std::shared_ptr<PhyloLikelihoodContainer> pC,
42 const std::vector<size_t>& nPhylo,
43 bool inCollection) :
46 AbstractPhyloLikelihoodSet(context, pC, {}, inCollection),
48 AbstractAlignedPhyloLikelihoodSet(context, pC, nPhylo, inCollection),
49 likCal_(make_shared<AlignedLikelihoodCalculation>(context))
50{
51 // get RowVectorXd for each single Calculation
52 std::vector<std::shared_ptr<Node_DF>> vSL;
53
54 for (auto np : nPhylo)
55 {
56 vSL.push_back(alignedPhyloLikelihood(np).alignedLikelihoodCalculation().getSiteLikelihoods(false));
57 }
58
59 auto sL = CWiseMul<RowLik, ReductionOf<RowLik>>::create(this->context(), std::move(vSL), RowVectorDimension (nbSites_));
60
61 likCal_->setSiteLikelihoods(sL);
62
63 auto su = SumOfLogarithms<Eigen::RowVectorXd>::create (this->context(), {sL}, RowVectorDimension (nbSites_));
64
65 likCal_->setLikelihoodNode(su);
66}
The AlignedPhyloLikelihoodSet abstract class.
The PhyloLikelihoodSet class, to manage a subset of PhyloLikelihoods from a given PhyloLikelihoodCont...
const std::vector< size_t > & getNumbersOfPhyloLikelihoods() const override
AlignedPhyloLikelihoodProduct(Context &context, std::shared_ptr< PhyloLikelihoodContainer > pC, bool inCollection=true)
Context for dataflow node construction.
Definition: DataFlow.h:527
static ValueRef< DataLik > create(Context &c, NodeRefVec &&deps, const Dimension< F > &mDim)
Build a new SumOfLogarithms node with the given input matrix dimensions.
Defines the basic types of data flow nodes.