bpp-phyl
2.2.0
|
Analytical reward using the eigen decomposition method. More...
#include <Bpp/Phyl/Mapping/DecompositionReward.h>
Public Member Functions | |
DecompositionReward (const SubstitutionModel *model, AlphabetIndex1 *alphIndex) | |
DecompositionReward (const DecompositionReward &dr) | |
DecompositionReward & | operator= (const DecompositionReward &dr) |
virtual | ~DecompositionReward () |
DecompositionReward * | clone () const |
double | getReward (size_t initialState, size_t finalState, double length) const |
Get the reward of susbstitutions on a branch, given the initial and final states, and the branch length. More... | |
Matrix< double > * | getAllRewards (double length) const |
Get the rewards on a branch, for each initial and final states, and given the branch length. More... | |
void | setSubstitutionModel (const SubstitutionModel *model) |
Set the substitution model. More... | |
bool | hasAlphabetIndex () const |
void | setAlphabetIndex (AlphabetIndex1 *alphIndex) |
const AlphabetIndex1 * | getAlphabetIndex () const |
AlphabetIndex1 * | getAlphabetIndex () |
virtual const Alphabet * | getAlphabet () const |
Short cut function, equivalent to getSubstitutionRegister()->getAlphabet(). More... | |
virtual size_t | getNumberOfStates () const |
Short cut function, equivalent to getSubstitutionRegister()->getAlphabet()->getSize(). More... | |
Protected Member Functions | |
void | computeRewards_ (double length) const |
void | jFunction_ (const std::vector< double > &lambda, double t, RowMatrix< double > &result) const |
void | alphabetIndexHasChanged () throw (Exception) |
Protected Attributes | |
AlphabetIndex1 * | alphIndex_ |
Private Member Functions | |
void | resetStates_ () |
void | computeBMatrice_ () |
void | computeEigen_ () |
void | computeProducts_ () |
Private Attributes | |
const ReversibleSubstitutionModel * | model_ |
size_t | nbStates_ |
RowMatrix< double > | jMat_ |
RowMatrix< double > | v_ |
RowMatrix< double > | vInv_ |
std::vector< double > | lambda_ |
RowMatrix< double > | bMatrice_ |
RowMatrix< double > | insideProduct_ |
RowMatrix< double > | rewards_ |
double | currentLength_ |
Analytical reward using the eigen decomposition method.
The codes is adapted from the original R code by Paula Tataru and Asger Hobolth to the formula in the article of Minin & Suchard.
Minin, V.N. and Suchard, M.A., Fast, accurate and simulation-free stochastic mapping Philosophical Transactions of the Royal Society B 2008 363:3985-95.
Only reversible models are supported for now.
Definition at line 65 of file DecompositionReward.h.
DecompositionReward::DecompositionReward | ( | const SubstitutionModel * | model, |
AlphabetIndex1 * | alphIndex | ||
) |
Definition at line 50 of file DecompositionReward.cpp.
References bpp::AbstractReward::alphIndex_, computeBMatrice_(), computeEigen_(), computeProducts_(), and bpp::SubstitutionModel::getAlphabet().
Referenced by clone().
|
inline |
Definition at line 80 of file DecompositionReward.h.
|
inlinevirtual |
Definition at line 110 of file DecompositionReward.h.
|
protectedvirtual |
Implements bpp::AbstractReward.
Definition at line 200 of file DecompositionReward.cpp.
References bpp::AbstractReward::alphIndex_, computeBMatrice_(), computeProducts_(), computeRewards_(), currentLength_, bpp::SubstitutionModel::getAlphabet(), and model_.
|
inlinevirtual |
Implements bpp::Reward.
Definition at line 112 of file DecompositionReward.h.
References DecompositionReward().
|
private |
Definition at line 78 of file DecompositionReward.cpp.
References bMatrice_, bpp::AbstractReward::getAlphabetIndex(), bpp::SubstitutionModel::getAlphabetStates(), model_, and nbStates_.
Referenced by alphabetIndexHasChanged(), and DecompositionReward().
|
private |
Definition at line 85 of file DecompositionReward.cpp.
References bpp::SubstitutionModel::getColumnRightEigenVectors(), bpp::SubstitutionModel::getEigenValues(), bpp::SubstitutionModel::getRowLeftEigenVectors(), lambda_, model_, v_, and vInv_.
Referenced by DecompositionReward(), and setSubstitutionModel().
|
private |
Definition at line 92 of file DecompositionReward.cpp.
References bMatrice_, insideProduct_, nbStates_, v_, and vInv_.
Referenced by alphabetIndexHasChanged(), DecompositionReward(), and setSubstitutionModel().
|
protected |
Definition at line 127 of file DecompositionReward.cpp.
References bpp::SubstitutionModel::getPij_t(), insideProduct_, jFunction_(), jMat_, lambda_, model_, nbStates_, rewards_, v_, and vInv_.
Referenced by alphabetIndexHasChanged(), getAllRewards(), getReward(), and setSubstitutionModel().
|
virtual |
Get the rewards on a branch, for each initial and final states, and given the branch length.
length | The length of the branch. |
Implements bpp::Reward.
Definition at line 148 of file DecompositionReward.cpp.
References computeRewards_(), currentLength_, and rewards_.
|
inlinevirtualinherited |
Short cut function, equivalent to getSubstitutionRegister()->getAlphabet().
Definition at line 108 of file Reward.h.
References bpp::Reward::getAlphabetIndex().
Referenced by bpp::Reward::getNumberOfStates().
|
inlinevirtualinherited |
Implements bpp::Reward.
Definition at line 194 of file Reward.h.
References bpp::AbstractReward::alphIndex_.
Referenced by computeBMatrice_().
|
inlinevirtualinherited |
Implements bpp::Reward.
Definition at line 196 of file Reward.h.
References bpp::AbstractReward::alphIndex_.
|
inlinevirtualinherited |
Short cut function, equivalent to getSubstitutionRegister()->getAlphabet()->getSize().
Definition at line 115 of file Reward.h.
References bpp::Reward::getAlphabet().
|
virtual |
Get the reward of susbstitutions on a branch, given the initial and final states, and the branch length.
initialState | The initial state. |
finalState | The final state. |
length | The length of the branch. |
Implements bpp::Reward.
Definition at line 162 of file DecompositionReward.cpp.
References computeRewards_(), currentLength_, and rewards_.
|
inlinevirtualinherited |
Implements bpp::Reward.
Definition at line 179 of file Reward.h.
References bpp::AbstractReward::alphIndex_.
|
protected |
Definition at line 110 of file DecompositionReward.cpp.
References nbStates_.
Referenced by computeRewards_().
|
inline |
Definition at line 94 of file DecompositionReward.h.
References bMatrice_, currentLength_, insideProduct_, jMat_, lambda_, model_, nbStates_, bpp::AbstractReward::operator=(), rewards_, v_, and vInv_.
|
private |
Definition at line 99 of file DecompositionReward.cpp.
References bMatrice_, insideProduct_, jMat_, lambda_, nbStates_, rewards_, v_, and vInv_.
Referenced by setSubstitutionModel().
|
inlinevirtualinherited |
alphind | The new AlphabetIndex1 object to be associated to this instance. |
Implements bpp::Reward.
Definition at line 188 of file Reward.h.
References bpp::AbstractReward::alphabetIndexHasChanged(), and bpp::AbstractReward::alphIndex_.
|
virtual |
Set the substitution model.
model | A pointer toward the substitution model to use. Only reversible models are currently supported. Setting a non-reversible model will throw an exception. |
Implements bpp::Reward.
Definition at line 176 of file DecompositionReward.cpp.
References bpp::AbstractReward::alphIndex_, computeEigen_(), computeProducts_(), computeRewards_(), currentLength_, bpp::SubstitutionModel::getAlphabet(), model_, nbStates_, and resetStates_().
|
protectedinherited |
Definition at line 155 of file Reward.h.
Referenced by alphabetIndexHasChanged(), DecompositionReward(), bpp::AbstractReward::getAlphabetIndex(), bpp::AbstractReward::hasAlphabetIndex(), bpp::AbstractReward::operator=(), bpp::AbstractReward::setAlphabetIndex(), and setSubstitutionModel().
|
private |
Definition at line 73 of file DecompositionReward.h.
Referenced by computeBMatrice_(), computeProducts_(), operator=(), and resetStates_().
|
mutableprivate |
Definition at line 75 of file DecompositionReward.h.
Referenced by alphabetIndexHasChanged(), getAllRewards(), getReward(), operator=(), and setSubstitutionModel().
|
private |
Definition at line 73 of file DecompositionReward.h.
Referenced by computeProducts_(), computeRewards_(), operator=(), and resetStates_().
|
mutableprivate |
Definition at line 71 of file DecompositionReward.h.
Referenced by computeRewards_(), operator=(), and resetStates_().
|
mutableprivate |
Definition at line 72 of file DecompositionReward.h.
Referenced by computeEigen_(), computeRewards_(), operator=(), and resetStates_().
|
private |
Definition at line 69 of file DecompositionReward.h.
Referenced by alphabetIndexHasChanged(), computeBMatrice_(), computeEigen_(), computeRewards_(), operator=(), and setSubstitutionModel().
|
private |
Definition at line 70 of file DecompositionReward.h.
Referenced by computeBMatrice_(), computeProducts_(), computeRewards_(), jFunction_(), operator=(), resetStates_(), and setSubstitutionModel().
|
mutableprivate |
Definition at line 74 of file DecompositionReward.h.
Referenced by computeRewards_(), getAllRewards(), getReward(), operator=(), and resetStates_().
|
mutableprivate |
Definition at line 71 of file DecompositionReward.h.
Referenced by computeEigen_(), computeProducts_(), computeRewards_(), operator=(), and resetStates_().
|
mutableprivate |
Definition at line 71 of file DecompositionReward.h.
Referenced by computeEigen_(), computeProducts_(), computeRewards_(), operator=(), and resetStates_().