40 #ifndef _ABSTRACTSUBSTITUTIONMODEL_H_ 41 #define _ABSTRACTSUBSTITUTIONMODEL_H_ 45 #include <Bpp/Numeric/AbstractParameterAliasable.h> 46 #include <Bpp/Numeric/VectorTools.h> 80 public virtual AbstractParameterAliasable
183 AbstractParameterAliasable(model),
207 AbstractParameterAliasable::operator=(model);
232 #ifndef NO_VIRTUAL_COV 259 virtual const Matrix<double>&
getPij_t(
double t)
const;
260 virtual const Matrix<double>&
getdPij_dt(
double t)
const;
261 virtual const Matrix<double>&
getd2Pij_dt2(
double t)
const;
275 virtual double freq(
size_t i)
const {
return freq_[i]; }
279 virtual double Pij_t (
size_t i,
size_t j,
double t)
const {
return getPij_t(t) (i, j); }
283 double getInitValue(
size_t i,
int state)
const throw (IndexOutOfBoundsException, BadIntException);
285 void setFreqFromData(
const SequenceContainer& data,
double pseudoCount = 0);
287 virtual void setFreq(std::map<int, double>&);
300 AbstractParameterAliasable::fireParameterChanged(parameters);
301 if ((parameters.size()!=1) || (parameters[0].
getName()!=getNamespace()+
"rate"))
338 virtual double getRate()
const;
340 virtual void setRate(
double rate);
378 AbstractParameterAliasable(prefix),
387 #ifndef NO_VIRTUAL_COV 419 #endif //_ABSTRACTSUBSTITUTIONMODEL_H_ virtual double d2Pij_dt2(size_t i, size_t j, double t) const
virtual void updateMatrices()
Diagonalize the matrix, and fill the eigenValues_, iEigenValues_, leftEigenVectors_ and rightEigenVe...
Interface for all substitution models.
bool enableEigenDecomposition()
Tell if eigenValues and Vectors must be computed.
RowMatrix< double > exchangeability_
The exchangeability matrix of the model, defined as . When the model is reversible, this matrix is symetric.
virtual void fireParameterChanged(const ParameterList ¶meters)
Tells the model that a parameter value has changed.
AbstractSubstitutionModel(const AbstractSubstitutionModel &model)
virtual double getRate() const
Get the rate.
bool isNonSingular_
boolean value for non-singularity of rightEigenVectors_
Partial implementation of the SubstitutionModel interface for models that are set for matching the bi...
virtual const Matrix< double > & getPij_t(double t) const
RowMatrix< double > d2pijt_
RowMatrix< double > pijt_
These ones are for bookkeeping:
RowMatrix< double > rightEigenVectors_
The matrix made of right eigen vectors (by column).
Vdouble eigenValues_
The vector of eigen values.
int getAlphabetStateAsInt(size_t index) const
const Vdouble & getEigenValues() const
const Matrix< double > & getRowLeftEigenVectors() const
Vdouble freq_
The vector of equilibrium frequencies.
double getInitValue(size_t i, int state) const
const Vdouble & getIEigenValues() const
std::string getAlphabetStateAsChar(size_t index) const
virtual double Qij(size_t i, size_t j) const
bool isNonSingular() const
std::vector< size_t > getModelStates(const std::string &code) const
Get the state in the model corresponding to a particular state in the alphabet.
virtual ~AbstractSubstitutionModel()
virtual void updateMatrices()
Compute and diagonalize the matrix, and fill the eigenValues_, leftEigenVectors_ and rightEigenVecto...
AbstractSubstitutionModel & operator=(const AbstractSubstitutionModel &model)
double getScale() const
Get the scalar product of diagonal elements of the generator and the frequencies vector. If the generator is normalized, then scale=1. Otherwise each element must be multiplied by 1/scale.
virtual AbstractSubstitutionModel * clone() const =0
const StateMap & getStateMap() const
Partial implementation of the SubstitutionModel interface.
void setFreqFromData(const SequenceContainer &data, double pseudoCount=0)
Set equilibrium frequencies equal to the frequencies estimated from the data.
AbstractReversibleSubstitutionModel(const Alphabet *alpha, StateMap *stateMap, const std::string &prefix)
Partial implementation of the ReversibleSubstitutionModel interface.
virtual AbstractReversibleSubstitutionModel * clone() const =0
bool isDiagonalizable() const
virtual double freq(size_t i) const
virtual double Pij_t(size_t i, size_t j, double t) const
Interface for reversible substitution models.
void setScale(double scale)
Multiplies the current generator by the given scale.
void enableEigenDecomposition(bool yn)
Set if eigenValues and Vectors must be computed.
const Alphabet * alphabet_
The alphabet relevant to this model.
virtual std::string getName() const =0
Get the name of the model.
virtual const Matrix< double > & getdPij_dt(double t) const
virtual const Matrix< double > & getd2Pij_dt2(double t) const
std::auto_ptr< StateMap > stateMap_
The map of model states with alphabet states.
const std::vector< int > & getAlphabetStates() const
bool eigenDecompose_
Tell if the eigen decomposition should be performed.
RowMatrix< double > leftEigenVectors_
The matrix made of left eigen vectors (by row) if rightEigenVectors_ is non-singular.
virtual double dPij_dt(size_t i, size_t j, double t) const
virtual ~AbstractReversibleSubstitutionModel()
double Sij(size_t i, size_t j) const
RowMatrix< double > generator_
The generator matrix of the model.
const Matrix< double > & getExchangeabilityMatrix() const
double rate_
The rate of the model (default: 1). The generator (and all its vectorial components) is independent o...
const Alphabet * getAlphabet() const
std::vector< size_t > getModelStates(int code) const
Get the state in the model corresponding to a particular state in the alphabet.
std::vector< RowMatrix< double > > vPowGen_
vector of the powers of generator_ for Taylor development (if rightEigenVectors_ is singular)...
virtual void setRate(double rate)
Set the rate of the model (must be positive).
const Matrix< double > & getColumnRightEigenVectors() const
RowMatrix< double > dpijt_
size_t size_
The size of the generator, i.e. the number of states.
const Matrix< double > & getGenerator() const
virtual const Vdouble & getFrequencies() const
Map the states of a given alphabet which have a model state.
RowMatrix< double > tmpMat_
For computational issues.
bool isDiagonalizable_
boolean value for diagonalizability in R of the generator_
Vdouble iEigenValues_
The vector of the imaginary part of the eigen values.
AbstractSubstitutionModel(const Alphabet *alpha, StateMap *stateMap, const std::string &prefix)
virtual void setFreq(std::map< int, double > &)
Set equilibrium frequencies.