Commit eab29f6b authored by Matthieu Garrigues's avatar Matthieu Garrigues
Browse files

Rename x variables into t in accumulators.


	* mln/accu/count.hh,
	* mln/accu/histo.hh,
	* mln/accu/max.hh,
	* mln/accu/max_h.hh,
	* mln/accu/mean.hh,
	* mln/accu/median.hh,
	* mln/accu/median_alt.hh,
	* mln/accu/min.hh,
	* mln/accu/min_h.hh,
	* mln/accu/p.hh,
	* mln/accu/pair.hh,
	* mln/accu/sum.hh,
	* mln/accu/v.hh,
	* mln/core/concept/accumulator.hh,
	* mln/core/concept/doc/accumulator.hh: Rename.

	* tests/value_float01.cc: Fix warnings.

git-svn-id: https://svn.lrde.epita.fr/svn/oln/trunk@1248 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent 3c675317
2007-10-04 Matthieu Garrigues <garrigues@lrde.epita.fr>
Rename x variables into t in accumulators.
* mln/accu/count.hh,
* mln/accu/histo.hh,
* mln/accu/max.hh,
* mln/accu/max_h.hh,
* mln/accu/mean.hh,
* mln/accu/median.hh,
* mln/accu/median_alt.hh,
* mln/accu/min.hh,
* mln/accu/min_h.hh,
* mln/accu/p.hh,
* mln/accu/pair.hh,
* mln/accu/sum.hh,
* mln/accu/v.hh,
* mln/core/concept/accumulator.hh,
* mln/core/concept/doc/accumulator.hh: Rename.
* tests/value_float01.cc: Fix warnings.
2007-10-04 Thierry Geraud <thierry.geraud@lrde.epita.fr>
Handle multiple super-categories.
......
......@@ -46,17 +46,17 @@ namespace mln
/*! Generic counter accumulator class.
*/
template <typename V>
struct count_ : public mln::accu::internal::base_< std::size_t , count_<V> >
template <typename T>
struct count_ : public mln::accu::internal::base_< std::size_t , count_<T> >
{
typedef V argument;
typedef T argument;
typedef std::size_t result; // FIXME: Up in Accumulator.
count_();
void init();
void take(const argument&);
void take(const count_<V>& other);
void take(const count_<T>& other);
std::size_t to_result() const;
void set_value(std::size_t c);
......@@ -70,53 +70,53 @@ namespace mln
// FIXME: Doc!
struct count : public Meta_Accumulator< count >
{
template <typename V>
template <typename T>
struct with
{
typedef count_<V> ret;
typedef count_<T> ret;
};
};
# ifndef MLN_INCLUDE_ONLY
template <typename V>
count_<V>::count_()
template <typename T>
count_<T>::count_()
{
init();
}
template <typename V>
template <typename T>
void
count_<V>::init()
count_<T>::init()
{
count__ = 0;
}
template <typename V>
template <typename T>
void
count_<V>::take(const argument&)
count_<T>::take(const argument&)
{
++count__;
}
template <typename V>
template <typename T>
void
count_<V>::take(const count_<V>& other)
count_<T>::take(const count_<T>& other)
{
count__ += other.count__;
}
template <typename V>
template <typename T>
std::size_t
count_<V>::to_result() const
count_<T>::to_result() const
{
return count__;
}
template <typename V>
template <typename T>
void
count_<V>::set_value(std::size_t c)
count_<T>::set_value(std::size_t c)
{
count__ = c;
}
......
......@@ -61,12 +61,12 @@ namespace mln
typedef mln_value(S) argument;
typedef const std::vector<std::size_t>& result;
void take(const argument& x);
void take(const argument& t);
void take(const histo<S>& other);
void untake(const argument& x);
void untake(const argument& t);
void init();
std::size_t operator()(const argument& x) const;
std::size_t operator()(const argument& t) const;
std::size_t operator[](std::size_t i) const;
std::size_t nvalues() const;
std::size_t sum() const;
......@@ -110,9 +110,9 @@ namespace mln
template <typename S>
void
histo<S>::take(const argument& x)
histo<S>::take(const argument& t)
{
++h_[s_.index_of(x)];
++h_[s_.index_of(t)];
++sum_;
}
......@@ -127,11 +127,11 @@ namespace mln
template <typename S>
void
histo<S>::untake(const argument& x)
histo<S>::untake(const argument& t)
{
mln_precondition(h_[s_.index_of(x)] > 0);
mln_precondition(h_[s_.index_of(t)] > 0);
mln_precondition(sum_ > 0);
--h_[s_.index_of(x)];
--h_[s_.index_of(t)];
--sum_;
}
......@@ -145,9 +145,9 @@ namespace mln
template <typename S>
std::size_t
histo<S>::operator()(const argument& x) const
histo<S>::operator()(const argument& t) const
{
return h_[s_.index_of(x)];
return h_[s_.index_of(t)];
}
template <typename S>
......
......@@ -47,26 +47,26 @@ namespace mln
/*! Generic max accumulator class.
*
* The parameter \c V is the type of values.
* The parameter \c T is the type of values.
*/
template <typename V>
struct max_ : public mln::accu::internal::base_< V , max_<V> >
template <typename T>
struct max_ : public mln::accu::internal::base_< T , max_<T> >
{
typedef V argument;
typedef V result;
typedef T argument;
typedef T result;
max_();
void init();
void take_as_init(const argument& x);
void take(const argument& x);
void take(const max_<V>& other);
void take_as_init(const argument& t);
void take(const argument& t);
void take(const max_<T>& other);
V to_result() const;
T to_result() const;
protected:
V x_;
T t_;
};
......@@ -76,10 +76,10 @@ namespace mln
// FIXME: Doc!
struct max : public Meta_Accumulator< max >
{
template <typename V>
template <typename T>
struct with
{
typedef max_<V> ret;
typedef max_<T> ret;
};
};
......@@ -87,47 +87,47 @@ namespace mln
# ifndef MLN_INCLUDE_ONLY
template <typename V>
max_<V>::max_()
template <typename T>
max_<T>::max_()
{
init();
}
template <typename V>
template <typename T>
void
max_<V>::init()
max_<T>::init()
{
x_ = mln_min(V);
t_ = mln_min(T);
}
template <typename V>
template <typename T>
void
max_<V>::take_as_init(const argument& x)
max_<T>::take_as_init(const argument& t)
{
x_ = x;
t_ = t;
}
template <typename V>
template <typename T>
void
max_<V>::take(const argument& x)
max_<T>::take(const argument& t)
{
if (x > x_)
x_ = x;
if (t > t_)
t_ = t;
}
template <typename V>
template <typename T>
void
max_<V>::take(const max_<V>& other)
max_<T>::take(const max_<T>& other)
{
if (other.x_ > x_)
x_ = other.x_;
if (other.t_ > t_)
t_ = other.t_;
}
template <typename V>
V
max_<V>::to_result() const
template <typename T>
T
max_<T>::to_result() const
{
return x_;
return t_;
}
# endif // ! MLN_INCLUDE_ONLY
......
......@@ -57,10 +57,10 @@ namespace mln
max_h();
void init();
void take(const argument& x);
void take_as_init(const argument& x);
void take(const argument& t);
void take_as_init(const argument& t);
void take(const max_h<S>& other);
void untake(const argument& x);
void untake(const argument& t);
unsigned card() const { return h_.sum(); }
......@@ -76,7 +76,7 @@ namespace mln
mutable std::size_t sum_;
mutable bool valid_;
mutable std::size_t i_; // the max index
mutable argument x_; // the max argument
mutable argument t_; // the max argument
// Auxiliary methods
void update_() const;
......@@ -105,15 +105,15 @@ namespace mln
template <typename S>
void
max_h<S>::take(const argument& x)
max_h<S>::take(const argument& t)
{
h_.take(x);
h_.take(t);
if (h_.sum() == 1)
{
this->take_as_init(x);
this->take_as_init(t);
return;
}
if (x > x_)
if (t > t_)
{
++sum_;
valid_ = false;
......@@ -134,23 +134,23 @@ namespace mln
template <typename S>
void
max_h<S>::untake(const argument& x)
max_h<S>::untake(const argument& t)
{
mln_precondition(h_(x) != 0);
h_.untake(x);
mln_precondition(h_(t) != 0);
h_.untake(t);
if (h_.sum() == 0)
{
init();
return;
}
if (x > x_)
if (t > t_)
{
mln_invariant(sum_ >= 1);
--sum_;
valid_ = false;
}
else
if (x == x_ && h_[i_] == 0)
if (t == t_ && h_[i_] == 0)
valid_ = false;
}
......@@ -173,7 +173,7 @@ namespace mln
do
--i_;
while (h_[i_] == 0);
x_ = s_[i_];
t_ = s_[i_];
}
template <typename S>
......@@ -186,7 +186,7 @@ namespace mln
if (h_[i_] != 0)
sum_ -= h_[i_];
} while (sum_ != 0);
x_ = s_[i_];
t_ = s_[i_];
}
template <typename S>
......@@ -196,18 +196,18 @@ namespace mln
h_.init();
sum_ = 0;
i_ = mln_min(argument);
x_ = s_[i_];
t_ = s_[i_];
valid_ = true;
}
template <typename S>
void
max_h<S>::take_as_init(const argument& x)
max_h<S>::take_as_init(const argument& t)
{
h_.take(x);
h_.take(t);
sum_ = 0;
i_ = s_.index_of(x);
x_ = x;
i_ = s_.index_of(t);
t_ = t;
valid_ = true;
}
......@@ -217,7 +217,7 @@ namespace mln
{
if (! valid_)
update_();
return x_;
return t_;
}
template <typename S>
......
......@@ -49,32 +49,32 @@ namespace mln
/*! Generic mean accumulator class.
*
* Parameter \c V is the type of values that we sum. Parameter \c
* Parameter \c T is the type of values that we sum. Parameter \c
* S is the type to store the sum of values; the default type of
* \c S is the summation type (property) of \c V. Parameter \c M
* \c S is the summation type (property) of \c T. Parameter \c M
* is the type of the mean value; the default type of \c M is \c
* S.
*/
template <typename V,
typename S = mln_sum(V),
template <typename T,
typename S = mln_sum(T),
typename M = S>
struct mean_ : public mln::accu::internal::base_< M , mean_<V,S,M> >
struct mean_ : public mln::accu::internal::base_< M , mean_<T,S,M> >
{
typedef V argument;
typedef T argument;
typedef M result;
mean_();
void init();
void take(const argument& x);
void take(const mean_<V,S,M>& other);
void take(const argument& t);
void take(const mean_<T,S,M>& other);
M to_result() const;
protected:
accu::count_<V> count_;
accu::sum_<V,S> sum_;
accu::count_<T> count_;
accu::sum_<T,S> sum_;
};
......@@ -87,50 +87,50 @@ namespace mln
// FIXME: Doc!
struct mean : public Meta_Accumulator< mean >
{
template < typename V,
typename S = mln_sum(V),
template < typename T,
typename S = mln_sum(T),
typename M = S >
struct with
{
typedef mean_<V,S,M> ret;
typedef mean_<T,S,M> ret;
};
};
# ifndef MLN_INCLUDE_ONLY
template <typename V, typename S, typename M>
mean_<V,S,M>::mean_()
template <typename T, typename S, typename M>
mean_<T,S,M>::mean_()
{
init();
}
template <typename V, typename S, typename M>
template <typename T, typename S, typename M>
void
mean_<V,S,M>::init()
mean_<T,S,M>::init()
{
count_.init();
sum_.init();
}
template <typename V, typename S, typename M>
void mean_<V,S,M>::take(const argument& x)
template <typename T, typename S, typename M>
void mean_<T,S,M>::take(const argument& t)
{
count_.take(x);
sum_.take(x);
count_.take(t);
sum_.take(t);
}
template <typename V, typename S, typename M>
template <typename T, typename S, typename M>
void
mean_<V,S,M>::take(const mean_<V,S,M>& other)
mean_<T,S,M>::take(const mean_<T,S,M>& other)
{
count_.take(other.count_);
sum_.take(other.sum_);
}
template <typename V, typename S, typename M>
template <typename T, typename S, typename M>
M
mean_<V,S,M>::to_result() const
mean_<T,S,M>::to_result() const
{
return sum_.to_result() / count_.to_result();
}
......
......@@ -57,9 +57,9 @@ namespace mln
median();
void init();
void take(const argument& x);
void take(const argument& t);
void take(const median<S>& other);
void untake(const argument& x);
void untake(const argument& t);
unsigned card() const { return h_.sum(); }
......@@ -76,7 +76,7 @@ namespace mln
mutable bool valid_;
mutable std::size_t i_; // the median index
mutable argument x_; // the median value
mutable argument t_; // the median value
// Auxiliary methods
void update_() const;
......@@ -105,13 +105,13 @@ namespace mln
template <typename S>
void
median<S>::take(const argument& x)
median<S>::take(const argument& t)
{
h_.take(x);
h_.take(t);
if (x < x_)
if (t < t_)
++sum_minus_;
else if (x > x_)
else if (t > t_)
++sum_plus_;
if (valid_)
......@@ -139,14 +139,14 @@ namespace mln
template <typename S>
void
median<S>::untake(const argument& x)
median<S>::untake(const argument& t)
{
mln_precondition(h_(x) != 0);
h_.untake(x);
mln_precondition(h_(t) != 0);
h_.untake(t);
if (x < x_)
if (t < t_)
--sum_minus_;
else if (x > x_)
else if (t > t_)
--sum_plus_;
if (valid_)
......@@ -191,7 +191,7 @@ namespace mln
sum_minus_ -= h_[i_];
}
while (2 * sum_minus_ > h_.sum());
x_ = s_[i_];
t_ = s_[i_];
}
template <typename S>
......@@ -207,7 +207,7 @@ namespace mln
sum_plus_ -= h_[i_];
}
while (2 * sum_plus_ > h_.sum());
x_ = s_[i_];
t_ = s_[i_];
}
template <typename S>
......@@ -218,7 +218,7 @@ namespace mln
sum_minus_ = 0;
sum_plus_ = 0;
i_ = (mln_max(argument) - mln_min(argument)) / 2;
x_ = s_[i_];
t_ = s_[i_];
valid_ = true;
}
......@@ -228,7 +228,7 @@ namespace mln
{
if (! valid_)
update_();
return x_;
return t_;
}
template <typename S>
......
......@@ -54,8 +54,8 @@ namespace mln
median_alt(const Value_Set<S>& s);
void take(const argument& x);
void untake(const argument& x);
void take(const argument& t);
void untake(const argument& t);
void init();