bpp-core3  3.0.0
Simplex.h
Go to the documentation of this file.
1 //
2 // File: Simplex.h
3 // Authors:
4 // Laurent Guéguen
5 // Created: mardi 31 mai 2011, à 11h 02
6 //
7 
8 /*
9  Copyright or © or Copr. Bio++ Development Team, (November 17, 2004)
10 
11  This software is a computer program whose purpose is to provide classes
12  for numerical calculus.
13 
14  This software is governed by the CeCILL license under French law and
15  abiding by the rules of distribution of free software. You can use,
16  modify and/ or redistribute the software under the terms of the CeCILL
17  license as circulated by CEA, CNRS and INRIA at the following URL
18  "http://www.cecill.info".
19 
20  As a counterpart to the access to the source code and rights to copy,
21  modify and redistribute granted by the license, users are provided only
22  with a limited warranty and the software's author, the holder of the
23  economic rights, and the successive licensors have only limited
24  liability.
25 
26  In this respect, the user's attention is drawn to the risks associated
27  with loading, using, modifying and/or developing or reproducing the
28  software by the user in light of its specific status of free software,
29  that may mean that it is complicated to manipulate, and that also
30  therefore means that it is reserved for developers and experienced
31  professionals having in-depth computer knowledge. Users are therefore
32  encouraged to load and test the software's suitability as regards their
33  requirements in conditions enabling the security of their systems and/or
34  data to be ensured and, more generally, to use and operate it in the
35  same conditions as regards security.
36 
37  The fact that you are presently reading this means that you have had
38  knowledge of the CeCILL license and that you accept its terms.
39 */
40 
41 #ifndef BPP_NUMERIC_PROB_SIMPLEX_H
42 #define BPP_NUMERIC_PROB_SIMPLEX_H
43 
44 
45 
46 // From the STL:
47 #include <vector>
48 
49 #include "../AbstractParameterAliasable.h"
50 
51 namespace bpp
52 {
103 class Simplex :
105 {
106 private:
111  size_t dim_;
112 
121  unsigned short method_;
122 
123  std::vector<double> vProb_;
124 
128  std::vector<double> valpha_;
129 
130 public:
145  Simplex(size_t dim, unsigned short method = 0, bool allowNull = false, const std::string& name = "Simplex.");
146 
160  Simplex(const std::vector<double>& probas, unsigned short method = 0, bool allowNull = false, const std::string& name = "Simplex.");
161 
162  virtual ~Simplex() {}
163 
164  Simplex* clone() const { return new Simplex(*this); }
165 
166 public:
167  void fireParameterChanged(const ParameterList& parameters);
168 
169  size_t dimension() const { return dim_; }
170 
171  void setFrequencies(const std::vector<double>&);
172 
173  const std::vector<double>& getFrequencies() const { return vProb_;}
174 
175  std::vector<double>& getFrequencies() { return vProb_;}
176 
177  double prob(size_t i) const { return vProb_[i]; }
178 
179  unsigned short getMethod() const { return method_; }
180 };
181 } // end of namespace bpp.
182 #endif // BPP_NUMERIC_PROB_SIMPLEX_H
A partial implementation of the Parametrizable interface.
The parameter list object.
Definition: ParameterList.h:65
A Simplex object, used to define sets of probabilities that sum 1.
Definition: Simplex.h:105
size_t dimension() const
Definition: Simplex.h:169
unsigned short getMethod() const
Definition: Simplex.h:179
double prob(size_t i) const
Definition: Simplex.h:177
unsigned short method_
the method of parametrization.
Definition: Simplex.h:121
const std::vector< double > & getFrequencies() const
Definition: Simplex.h:173
Simplex * clone() const
Create a copy of this object and send a pointer to it.
Definition: Simplex.h:164
void fireParameterChanged(const ParameterList &parameters)
Notify the class when one or several parameters have changed.
Definition: Simplex.cpp:169
std::vector< double > vProb_
Definition: Simplex.h:123
size_t dim_
The dimension+1 of the space simplex (ie the number of probabilities).
Definition: Simplex.h:111
std::vector< double > valpha_
just used with local ratio (method 2)
Definition: Simplex.h:128
virtual ~Simplex()
Definition: Simplex.h:162
void setFrequencies(const std::vector< double > &)
Definition: Simplex.cpp:246
std::vector< double > & getFrequencies()
Definition: Simplex.h:175
Simplex(size_t dim, unsigned short method=0, bool allowNull=false, const std::string &name="Simplex.")
Builds a new Simplex object from a number of probabilities. They are initialized equal.
Definition: Simplex.cpp:121