aGrUM  0.16.0
discretizedVariable.h
Go to the documentation of this file.
1 
23 #ifndef GUM_DISCRETIZED_VARIABLE_H
24 #define GUM_DISCRETIZED_VARIABLE_H
25 
26 #include <iostream>
27 #include <limits>
28 #include <sstream>
29 #include <vector>
30 
31 #include <agrum/agrum.h>
32 
34 
35 namespace gum {
56  template < typename T_TICKS >
58  private:
59  std::vector< T_TICKS > __ticks; // Array from 0 to domainSize-2
61 
62  protected:
69  void _copy(const DiscretizedVariable< T_TICKS >& aDRV);
70 
80  Idx _dichotomy(const T_TICKS& target, Idx min, Idx max) const;
81 
87  Idx _pos(const T_TICKS& target) const;
88 
89  public:
99  DiscretizedVariable(const std::string& aName, const std::string& aDesc);
100 
106  DiscretizedVariable(const std::string& aName,
107  const std::string& aDesc,
108  const std::vector< T_TICKS >& ticks);
109 
115 
119  virtual ~DiscretizedVariable();
120 
122 
124  virtual DiscretizedVariable< T_TICKS >* clone() const;
125 
127 
128  virtual VarType varType() const;
129 
137 
143  bool isTick(const T_TICKS& aTick) const;
144 
150  DiscretizedVariable& addTick(const T_TICKS& aTick);
151 
155  void eraseTicks();
156 
162  virtual std::string label(Idx i) const;
163 
165  virtual double numerical(Idx indice) const;
166 
169  virtual Idx index(const std::string& label) const;
170 
175  virtual Size domainSize() const;
176  virtual const std::string domain() const;
177 
180  const T_TICKS& tick(Idx i) const;
181 
183  const std::vector< T_TICKS >& ticks() const;
184 
186  virtual std::vector< double > ticksAsDoubles() const;
187  };
188 
189 } /* namespace gum */
190 
193 
194 #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
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
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:41
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:53
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:48
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.