milena r4148: Move inf and sup accumulators into math directory

URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena ChangeLog: 2009-06-15 Edwin Carlinet <carlinet@lrde.epita.fr> Move inf and sup accumulators into math directory. * mln/accu/inf.hh, * mln/accu/sup.hh: Move to... * mln/accu/math/inf.hh, * mln/accu/math/sup.hh: Move inf, sup accus. * mln/accu/math/all.hh: Update all.hh with respect to new location. * sandbox/theo/esiee/slides_2009_may/dilation.hh: Replace accu::accu_name by accu::math::accu_name, accu/accu_name by accu/math/accu_name. --- mln/accu/math/all.hh | 2 mln/accu/math/inf.hh | 178 ++++++++++++++++++++++++ mln/accu/math/sup.hh | 180 +++++++++++++++++++++++++ sandbox/theo/esiee/slides_2009_may/dilation.hh | 2 4 files changed, 361 insertions(+), 1 deletion(-) Index: trunk/milena/mln/accu/inf.hh (deleted) =================================================================== Index: trunk/milena/mln/accu/sup.hh (deleted) =================================================================== Index: trunk/milena/mln/accu/math/sup.hh =================================================================== --- trunk/milena/mln/accu/math/sup.hh (revision 0) +++ trunk/milena/mln/accu/math/sup.hh (revision 4148) @@ -0,0 +1,180 @@ +// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE) +// +// This file is part of Olena. +// +// Olena is free software: you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation, version 2 of the License. +// +// Olena is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Olena. If not, see <http://www.gnu.org/licenses/>. +// +// As a special exception, you may use this file as part of a free +// software project without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to produce +// an executable, this file does not by itself cause the resulting +// executable to be covered by the GNU General Public License. This +// exception does not however invalidate any other reasons why the +// executable file might be covered by the GNU General Public License. + +#ifndef MLN_ACCU_MATH_SUP_HH +# define MLN_ACCU_MATH_SUP_HH + +/// \file +/// +/// Define an accumulator that computes a sup. + +# include <mln/accu/internal/base.hh> +# include <mln/core/concept/meta_accumulator.hh> +# include <mln/trait/value_.hh> +# include <mln/util/pix.hh> +# include <mln/fun/math/sup.hh> + +namespace mln +{ + + namespace accu + { + + namespace math + { + + + /// \brief Generic sup accumulator class. + /*! + * The parameter \c T is the type of values. + * + * \ingroup modaccuvalues + */ + template <typename T> + struct sup : public mln::accu::internal::base< const T&, sup<T> > + { + typedef T argument; + + sup(); + + /// Manipulators. + /// \{ + void init(); + void take_as_init_(const argument& t); + void take(const argument& t); + void take(const sup<T>& other); + /// \} + + /// Get the value of the accumulator. + const T& to_result() const; + + /// Check whether this accu is able to return a result. + /// Always true here. + bool is_valid() const; + + protected: + + T t_; + typename mln::fun::sup::with<T, T>::ret fun_; + }; + + + template <typename I> struct sup< util::pix<I> >; + + + } // end of mln::accu::math + + + namespace meta + { + + namespace math + { + + /// Meta accumulator for sup. + + struct sup : public Meta_Accumulator< sup > + { + template <typename T> + struct with + { + typedef accu::math::sup<T> ret; + }; + }; + + } // end of namespace mln::accu::meta::math + + } // end of namespace mln::accu::meta + + + +# ifndef MLN_INCLUDE_ONLY + + namespace math + { + + template <typename T> + inline + sup<T>::sup() + { + init(); + } + + template <typename T> + inline + void + sup<T>::init() + { + t_ = mln_min(T); + } + + template <typename T> + inline + void sup<T>::take_as_init_(const argument& t) + { + t_ = t; + } + + template <typename T> + inline + void sup<T>::take(const argument& t) + { + this->t_ = this->fun_(t_, t); + } + + template <typename T> + inline + void + sup<T>::take(const sup<T>& other) + { + this->t_ = this->fun_(t_, other.t_); + } + + template <typename T> + inline + const T& + sup<T>::to_result() const + { + return t_; + } + + template <typename T> + inline + bool + sup<T>::is_valid() const + { + return true; + } + +# endif // ! MLN_INCLUDE_ONLY + + } // end of namespace mln::accu::math + + } // end of namespace mln::accu + +} // end of namespace mln + + +#endif // ! MLN_ACCU_MATH_SUP_HH Property changes on: trunk/milena/mln/accu/math/sup.hh ___________________________________________________________________ Added: svn:mergeinfo Index: trunk/milena/mln/accu/math/all.hh =================================================================== --- trunk/milena/mln/accu/math/all.hh (revision 4147) +++ trunk/milena/mln/accu/math/all.hh (revision 4148) @@ -54,5 +54,7 @@ # include <mln/accu/math/sum.hh> # include <mln/accu/math/count.hh> +# include <mln/accu/math/inf.hh> +# include <mln/accu/math/sup.hh> #endif // ! MLN_ACCU_MATH_ALL_HH Index: trunk/milena/mln/accu/math/inf.hh =================================================================== --- trunk/milena/mln/accu/math/inf.hh (revision 0) +++ trunk/milena/mln/accu/math/inf.hh (revision 4148) @@ -0,0 +1,178 @@ +// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE) +// +// This file is part of Olena. +// +// Olena is free software: you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation, version 2 of the License. +// +// Olena is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Olena. If not, see <http://www.gnu.org/licenses/>. +// +// As a special exception, you may use this file as part of a free +// software project without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to produce +// an executable, this file does not by itself cause the resulting +// executable to be covered by the GNU General Public License. This +// exception does not however invalidate any other reasons why the +// executable file might be covered by the GNU General Public License. + +#ifndef MLN_ACCU_MATH_INF_HH +# define MLN_ACCU_MATH_INF_HH + +/// \file +/// +/// Define an accumulator that computes a inf. + +# include <mln/accu/internal/base.hh> +# include <mln/core/concept/meta_accumulator.hh> +# include <mln/trait/value_.hh> +# include <mln/util/pix.hh> +# include <mln/fun/math/inf.hh> + +namespace mln +{ + + namespace accu + { + + namespace math + { + + + /// \brief Generic inf accumulator class. + /// + /// The parameter \c T is the type of values. + /// + /// \ingroup modaccuvalues + // + template <typename T> + struct inf : public mln::accu::internal::base< const T&, inf<T> > + { + typedef T argument; + + inf(); + + /// Manipulators. + /// \{ + void init(); + void take_as_init_(const argument& t); + void take(const argument& t); + void take(const inf<T>& other); + /// \} + + /// Get the value of the accumulator. + const T& to_result() const; + + /// Check whether this accu is able to return a result. + /// Always true here. + bool is_valid() const; + + protected: + + T t_; + typename mln::fun::inf::with<T, T>::ret fun_; + }; + + + template <typename I> struct inf< util::pix<I> >; + + } // end of mln::accu::math + + + namespace meta + { + + namespace math + { + + /// Meta accumulator for inf. + + struct inf : public Meta_Accumulator< inf > + { + template <typename T> + struct with + { + typedef accu::math::inf<T> ret; + }; + }; + + } // end of namespace mln::accu::meta::math + + } // end of namespace mln::accu::meta + + +# ifndef MLN_INCLUDE_ONLY + + namespace math + { + + template <typename T> + inline + inf<T>::inf() + { + init(); + } + + template <typename T> + inline + void + inf<T>::init() + { + t_ = mln_max(T); + } + + template <typename T> + inline + void inf<T>::take_as_init_(const argument& t) + { + t_ = t; + } + + template <typename T> + inline + void inf<T>::take(const argument& t) + { + this->t_ = this->fun_(t_, t); + } + + template <typename T> + inline + void + inf<T>::take(const inf<T>& other) + { + this->t_ = this->fun_(t_, other.t_); + } + + template <typename T> + inline + const T& + inf<T>::to_result() const + { + return t_; + } + + template <typename T> + inline + bool + inf<T>::is_valid() const + { + return true; + } + +# endif // ! MLN_INCLUDE_ONLY + + } // end of namespace mln::accu::math + + } // end of namespace mln::accu + +} // end of namespace mln + + +#endif // ! MLN_ACCU_MATH_INF_HH Property changes on: trunk/milena/mln/accu/math/inf.hh ___________________________________________________________________ Added: svn:mergeinfo Index: trunk/milena/sandbox/theo/esiee/slides_2009_may/dilation.hh =================================================================== --- trunk/milena/sandbox/theo/esiee/slides_2009_may/dilation.hh (revision 4147) +++ trunk/milena/sandbox/theo/esiee/slides_2009_may/dilation.hh (revision 4148) @@ -52,7 +52,7 @@ mln_piter(I) p(ima.domain()); mln_qiter(W) q(win, p); - accu::sup<mln_value(I)> sup; + accu::math::sup<mln_value(I)> sup; for_all(p) {
participants (1)
-
Edwin Carlinet