bpp-core  2.2.0
Simplex.h
Go to the documentation of this file.
1 //
2 // File: Simplex.h
3 // Created by: Laurent Guéguen
4 // Created on: mardi 31 mai 2011, à 11h 02
5 //
6 
7 /*
8  Copyright or © or Copr. Bio++ Development Team, (November 17, 2004)
9 
10  This software is a computer program whose purpose is to provide classes
11  for numerical calculus.
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 _SIMPLEX_H_
41 #define _SIMPLEX_H_
42 
43 
44 // From the STL:
45 #include <vector>
46 
47 #include "../AbstractParameterAliasable.h"
48 
49 namespace bpp
50 {
100 class Simplex :
102 {
103 private:
104 
109  size_t dim_;
110 
119  unsigned short method_;
120 
121  std::vector<double> vProb_;
122 
126  std::vector<double> valpha_;
127 
128 public:
143  Simplex(size_t dim, unsigned short method = 0, bool allowNull = false, const std::string& name = "Simplex.");
144 
158  Simplex(const std::vector<double>& probas, unsigned short method = 0, bool allowNull = false, const std::string& name = "Simplex.");
159 
160  virtual ~Simplex() {}
161 
162  Simplex* clone() const { return new Simplex(*this); }
163 
164 public:
165  void fireParameterChanged(const ParameterList& parameters);
166 
167  size_t dimension() const { return dim_; }
168 
169  void setFrequencies(const std::vector<double>&);
170 
171  const std::vector<double>& getFrequencies() const { return vProb_;}
172 
173  std::vector<double>& getFrequencies() { return vProb_;}
174 
175  double prob(size_t i) const { return vProb_[i]; }
176 
177  unsigned short getMethod() const { return method_; }
178 };
179 } // end of namespace bpp.
180 
181 #endif // _SIMPLEDISCRETEDISTRIBUTION_H_
182 
std::vector< double > & getFrequencies()
Definition: Simplex.h:173
void setFrequencies(const std::vector< double > &)
Definition: Simplex.cpp:240
const std::vector< double > & getFrequencies() const
Definition: Simplex.h:171
void fireParameterChanged(const ParameterList &parameters)
Notify the class when one or several parameters have changed.
Definition: Simplex.cpp:168
unsigned short getMethod() const
Definition: Simplex.h:177
This class allows to perform a correspondence analysis.
std::vector< double > vProb_
Definition: Simplex.h:121
size_t dim_
The dimension+1 of the space simplex (ie the number of probabilities).
Definition: Simplex.h:109
double prob(size_t i) const
Definition: Simplex.h:175
A Simplex object, used to define sets of probabilities that sum 1.
Definition: Simplex.h:100
The parameter list object.
Definition: ParameterList.h:61
A partial implementation of the Parametrizable interface.
std::vector< double > valpha_
just used with local ratio (method 2)
Definition: Simplex.h:126
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:120
virtual ~Simplex()
Definition: Simplex.h:160
unsigned short method_
the method of parametrization.
Definition: Simplex.h:119
size_t dimension() const
Definition: Simplex.h:167
Simplex * clone() const
Create a copy of this object and send a pointer to it.
Definition: Simplex.h:162