Commit 85855161 authored by Christophe Gonzales's avatar Christophe Gonzales

enable databases to use translators for DiscretizedVariable<X> and…

enable databases to use translators for DiscretizedVariable<X> and ContinuousVariable<X>, with different types X
parent 74af3833
Pipeline #23105428 failed with stages
in 5 minutes and 14 seconds
......@@ -42,7 +42,7 @@ namespace gum {
try {
for (auto node : bn.dag()) {
const Variable& var = bn.variable(node);
__database.template insertTranslator<GUM_SCALAR,std::allocator>(var, var_names[var.name()], missing_symbols);
__database.insertTranslator(var, var_names[var.name()], missing_symbols);
}
} catch (NotFound&) {
GUM_ERROR(MissingVariableInDatabase,
......
......@@ -169,8 +169,8 @@ namespace gum {
const bool fit_range = false,
const allocator_type& alloc = allocator_type());
/// default constructor with a discrete variable as translator
/** @param var a labelized variable whose labels will be used for
/// default constructor with a continuous variable as translator
/** @param var a continuous variable that will be used for
* translations. The translator keeps a copy of this variable
* @param missing_symbols the set of symbols in the database
* representing missing values
......@@ -190,10 +190,10 @@ namespace gum {
const bool fit_range = false,
const allocator_type& alloc = allocator_type());
/** @brief default constructor with a discrete variable as translator
/** @brief default constructor with a continuous variable as translator
* but without missing symbol
*
* @param var a labelized variable whose labels will be used for
* @param var a continuous variable that will be used for
* translations. The translator keeps a copy of this variable
* @param fit_range if true, the range of the variable is updated
* so that it precisely fits the range of the observed values in the
......@@ -210,6 +210,46 @@ namespace gum {
const bool fit_range = false,
const allocator_type& alloc = allocator_type());
/// default constructor with a IContinuous variable as translator
/** @param var a IContinuous variable that will be used for
* translations. The translator keeps a copy of this variable
* @param missing_symbols the set of symbols in the database
* representing missing values
* @param fit_range if true, the range of the variable is updated
* so that it precisely fits the range of the observed values in the
* database, else the range is kept to (-inf,inf)
* @param alloc The allocator used to allocate memory for all the
* fields of the DBTranslator4ContinuousVariable
* @warning If a missing value symbol is a number included in the range
* of the continuous variable, it will be discarded. If the fit_range
* parameter is on, the range of the variable is updated so that it
* can contain the range of the observed values in the database. */
template < template < typename > class XALLOC >
DBTranslator4ContinuousVariable(
const IContinuousVariable& var,
const std::vector< std::string, XALLOC< std::string > >& missing_symbols,
const bool fit_range = false,
const allocator_type& alloc = allocator_type());
/** @brief default constructor with a IContinuous variable as translator
* but without missing symbol
*
* @param var a IContinuous variable that will be used for
* translations. The translator keeps a copy of this variable
* @param fit_range if true, the range of the variable is updated
* so that it precisely fits the range of the observed values in the
* database, else the range is kept to (-inf,inf)
* @param alloc The allocator used to allocate memory for all the
* fields of the DBTranslator4ContinuousVariable
* @warning If a missing value symbol is a number included in the range
* of the continuous variable, it will be discarded. If the fit_range
* parameter is on, the range of the variable is updated so that it
* can contain the range of the observed values in the database. */
DBTranslator4ContinuousVariable(
const IContinuousVariable& var,
const bool fit_range = false,
const allocator_type& alloc = allocator_type());
/// copy constructor
DBTranslator4ContinuousVariable(
const DBTranslator4ContinuousVariable< ALLOC >& from);
......
......@@ -95,7 +95,7 @@ namespace gum {
}
/// default constructor with a range variable as translator
/// default constructor with a continuous variable as translator
template < template < typename > class ALLOC >
template < typename GUM_SCALAR, template < typename > class XALLOC >
DBTranslator4ContinuousVariable< ALLOC >::DBTranslator4ContinuousVariable(
......@@ -135,7 +135,7 @@ namespace gum {
}
/// default constructor with a range variable as translator
/// default constructor with a continuous variable as translator
template < template < typename > class ALLOC >
template < typename GUM_SCALAR >
DBTranslator4ContinuousVariable< ALLOC >::DBTranslator4ContinuousVariable(
......@@ -155,7 +155,67 @@ namespace gum {
GUM_CONSTRUCTOR(DBTranslator4ContinuousVariable);
}
/// default constructor with a IContinuous variable as translator
template < template < typename > class ALLOC >
template < template < typename > class XALLOC >
DBTranslator4ContinuousVariable< ALLOC >::DBTranslator4ContinuousVariable(
const IContinuousVariable& var,
const std::vector< std::string, XALLOC< std::string > >& missing_symbols,
const bool fit_range,
const typename DBTranslator4ContinuousVariable< ALLOC >::allocator_type&
alloc) :
DBTranslator< ALLOC >(
DBTranslatedValueType::CONTINUOUS, missing_symbols, fit_range, 1, alloc),
__variable(var.name(), var.description()), __fit_range(fit_range) {
// get the bounds of the range variable
const float lower_bound = var.lowerBoundAsFloat ();
const float upper_bound = var.upperBoundAsFloat ();
__variable.setLowerBound(lower_bound);
__variable.setUpperBound(upper_bound);
// remove all the missing symbols corresponding to a number between
// lower_bound and upper_bound
bool non_float_symbol_found = false;
for (auto iter = this->_missing_symbols.beginSafe();
iter != this->_missing_symbols.endSafe();
++iter) {
if (DBCell::isReal(*iter)) {
const float missing_val = std::stof(*iter);
if ((missing_val >= lower_bound) && (missing_val <= upper_bound)) {
this->_missing_symbols.erase(iter);
} else
__status_float_missing_symbols.insert(*iter, false);
} else if (!non_float_symbol_found) {
non_float_symbol_found = true;
__nonfloat_missing_symbol = *iter;
}
}
GUM_CONSTRUCTOR(DBTranslator4ContinuousVariable);
}
/// default constructor with a IContinuous variable as translator
template < template < typename > class ALLOC >
DBTranslator4ContinuousVariable< ALLOC >::DBTranslator4ContinuousVariable(
const IContinuousVariable& var,
const bool fit_range,
const typename DBTranslator4ContinuousVariable< ALLOC >::allocator_type&
alloc) :
DBTranslator< ALLOC >(
DBTranslatedValueType::CONTINUOUS, fit_range, 1, alloc),
__variable(var.name(), var.description()), __fit_range(fit_range) {
// get the bounds of the range variable
const float lower_bound = var.lowerBoundAsFloat();
const float upper_bound = var.upperBoundAsFloat();
__variable.setLowerBound(lower_bound);
__variable.setUpperBound(upper_bound);
GUM_CONSTRUCTOR(DBTranslator4ContinuousVariable);
}
/// copy constructor with a given allocator
template < template < typename > class ALLOC >
DBTranslator4ContinuousVariable< ALLOC >::DBTranslator4ContinuousVariable(
......
......@@ -168,6 +168,46 @@ namespace gum {
std::size_t max_dico_entries = std::numeric_limits< std::size_t >::max(),
const allocator_type& alloc = allocator_type());
/// default constructor with a IDiscretized variable as translator
/** @param var a IDiscretized variable which will be used for translations.
* The translator keeps a copy of this variable
* @param missing_symbols the set of symbols in the dataset
* representing missing values
* @param max_dico_entries the max number of entries that the dictionary
* can contain. During the construction, we check that the discretized
* variable passed in argument has fewer discretization intervals than
* the admissible dictionary size
* @param alloc The allocator used to allocate memory for all the
* fields of the DBTranslator4DiscretizedVariable
* @warning If the variable contained into the translator has a label
* equal to a missing value symbol, the label will be taken into
* account in the translation, not the missing value. */
template < template < typename > class XALLOC >
DBTranslator4DiscretizedVariable(
const IDiscretizedVariable& var,
const std::vector< std::string, XALLOC< std::string > >& missing_symbols,
std::size_t max_dico_entries = std::numeric_limits< std::size_t >::max(),
const allocator_type& alloc = allocator_type());
/** @brief default constructor with a IDiscretized variable as translator
* but without missing symbols
*
* @param var a discretized variable which will be used for translations.
* The translator keeps a copy of this variable
* @param max_dico_entries the max number of entries that the dictionary
* can contain. During the construction, we check that the discretized
* variable passed in argument has fewer discretization intervals than
* the admissible dictionary size
* @param alloc The allocator used to allocate memory for all the
* fields of the DBTranslator4DiscretizedVariable
* @warning If the variable contained into the translator has a label
* equal to a missing value symbol, the label will be taken into
* account in the translation, not the missing value. */
DBTranslator4DiscretizedVariable(
const IDiscretizedVariable& var,
std::size_t max_dico_entries = std::numeric_limits< std::size_t >::max(),
const allocator_type& alloc = allocator_type());
/// copy constructor
DBTranslator4DiscretizedVariable(
const DBTranslator4DiscretizedVariable< ALLOC >& from);
......
......@@ -101,6 +101,70 @@ namespace gum {
}
/// default constructor with a IDiscretized variable as translator
template < template < typename > class ALLOC >
template < template < typename > class XALLOC >
DBTranslator4DiscretizedVariable< ALLOC >::DBTranslator4DiscretizedVariable(
const IDiscretizedVariable& var,
const std::vector< std::string, XALLOC< std::string > >& missing_symbols,
std::size_t max_dico_entries,
const typename DBTranslator4DiscretizedVariable< ALLOC >::allocator_type&
alloc) :
DBTranslator< ALLOC >(DBTranslatedValueType::DISCRETE,
missing_symbols,
false,
max_dico_entries,
alloc),
__variable(var.name(), var.description()) {
// check that the variable has not too many entries
if (var.domainSize() > max_dico_entries) {
GUM_ERROR(SizeError,
"the dictionary induced by the variable is too large");
}
// copy the ticks of var into our internal variable
const auto ticks = var.ticksAsFloats ();
for (const auto tick : ticks) {
__variable.addTick( tick );
}
// the the bounds of the discretized variable
const float lower_bound = ticks[0];
const float upper_bound = ticks.back();
// remove all the missing symbols corresponding to a number between
// lower_bound and upper_bound
for (auto iter = this->_missing_symbols.beginSafe();
iter != this->_missing_symbols.endSafe();
++iter) {
if (DBCell::isReal(*iter)) {
const float missing_val = std::stof(*iter);
if ((missing_val >= lower_bound) && (missing_val <= upper_bound)) {
this->_missing_symbols.erase(iter);
}
}
}
// add the content of the variable into the back dictionary
std::size_t size = 0;
for (const auto& label : var.labels()) {
// if the label corresponds to a missing value, then remove it from
// the set of missing symbols. If, in addition, it has already
// been entered into the back_dictionary, then, this has been done
// because the label corresponded to a missing value, so we should
// remove the label as well from the back_dictionary.
if (this->_missing_symbols.exists(label)) {
this->_missing_symbols.erase(label);
}
this->_back_dico.insert(size, label);
++size;
}
GUM_CONSTRUCTOR(DBTranslator4DiscretizedVariable);
}
/// default constructor with a discretized variable as translator
template < template < typename > class ALLOC >
template < typename GUM_SCALAR >
......@@ -135,6 +199,39 @@ namespace gum {
}
/// default constructor with a IDiscretized variable as translator
template < template < typename > class ALLOC >
DBTranslator4DiscretizedVariable< ALLOC >::DBTranslator4DiscretizedVariable(
const IDiscretizedVariable& var,
std::size_t max_dico_entries,
const typename DBTranslator4DiscretizedVariable< ALLOC >::allocator_type&
alloc) :
DBTranslator< ALLOC >(
DBTranslatedValueType::DISCRETE, false, max_dico_entries, alloc),
__variable(var.name(), var.description()) {
// check that the variable has not too many entries
if (var.domainSize() > max_dico_entries) {
GUM_ERROR(SizeError,
"the dictionary induced by the variable is too large");
}
// copy the ticks of var into our internal variable
const auto ticks = var.ticksAsFloats();
for (const auto tick : ticks) {
__variable.addTick(tick);
}
// add the content of the variable into the back dictionary
std::size_t size = 0;
for (const auto& label : var.labels()) {
this->_back_dico.insert(size, label);
++size;
}
GUM_CONSTRUCTOR(DBTranslator4DiscretizedVariable);
}
/// copy constructor with a given allocator
template < template < typename > class ALLOC >
DBTranslator4DiscretizedVariable< ALLOC >::DBTranslator4DiscretizedVariable(
......
......@@ -212,8 +212,7 @@ namespace gum {
* @throw DuplicateElement is raised if there already exists a translator
* reading the column passed in argument.
*/
template < typename GUM_SCALAR = float,
template < typename > class XALLOC = ALLOC >
template < template < typename > class XALLOC >
std::size_t insertTranslator(
const Variable& var,
const std::size_t column,
......@@ -233,7 +232,6 @@ namespace gum {
* @throw DuplicateElement is raised if there already exists a translator
* reading the column passed in argument.
*/
template < typename GUM_SCALAR = float >
std::size_t insertTranslator(const Variable& var, const std::size_t column);
/** @brief erases either the kth translator or that parsing the kth
......
......@@ -252,7 +252,7 @@ namespace gum {
/// inserts a new translator for a given variable in the translator set
template < template < typename > class ALLOC >
template < typename GUM_SCALAR, template < typename > class XALLOC >
template < template < typename > class XALLOC >
std::size_t DBTranslatorSet< ALLOC >::insertTranslator(
const Variable& var,
const std::size_t column,
......@@ -268,22 +268,23 @@ namespace gum {
}
case VarType::Discretized: {
const DiscretizedVariable< GUM_SCALAR >& xvar =
static_cast< const DiscretizedVariable< GUM_SCALAR >& >(var);
const IDiscretizedVariable& xvar =
static_cast< const IDiscretizedVariable& >(var);
DBTranslator4DiscretizedVariable< ALLOC > translator(xvar,
missing_symbols);
return insertTranslator(translator, column);
}
case VarType::Range: {
const RangeVariable& xvar = static_cast< const RangeVariable& >(var);
const RangeVariable& xvar =
static_cast< const RangeVariable& >(var);
DBTranslator4RangeVariable< ALLOC > translator(xvar, missing_symbols);
return insertTranslator(translator, column);
}
case VarType::Continuous: {
const ContinuousVariable< GUM_SCALAR >& xvar =
static_cast< const ContinuousVariable< GUM_SCALAR >& >(var);
const IContinuousVariable& xvar =
static_cast< const IContinuousVariable& >(var);
DBTranslator4ContinuousVariable< ALLOC > translator(xvar,
missing_symbols);
return insertTranslator(translator, column);
......@@ -296,12 +297,11 @@ namespace gum {
/// inserts a new translator for a given variable in the translator set
template < template < typename > class ALLOC >
template < typename GUM_SCALAR >
INLINE std::size_t
DBTranslatorSet< ALLOC >::insertTranslator(const Variable& var,
const std::size_t column) {
const std::vector< std::string, ALLOC< std::string > > missing;
return insertTranslator< GUM_SCALAR, ALLOC >(var, column, missing);
return this->insertTranslator (var, column, missing);
}
......
......@@ -316,8 +316,7 @@ namespace gum {
* @throw DuplicateElement is raised if there already exists a translator
* reading the column passed in argument.
*/
template < typename GUM_SCALAR = float,
template < typename > class XALLOC = ALLOC >
template < template < typename > class XALLOC = ALLOC >
void insertTranslator(
const Variable& var,
const std::size_t input_column,
......
......@@ -219,7 +219,7 @@ namespace gum {
/// insert a new translator into the database
template < template < typename > class ALLOC >
template < typename GUM_SCALAR, template < typename > class XALLOC >
template < template < typename > class XALLOC >
void DatabaseTable< ALLOC >::insertTranslator(
const Variable& var,
const std::size_t input_column,
......@@ -244,7 +244,7 @@ namespace gum {
// insert the translator into the translator set
const std::size_t pos =
__translators.template insertTranslator<GUM_SCALAR,XALLOC>(var, input_column, missing_symbols);
__translators.insertTranslator (var, input_column, missing_symbols);
// insert the name of the translator's variable to the set of variable names
try {
......
......@@ -32,7 +32,7 @@
#include <string>
#include <agrum/agrum.h>
#include <agrum/variables/variable.h>
#include <agrum/variables/IContinuousVariable.h>
namespace gum {
......@@ -41,7 +41,7 @@ namespace gum {
* @brief Defines a continuous random variable.
*/
template < typename GUM_SCALAR = float >
class ContinuousVariable : public Variable {
class ContinuousVariable : public IContinuousVariable {
public:
// ##########################################################################
/// @name Constructors / Destructors
......@@ -119,16 +119,48 @@ namespace gum {
/// returns the upper bound of the domain of the variable
GUM_SCALAR upperBound() const;
/// returns the lower bound of the domain of the variable as a float
virtual float lowerBoundAsFloat() const;
/// returns the lower bound of the domain of the variable as a double
virtual double lowerBoundAsDouble() const;
/// returns the upper bound of the domain of the variable as a float
virtual float upperBoundAsFloat() const;
/// returns the upper bound of the domain of the variable as a double
virtual double upperBoundAsDouble() const;
/// updates the lower bound of the domain of the variable
/** @throw OutOfBounds is raised if the new bound is higher than the
* current upper bound. */
void setLowerBound(const GUM_SCALAR& new_bound);
/// updates the lower bound of the domain of the variable
/** @throw OutOfBounds is raised if the new bound is higher than the
* current upper bound. */
virtual void setLowerBoundFromFloat (const float new_bound);
/// updates the lower bound of the domain of the variable
/** @throw OutOfBounds is raised if the new bound is higher than the
* current upper bound. */
virtual void setLowerBoundFromDouble (const double new_bound);
/// updates the lower bound of the domain of the variable
/** @throw OutOfBounds is raised if the new bound is lower than the
* current lower bound */
void setUpperBound(const GUM_SCALAR& new_bound);
/// updates the lower bound of the domain of the variable
/** @throw OutOfBounds is raised if the new bound is lower than the
* current lower bound */
virtual void setUpperBoundFromFloat (const float new_bound);
/// updates the lower bound of the domain of the variable
/** @throw OutOfBounds is raised if the new bound is lower than the
* current lower bound */
virtual void setUpperBoundFromDouble (const double new_bound);
/// returns a string containing the value of the variable passed in argument
/**
* @param value the value of the variable we wish to return
......
......@@ -41,7 +41,7 @@ namespace gum {
const std::string& aDesc,
GUM_SCALAR lower_bound,
GUM_SCALAR upper_bound) :
Variable(aName, aDesc),
IContinuousVariable(aName, aDesc),
__lower_bound(lower_bound), __upper_bound(upper_bound) {
if (__lower_bound > __upper_bound) { std::swap(__upper_bound, __lower_bound); }
GUM_CONSTRUCTOR(ContinuousVariable);
......@@ -52,7 +52,7 @@ namespace gum {
template < typename GUM_SCALAR >
INLINE ContinuousVariable< GUM_SCALAR >::ContinuousVariable(
const ContinuousVariable< GUM_SCALAR >& from) :
Variable(from),
IContinuousVariable(from),
__lower_bound(from.__lower_bound), __upper_bound(from.__upper_bound) {
GUM_CONS_CPY(ContinuousVariable);
}
......@@ -63,7 +63,7 @@ namespace gum {
template < typename TX_VAL >
INLINE ContinuousVariable< GUM_SCALAR >::ContinuousVariable(
const ContinuousVariable< TX_VAL >& from) :
Variable(from),
IContinuousVariable(from),
__lower_bound(from.__lower_bound), __upper_bound(from.__upper_bound) {
GUM_CONS_CPY(ContinuousVariable);
}
......@@ -73,7 +73,7 @@ namespace gum {
template < typename GUM_SCALAR >
INLINE ContinuousVariable< GUM_SCALAR >::ContinuousVariable(
ContinuousVariable< GUM_SCALAR >&& from) :
Variable(std::move(from)),
IContinuousVariable(std::move(from)),
__lower_bound(from.__lower_bound), __upper_bound(from.__upper_bound) {
GUM_CONS_MOV(ContinuousVariable);
}
......@@ -98,7 +98,7 @@ namespace gum {
template < typename GUM_SCALAR >
INLINE ContinuousVariable< GUM_SCALAR >& ContinuousVariable< GUM_SCALAR >::
operator=(const ContinuousVariable< GUM_SCALAR >& from) {
Variable::operator=(from);
IContinuousVariable::operator=(from);
__lower_bound = from.__lower_bound;
__upper_bound = from.__upper_bound;
return *this;
......@@ -110,7 +110,7 @@ namespace gum {
template < typename TX_VAL >
INLINE ContinuousVariable< GUM_SCALAR >& ContinuousVariable< GUM_SCALAR >::
operator=(const ContinuousVariable< TX_VAL >& from) {
Variable::operator=(from);
IContinuousVariable::operator=(from);
__lower_bound = from.__lower_bound;
__upper_bound = from.__upper_bound;
return *this;
......@@ -121,7 +121,7 @@ namespace gum {
template < typename GUM_SCALAR >
INLINE ContinuousVariable< GUM_SCALAR >& ContinuousVariable< GUM_SCALAR >::
operator=(ContinuousVariable< GUM_SCALAR >&& from) {
Variable::operator=(std::move(from));
IContinuousVariable::operator=(std::move(from));
__lower_bound = from.__lower_bound;
__upper_bound = from.__upper_bound;
return *this;
......@@ -151,6 +151,20 @@ namespace gum {
}
/// returns the lower bound of the domain of the variable as a float
template < typename GUM_SCALAR >
INLINE float ContinuousVariable< GUM_SCALAR >::lowerBoundAsFloat() const {
return (float) __lower_bound;
}
/// returns the lower bound of the domain of the variable as a double
template < typename GUM_SCALAR >
INLINE double ContinuousVariable< GUM_SCALAR >::lowerBoundAsDouble() const {
return (double) __lower_bound;
}
/// returns the upper bound of the domain of the variable
template < typename GUM_SCALAR >
INLINE GUM_SCALAR ContinuousVariable< GUM_SCALAR >::upperBound() const {
......@@ -158,10 +172,24 @@ namespace gum {
}
/// returns the upper bound of the domain of the variable
template < typename GUM_SCALAR >
INLINE float ContinuousVariable< GUM_SCALAR >::upperBoundAsFloat() const {
return (float) __upper_bound;
}
/// returns the upper bound of the domain of the variable
template < typename GUM_SCALAR >
INLINE double ContinuousVariable< GUM_SCALAR >::upperBoundAsDouble() const {
return (double) __upper_bound;
}
/// updates the lower bound of the domain of the variable
template < typename GUM_SCALAR >
INLINE void
ContinuousVariable< GUM_SCALAR >::setLowerBound(const GUM_SCALAR& new_bound) {
ContinuousVariable< GUM_SCALAR >::setLowerBound(const GUM_SCALAR& new_bound) {
if (new_bound <= __upper_bound)
__lower_bound = new_bound;
else
......@@ -173,7 +201,25 @@ namespace gum {
/// updates the lower bound of the domain of the variable
template < typename GUM_SCALAR >
INLINE void
ContinuousVariable< GUM_SCALAR >::setUpperBound(const GUM_SCALAR& new_bound) {
ContinuousVariable< GUM_SCALAR >::setLowerBoundFromFloat (
const float new_bound) {
setLowerBound ( (GUM_SCALAR) new_bound );
}
/// updates the lower bound of the domain of the variable
template < typename GUM_SCALAR >
INLINE void
ContinuousVariable< GUM_SCALAR >::setLowerBoundFromDouble(
const double new_bound) {
setLowerBound ( (GUM_SCALAR) new_bound );
}
/// updates the lower bound of the domain of the variable
template < typename GUM_SCALAR >
INLINE void
ContinuousVariable< GUM_SCALAR >::setUpperBound(const GUM_SCALAR& new_bound) {
if (new_bound >= __lower_bound)
__upper_bound = new_bound;
else
......@@ -182,6 +228,24 @@ namespace gum {
}
/// updates the lower bound of the domain of the variable
template < typename GUM_SCALAR >
INLINE void
ContinuousVariable< GUM_SCALAR >::setUpperBoundFromFloat(
const float new_bound) {
setUpperBound ( (GUM_SCALAR) new_bound );
}
/// updates the lower bound of the domain of the variable
template < typename GUM_SCALAR >
INLINE void
ContinuousVariable< GUM_SCALAR >::setUpperBoundFromDouble(
const double new_bound) {
setUpperBound ( (GUM_SCALAR) new_bound );
}
/// returns the type of the variable
template < typename GUM_SCALAR >
INLINE VarType ContinuousVariable< GUM_SCALAR >::varType() const {
......
......@@ -27,7 +27,7 @@
#include <agrum/agrum.h>
#include <agrum/variables/discreteVariable.h>
#include <agrum/variables/IDiscretizedVariable.h>
namespace gum {
/**
......@@ -51,7 +51,7 @@ namespace gum {
* @author Pierre-Henri WUILLEMIN et Christophe GONZALES
*/
template < typename T_TICKS >
class DiscretizedVariable : public DiscreteVariable {
class DiscretizedVariable : public IDiscretizedVariable {
private:
std::vector< T_TICKS > __ticks; // Array from 0 to domainSize-2
Size __ticks_size;
......@@ -118,7 +118,7 @@ namespace gum {
/// @}
/// a virtual clone
virtual DiscreteVariable* clone() const;
virtual DiscretizedVariable<T_TICKS>* clone() const;
/// returns the type of variable
......@@ -178,6 +178,13 @@ namespace gum {
/// Return the list of ticks
const std::vector< T_TICKS >& ticks() const;
/// return the list of ticks as a vector of floats
virtual std::vector<float> ticksAsFloats () const;
/// return the list of ticks as a vector of doubles
virtual std::vector<double> ticksAsDoubles () const;
};
} /* namespace gum */