aGrUM  0.14.2
discretizedVariable.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005 by Pierre-Henri WUILLEMIN et Christophe GONZALES *
3  * {prenom.nom}_at_lip6.fr *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
20 #ifndef GUM_DISCRETIZED_VARIABLE_H
21 #define GUM_DISCRETIZED_VARIABLE_H
22 
23 #include <iostream>
24 #include <limits>
25 #include <sstream>
26 #include <vector>
27 
28 #include <agrum/agrum.h>
29 
31 
32 namespace gum {
53  template < typename T_TICKS >
55  private:
56  std::vector< T_TICKS > __ticks; // Array from 0 to domainSize-2
58 
59  protected:
66  void _copy(const DiscretizedVariable< T_TICKS >& aDRV);
67 
77  Idx _dichotomy(const T_TICKS& target, Idx min, Idx max) const;
78 
84  Idx _pos(const T_TICKS& target) const;
85 
86  public:
96  DiscretizedVariable(const std::string& aName, const std::string& aDesc);
97 
103  DiscretizedVariable(const std::string& aName,
104  const std::string& aDesc,
105  const std::vector< T_TICKS >& ticks);
106 
112 
116  virtual ~DiscretizedVariable();
117 
119 
121  virtual DiscretizedVariable< T_TICKS >* clone() const;
122 
124 
125  virtual VarType varType() const;
126 
134 
140  bool isTick(const T_TICKS& aTick) const;
141 
147  DiscretizedVariable& addTick(const T_TICKS& aTick);
148 
152  void eraseTicks();
153 
159  virtual std::string label(Idx i) const;
160 
162  virtual double numerical(Idx indice) const;
163 
166  virtual Idx index(const std::string& label) const;
167 
172  virtual Size domainSize() const;
173  virtual const std::string domain() const;
174 
177  const T_TICKS& tick(Idx i) const;
178 
180  const std::vector< T_TICKS >& ticks() const;
181 
183  virtual std::vector< double > ticksAsDoubles() const;
184  };
185 
186 } /* namespace gum */
187 
190 
191 #endif /* GUM_DISCRETIZED_VARIABLE_H */
virtual std::vector< double > ticksAsDoubles() const
return the list of ticks as a vector of doubles
std::vector< T_TICKS > __ticks
virtual Idx index(const std::string &label) const
from the label to its index in var.
Class for discretized random variable.
virtual Size domainSize() const
gum is the global namespace for all aGrUM entities
Definition: agrum.h:25
virtual ~DiscretizedVariable()
Destructor.
virtual std::string label(Idx i) const
const std::vector< T_TICKS > & ticks() const
Return the list of ticks.
bool isTick(const T_TICKS &aTick) const
DiscretizedVariable & addTick(const T_TICKS &aTick)
add a tick.
VarType
Definition: variable.h:38
virtual double numerical(Idx indice) const
get a numerical representation of he indice-the value.
DiscretizedVariable(const std::string &aName, const std::string &aDesc)
Constructor.
Idx _pos(const T_TICKS &target) const
seach the class of target (internally use _dichotomy)
DiscretizedVariable< T_TICKS > & operator=(const DiscretizedVariable< T_TICKS > &aDRV)
operator =
const T_TICKS & tick(Idx i) const
from the index to the tick.
void eraseTicks()
erase all the Ticks
virtual DiscretizedVariable< T_TICKS > * clone() const
a virtual clone
Size Idx
Type for indexes.
Definition: types.h:50
virtual const std::string domain() const
string represent the domain of the variable
virtual VarType varType() const
returns the type of variable
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:45
void _copy(const DiscretizedVariable< T_TICKS > &aDRV)
make a copy TODO since we removed T_OtherData maybe some changes are needed in this method...
Idx _dichotomy(const T_TICKS &target, Idx min, Idx max) const
perform a dichotomy on ticks
A base class for discretized variables, independent of the ticks type.