LRE
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
List overview
Download
Olena-patches
May 2005
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
olena-patches@lrde.epita.fr
8 participants
22 discussions
Start a n
N
ew thread
proto-1.0 180: Clean up arith, logic, and cmp.
by Thierry GERAUD
2005-05-01 Thierry Geraud <theo@shuttle> * oln/arith/min.hh: Remove (obsolete). * oln/arith/max.hh: Likewise. * oln/arith/ops.hh: Move to... * oln/ops/arith.hh: ...this new file. * oln/arith/logic.hh: Move to... * oln/ops/logic.hh: ...this new file. * oln/arith/cmp.hh: Move to... * oln/ops/cmp.hh: ...this new file. * oln/morpho/geodesic_dilation.hh: Update. * oln/morpho/geodesic_erosion.hh: Likewise. * oln/funobj/abstract/binary.hh (binary_meta_result): Rename as... (mbinary_result): ...this. * oln/core/pw/binary_op.hh: Update. * oln/funobj/abstract/unary.hh (unary_meta_result): Rename as... (munary_result): ...this. * oln/core/pw/unary_op.hh: Update. * oln/core/abstract/image.hh: Include piter.hh. * oln/utils/clone.hh: Update. Do not use image_operator any more. * oln/core/apply.hh: Likewise. (apply, apply2): New routines to accept oln/funobj/*. * oln/core/ch_value_type.hh (oln_ch_concrete_type): New macro. * oln/level/arith.hh: New file. * oln/level/logic.hh: New file. Index: oln/funobj/abstract/binary.hh =================================================================== --- oln/funobj/abstract/binary.hh (revision 179) +++ oln/funobj/abstract/binary.hh (working copy) @@ -31,6 +31,7 @@ # include <mlc/any.hh> # include <mlc/contract.hh> # include <mlc/types.hh> + # include <ntg/all.hh> # include <oln/core/abstract/image.hh> @@ -96,7 +97,7 @@ template <typename F, typename L, typename R> - struct binary_meta_result + struct mbinary_result { typedef mlc::no_type ret; }; @@ -143,12 +144,21 @@ struct mbinary : public mlc::any<E> { template <typename L, typename R> - const typename binary_meta_result<E,L,R>::ret + const typename mbinary_result<E,L,R>::ret operator()(const L& left, const R& right) const { return this->exact().impl_binop(left, right); } + template <typename Il, typename Ir> + const typename mbinary_result<E, + oln_type_of(Il, value), + oln_type_of(Ir, value)>::ret + operator()(const value_box<Il>& left, const value_box<Ir>& right) const + { + return this->exact().impl_binop(left, right); + } + protected: mbinary() {} @@ -159,12 +169,14 @@ struct mbinary1 : public mlc::any<E> { template <typename T> - const typename binary_meta_result<E,T,T>::ret + const typename mbinary_result<E,T,T>::ret operator()(const T& left, const T& right) const { return this->exact().impl_binop(left, right); } + // FIXME: handle value_box like above... + protected: mbinary1() {} @@ -182,14 +194,24 @@ // result template <template <typename, typename> class F, typename L, typename R> - struct binary_meta_result < binary_meta<F>, L, R > + struct mbinary_result < binary_meta<F>, L, R > { - typedef oln_fun2_type_2_of(F<L,R>, res) ret; + typedef F<L,R> fun_type; + typedef oln_fun2_type_of(fun_type, res) ret; }; +// template <template <typename, typename> class F, typename Il, typename Ir> +// struct mbinary_result < binary_meta<F>, value_box<Il>, value_box<Ir> > +// { +// typedef oln_type_of(Il, value) L; +// typedef oln_type_of(Ir, value) R; +// typedef F<L,R> fun_type; +// typedef oln_fun2_type_of(fun_type, res) ret; +// }; template <template <typename> class F, typename T> - struct binary_meta_result < binary1_meta<F>, T, T > + struct mbinary_result < binary1_meta<F>, T, T > { - typedef oln_fun2_type_of(F<T>, res) ret; + typedef F<T> fun_type; + typedef oln_fun2_type_of(fun_type, res) ret; }; // class Index: oln/funobj/abstract/unary.hh =================================================================== --- oln/funobj/abstract/unary.hh (revision 179) +++ oln/funobj/abstract/unary.hh (working copy) @@ -84,7 +84,7 @@ { template <typename F, typename T> - struct unary_meta_result + struct munary_result { typedef mlc::no_type ret; }; @@ -118,7 +118,7 @@ struct munary : public mlc::any<E> { template <typename T> - const typename unary_meta_result<E,T>::ret + const typename munary_result<E,T>::ret operator()(const T& arg) const { return this->exact().impl_unop(arg); @@ -141,7 +141,7 @@ // result template <template <typename> class F, typename T> - struct unary_meta_result < unary_meta<F>, T > + struct munary_result < unary_meta<F>, T > { typedef oln_fun1_type_of(F<T>, res) ret; }; Index: oln/core/abstract/image.hh =================================================================== --- oln/core/abstract/image.hh (revision 179) +++ oln/core/abstract/image.hh (working copy) @@ -486,6 +486,9 @@ } // end of namespace oln +# include <oln/core/abstract/piter.hh> +// this allows for browsing points in file +// where oln/core/abstract/image.hh is included #endif // ! OLENA_CORE_ABSTRACT_IMAGE_HH Index: oln/core/apply.hh =================================================================== --- oln/core/apply.hh (revision 179) +++ oln/core/apply.hh (working copy) @@ -28,80 +28,67 @@ #ifndef OLENA_CORE_APPLY_HH # define OLENA_CORE_APPLY_HH +# include <mlc/cmp.hh> # include <mlc/fun.hh> -# include <oln/basics.hh> -# include <oln/core/abstract/image_operator.hh> +# include <oln/core/abstract/image.hh> +# include <oln/funobj/abstract/unary.hh> +# include <oln/funobj/abstract/binary.hh> # include <oln/core/ch_value_type.hh> + namespace oln { + /*--------. | Unary. | `--------*/ - // Fwd decl. - namespace impl { - template <typename F, typename I> - struct apply1_type; - } - - // Super type. + /*! \brief Standard unary \a apply procedure. + ** + ** Apply a function \a f to each element of \a input, the function + ** is passed as a type and is instantiated. + */ template <typename F, typename I> - struct set_super_type< impl::apply1_type<F, I> > + typename ch_value_type<I, typename F::result_type>::ret + apply(const mlc::abstract::unary_function<F>& f, + const abstract::image<I>& input) { - typedef typename ch_value_type<I, - typename F::result_type>::ret output_type; - typedef typename abstract::image_operator<output_type, impl::apply1_type<F, I> > ret; - }; + entering("apply"); + registering(input, "input"); - namespace impl { + typedef typename ch_value_type<I, typename F::result_type>::ret + output_type; + output_type output(input.size(), "output"); - template <typename F, typename I> - struct apply1_type : - public abstract::image_operator< - typename ch_value_type<I, typename F::result_type>::ret, - apply1_type<F, I> > - { - typedef typename ch_value_type<I, typename F::result_type>::ret - output_type; + oln_type_of(I, fwd_piter) p(input.size()); + for_all_p (p) + output[p] = f(input[p]); - F f_; - box<const I> input_; + exiting("apply"); + return output; + } - apply1_type(const mlc::abstract::unary_function<F>& f, - const abstract::image<I>& input) : - f_(f.exact ()), - input_(input.exact()) - { - } + // version with oln::f_::abstract::unary<F> - void impl_run() - { - output_type tmp(input_.size()); - oln_type_of(I, fwd_piter) p(input_.size()); - for_all_p (p) - tmp[p] = f_(input_[p]); - this->output = tmp; - } - }; + template <typename F, typename I> + typename ch_value_type<I, oln_fun1_type_of(F, res)>::ret + apply(const oln::f_::abstract::unary<F>& f, + const abstract::image<I>& input) + { + entering("apply"); + registering(input, "input"); - } // end of namespace impl + typedef typename ch_value_type<I, oln_fun1_type_of(F, res)>::ret + output_type; + output_type output(input.size(), "output"); + oln_type_of(I, fwd_piter) p(input.size()); + for_all_p (p) + output[p] = f(input[p]); - /*! \brief Standard unary \a apply procedure. - ** - ** Apply a function \a f to each element of \a input, the function - ** is passed as a type and is instantiated. - */ - template <typename F, typename I> - impl::apply1_type<F, I> - apply(const mlc::abstract::unary_function<F>& f, - const abstract::image<I>& input) - { - impl::apply1_type<F, I> tmp(f, input); - tmp.run(); - return tmp; + exiting("apply"); + return output; } @@ -109,77 +96,102 @@ | Binary. | `---------*/ - // Fwd decl. - namespace impl { - template <typename F, typename I1, typename I2> - struct apply2_type; + /*! \brief Standard binary \a apply procedure. + ** + ** Apply a function \a f to each pair of elements of + ** \a input1 x \a input2. + */ + template <typename F, typename I1, typename I2> + typename ch_value_type<I1, typename F::result_type>::ret + apply2(const mlc::abstract::binary_function<F>& f, + const abstract::image<I1>& input1, + const abstract::image<I2>& input2) + { + mlc::eq<oln_type_of(I1, grid), oln_type_of(I2, grid)>::ensure(); + + entering("apply2"); + registering(input1, "input1"); + registering(input2, "input2"); + + precondition(input1.size() == input2.size()); + + typedef typename ch_value_type<I1, typename F::result_type>::ret + output_type; + output_type output(input1.size(), "output"); + + oln_type_of(I1, fwd_piter) p(input1.size()); + for_all_p (p) + output[p] = f(input1[p], input2[p]); + + exiting("apply2"); + return output; } - // Super type. + + // version with oln::f_::abstract::binary<F> + template <typename F, typename I1, typename I2> - struct set_super_type< impl::apply2_type<F, I1, I2> > + typename ch_value_type<I1, oln_fun2_type_of(F, res)>::ret + apply2(const oln::f_::abstract::binary<F>& f, + const abstract::image<I1>& input1, + const abstract::image<I2>& input2) { - typedef typename ch_value_type<I1, - typename F::result_type>::ret output_type; - typedef typename abstract::image_operator<output_type, - impl::apply2_type<F, I1, I2> > ret; - }; + mlc::eq<oln_type_of(I1, grid), oln_type_of(I2, grid)>::ensure(); - namespace impl { + entering("apply2"); + registering(input1, "input1"); + registering(input2, "input2"); - template <typename F, typename I1, typename I2> - struct apply2_type : - public abstract::image_operator< - typename ch_value_type<I1, typename F::result_type>::ret, - apply2_type<F, I1, I2> > - { - typedef typename ch_value_type<I1, typename F::result_type>::ret - output_type; + precondition(input1.size() == input2.size()); - F f_; - box<const I1> input1_; - box<const I2> input2_; + typedef typename ch_value_type<I1, oln_fun2_type_of(F, res)>::ret + output_type; + output_type output(input1.size(), "output"); - apply2_type(const mlc::abstract::binary_function<F>& f, - const abstract::image<I1>& input1, - const abstract::image<I2>& input2) : - f_(f.exact ()), - input1_(input1.exact()), - input2_(input2.exact()) - { - assertion (input1_.size() == input2_.size()); - } + oln_type_of(I1, fwd_piter) p(input1.size()); + for_all_p (p) + output[p] = f(input1[p], input2[p]); - void impl_run() - { - output_type tmp(input1_.size()); - oln_type_of(I1, fwd_piter) p(input1_.size()); - for_all_p (p) - tmp[p] = f_(input1_[p], input2_[p]); - this->output = tmp; - } - }; + exiting("apply2"); + return output; + } - } // end of namespace impl + // version with oln::f_::abstract::mbinary<F> - /*! \brief Standard binary \a apply procedure. - ** - ** Apply a function \a f to each pair of elements of - ** \a input1 x \a input2. - */ template <typename F, typename I1, typename I2> - impl::apply2_type<F, I1, I2> - apply(const mlc::abstract::binary_function<F>& f, - const abstract::image<I1>& input1, - const abstract::image<I2>& input2) + typename ch_value_type<I1, typename f_::mbinary_result<F, + oln_type_of(I1, value), + oln_type_of(I2, value)>::ret + >::ret + apply2(const oln::f_::abstract::mbinary<F>& f, + const abstract::image<I1>& input1, + const abstract::image<I2>& input2) { - assertion (input1.size() == input2.size()); - impl::apply2_type<F, I1, I2> tmp(f, input1, input2); - tmp.run(); - return tmp; + mlc::eq<oln_type_of(I1, grid), oln_type_of(I2, grid)>::ensure(); + + entering("apply2"); + registering(input1, "input1"); + registering(input2, "input2"); + + precondition(input1.size() == input2.size()); + + typedef + typename ch_value_type<I1, typename f_::mbinary_result<F, + oln_type_of(I1, value), + oln_type_of(I2, value)>::ret + >::ret output_type; + output_type output(input1.size(), "output"); + + oln_type_of(I1, fwd_piter) p(input1.size()); + for_all_p (p) + output[p] = f(input1[p], input2[p]); + + exiting("apply2"); + return output; } + } // end of namespace oln #endif // ! OLENA_CORE_APPLY_HH Index: oln/core/ch_value_type.hh =================================================================== --- oln/core/ch_value_type.hh (revision 179) +++ oln/core/ch_value_type.hh (working copy) @@ -30,6 +30,16 @@ # include <oln/core/abstract/image.hh> + +# define oln_ch_value_type(I, T) \ + typename ch_value_type< I, T >::ret + + +// FIXME: bad name... +# define oln_ch_concrete_type(I, T) \ + typename ch_value_type< oln_type_of(I, concrete), T >::ret + + namespace oln { template<class I, class T = oln_type_of(I, value)> Index: oln/core/pw/binary_op.hh =================================================================== --- oln/core/pw/binary_op.hh (revision 179) +++ oln/core/pw/binary_op.hh (working copy) @@ -50,9 +50,9 @@ struct set_props < category::pw, pw::binary_op<F,L,R> > { typedef - typename f_::binary_meta_result< F, - oln_pw_type_of(L, value), - oln_pw_type_of(R, value) >::ret + typename f_::mbinary_result< F, + oln_pw_type_of(L, value), + oln_pw_type_of(R, value) >::ret value_type; }; Index: oln/core/pw/unary_op.hh =================================================================== --- oln/core/pw/unary_op.hh (revision 179) +++ oln/core/pw/unary_op.hh (working copy) @@ -50,7 +50,7 @@ template <typename F, typename A> struct set_props < category::pw, pw::unary_op<F,A> > { - typedef typename f_::unary_meta_result<F,A>::ret value_type; + typedef typename f_::munary_result<F,A>::ret value_type; }; Index: oln/utils/clone.hh =================================================================== --- oln/utils/clone.hh (revision 179) +++ oln/utils/clone.hh (working copy) @@ -28,74 +28,59 @@ #ifndef OLN_UTILS_CLONE_HH # define OLN_UTILS_CLONE_HH -# include <oln/basics.hh> -# include <oln/core/abstract/image_operator.hh> +# include <oln/core/abstract/image.hh> +# include <oln/utils/record.hh> -namespace oln { - // fwd decl - namespace utils { - namespace impl { - template <typename I> struct clone_type; - } - } +namespace oln +{ - // category - template <typename I> - struct set_category < utils::impl::clone_type<I> > - { - typedef category::image ret; - }; + // Fwd decl of erosion's facade. - // super_type template <typename I> - struct set_super_type < utils::impl::clone_type<I> > - { - typedef abstract::image_unary_operator<I, I, utils::impl::clone_type<I> > ret; - }; + oln_type_of(I, concrete) clone(const abstract::image<I>& input); + namespace impl { - namespace utils { + // generic - namespace impl { + template <typename I> + oln_type_of(I, concrete) clone_(const abstract::image<I>& input) + { + entering("->generic"); + registering(input, "input"); - template <typename I> - struct clone_type - : public abstract::image_unary_operator<oln_type_of(I, concrete), I, clone_type<I> > - // FIXME: use concrete_type; Cf. erosion.hh - { - typedef abstract::image_unary_operator<oln_type_of(I, concrete), I, clone_type<I> > super_type; + oln_type_of(I, concrete) output(input.size(), "output"); + oln_type_of(I, fwd_piter) p(input.size()); + for_all_p (p) + output[p] = input[p]; - clone_type(const abstract::image<I>& input) : - super_type(input) - { - } + exiting("->generic"); + return output; + } - void impl_run() - { - oln_type_of(I, concrete) tmp(this->input.size()); // FIXME: trick - this->output = tmp; + // add some other impls here... - oln_type_of(I, fwd_piter) p(this->input.size()); - for_all_p (p) - this->output[p] = this->input[p]; - } - }; + } // end of namespace oln::morpho::impl - } // end of namespace oln::utils::impl + /// Generic clone (facade). - template <typename I> - impl::clone_type<I> clone(const abstract::image<I>& ima) - { - impl::clone_type<I> tmp(ima.exact()); - tmp.run(); - return tmp; - } + template <typename I> + oln_type_of(I, concrete) clone(const abstract::image<I>& input) + { + entering("clone"); + registering(input, "input"); - } // end of namespace oln::utils + oln_type_of(I, concrete) output("output"); + output = impl::clone_(input.exact()); + exiting("clone"); + return output; + } + + } // end of namespace oln Index: oln/ops/arith.hh =================================================================== --- oln/ops/arith.hh (revision 0) +++ oln/ops/arith.hh (working copy) @@ -25,8 +25,8 @@ // reasons why the executable file might be covered by the GNU General // Public License. -#ifndef OLENA_ARITH_OPS_HH -# define OLENA_ARITH_OPS_HH +#ifndef OLENA_OPS_ARITH_HH +# define OLENA_OPS_ARITH_HH # include <oln/core/abstract/image.hh> # include <oln/core/pw/image.hh> @@ -157,4 +157,4 @@ // FIXME: to be continued... -#endif // ! OLENA_ARITH_OPS_HH +#endif // ! OLENA_OPS_ARITH_HH Index: oln/ops/logic.hh =================================================================== --- oln/ops/logic.hh (revision 0) +++ oln/ops/logic.hh (working copy) @@ -25,8 +25,8 @@ // reasons why the executable file might be covered by the GNU General // Public License. -#ifndef OLENA_ARITH_LOGIC_HH -# define OLENA_ARITH_LOGIC_HH +#ifndef OLENA_OPS_LOGIC_HH +# define OLENA_OPS_LOGIC_HH # include <oln/core/abstract/image.hh> # include <oln/core/pw/image.hh> @@ -85,4 +85,4 @@ -#endif // ! OLENA_ARITH_LOGIC_HH +#endif // ! OLENA_OPS_LOGIC_HH Index: oln/ops/cmp.hh =================================================================== --- oln/ops/cmp.hh (revision 0) +++ oln/ops/cmp.hh (working copy) @@ -25,8 +25,8 @@ // reasons why the executable file might be covered by the GNU General // Public License. -#ifndef OLENA_ARITH_CMP_HH -# define OLENA_ARITH_CMP_HH +#ifndef OLENA_OPS_CMP_HH +# define OLENA_OPS_CMP_HH # include <oln/core/abstract/image.hh> # include <oln/core/pw/cmp.hh> @@ -93,4 +93,4 @@ } -#endif // ! OLENA_ARITH_CMP_HH +#endif // ! OLENA_OPS_CMP_HH Index: oln/morpho/geodesic_dilation.hh =================================================================== --- oln/morpho/geodesic_dilation.hh (revision 179) +++ oln/morpho/geodesic_dilation.hh (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2001, 2002, 2003, 2004, 2005 EPITA Research and Development Laboratory +// Copyright (C) 2001-2005 EPITA Research and Development Laboratory // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -32,7 +32,7 @@ # include <mlc/contract.hh> # include <oln/utils/record.hh> -# include <oln/arith/cmp.hh> +# include <oln/ops/cmp.hh> # include <oln/core/gen/image_with_nbh.hh> // FIXME: should be in core/abstract/ (?) # include <oln/morpho/elementary_dilation.hh> Index: oln/morpho/geodesic_erosion.hh =================================================================== --- oln/morpho/geodesic_erosion.hh (revision 179) +++ oln/morpho/geodesic_erosion.hh (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2005 EPITA Research and Development Laboratory +// Copyright (C) 2001-2005 EPITA Research and Development Laboratory // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -32,7 +32,7 @@ # include <mlc/contract.hh> # include <oln/utils/record.hh> -# include <oln/arith/cmp.hh> +# include <oln/ops/cmp.hh> # include <oln/core/gen/image_with_nbh.hh> # include <oln/morpho/elementary_erosion.hh> Index: oln/arith/ops.hh =================================================================== --- oln/arith/ops.hh (revision 179) +++ oln/arith/ops.hh (working copy) @@ -1,160 +0,0 @@ -// Copyright (C) 2005 EPITA Research and Development Laboratory -// -// This file is part of the Olena Library. This library is free -// software; you can redistribute it and/or modify it under the terms -// of the GNU General Public License version 2 as published by the -// Free Software Foundation. -// -// This library 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 this library; see the file COPYING. If not, write to -// the Free Software Foundation, 59 Temple Place - Suite 330, Boston, -// MA 02111-1307, USA. -// -// As a special exception, you may use this file as part of a free -// software library 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 OLENA_ARITH_OPS_HH -# define OLENA_ARITH_OPS_HH - -# include <oln/core/abstract/image.hh> -# include <oln/core/pw/image.hh> -# include <oln/core/pw/value.hh> -# include <oln/core/pw/arith.hh> - - -namespace oln -{ - - /// Operator-like "min" and "max" between 2 images. - - template <typename L, typename R> - image_from_pwf< pw::binary_op< f_min_type, - pw::value<L>, - pw::value<R> > > - min (const abstract::image<L>& lhs, - const abstract::image<R>& rhs) - { - return image_for_all_p( min(pw_value(lhs), pw_value(rhs)) ); - } - - template <typename L, typename R> - image_from_pwf< pw::binary_op< f_max_type, - pw::value<L>, - pw::value<R> > > - max (const abstract::image<L>& lhs, - const abstract::image<R>& rhs) - { - return image_for_all_p( max(pw_value(lhs), pw_value(rhs)) ); - } - -} // end of namespace oln - - -/// Operator '+' between 2 images. - -template <typename L, typename R> -oln::image_from_pwf< oln::pw::binary_op< oln::f_plus_type, - oln::pw::value<L>, - oln::pw::value<R> > > -operator + (const oln::abstract::image<L>& lhs, - const oln::abstract::image<R>& rhs) -{ - return oln::image_for_all_p(oln::pw_value(lhs) + oln::pw_value(rhs)); -} - - -/// Operator '-' between 2 images. - -template <typename L, typename R> -oln::image_from_pwf< oln::pw::binary_op< oln::f_minus_type, - oln::pw::value<L>, - oln::pw::value<R> > > -operator - (const oln::abstract::image<L>& lhs, - const oln::abstract::image<R>& rhs) -{ - return oln::image_for_all_p(oln::pw_value(lhs) - oln::pw_value(rhs)); -} - - -/// Operator '*' between 2 images. - -template <typename L, typename R> -oln::image_from_pwf< oln::pw::binary_op< oln::f_times_type, - oln::pw::value<L>, - oln::pw::value<R> > > -operator * (const oln::abstract::image<L>& lhs, - const oln::abstract::image<R>& rhs) -{ - return oln::image_for_all_p(oln::pw_value(lhs) * oln::pw_value(rhs)); -} - - -/// Operator '/' between 2 images. - -template <typename L, typename R> -oln::image_from_pwf< oln::pw::binary_op< oln::f_div_type, - oln::pw::value<L>, - oln::pw::value<R> > > -operator / (const oln::abstract::image<L>& lhs, - const oln::abstract::image<R>& rhs) -{ - return oln::image_for_all_p(oln::pw_value(lhs) / oln::pw_value(rhs)); -} - - -/// Operator '%' between 2 images. - -template <typename L, typename R> -oln::image_from_pwf< oln::pw::binary_op< oln::f_mod_type, - oln::pw::value<L>, - oln::pw::value<R> > > -operator % (const oln::abstract::image<L>& lhs, - const oln::abstract::image<R>& rhs) -{ - return oln::image_for_all_p(oln::pw_value(lhs) % oln::pw_value(rhs)); -} - - - - -// FIXME... - -// /// Operator - (unary) on image. - -// template <typename R> -// oln::image_from_pw< oln::pw::minus< oln::pw::literal< oln_pw_type_of(R, value) >, -// oln::pw::image<R> > > -// operator - (const oln::abstract::image<R>& rhs) -// { -// return oln::image_for_all_p( - oln::p_value(rhs)); -// } - - -// template <typename I, typename F> -// void operator + (const oln::abstract::image<I>&, -// const oln::pw::abstract::function<F>&) -// { -// struct OLENA_ERROR__args_are_not_compatible(); -// } -// template <typename F, typename I> -// void operator + (const oln::pw::abstract::function<F>&, -// const oln::abstract::image<I>&) -// { -// struct OLENA_ERROR__args_are_not_compatible(); -// } -// FIXME: to be continued... - - -#endif // ! OLENA_ARITH_OPS_HH Index: oln/arith/min.hh =================================================================== --- oln/arith/min.hh (revision 179) +++ oln/arith/min.hh (working copy) @@ -1,105 +0,0 @@ -// Copyright (C) 2005 EPITA Research and Development Laboratory -// -// This file is part of the Olena Library. This library is free -// software; you can redistribute it and/or modify it under the terms -// of the GNU General Public License version 2 as published by the -// Free Software Foundation. -// -// This library 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 this library; see the file COPYING. If not, write to -// the Free Software Foundation, 59 Temple Place - Suite 330, Boston, -// MA 02111-1307, USA. -// -// As a special exception, you may use this file as part of a free -// software library 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 OLENA_ARITH_MIN_HH -# define OLENA_ARITH_MIN_HH - -# include <oln/basics.hh> -# include <oln/core/abstract/image_operator.hh> - -# include <ntg/all.hh> - -namespace oln { - - namespace arith { - // fwd decl - namespace impl { - template <typename I1, typename I2> struct min_type; - } - - } - - // super_type - template <typename I1, typename I2> - struct set_super_type< arith::impl::min_type<I1, I2> > - { - typedef oln_type_of(I1, concrete) output_type; - typedef arith::impl::min_type<I1, I2> self_type; - typedef abstract::image_binary_operator<output_type, I1, I2, self_type> ret; - }; - - namespace arith { - - namespace impl { - - template <typename I1, typename I2> - struct min_type : - // FIXME: oln_super_of_ - public oln::internal::get_super_type< min_type<I1,I2> >::ret - { - typedef typename oln::internal::get_super_type< min_type<I1,I2> >::ret - super_type; - typedef oln_type_of(I1, concrete) output_type; - - min_type(const abstract::image<I1>& input1, - const abstract::image<I2>& input2) : - super_type(input1.exact(), input2.exact()) - {} - - void impl_run() - { - precondition(this->input1.size() == this->input2.size()); - output_type output(this->input1.size()); - - oln_type_of(I1, fwd_piter) p(this->input1.size()); - - for_all_p (p) - output[p] = ntg::min(this->input1[p].value(), this->input2[p].value()); - - this->output = output; - } - - }; - - } - - template <typename I1, typename I2> - impl::min_type<I1, I2> min(const abstract::image<I1>& input1, - const abstract::image<I2>& input2) - { - mlc::eq<oln_type_of(I1, grid), oln_type_of(I2, grid)>::ensure(); - impl::min_type<I1, I2> tmp(input1, input2); - tmp.run(); - return tmp; - } - - } - -} // end of namespace oln - - -#endif // ! OLENA_ARITH_MIN_HH Index: oln/arith/max.hh =================================================================== --- oln/arith/max.hh (revision 179) +++ oln/arith/max.hh (working copy) @@ -1,105 +0,0 @@ -// Copyright (C) 2005 EPITA Research and Development Laboratory -// -// This file is part of the Olena Library. This library is free -// software; you can redistribute it and/or modify it under the terms -// of the GNU General Public License version 2 as published by the -// Free Software Foundation. -// -// This library 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 this library; see the file COPYING. If not, write to -// the Free Software Foundation, 59 Temple Place - Suite 330, Boston, -// MA 02111-1307, USA. -// -// As a special exception, you may use this file as part of a free -// software library 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 OLENA_ARITH_MAX_HH -# define OLENA_ARITH_MAX_HH - -# include <oln/basics.hh> -# include <oln/core/abstract/image_operator.hh> - -# include <ntg/all.hh> - -namespace oln { - - namespace arith { - // fwd decl - namespace impl { - template <typename I1, typename I2> struct max_type; - } - - } - - // super_type - template <typename I1, typename I2> - struct set_super_type< arith::impl::max_type<I1, I2> > - { - typedef oln_type_of(I1, concrete) output_type; - typedef arith::impl::max_type<I1, I2> self_type; - typedef abstract::image_binary_operator<output_type, I1, I2, self_type> ret; - }; - - namespace arith { - - namespace impl { - - template <typename I1, typename I2> - struct max_type : - // FIXME: oln_super_of_ - public oln::internal::get_super_type< max_type<I1,I2> >::ret - { - typedef typename oln::internal::get_super_type< max_type<I1,I2> >::ret - super_type; - typedef oln_type_of(I1, concrete) output_type; - - max_type(const abstract::image<I1>& input1, - const abstract::image<I2>& input2) : - super_type(input1.exact(), input2.exact()) - {} - - void impl_run() - { - precondition(this->input1.size() == this->input2.size()); - output_type output(this->input1.size()); - - oln_type_of(I1, fwd_piter) p(this->input1.size()); - - for_all_p (p) - output[p] = ntg::max(this->input1[p].value(), this->input2[p].value()); - - this->output = output; - } - - }; - - } - - template <typename I1, typename I2> - impl::max_type<I1, I2> max(const abstract::image<I1>& input1, - const abstract::image<I2>& input2) - { - mlc::eq<oln_type_of(I1, grid), oln_type_of(I2, grid)>::ensure(); - impl::max_type<I1, I2> tmp(input1, input2); - tmp.run(); - return tmp; - } - - } - -} // end of namespace oln - - -#endif // ! OLENA_ARITH_MAX_HH Index: oln/arith/logic.hh =================================================================== --- oln/arith/logic.hh (revision 179) +++ oln/arith/logic.hh (working copy) @@ -1,88 +0,0 @@ -// Copyright (C) 2005 EPITA Research and Development Laboratory -// -// This file is part of the Olena Library. This library is free -// software; you can redistribute it and/or modify it under the terms -// of the GNU General Public License version 2 as published by the -// Free Software Foundation. -// -// This library 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 this library; see the file COPYING. If not, write to -// the Free Software Foundation, 59 Temple Place - Suite 330, Boston, -// MA 02111-1307, USA. -// -// As a special exception, you may use this file as part of a free -// software library 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 OLENA_ARITH_LOGIC_HH -# define OLENA_ARITH_LOGIC_HH - -# include <oln/core/abstract/image.hh> -# include <oln/core/pw/image.hh> -# include <oln/core/pw/value.hh> -# include <oln/core/pw/logic.hh> - - -/// Operator 'and' between 2 binary images. - -template <typename L, typename R> -const oln::image_from_pwf< oln::pw::binary_op< oln::f_and_type, - oln::pw::value<L>, - oln::pw::value<R> > > -operator and (const oln::abstract::binary_image<L>& lhs, - const oln::abstract::binary_image<R>& rhs) -{ - return oln::image_for_all_p(oln::pw_value(lhs) and oln::pw_value(rhs)); -} - - -/// Operator 'or' between 2 binary images. - -template <typename L, typename R> -const oln::image_from_pwf< oln::pw::binary_op< oln::f_or_type, - oln::pw::value<L>, - oln::pw::value<R> > > -operator or (const oln::abstract::binary_image<L>& lhs, - const oln::abstract::binary_image<R>& rhs) -{ - return oln::image_for_all_p(oln::pw_value(lhs) or oln::pw_value(rhs)); -} - - -/// Operator 'xor' between 2 binary images. - -template <typename L, typename R> -const oln::image_from_pwf< oln::pw::binary_op< oln::f_xor_type, - oln::pw::value<L>, - oln::pw::value<R> > > -operator xor (const oln::abstract::binary_image<L>& lhs, - const oln::abstract::binary_image<R>& rhs) -{ - return oln::image_for_all_p(oln::pw_value(lhs) xor oln::pw_value(rhs)); -} - - -// FIXME... -// /// Unary operator 'not' on a binary image. - -// template <typename I> -// oln::image_from_pw< oln::pw::not_< oln::pw::image<I> > > -// operator ! (const oln::abstract::binary_image<I>& rhs) -// { -// return oln::image_for_all_p(!oln::p_value(rhs)); -// } - - - -#endif // ! OLENA_ARITH_LOGIC_HH Index: oln/arith/cmp.hh =================================================================== --- oln/arith/cmp.hh (revision 179) +++ oln/arith/cmp.hh (working copy) @@ -1,96 +0,0 @@ -// Copyright (C) 2005 EPITA Research and Development Laboratory -// -// This file is part of the Olena Library. This library is free -// software; you can redistribute it and/or modify it under the terms -// of the GNU General Public License version 2 as published by the -// Free Software Foundation. -// -// This library 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 this library; see the file COPYING. If not, write to -// the Free Software Foundation, 59 Temple Place - Suite 330, Boston, -// MA 02111-1307, USA. -// -// As a special exception, you may use this file as part of a free -// software library 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 OLENA_ARITH_CMP_HH -# define OLENA_ARITH_CMP_HH - -# include <oln/core/abstract/image.hh> -# include <oln/core/pw/cmp.hh> -# include <oln/core/pw/check.hh> - - -/// Operator '==' between 2 images. - -template <typename L, typename R> -bool operator == (const oln::abstract::image<L>& lhs, - const oln::abstract::image<R>& rhs) -{ - return oln::pw::check(oln::pw_value(lhs) == oln::pw_value(rhs)); -} - - -/// Operator '!=' between 2 images. - -template <typename L, typename R> -bool operator != (const oln::abstract::image<L>& lhs, - const oln::abstract::image<R>& rhs) -{ - return oln::pw::check(oln::pw_value(lhs) != oln::pw_value(rhs)); -} - - -/// Operator '<' between 2 images. - -template <typename L, typename R> -bool operator < (const oln::abstract::image<L>& lhs, - const oln::abstract::image<R>& rhs) -{ - return oln::pw::check(oln::pw_value(lhs) < oln::pw_value(rhs)); -} - - -/// Operator '<=' between 2 images. - -template <typename L, typename R> -bool operator <= (const oln::abstract::image<L>& lhs, - const oln::abstract::image<R>& rhs) -{ - return oln::pw::check(oln::pw_value(lhs) <= oln::pw_value(rhs)); -} - - -/// Operator '>' between 2 images. - -template <typename L, typename R> -bool operator > (const oln::abstract::image<L>& lhs, - const oln::abstract::image<R>& rhs) -{ - return oln::pw::check(oln::pw_value(lhs) > oln::pw_value(rhs)); -} - - -/// Operator '>=' between 2 images. - -template <typename L, typename R> -bool operator >= (const oln::abstract::image<L>& lhs, - const oln::abstract::image<R>& rhs) -{ - return oln::pw::check(oln::pw_value(lhs) >= oln::pw_value(rhs)); -} - - -#endif // ! OLENA_ARITH_CMP_HH Index: oln/level/arith.hh =================================================================== --- oln/level/arith.hh (revision 0) +++ oln/level/arith.hh (revision 0) @@ -0,0 +1,246 @@ +// Copyright (C) 2005 EPITA Research and Development Laboratory +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// of the GNU General Public License version 2 as published by the +// Free Software Foundation. +// +// This library 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 this library; see the file COPYING. If not, write to +// the Free Software Foundation, 59 Temple Place - Suite 330, Boston, +// MA 02111-1307, USA. +// +// As a special exception, you may use this file as part of a free +// software library 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 OLENA_LEVEL_ARITH_HH +# define OLENA_LEVEL_ARITH_HH + +# include <mlc/cmp.hh> +# include <oln/core/ch_value_type.hh> + +# include <oln/funobj/arith.hh> + +# include <oln/ops/arith.hh> +# include <oln/utils/clone.hh> + + +# define oln_arith_output(Op, I1, I2) \ + typename arith_output<f_::Op##_,I1,I2>::ret + + + +namespace oln +{ + + namespace level + { + + // min + + template <typename I1, typename I2> + oln_type_of(I1, concrete) + min (const abstract::image<I1>& input1, + const abstract::image<I2>& input2) + { + mlc::eq<oln_type_of(I1, grid), oln_type_of(I2, grid)>::ensure(); + mlc::eq<oln_type_of(I1, value), oln_type_of(I2, value)>::ensure(); + + entering("level::min"); + registering(input1, "input1"); + registering(input2, "input2"); + + precondition(input1.size() == input2.size()); + + oln_type_of(I1, concrete) output("output"); + output = clone( oln::min(input1, input2) ); + + exiting("level::min"); + return output; + } + + + // max + + template <typename I1, typename I2> + oln_type_of(I1, concrete) + max (const abstract::image<I1>& input1, + const abstract::image<I2>& input2) + { + mlc::eq<oln_type_of(I1, grid), oln_type_of(I2, grid)>::ensure(); + mlc::eq<oln_type_of(I1, value), oln_type_of(I2, value)>::ensure(); + + entering("level::max"); + registering(input1, "input1"); + registering(input2, "input2"); + + precondition(input1.size() == input2.size()); + + oln_type_of(I1, concrete) output("output"); + output = clone( oln::max(input1, input2) ); + + exiting("level::max"); + return output; + } + + + // arith output + + template <template <typename, typename> class F, + typename I1, typename I2> + struct arith_output + { + typedef oln_type_of(I1, value) T1; + typedef oln_type_of(I2, value) T2; + typedef oln_fun2_type_2_of(F<T1,T2>, res) T; + typedef oln_ch_concrete_type(I1, T) ret; + }; + + + template <typename I1, typename I2> + oln_arith_output(plus, I1, I2) + f_plus (const abstract::image<I1>& input1, + const abstract::image<I2>& input2) + { + // FIXME: recording(?) + mlc::eq<oln_type_of(I1, grid), oln_type_of(I2, grid)>::ensure(); + typedef oln::f_::plus_<oln_type_of(I1, value), oln_type_of(I2, value)> fun_type; + return apply2(fun_type(), input1, input2); + // FIXME: does not work yet! +// return apply2(oln::f_plus, input1, input2); + } + + +// // plus + +// template <typename I1, typename I2> +// oln_arith_output(plus,I1,I2) +// plus (const abstract::image<I1>& input1, +// const abstract::image<I2>& input2) +// { +// mlc::eq<oln_type_of(I1, grid), oln_type_of(I2, grid)>::ensure(); + +// entering("level::plus"); +// registering(input1, "input1"); +// registering(input2, "input2"); + +// precondition(input1.size() == input2.size()); + +// oln_arith_output(plus,I1,I2) output("output"); +// output = clone( input1 + input2 ); + +// exiting("level::plus"); +// return output; +// } + + + // minus + + template <typename I1, typename I2> + oln_arith_output(minus,I1,I2) + minus (const abstract::image<I1>& input1, + const abstract::image<I2>& input2) + { + mlc::eq<oln_type_of(I1, grid), oln_type_of(I2, grid)>::ensure(); + + entering("level::minus"); + registering(input1, "input1"); + registering(input2, "input2"); + + precondition(input1.size() == input2.size()); + + oln_arith_output(minus,I1,I2) output("output"); + output = clone( input1 + input2 ); + + exiting("level::minus"); + return output; + } + + + // times + + template <typename I1, typename I2> + oln_arith_output(times,I1,I2) + times (const abstract::image<I1>& input1, + const abstract::image<I2>& input2) + { + mlc::eq<oln_type_of(I1, grid), oln_type_of(I2, grid)>::ensure(); + + entering("level::times"); + registering(input1, "input1"); + registering(input2, "input2"); + + precondition(input1.size() == input2.size()); + + oln_arith_output(times,I1,I2) output("output"); + output = clone( input1 + input2 ); + + exiting("level::times"); + return output; + } + + + // div + + template <typename I1, typename I2> + oln_arith_output(div,I1,I2) + div (const abstract::image<I1>& input1, + const abstract::image<I2>& input2) + { + mlc::eq<oln_type_of(I1, grid), oln_type_of(I2, grid)>::ensure(); + + entering("level::div"); + registering(input1, "input1"); + registering(input2, "input2"); + + precondition(input1.size() == input2.size()); + + oln_arith_output(div,I1,I2) output("output"); + output = clone( input1 + input2 ); + + exiting("level::div"); + return output; + } + + + // mod + + template <typename I1, typename I2> + oln_arith_output(mod,I1,I2) + mod (const abstract::image<I1>& input1, + const abstract::image<I2>& input2) + { + mlc::eq<oln_type_of(I1, grid), oln_type_of(I2, grid)>::ensure(); + + entering("level::mod"); + registering(input1, "input1"); + registering(input2, "input2"); + + precondition(input1.size() == input2.size()); + + oln_arith_output(mod,I1,I2) output("output"); + output = clone( input1 + input2 ); + + exiting("level::mod"); + return output; + } + + + } // end of namespace oln::level + +} // end of namespace oln + + +#endif // ! OLENA_LEVEL_ARITH_HH Index: oln/level/logic.hh =================================================================== --- oln/level/logic.hh (revision 0) +++ oln/level/logic.hh (revision 0) @@ -0,0 +1,122 @@ +// Copyright (C) 2005 EPITA Research and Development Laboratory +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// of the GNU General Public License version 2 as published by the +// Free Software Foundation. +// +// This library 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 this library; see the file COPYING. If not, write to +// the Free Software Foundation, 59 Temple Place - Suite 330, Boston, +// MA 02111-1307, USA. +// +// As a special exception, you may use this file as part of a free +// software library 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 OLENA_LEVEL_LOGIC_HH +# define OLENA_LEVEL_LOGIC_HH + +# include <oln/core/abstract/image_entry.hh> +# include <oln/core/apply.hh> +# include <oln/funobj/logic.hh> + + + +namespace oln +{ + + namespace level + { + + // f_and + + template <typename I1, typename I2> + oln_type_of(I1, concrete) + f_and (const abstract::binary_image<I1>& input1, + const abstract::binary_image<I2>& input2) + { + // FIXME: recording(?) + mlc::eq<oln_type_of(I1, grid), oln_type_of(I2, grid)>::ensure(); + return apply2(oln::f_and, input1, input2); + } + + + // f_nand + + template <typename I1, typename I2> + oln_type_of(I1, concrete) + f_nand (const abstract::binary_image<I1>& input1, + const abstract::binary_image<I2>& input2) + { + mlc::eq<oln_type_of(I1, grid), oln_type_of(I2, grid)>::ensure(); + return apply2(oln::f_nand, input1, input2); + } + + + // f_or + + template <typename I1, typename I2> + oln_type_of(I1, concrete) + f_or (const abstract::binary_image<I1>& input1, + const abstract::binary_image<I2>& input2) + { + mlc::eq<oln_type_of(I1, grid), oln_type_of(I2, grid)>::ensure(); + return apply2(oln::f_or, input1, input2); + } + + + // f_nor + + template <typename I1, typename I2> + oln_type_of(I1, concrete) + f_nor (const abstract::binary_image<I1>& input1, + const abstract::binary_image<I2>& input2) + { + mlc::eq<oln_type_of(I1, grid), oln_type_of(I2, grid)>::ensure(); + return apply2(oln::f_nor, input1, input2); + } + + + + // f_xor + + template <typename I1, typename I2> + oln_type_of(I1, concrete) + f_xor (const abstract::binary_image<I1>& input1, + const abstract::binary_image<I2>& input2) + { + mlc::eq<oln_type_of(I1, grid), oln_type_of(I2, grid)>::ensure(); + return apply2(oln::f_xor, input1, input2); + } + + + // f_nxor + + template <typename I1, typename I2> + oln_type_of(I1, concrete) + f_xnor (const abstract::binary_image<I1>& input1, + const abstract::binary_image<I2>& input2) + { + mlc::eq<oln_type_of(I1, grid), oln_type_of(I2, grid)>::ensure(); + return apply2(oln::f_xnor, input1, input2); + } + + + } // end of namespace oln::level + +} // end of namespace oln + + +#endif // ! OLENA_LEVEL_LOGIC_HH
19 years, 7 months
1
0
0
0
proto-1.0 181: add ch_value to image_with_nbh.
by Thierry GERAUD
2005-05-02 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr> * oln/core/ch_value_type.hh: Fix bug. * oln/core/gen/image_with_nbh.hh (ch_value_type): Add. Index: oln/core/ch_value_type.hh =================================================================== --- oln/core/ch_value_type.hh (revision 180) +++ oln/core/ch_value_type.hh (working copy) @@ -37,12 +37,12 @@ // FIXME: bad name... # define oln_ch_concrete_type(I, T) \ - typename ch_value_type< oln_type_of(I, concrete), T >::ret + typename oln::ch_value_type< oln_type_of(I, concrete), T >::ret namespace oln { - template<class I, class T = oln_type_of(I, value)> + template<class I, class T>// FIXME: remove cause pb with compiler = oln_type_of(I, value)> struct ch_value_type { // FIXME: Use/extend oln/core/properties.hh mechanisms, instead of Index: oln/core/gen/image_with_nbh.hh =================================================================== --- oln/core/gen/image_with_nbh.hh (revision 180) +++ oln/core/gen/image_with_nbh.hh (working copy) @@ -30,6 +30,7 @@ # include <oln/core/abstract/image_with_extension.hh> # include <oln/core/abstract/neighborhood.hh> +# include <oln/core/ch_value_type.hh> # include <oln/utils/record.hh> @@ -51,6 +52,13 @@ typedef is_a<abstract::image_with_nbh> image_neighbness_type; typedef N neighb_type; typedef image_with_nbh< oln_type_of(I, concrete), N> concrete_type; + + template <typename U> + struct ch_value_type + { + typedef typename oln::ch_value_type<I, U>::ret IU; + typedef oln::image_with_nbh< IU, N > ret; + }; };
19 years, 7 months
1
0
0
0
← Newer
1
2
3
Older →
Jump to page:
1
2
3
Results per page:
10
25
50
100
200