Commit 9225184f authored by Christophe Gonzales's avatar Christophe Gonzales

removed float methods in IDiscretizedVariable and IContinuousVariable

parent 809677a9
Pipeline #23191053 canceled with stages
in 11 minutes 47 seconds
......@@ -181,8 +181,8 @@ namespace gum {
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 ();
const float lower_bound = var.lowerBoundAsDouble ();
const float upper_bound = var.upperBoundAsDouble ();
__variable.setLowerBound(lower_bound);
__variable.setUpperBound(upper_bound);
......@@ -222,8 +222,8 @@ namespace gum {
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();
const float lower_bound = var.lowerBoundAsDouble();
const float upper_bound = var.upperBoundAsDouble();
__variable.setLowerBound(lower_bound);
__variable.setUpperBound(upper_bound);
......@@ -538,8 +538,8 @@ namespace gum {
template < template < typename > class ALLOC >
INLINE const IContinuousVariable*
DBTranslator4ContinuousVariable< ALLOC >::variable() const {
__real_variable->setLowerBoundFromFloat ( __variable.lowerBound () );
__real_variable->setUpperBoundFromFloat ( __variable.upperBound () );
__real_variable->setLowerBoundFromDouble ( __variable.lowerBound () );
__real_variable->setUpperBoundFromDouble ( __variable.upperBound () );
return __real_variable;
}
......
......@@ -126,9 +126,9 @@ namespace gum {
}
// copy the ticks of var into our internal variable
const auto ticks = var.ticksAsFloats ();
const auto ticks = var.ticksAsDoubles ();
for (const auto tick : ticks) {
__variable.addTick( tick );
__variable.addTick( (float) tick );
}
// the the bounds of the discretized variable
......@@ -225,9 +225,9 @@ namespace gum {
}
// copy the ticks of var into our internal variable
const auto ticks = var.ticksAsFloats();
const auto ticks = var.ticksAsDoubles();
for (const auto tick : ticks) {
__variable.addTick(tick);
__variable.addTick((float) tick);
}
// add the content of the variable into the back dictionary
......
......@@ -76,33 +76,17 @@ namespace gum {
// ############################################################################
/// @{
/// returns the lower bound of the domain of the variable as a float
virtual float lowerBoundAsFloat() const = 0;
/// returns the lower bound of the domain of the variable as a double
virtual double lowerBoundAsDouble() const = 0;
/// returns the upper bound of the domain of the variable as a float
virtual float upperBoundAsFloat() const = 0;
/// returns the upper bound of the domain of the variable as a double
virtual double upperBoundAsDouble() const = 0;
/// 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) = 0;
/// 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) = 0;
/// 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) = 0;
/// 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 */
......
......@@ -67,9 +67,6 @@ namespace gum {
// ############################################################################
/// @{
/// return the list of ticks as a vector of floats
virtual std::vector<float> ticksAsFloats () const = 0;
/// return the list of ticks as a vector of doubles
virtual std::vector<double> ticksAsDoubles () const = 0;
......
......@@ -116,17 +116,11 @@ namespace gum {
/// returns the lower bound of the domain of the variable
GUM_SCALAR lowerBound() const;
/// 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
GUM_SCALAR upperBound() const;
/// returns the upper bound of the domain of the variable as a double
virtual double upperBoundAsDouble() const;
......@@ -136,11 +130,6 @@ namespace gum {
* 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. */
......@@ -151,11 +140,6 @@ namespace gum {
* 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 */
......
......@@ -151,13 +151,6 @@ 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 {
......@@ -172,13 +165,6 @@ 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 {
......@@ -198,15 +184,6 @@ namespace gum {
}
/// updates the lower bound of the domain of the variable
template < typename GUM_SCALAR >
INLINE void
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
......@@ -228,15 +205,6 @@ 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
......
......@@ -179,9 +179,6 @@ 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;
......
......@@ -281,16 +281,6 @@ namespace gum {
return this->__ticks;
}
template < typename T_TICKS >
INLINE std::vector<float>
DiscretizedVariable< T_TICKS >::ticksAsFloats () const {
const std::size_t size = __ticks.size ();
std::vector<float> ticks ( size );
for ( std::size_t i = std::size_t(0); i < size; ++i )
ticks[i] = (float) __ticks[i];
return ticks;
}
template < typename T_TICKS >
INLINE std::vector<double>
DiscretizedVariable< T_TICKS >::ticksAsDoubles () const {
......
......@@ -238,25 +238,25 @@ namespace gum_tests {
allocator.deallocate(translator5, 1);
TS_ASSERT(translator4.translate("12").cont_val == 12.0f);
TS_ASSERT(translator4.variable()->lowerBoundAsFloat() == -2.0f);
TS_ASSERT(translator4.variable()->upperBoundAsFloat() == 12.0f);
TS_ASSERT(translator4.variable()->lowerBoundAsDouble() == -2.0f);
TS_ASSERT(translator4.variable()->upperBoundAsDouble() == 12.0f);
translator4 = translator2;
TS_ASSERT(translator4.variable()->lowerBoundAsFloat() == -2.0f);
TS_ASSERT(translator4.variable()->upperBoundAsFloat() == 10.0f);
TS_ASSERT(translator4.variable()->lowerBoundAsDouble() == -2.0f);
TS_ASSERT(translator4.variable()->upperBoundAsDouble() == 10.0f);
TS_ASSERT(translator.translate("12").cont_val == 12.0f);
TS_ASSERT(translator.variable()->lowerBoundAsFloat() == -2.0f);
TS_ASSERT(translator.variable()->upperBoundAsFloat() == 12.0f);
TS_ASSERT(translator.variable()->lowerBoundAsDouble() == -2.0f);
TS_ASSERT(translator.variable()->upperBoundAsDouble() == 12.0f);
translator = translator2;
TS_ASSERT(translator.variable()->lowerBoundAsFloat() == -2.0f);
TS_ASSERT(translator.variable()->upperBoundAsFloat() == 10.0f);
TS_ASSERT(translator.variable()->lowerBoundAsDouble() == -2.0f);
TS_ASSERT(translator.variable()->upperBoundAsDouble() == 10.0f);
TS_ASSERT(translator.translate("12").cont_val == 12.0f);
TS_ASSERT(translator.variable()->lowerBoundAsFloat() == -2.0f);
TS_ASSERT(translator.variable()->upperBoundAsFloat() == 12.0f);
TS_ASSERT(translator.variable()->lowerBoundAsDouble() == -2.0f);
TS_ASSERT(translator.variable()->upperBoundAsDouble() == 12.0f);
translator = std::move(translator2);
TS_ASSERT(translator.variable()->lowerBoundAsFloat() == -2.0f);
TS_ASSERT(translator.variable()->upperBoundAsFloat() == 10.0f);
TS_ASSERT(translator.variable()->lowerBoundAsDouble() == -2.0f);
TS_ASSERT(translator.variable()->upperBoundAsDouble() == 10.0f);
}
TS_ASSERT(MyAllocCount::hasMeroryLeak() == false);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment