bpp-phyl  2.2.0
LaplaceSubstitutionCount.h
Go to the documentation of this file.
1 //
2 // File: LaplaceSubstitutionCount.h
3 // Created by: Julien Dutheil
4 // Created on: Wed Apr 5 11:21 2006
5 //
6 
7 /*
8  Copyright or © or Copr. Bio++ Development Team, (November 16, 2004, 2005, 2006)
9 
10  This software is a computer program whose purpose is to provide classes
11  for phylogenetic data analysis.
12 
13  This software is governed by the CeCILL license under French law and
14  abiding by the rules of distribution of free software. You can use,
15  modify and/ or redistribute the software under the terms of the CeCILL
16  license as circulated by CEA, CNRS and INRIA at the following URL
17  "http://www.cecill.info".
18 
19  As a counterpart to the access to the source code and rights to copy,
20  modify and redistribute granted by the license, users are provided only
21  with a limited warranty and the software's author, the holder of the
22  economic rights, and the successive licensors have only limited
23  liability.
24 
25  In this respect, the user's attention is drawn to the risks associated
26  with loading, using, modifying and/or developing or reproducing the
27  software by the user in light of its specific status of free software,
28  that may mean that it is complicated to manipulate, and that also
29  therefore means that it is reserved for developers and experienced
30  professionals having in-depth computer knowledge. Users are therefore
31  encouraged to load and test the software's suitability as regards their
32  requirements in conditions enabling the security of their systems and/or
33  data to be ensured and, more generally, to use and operate it in the
34  same conditions as regards security.
35 
36  The fact that you are presently reading this means that you have had
37  knowledge of the CeCILL license and that you accept its terms.
38 */
39 
40 #ifndef _LAPLACESUBSTITUTIONCOUNT_H_
41 #define _LAPLACESUBSTITUTIONCOUNT_H_
42 
43 #include "SubstitutionCount.h"
44 #include "../Model/SubstitutionModel.h"
45 
46 namespace bpp
47 {
48 
63  {
64  private:
66  size_t cutOff_;
67  mutable double currentLength_;
68  mutable RowMatrix<double> m_;
69 
70  public:
71  LaplaceSubstitutionCount(const SubstitutionModel* model, size_t cutOff) :
73  model_ (model),
74  cutOff_ (cutOff),
75  currentLength_(-1),
76  m_ (model->getNumberOfStates(), model->getNumberOfStates())
77  {}
78 
81  model_ (asc.model_),
82  cutOff_ (asc.cutOff_),
84  m_ (asc.m_)
85  {}
86 
88  {
90  model_ = asc.model_;
91  cutOff_ = asc.cutOff_;
93  m_ = asc.m_;
94  return *this;
95  }
96 
98 
100 
101  public:
102  double getNumberOfSubstitutions(size_t initialState, size_t finalState, double length, size_t type = 1) const;
103  Matrix<double>* getAllNumbersOfSubstitutions(double length, size_t type = 1) const;
104  std::vector<double> getNumberOfSubstitutionsForEachType(size_t initialState, size_t finalState, double length) const
105  {
106  std::vector<double> v(0);
107  v[0] = getNumberOfSubstitutions(initialState, finalState, length, 0);
108  return v;
109  }
110 
111  void setSubstitutionModel(const SubstitutionModel* model);
112 
113  /*
114  *@param reg pointer to a SubstitutionRegister
115  *
116  */
117  void setSubstitutionRegister(SubstitutionRegister* reg) throw (Exception) {
118  throw Exception("LaplaceSubstitutionCount::setSubstitutionRegister. This SubstitutionsCount only works with a TotalSubstitutionRegister.");
119  }
120 
121  protected:
122  void computeCounts(double length) const;
124  };
125 
126 } //end of namespace bpp.
127 
128 #endif //_LAPLACESUBSTITUTIONCOUNT_H_
129 
void setSubstitutionModel(const SubstitutionModel *model)
Set the substitution model associated with this count, if relevent.
Interface for all substitution models.
LaplaceSubstitutionCount(const SubstitutionModel *model, size_t cutOff)
AbstractSubstitutionCount & operator=(const AbstractSubstitutionCount &asc)
std::vector< double > getNumberOfSubstitutionsForEachType(size_t initialState, size_t finalState, double length) const
Get the numbers of susbstitutions on a branch for all types, for an initial and final states...
virtual size_t getNumberOfStates() const
Short cut function, equivalent to getSubstitutionRegister()->getAlphabet()->getSize().
Basic implementation of the the SubstitutionCount interface.
void computeCounts(double length) const
The SubstitutionRegister interface.
void setSubstitutionRegister(SubstitutionRegister *reg)
Matrix< double > * getAllNumbersOfSubstitutions(double length, size_t type=1) const
Get the numbers of susbstitutions on a branch, for each initial and final states, and given the branc...
const SubstitutionModel * model_
LaplaceSubstitutionCount & operator=(const LaplaceSubstitutionCount &asc)
LaplaceSubstitutionCount * clone() const
double getNumberOfSubstitutions(size_t initialState, size_t finalState, double length, size_t type=1) const
Get the number of susbstitutions on a branch, given the initial and final states, and the branch leng...
Laplace estimate of the substitution count.
LaplaceSubstitutionCount(const LaplaceSubstitutionCount &asc)