Olena-patches
Threads by month
- ----- 2025 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 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
- 9625 discussions
From: Vivien Delmon <vivien.delmon(a)lrde.epita.fr>
To: olena-patches(a)lrde.epita.fr
Subject: milena r2745: Generalize erosion in 2d for any accumulator
URL: https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
ChangeLog:
2008-10-31 Vivien Delmon <vivien.delmon(a)lrde.epita.fr>
Generalize erosion in 2d for any accumulator.
* mln/morpho/erosion.spe.hh: Add accumulator type as parameter and
rename min as accu.
---
erosion.spe.hh | 38 +++++++++++++++++++-------------------
1 file changed, 19 insertions(+), 19 deletions(-)
Index: branches/cleanup-2008/milena/mln/morpho/erosion.spe.hh
===================================================================
--- branches/cleanup-2008/milena/mln/morpho/erosion.spe.hh (revision 2744)
+++ branches/cleanup-2008/milena/mln/morpho/erosion.spe.hh (revision 2745)
@@ -463,17 +463,17 @@
}
- template <typename I, typename W>
+ template <typename I, typename W, typename A>
struct erosion_arbitrary_2d_functor
{
- typedef erosion_arbitrary_2d_functor<I,W> self;
+ typedef erosion_arbitrary_2d_functor<I,W, A> self;
typedef void (self::*move_fun)();
typedef mln_deduce(I, psite, delta) dpsite;
const I& input;
const W& win;
mln_concrete(I) output;
- accu::min_h<mln_value(I)> min;
+ Accumulator<A> accu;
mln_psite(I) p;
@@ -503,7 +503,7 @@
erosion_arbitrary_2d_functor(const I& input, const W& win)
: input(input),
win(win),
- min(),
+ accu(),
win_left_fwd(win::shift(win, mln::left) - win),
win_right_fwd(win - win::shift(win, mln::left)),
@@ -557,48 +557,48 @@
{
extension::adjust_fill(input, win, mln_max(mln_value(I)));
initialize(output, input);
- min.init();
+ accu.init();
p = input.domain().pmin() - dps[0];
mln_qiter(W) q(win, p);
for_all(q)
- min.take(input(q));
+ accu.take(input(q));
p = input.domain().pmin();
}
void right()
{
for_all(q_l_fwd)
- min.untake(input(q_l_fwd));
+ accu.untake(input(q_l_fwd));
for_all(q_r_fwd)
- min.take(input(q_r_fwd));
- output(p) = min;
+ accu.take(input(q_r_fwd));
+ output(p) = accu;
}
void left()
{
for_all(q_r_bkd)
- min.untake(input(q_r_bkd));
+ accu.untake(input(q_r_bkd));
for_all(q_l_bkd)
- min.take(input(q_l_bkd));
- output(p) = min;
+ accu.take(input(q_l_bkd));
+ output(p) = accu;
}
void down()
{
for_all(q_top_down)
- min.untake(input(q_top_down));
+ accu.untake(input(q_top_down));
for_all(q_bot_down)
- min.take(input(q_bot_down));
- output(p) = min;
+ accu.take(input(q_bot_down));
+ output(p) = accu;
}
void up()
{
for_all(q_bot_up)
- min.untake(input(q_bot_up));
+ accu.untake(input(q_bot_up));
for_all(q_top_up)
- min.take(input(q_top_up));
- output(p) = min;
+ accu.take(input(q_top_up));
+ output(p) = accu;
}
};
@@ -610,7 +610,7 @@
{
trace::entering("morpho::impl:erosion_arbitrary_2d");
- typedef erosion_arbitrary_2d_functor<I, W> F;
+ typedef erosion_arbitrary_2d_functor<I, W, accu::min_h<mln_value(I)> > F;
F f(exact(input), exact(win));
canvas::browsing::snake_generic(f);
1
0
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Revamp linear convolution.
* mln/linear/convolve.hh: Re-vamp.
* tests/linear/convolve.cc: Update.
* mln/core/routine/primary.hh: New; not completed yet.
* mln/core/routine/all.hh: Update.
* mln/core/concept/window.hh (todo): New.
* mln/morpho/erosion.hh (tests): New.
mln/core/concept/window.hh | 3
mln/core/routine/all.hh | 7 -
mln/core/routine/primary.hh | 100 ++++++++++++++++++++++
mln/linear/convolve.hh | 198 +++++++++++++++++++++++++-------------------
mln/morpho/erosion.hh | 21 ++++
tests/linear/convolve.cc | 8 -
6 files changed, 245 insertions(+), 92 deletions(-)
Index: tests/linear/convolve.cc
--- tests/linear/convolve.cc (revision 2743)
+++ tests/linear/convolve.cc (working copy)
@@ -54,7 +54,6 @@
image2d<int_u8> lena;
io::pgm::load(lena, MLN_IMG_DIR "/lena.pgm");
- image2d<int_u8> out(lena.domain());
float ws[] = { .04, .04, .04, .04, .04,
.04, .04, .04, .04, .04,
@@ -63,9 +62,10 @@
.04, .04, .04, .04, .04 };
w_window2d_float w = make::w_window2d(ws);
- image2d<float> tmp(lena.domain());
- linear::convolve(lena, w, tmp);
- level::transform(tmp, math::round<int_u8>(), out);
+// image2d<float> tmp = linear::convolve(lena, w);
+// image2d<int_u8> out = level::transform(tmp, math::round<int_u8>());
+
+ image2d<int_u8> out = linear::convolve(lena, w);
io::pgm::save(out, "out.pgm");
}
Index: mln/core/routine/primary.hh
--- mln/core/routine/primary.hh (revision 0)
+++ mln/core/routine/primary.hh (revision 0)
@@ -0,0 +1,100 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// 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, 51 Franklin Street, Fifth Floor,
+// 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 MLN_CORE_ROUTINE_PRIMARY_HH
+# define MLN_CORE_ROUTINE_PRIMARY_HH
+
+/*! \file mln/core/routine/primary.hh
+ *
+ * \brief FIXME
+ *
+ * \todo We also need to get the extension image to handle border
+ * routines.
+ */
+
+# include <mln/core/concept/image.hh>
+
+
+namespace mln
+{
+
+ /// FIXME: Doc!
+ template <typename I>
+ void primary(const Image<I>& ima);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ namespace internal
+ {
+
+ // Primary_type.
+
+ template <typename I> struct primary_type;
+
+ template <typename I, typename C>
+ struct primary_type_helper
+ {
+ typedef typename primary_type<mln_delegatee(I)>::ret ret;
+ };
+
+ template <typename I>
+ struct primary_type_helper< I, mln::trait::image::category::primary >
+ {
+ typedef I ret;
+ };
+
+ template <typename I>
+ struct primary_type
+ {
+ typedef mln_trait_image_category(I) Cat;
+ typedef typename primary_type_helper<I, Cat>::ret ret;
+ };
+
+
+ // Routine.
+
+ } // end of namespace mln::internal
+
+
+
+ // Facade.
+
+ template <typename I>
+ inline
+ void primary(const Image<I>&)
+ {
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_ROUTINE_PRIMARY_HH
Index: mln/core/routine/all.hh
--- mln/core/routine/all.hh (revision 2743)
+++ mln/core/routine/all.hh (working copy)
@@ -36,10 +36,11 @@
*/
-// # include <mln/core/routine/clone.hh>
-// # include <mln/core/routine/exact.hh>
+# include <mln/core/routine/clone.hh>
+# include <mln/core/routine/exact.hh>
# include <mln/core/routine/extend.hh>
-// # include <mln/core/routine/initialize.hh>
+# include <mln/core/routine/initialize.hh>
+# include <mln/core/routine/primary.hh>
#endif // ! MLN_CORE_ROUTINE_ALL_HH
Index: mln/core/concept/window.hh
--- mln/core/concept/window.hh (revision 2743)
+++ mln/core/concept/window.hh (working copy)
@@ -34,6 +34,9 @@
* \todo Operator== should test if the cmp is possible.
*
* \todo Add an is_valid() method.
+ *
+ * \todo The is_centered() method could also exist when the window is
+ * not regular...
*/
# include <mln/core/concept/object.hh>
Index: mln/linear/convolve.hh
--- mln/linear/convolve.hh (revision 2743)
+++ mln/linear/convolve.hh (working copy)
@@ -31,6 +31,8 @@
/*! \file mln/linear/convolve.hh
*
* \brief Convolution.
+ *
+ * \todo Introduce an accumulator.
*/
# include <mln/core/concept/image.hh>
@@ -56,107 +58,90 @@
*
* \pre output.domain = input.domain
*/
- template <typename I, typename W, typename O>
- void convolve(const Image<I>& input, const Weighted_Window<W>& w_win,
- Image<O>& output);
+ template <typename I, typename W>
+ mln_concrete(I)
+ convolve(const Image<I>& input, const Weighted_Window<W>& w_win);
+
# ifndef MLN_INCLUDE_ONLY
- namespace impl
+ // Tests.
+
+ namespace internal
+ {
+
+ template <typename I, typename W>
+ void
+ convolve_tests(const Image<I>& input,
+ const Weighted_Window<W>& w_win)
{
- /* FIXME: We must clean up the interface of
- mln::linear::impl::convolve_:
+ mln_precondition(exact(input).has_data());
+ // mln_precondition(exact(w_win).is_valid());
+ }
- - either allow certain patterns of speed traits (e.g.,
- any/any, fastest/fastest, fastest/any, etc.). In this
- case, the generic version should abort at compile time;
+ } // end of namespace mln::linear::internal
- - or accept all combinations (which is the current case), and
- default to the slowest one (presumably any/any).
- */
- // Fwd decl.
- template <typename I, typename W, typename O>
- inline
- void convolve_(const I& input,
- const Weighted_Window<W>& w_win_,
- O& output);
-
- /// Default version, delegating to the generic version.
- template <typename Speed_I, typename I, typename W,
- typename Speed_O, typename O>
- inline
- void convolve_(Speed_I, const I& input,
- const Weighted_Window<W>& w_win_,
- Speed_O, O& output)
- {
- /* Don't delegate using such a call:
-
- \code
- impl::convolve_(trait::image::speed::any(), input,
- w_win_,
- trait::image::speed::any(), output);
- \endcode
-
- since it would end up with infinite recursion. The reason
- is that the compiler would select this function (in which
- you read this very comment), instead of the next one (with
- input and output speed traits set to `any'), to resolve the
- call. This is because C++ overloading rules favor the
- generic function over the more specialized one. And we
- cannot use explicit partial specialization, since it just
- doesn't exist for functions.
-
- Hence the chosen solution: create and call another
- overloading for mln::linear::impl::convolve_, with no
- unnatural selection behavior. */
- impl::convolve_(input, w_win_, output);
- }
-
- template <typename I, typename W, typename O>
- inline
- void convolve_(trait::image::speed::any, const I& input,
- const Weighted_Window<W>& w_win_,
- trait::image::speed::any, O& output)
- {
- // Delegate the call to the generic version.
- impl::convolve_(input, w_win_, output);
- }
-
- /// A factored implementation of the most generic version of
- /// mln::linear::impl::convolve_.
- template <typename I, typename W, typename O>
- inline
- void convolve_(const I& input,
- const Weighted_Window<W>& w_win_,
- O& output)
+ // Implementation.
+
+ namespace impl
+ {
+
+ namespace generic
{
+
+ template <typename I, typename W>
+ mln_concrete(I)
+ convolve(const Image<I>& input_,
+ const Weighted_Window<W>& w_win_)
+ {
+ trace::entering("linear::impl::generic::convolve");
+
+ const I& input = exact(input_);
const W& w_win = exact(w_win_);
+ internal::convolve_tests(input, w_win);
+
+ // extension::adjust_duplicate(input, w_win);
+
+ typedef mln_concrete(I) O;
+ O output;
+ initialize(output, input);
mln_piter(I) p(input.domain());
mln_qiter(W) q(w_win, p);
for_all(p)
{
- mln_value(O) v = 0;
+ mln_value(O) v = literal::zero;
for_all(q) if (input.has(q))
v += input(q) * q.w();
output(p) = v;
}
+
+ trace::exiting("linear::impl::generic::convolve");
+ return output;
}
- template <typename I, typename W, typename O>
- inline
- void convolve_(trait::image::speed::fastest, const I& input,
- const Weighted_Window<W>& w_win_,
- trait::image::speed::fastest, O& output)
+ } // end of namespace mln::linear::impl::generic
+
+
+ template <typename I, typename W>
+ mln_concrete(I)
+ convolve_fastest(const Image<I>& input_,
+ const Weighted_Window<W>& w_win_)
{
+ trace::entering("linear::impl::convolve_fastest");
+
+ const I& input = exact(input_);
const W& w_win = exact(w_win_);
+ internal::convolve_tests(input, w_win);
- border::resize(input, w_win.delta());
- border::duplicate(input);
+ // extension::adjust_duplicate(input, w_win);
+ typedef mln_concrete(I) O;
+ O output;
+ initialize(output, input);
mln_pixter(O) p_out(output);
mln_pixter(const I) p(input);
@@ -164,28 +149,71 @@
for_all_2(p, p_out)
{
- mln_value(O) v = 0;
+ mln_value(O) v = literal::zero;
unsigned i = 0;
for_all(q)
v += w_win.w(i++) * q.val();
p_out.val() = v;
}
+
+ trace::exiting("linear::impl::convolve_fastest");
+ return output;
}
} // end of namespace mln::linear::impl
+ // Dispatch.
+
+ namespace internal
+ {
+
+ template <typename I, typename W>
+ mln_concrete(I)
+ convolve_dispatch(trait::image::speed::any,
+ const Image<I>& input,
+ const Weighted_Window<W>& w_win)
+ {
+ return impl::generic::convolve(input, w_win);
+ }
+
+ template <typename I, typename W>
+ mln_concrete(I)
+ convolve_dispatch(trait::image::speed::fastest,
+ const Image<I>& input,
+ const Weighted_Window<W>& w_win)
+ {
+ return impl::convolve_fastest(input, w_win);
+ }
+
+ template <typename I, typename W>
+ mln_concrete(I)
+ convolve_dispatch(const Image<I>& input,
+ const Weighted_Window<W>& w_win)
+ {
+ return convolve_dispatch(mln_trait_image_speed(I)(),
+ input, w_win);
+ }
+
+ } // end of namespace mln::linear::internal
+
+
// Facade.
- template <typename I, typename W, typename O>
- inline
- void convolve(const Image<I>& input, const Weighted_Window<W>& w_win,
- Image<O>& output)
- {
- mln_precondition(exact(output).domain() == exact(input).domain());
- impl::convolve_(mln_trait_image_speed(I)(), exact(input),
- exact(w_win),
- mln_trait_image_speed(O)(), exact(output));
+ template <typename I, typename W>
+ mln_concrete(I)
+ convolve(const Image<I>& input, const Weighted_Window<W>& w_win)
+ {
+ trace::entering("linear::convolve");
+
+ internal::convolve_tests(input, w_win);
+
+ mln_concrete(I) output;
+ output = internal::convolve_dispatch(mln_trait_image_speed(I)(),
+ input, w_win);
+
+ trace::exiting("linear::convolve");
+ return output;
}
# endif // ! MLN_INCLUDE_ONLY
Index: mln/morpho/erosion.hh
--- mln/morpho/erosion.hh (revision 2743)
+++ mln/morpho/erosion.hh (working copy)
@@ -52,6 +52,25 @@
# ifndef MLN_INCLUDE_ONLY
+
+ namespace internal
+ {
+
+ template <typename I, typename W>
+ inline
+ void
+ erosion_tests(const Image<I>& input_, const Window<W>& win_)
+ {
+ const I& input = exact(input_);
+ const W& win = exact(win_);
+
+ mln_precondition(exact(input).has_data());
+ mln_precondition(! exact(win).is_empty());
+ }
+
+ } // end of mln::morpho::internal
+
+
namespace impl
{
@@ -69,6 +88,7 @@
const I& input = exact(input_);
const W& win = exact(win_);
+ internal::erosion_tests(input, win);
extension::adjust_fill(input, win, mln_max(mln_value(I)));
@@ -139,6 +159,7 @@
mln_precondition(exact(input).has_data());
mln_precondition(! exact(win).is_empty());
+ internal::erosion_tests(input, win);
mln_concrete(I) output = internal::erosion_dispatch(input, win);
if (exact(win).is_centered())
1
0
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Ugo Jardonnet <jardonnet(a)lrde.epita.fr>
Fix wrong include.
* mln/core/site_set/p_graph.hh,
* mln/core/image/graph_image.hh,
* mln/display/remove.hh,
* mln/display/save.hh,
* mln/display/show.hh,
* mln/util/greater_point.hh: Include image/image_if.hh instead
of image_if_value.hh.
core/image/graph_image.hh | 2 +-
core/site_set/p_graph.hh | 1 -
display/remove.hh | 2 +-
display/save.hh | 2 +-
display/show.hh | 2 +-
util/greater_point.hh | 2 +-
6 files changed, 5 insertions(+), 6 deletions(-)
Index: mln/core/site_set/p_graph.hh
--- mln/core/site_set/p_graph.hh (revision 2742)
+++ mln/core/site_set/p_graph.hh (working copy)
@@ -35,7 +35,6 @@
# include <mln/util/graph.hh>
# include <mln/util/tracked_ptr.hh>
-# include <mln/core/image/graph_psite.hh>
# include <mln/core/site_set/p_graph_piter.hh>
/* FIXME: This class shares a lot with p_line_graph. Factor as much
Index: mln/core/image/graph_image.hh
--- mln/core/image/graph_image.hh (revision 2742)
+++ mln/core/image/graph_image.hh (working copy)
@@ -38,7 +38,7 @@
# include <mln/core/internal/image_primary.hh>
# include <mln/algebra/vec.hh>
# include <mln/core/site_set/p_graph.hh>
-# include <mln/core/image/graph_psite.hh>
+# include <mln/core/image/bgraph_psite.hh>
# include <mln/value/set.hh>
/* FIXME: This class shares a lot with line_graph_image. Factor as
Index: mln/display/remove.hh
--- mln/display/remove.hh (revision 2742)
+++ mln/display/remove.hh (working copy)
@@ -35,7 +35,7 @@
*/
# include <mln/trait/image_from_grid.hh>
-# include <mln/core/image_if_value.hh>
+# include <mln/core/image/image_if.hh>
# include <mln/core/image/image2d.hh>
# include <mln/display/save.hh>
Index: mln/display/save.hh
--- mln/display/save.hh (revision 2742)
+++ mln/display/save.hh (working copy)
@@ -35,7 +35,7 @@
*/
# include <mln/trait/image_from_grid.hh>
-# include <mln/core/image_if_value.hh>
+# include <mln/core/image/image_if.hh>
# include <mln/core/image/image2d.hh>
# include <mln/value/rgb8.hh>
# include <mln/level/fill.hh>
Index: mln/display/show.hh
--- mln/display/show.hh (revision 2742)
+++ mln/display/show.hh (working copy)
@@ -35,7 +35,7 @@
*/
# include <mln/trait/image_from_grid.hh>
-# include <mln/core/image_if_value.hh>
+# include <mln/core/image/image_if.hh>
# include <mln/core/image/image2d.hh>
# include <mln/display/save.hh>
Index: mln/util/greater_point.hh
--- mln/util/greater_point.hh (revision 2742)
+++ mln/util/greater_point.hh (working copy)
@@ -1,4 +1,4 @@
-:/ Copyright (C) 2005, 2008 EPITA Research and Development Laboratory
(LRDE)
+// Copyright (C) 2005, 2008 EPITA Research and Development Laboratory
(LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
1
0
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Ugo Jardonnet <jardonnet(a)lrde.epita.fr>
Fix wrong include.
* mln/core/site_set/p_graph.hh,
* mln/core/image/graph_image.hh,
* mln/display/remove.hh,
* mln/display/save.hh,
* mln/display/show.hh,
* mln/util/greater_point.hh: Include image/image_if.hh instead
of image_if_value.hh.
core/image/graph_image.hh | 2 +-
core/site_set/p_graph.hh | 1 -
display/remove.hh | 2 +-
display/save.hh | 2 +-
display/show.hh | 2 +-
util/greater_point.hh | 2 +-
6 files changed, 5 insertions(+), 6 deletions(-)
Index: mln/core/site_set/p_graph.hh
--- mln/core/site_set/p_graph.hh (revision 2742)
+++ mln/core/site_set/p_graph.hh (working copy)
@@ -35,7 +35,6 @@
# include <mln/util/graph.hh>
# include <mln/util/tracked_ptr.hh>
-# include <mln/core/image/graph_psite.hh>
# include <mln/core/site_set/p_graph_piter.hh>
/* FIXME: This class shares a lot with p_line_graph. Factor as much
Index: mln/core/image/graph_image.hh
--- mln/core/image/graph_image.hh (revision 2742)
+++ mln/core/image/graph_image.hh (working copy)
@@ -38,7 +38,7 @@
# include <mln/core/internal/image_primary.hh>
# include <mln/algebra/vec.hh>
# include <mln/core/site_set/p_graph.hh>
-# include <mln/core/image/graph_psite.hh>
+# include <mln/core/image/bgraph_psite.hh>
# include <mln/value/set.hh>
/* FIXME: This class shares a lot with line_graph_image. Factor as
Index: mln/display/remove.hh
--- mln/display/remove.hh (revision 2742)
+++ mln/display/remove.hh (working copy)
@@ -35,7 +35,7 @@
*/
# include <mln/trait/image_from_grid.hh>
-# include <mln/core/image_if_value.hh>
+# include <mln/core/image/image_if.hh>
# include <mln/core/image/image2d.hh>
# include <mln/display/save.hh>
Index: mln/display/save.hh
--- mln/display/save.hh (revision 2742)
+++ mln/display/save.hh (working copy)
@@ -35,7 +35,7 @@
*/
# include <mln/trait/image_from_grid.hh>
-# include <mln/core/image_if_value.hh>
+# include <mln/core/image/image_if.hh>
# include <mln/core/image/image2d.hh>
# include <mln/value/rgb8.hh>
# include <mln/level/fill.hh>
Index: mln/display/show.hh
--- mln/display/show.hh (revision 2742)
+++ mln/display/show.hh (working copy)
@@ -35,7 +35,7 @@
*/
# include <mln/trait/image_from_grid.hh>
-# include <mln/core/image_if_value.hh>
+# include <mln/core/image/image_if.hh>
# include <mln/core/image/image2d.hh>
# include <mln/display/save.hh>
Index: mln/util/greater_point.hh
--- mln/util/greater_point.hh (revision 2742)
+++ mln/util/greater_point.hh (working copy)
@@ -1,4 +1,4 @@
-:/ Copyright (C) 2005, 2008 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2005, 2008 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
1
0
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr>
Add majority accu.
* mln/accu/maj_h.hh: Add majority accumulator.
* mln/accu/histo.hh: Remove bad use of size_t.
* mln/accu/mean.hh: Temporary fix.
* mln/fun/x2x/rotation.hh: Fix matrix parameters.
accu/histo.hh | 24 ++---
accu/maj_h.hh | 213 ++++++++++++++++++++++++++++++++++++++++++++++++++++
accu/mean.hh | 9 ++
fun/x2x/rotation.hh | 2
4 files changed, 235 insertions(+), 13 deletions(-)
Index: mln/accu/histo.hh
--- mln/accu/histo.hh (revision 2740)
+++ mln/accu/histo.hh (working copy)
@@ -56,7 +56,7 @@
*/
template <typename V>
struct histo :
- public mln::accu::internal::base<const std::vector<std::size_t>& ,
+ public mln::accu::internal::base<const std::vector<unsigned>& ,
histo<V> >
{
histo();
@@ -70,16 +70,16 @@
void untake(const argument& t);
void init();
- std::size_t operator()(const argument& t) const;
- std::size_t operator[](unsigned i) const;
+ unsigned operator()(const argument& t) const;
+ unsigned operator[](unsigned i) const;
unsigned nvalues() const;
- std::size_t sum() const;
+ unsigned sum() const;
/// \}
/// Get the value of the accumulator.
/// \{
- const std::vector<std::size_t>& vect() const;
- const std::vector<std::size_t>& to_result() const;
+ const std::vector<unsigned>& vect() const;
+ const std::vector<unsigned>& to_result() const;
/// \}
const value::set<V>& vset() const;
@@ -91,7 +91,7 @@
protected:
mln::histo::data<V> h_;
- std::size_t sum_;
+ unsigned sum_;
};
template <typename V>
@@ -165,7 +165,7 @@
template <typename V>
inline
- std::size_t
+ unsigned
histo<V>::operator()(const argument& t) const
{
return h_[h_.vset().index_of(t)];
@@ -173,7 +173,7 @@
template <typename V>
inline
- std::size_t
+ unsigned
histo<V>::operator[](unsigned i) const
{
mln_precondition(i < h_.vset().nvalues());
@@ -190,7 +190,7 @@
template <typename V>
inline
- std::size_t
+ unsigned
histo<V>::sum() const
{
return sum_;
@@ -198,7 +198,7 @@
template <typename V>
inline
- const std::vector<std::size_t>&
+ const std::vector<unsigned>&
histo<V>::vect() const
{
return h_.vect();
@@ -206,7 +206,7 @@
template <typename V>
inline
- const std::vector<std::size_t>&
+ const std::vector<unsigned>&
histo<V>::to_result() const
{
return this->vect();
Index: mln/accu/maj_h.hh
--- mln/accu/maj_h.hh (revision 0)
+++ mln/accu/maj_h.hh (revision 0)
@@ -0,0 +1,213 @@
+// Copyright (C) 2007, 2008 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, 51 Franklin Street, Fifth Floor,
+// 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 MLN_ACCU_MAJ_H_HH
+# define MLN_ACCU_MAJ_H_HH
+
+/*! \file mln/accu/maj_h.hh
+ *
+ * \brief Define an accumulator that computes a maj_h.
+ */
+
+# include <mln/core/concept/meta_accumulator.hh>
+# include <mln/accu/internal/base.hh>
+# include <mln/trait/value_.hh>
+# include <mln/util/pix.hh>
+# include <mln/accu/histo.hh>
+# include <vector>
+
+
+namespace mln
+{
+
+ namespace accu
+ {
+
+
+ /*! \brief Generic maj_h accumulator class.
+ *
+ * The parameter \c T is the type of values.
+ */
+ template <typename T>
+ struct maj_h : public mln::accu::internal::base< const T& , maj_h<T> >
+ {
+ typedef T argument;
+
+ maj_h();
+
+ /// Manipulators.
+ /// \{
+ void init();
+ void take(const argument& t);
+ void untake(const argument& t);
+ void take(const maj_h<T>& other);
+ /// \}
+
+ /// Get the value of the accumulator.
+ const T& to_result() const;
+
+ //operator T () const;
+
+ /// Check whether this accu is able to return a result.
+ /// Always true here.
+ bool is_valid() const;
+
+ void update_() const;
+
+ mutable bool valid_;
+
+ const accu::histo<T>& histo() const;
+
+ protected:
+
+ mutable argument t_;
+ mutable accu::histo<T> h_;
+ };
+
+
+ template <typename I> struct maj_h< util::pix<I> >;
+
+
+ namespace meta
+ {
+
+ /// Meta accumulator for maj_h.
+
+ struct maj_h : public Meta_Accumulator< maj_h >
+ {
+ template <typename T>
+ struct with
+ {
+ typedef accu::maj_h<T> ret;
+ };
+ };
+
+ } // end of namespace mln::accu::meta
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename T>
+ inline
+ maj_h<T>::maj_h()
+ {
+ init();
+ valid_ = true;
+ }
+
+ template <typename T>
+ inline
+ void
+ maj_h<T>::init()
+ {
+ h_.init();
+ }
+
+ template <typename T>
+ inline
+ void
+ maj_h<T>::take(const argument& t)
+ {
+ h_.take(t);
+
+ //update return value
+ if (h_(t) > h_(t_))
+ t_ = t;
+ }
+
+ template <typename T>
+ inline
+ void
+ maj_h<T>::untake(const argument& t)
+ {
+ h_.untake(t);
+
+ if (valid_)
+ valid_ = false;
+ }
+
+ template <typename T>
+ inline
+ void
+ maj_h<T>::take(const maj_h<T>& other)
+ {
+ h_.take(other.h_);
+
+ //FIXME: t_ is wrong then
+ }
+
+ template <typename T>
+ inline
+ void
+ maj_h<T>::update_() const
+ {
+ const std::vector<unsigned>& v = h_.vect();
+
+ for(unsigned i = 0; i != v.size(); i++)
+ {
+ // if nb referents of occurrence i > nb referents of t_
+ if (v[i] > h_(t_))
+ t_ = h_.vset()[i]; // t_ <- current
+ }
+ valid_ = true;
+ }
+
+ template <typename T>
+ inline
+ const T&
+ maj_h<T>::to_result() const
+ {
+ if (not valid_)
+ update_();
+ return t_;
+ }
+
+ template <typename T>
+ inline
+ bool
+ maj_h<T>::is_valid() const
+ {
+ return true;
+ }
+
+ template <typename V>
+ inline
+ const accu::histo<V>&
+ maj_h<V>::histo() const
+ {
+ return h_;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::accu
+
+} // end of namespace mln
+
+
+#endif // ! MLN_ACCU_MAJ_H _HH
Index: mln/accu/mean.hh
--- mln/accu/mean.hh (revision 2740)
+++ mln/accu/mean.hh (working copy)
@@ -61,6 +61,7 @@
struct mean : public mln::accu::internal::base< M , mean<T,S,M> >
{
typedef T argument;
+ typedef M result;
mean();
@@ -73,6 +74,7 @@
/// Get the value of the accumulator.
M to_result() const;
+ operator M () const;
/// Check whether this accu is able to return a result.
/// Always true here.
@@ -153,6 +155,13 @@
template <typename T, typename S, typename M>
inline
+ mean<T,S,M>::operator M() const
+ {
+ return M(sum_.to_result() / count_.to_result());
+ }
+
+ template <typename T, typename S, typename M>
+ inline
bool
mean<T,S,M>::is_valid() const
{
Index: mln/fun/x2x/rotation.hh
--- mln/fun/x2x/rotation.hh (revision 2740)
+++ mln/fun/x2x/rotation.hh (working copy)
@@ -189,7 +189,7 @@
xy + zw, 1.f - x2 - z2, yz - xw, 0,
xz - yw, yz + xw, 1.f - x2 - y2, 0,
0, 0, 0, 1};
- this->m_(make::mat<4,4,16,float>(t));
+ this->m_(make::mat<4,4>(t));
}
template <unsigned n, typename C>
1
0
30 Oct '08
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena/sandbox
Index: ChangeLog
from Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr>
INIM: Classif: Make use of maj_h. Fix Makefile.
* classif/proj.hh: Make use of majority.
* classif/Makefile: Proper dependencies.
Makefile | 21 ++++++++++++++++++---
proj.hh | 10 ++++++----
2 files changed, 24 insertions(+), 7 deletions(-)
Index: classif/proj.hh
--- classif/proj.hh (revision 2739)
+++ classif/proj.hh (working copy)
@@ -32,7 +32,7 @@
#include <mln/io/pgm/save.hh>
#include <mln/level/paste.hh>
#include <mln/accu/mean.hh>
-#include <mln/accu/max.hh>
+#include <mln/accu/maj_h.hh>
#include <mln/literal/white.hh>
namespace mln
@@ -59,11 +59,13 @@
{
//accu::mean<unsigned, unsigned long, value::int_u8> mean_accu;
- accu::max<value::int_u8> max_1;//FIXME: use majoritaire accu
+ accu::maj_h<value::int_u8> max_1;
image2d<value::int_u8> hproj = proj(histo, max_1);
- accu::max<U> max_2;//FIXME: use majoritaire accu
- image2d<U> proj_class = proj(ws, max_2);
+ accu::maj_h<value::int_u8> max_2;
+ image2d<value::int_u8> proj_class = proj(ws, max_2);
+
+ //std::cout << histo;
image2d<value::rgb8> out(proj_class.domain());
Index: classif/Makefile
--- classif/Makefile (revision 2739)
+++ classif/Makefile (working copy)
@@ -12,7 +12,7 @@
# V2
-V2_INCLUDES=-I../.. -I../garrigues/fllt
+V2_INCLUDES=-I../..
V2_SRC=v2.cc max_tree.hh
V2=v2
V2_DBG=v2_dbg
@@ -32,11 +32,11 @@
g++ $(V2_INCLUDES) -O1 -DNDEBUG $(V2_SRC) -o $(V2)
-$(V2_DBG): $(V2_SRC)
+$(V2_DBG): $(V2_SRC) .dep_v2
g++ $(V2_INCLUDES) -O0 -g3 -ggdb3 $(V2_SRC) -o $(V2_DBG)
-.PHONY:clean check check-debug valgrind
+.PHONY:clean check check-debug valgrind .dep_iccvg .dep_v2
clean:
rm -f $(ICCVG)
@@ -44,6 +44,7 @@
rm -f $(V2)
rm -f $(V2_DBG)
rm -f *.log
+ rm -f .dep_iccvg .dep_v2
check-debug: $(ICCVG_DBG)
./iccvg_dbg $(IMG) $(DIV) $(LAMBDA) $(LOG)
@@ -70,3 +71,17 @@
v2-gdb: $(V2_DBG)
echo "run ../../img/lena.ppm $(DIV) $(LAMBDA) $(LOG)" > gdb.cmd
gdb $(V2_DBG) -x gdb.cmd
+
+
+.dep_iccvg:
+ g++ $(ICCVG_INCLUDES) -MM iccvg04.cc > $@
+ @sed -ir s/iccvg04.cc// .dep_iccvg
+ @sed -ir s/iccvg04.o/iccvg/ .dep_iccvg
+
+.dep_v2:
+ g++ $(V2_INCLUDES) -MM v2.cc > $@
+ @sed -ir s/v2.cc// .dep_v2
+ @sed -ir s/v2.o/v2/ .dep_v2
+
+-include .dep_iccvg
+-include .dep_v2
\ No newline at end of file
1
0
30 Oct '08
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add a generic discrete distance transform.
* milena/mln/transform: New.
* milena/mln/transform/distance.hh: New.
* milena/tests/transform: New directory.
* milena/tests/transform/Makefile.am: New.
* milena/tests/transform/distance.cc: New.
* milena/sandbox/geraud/skel.cc: Layout.
* milena/sandbox/geraud/dmap.cc: Update.
Slight change in w_window.
* milena/mln/core/w_window.hh (from_to): Prepare new overload.
For that, add some new meta-code:
* milena/mln/metal/math/root.hh: New.
* milena/mln/metal/math/all.hh: Update.
* milena/mln/metal/math/sqrt.hh (todo): New.
* milena/tests/metal/math/root.cc: New.
* milena/tests/metal/math/pow.cc: Remove echo.
* milena/tests/metal/math/Makefile.am: Update.
* milena/tests/morpho/Makefile.am (SUBDIRS): Fix missing.
mln/core/w_window.hh | 17 +++
mln/metal/math/all.hh | 3
mln/metal/math/root.hh | 71 +++++----------
mln/metal/math/sqrt.hh | 2
mln/transform/distance.hh | 197 +++++++++++++++++++++++++++++++++++++++++++
sandbox/geraud/dmap.cc | 33 +++----
sandbox/geraud/skel.cc | 4
tests/metal/math/Makefile.am | 4
tests/metal/math/pow.cc | 5 -
tests/metal/math/root.cc | 15 +--
tests/morpho/Makefile.am | 2
tests/transform/Makefile.am | 10 ++
tests/transform/distance.cc | 61 +++++++++++++
13 files changed, 349 insertions(+), 75 deletions(-)
Index: milena/tests/metal/math/root.cc
--- milena/tests/metal/math/root.cc (revision 2732)
+++ milena/tests/metal/math/root.cc (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 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
@@ -25,23 +25,20 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/metal/math/pow.cc
+/*! \file tests/metal/math/root.cc
*
- * \brief Test on mln::metal::math::pow.
+ * \brief Test on mln::metal::math::root.
*/
#include <iostream>
#include <mln/core/contract.hh>
-#include <mln/metal/math/pow.hh>
+#include <mln/metal/math/root.hh>
int main()
{
using namespace mln;
- using namespace mln::metal;
- int res = metal::math::pow_int<2,3>::value;
- mln_assertion(res == 8);
-
- std::cout << metal::math::pow< int_<2>, int_<3> >::ret().name() << std::endl;
+ int res = metal::math::root<3,8>::value;
+ mln_assertion(res == 2);
}
Index: milena/tests/metal/math/pow.cc
--- milena/tests/metal/math/pow.cc (revision 2738)
+++ milena/tests/metal/math/pow.cc (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 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
@@ -43,5 +43,6 @@
int res = metal::math::pow_int<2,3>::value;
mln_assertion(res == 8);
- std::cout << metal::math::pow< int_<2>, int_<3> >::ret().name() << std::endl;
+ std::string s = metal::math::pow< int_<2>, int_<3> >::ret().name();
+ mln_assertion(s == "metal::int_<8>");
}
Index: milena/tests/metal/math/Makefile.am
--- milena/tests/metal/math/Makefile.am (revision 2738)
+++ milena/tests/metal/math/Makefile.am (working copy)
@@ -3,8 +3,10 @@
include $(top_srcdir)/milena/tests/tests.mk
check_PROGRAMS = \
- pow
+ pow \
+ root
pow_SOURCES = pow.cc
+root_SOURCES = root.cc
TESTS = $(check_PROGRAMS)
Index: milena/tests/transform/Makefile.am
--- milena/tests/transform/Makefile.am (revision 0)
+++ milena/tests/transform/Makefile.am (revision 0)
@@ -0,0 +1,10 @@
+## Process this file through Automake to create Makefile.in -*- Makefile -*-
+
+include $(top_srcdir)/milena/tests/tests.mk
+
+check_PROGRAMS = \
+ distance
+
+distance_SOURCES = distance.cc
+
+TESTS = $(check_PROGRAMS)
Index: milena/tests/transform/distance.cc
--- milena/tests/transform/distance.cc (revision 0)
+++ milena/tests/transform/distance.cc (revision 0)
@@ -0,0 +1,61 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// 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, 51 Franklin Street, Fifth Floor,
+// 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.
+
+/*! \file tests/transform/distance.cc
+ *
+ * \brief Test on mln::transform::distance.
+ */
+
+#include <mln/core/image/image2d.hh>
+#include <mln/core/alias/neighb2d.hh>
+#include <mln/make/w_window2d_int.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/level/fill.hh>
+#include <mln/debug/println.hh>
+
+#include <mln/transform/distance.hh>
+
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+
+ image2d<bool> input(9, 9);
+ level::fill(input, false);
+ input.at(4, 4) = true;
+
+ int vals[] = { 0, 9, 0, 9, 0,
+ 9, 6, 4, 6, 9,
+ 0, 4, 0, 4, 0,
+ 9, 6, 4, 6, 9,
+ 0, 9, 0, 9, 0 };
+
+ image2d<int_u8> output = transform::distance(int_u8(), input,
+ c4(), make::w_window2d_int(vals));
+ debug::println(output);
+}
Index: milena/tests/morpho/Makefile.am
--- milena/tests/morpho/Makefile.am (revision 2738)
+++ milena/tests/morpho/Makefile.am (working copy)
@@ -2,6 +2,8 @@
include $(top_srcdir)/milena/tests/tests.mk
+SUBDIRS = elementary
+
check_PROGRAMS = \
artificial_line_graph_image_wst \
closing_area \
Index: milena/mln/core/w_window.hh
--- milena/mln/core/w_window.hh (revision 2738)
+++ milena/mln/core/w_window.hh (working copy)
@@ -148,6 +148,10 @@
void
from_to(const Image<I>& from, w_window<D,W>& to);
+ template <typename V, unsigned S, typename D, typename W>
+ void
+ from_to(const V (&values)[S], w_window<D,W>& to);
+
} // end of namespace mln::convert
@@ -339,6 +343,19 @@
to.insert(ima(p), convert::to<D>(p));
}
+// template <typename V, unsigned S, typename D, typename W>
+// void
+// from_to(const V (&values)[S], w_window<D,W>& to)
+// {
+// enum { d = D::dim,
+// s = mlc_root(d,S)::value / 2 };
+// metal::bool_<(mlc_pow_int(2 * s + 1, d) == S)>::check();
+// to.clear();
+// D dp;
+// dp.set_all(-s);
+// FIXME
+// }
+
} // end of namespace mln::convert
Index: milena/mln/metal/math/root.hh
--- milena/mln/metal/math/root.hh (revision 2732)
+++ milena/mln/metal/math/root.hh (working copy)
@@ -25,19 +25,20 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_METAL_MATH_SQRT_HH
-# define MLN_METAL_MATH_SQRT_HH
+#ifndef MLN_METAL_MATH_ROOT_HH
+# define MLN_METAL_MATH_ROOT_HH
-/*! \file mln/metal/math/sqrt.hh
+/*! \file mln/metal/math/root.hh
*
- * \brief Definition of the 'sqrt' static function.
+ * \brief Definition of the 'nth-root' static function.
+ *
+ * \todo Have consistent writing of math meta-routines.
*/
-# include <mln/metal/bool.hh>
-# include <mln/metal/int.hh>
+# include <mln/metal/math/pow.hh>
-# define mlc_sqrt_int(N) mln::metal::math::sqrt_int<( N )>::value
+# define mlc_root(N,X) mln::metal::math::root<( N ),( X )>
namespace mln
@@ -49,63 +50,43 @@
namespace math
{
- // sqrt_int<x>
-
namespace impl
{
- template <int n, int lo = 1, int hi = n>
- struct sqrt_int_
+ template <unsigned n, unsigned x,
+ unsigned lo = 1, unsigned hi = x>
+ struct root
{
enum {
mid = (lo + hi + 1) / 2,
- val_lo = sqrt_int_<n, lo, mid-1>::value,
- val_hi = sqrt_int_<n, mid, hi>::value
+ val_lo = root<n, x, lo, mid-1>::value,
+ val_hi = root<n, x, mid, hi>::value
};
- enum { value = n < mid * mid ? val_lo : val_hi };
+ enum { value = x < mlc_pow_int(mid, n) ? val_lo : val_hi };
};
- template<int n, int m>
- struct sqrt_int_<n, m, m>
- {
- enum { value = m };
- };
-
- // Entry.
-
- template <int n, bool b>
- struct sqrt_int_if_ : sqrt_int_<n>
- {
- enum { value_ = sqrt_int_<n>::value,
- reminder_ = n - value_ * value_ };
- // FIXME: Check that reminder_ == 0.
- };
-
- template <int n>
- struct sqrt_int_if_< n, false >
+ template<unsigned n, unsigned x, unsigned m>
+ struct root<n, x, m, m>
{
+ enum { value = m }; // Found.
};
} // end of namespace mln::metal::math::impl
- template <int n>
- struct sqrt_int : impl::sqrt_int_if_< n, (n >= 0) >
+ template <unsigned n, unsigned x>
+ struct root : bool_<(n != 0)>::check_t
{
+ enum { value = impl::root<n,x>::value,
+ reminder = x - mlc_pow_int(value, n) };
};
-
- // sqrt<N>
-
- template <typename N>
- struct sqrt;
-
- template <int n>
- struct sqrt< int_<n> >
+ template <unsigned n>
+ struct root<n, 0> : bool_<(n != 0)>::check_t
{
- typedef int_< sqrt_int<n>::value > ret;
+ enum { value = 0,
+ reminder = 0};
};
-
} // end of namespace mln::metal::math
} // end of namespace mln::metal
@@ -113,4 +94,4 @@
} // end of namespace mln
-#endif // ! MLN_METAL_MATH_SQRT_HH
+#endif // ! MLN_METAL_MATH_ROOT_HH
Index: milena/mln/metal/math/all.hh
--- milena/mln/metal/math/all.hh (revision 2738)
+++ milena/mln/metal/math/all.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 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
@@ -54,6 +54,7 @@
# include <mln/metal/math/pow.hh>
+# include <mln/metal/math/root.hh>
# include <mln/metal/math/sqrt.hh>
# include <mln/metal/math/max.hh>
// ...
Index: milena/mln/metal/math/sqrt.hh
--- milena/mln/metal/math/sqrt.hh (revision 2738)
+++ milena/mln/metal/math/sqrt.hh (working copy)
@@ -31,6 +31,8 @@
/*! \file mln/metal/math/sqrt.hh
*
* \brief Definition of the 'sqrt' static function.
+ *
+ * \todo Rely on nth-root.
*/
# include <mln/metal/bool.hh>
Index: milena/mln/transform/distance.hh
--- milena/mln/transform/distance.hh (revision 0)
+++ milena/mln/transform/distance.hh (revision 0)
@@ -0,0 +1,197 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// 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, 51 Franklin Street, Fifth Floor,
+// 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 MLN_TRANSFORM_DISTANCE_HH
+# define MLN_TRANSFORM_DISTANCE_HH
+
+/*! \file mln/transform/distance.hh
+ *
+ * \brief Discrete distance transform.
+ */
+
+# include <vector>
+# include <mln/core/concept/image.hh>
+# include <mln/core/concept/neighborhood.hh>
+# include <mln/core/concept/weighted_window.hh>
+# include <mln/level/fill.hh>
+# include <mln/accu/max.hh>
+
+
+
+namespace mln
+{
+
+ namespace transform
+ {
+
+ /*! Discrete distance transform.
+ *
+ * FIXME: doc.
+ */
+ template <typename D, typename I, typename N, typename W>
+ mln_ch_value(I, D)
+ distance(D, const Image<I>& input,
+ const Neighborhood<N>& nbh, const Weighted_Window<W>& w_win);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace impl
+ {
+
+ namespace generic
+ {
+
+ template <typename D, typename I, typename N, typename W>
+ mln_ch_value(I, D)
+ distance(D, const Image<I>& input_,
+ const Neighborhood<N>& nbh_, const Weighted_Window<W>& w_win_)
+ {
+ trace::entering("transform::impl::generic::distance");
+
+ const I& input = exact(input_);
+ const N& nbh = exact(nbh_);
+ const W& w_win = exact(w_win_);
+
+ mln_precondition(input.has_data());
+
+ const D Max = mln_max(D);
+
+ typedef mln_site(I) P;
+ typedef std::vector<P> bucket_t;
+
+ mln_ch_value(I, D) output;
+ initialize(output, input);
+ level::fill(output, Max);
+
+ // Modulus determination.
+ unsigned mod;
+ {
+ mln::accu::max<unsigned> accu;
+ P p;
+ mln_qiter(W) q(w_win, p);
+ for_all(q)
+ accu.take(q.w());
+ mod = accu.to_result() + 1;
+ }
+
+ std::vector<bucket_t> bucket;
+ bucket.resize(mod);
+ unsigned bucket_size = 0;
+
+ // Initialization.
+ {
+ mln_piter(I) p(input.domain());
+ mln_niter(N) n(nbh, p);
+ for_all(p)
+ if (input(p) == true)
+ {
+ output(p) = literal::zero;
+ for_all(n)
+ if (input.domain().has(n) && input(n) == false)
+ {
+ bucket[0].push_back(p);
+ ++bucket_size;
+ break;
+ }
+ }
+ }
+
+ // Propagation.
+ {
+ P p;
+ mln_qiter(W) q(w_win, p);
+
+ for (unsigned d = 0; bucket_size != 0; ++d)
+ {
+ bucket_t& bucket_d = bucket[d % mod];
+ for (unsigned i = 0; i < bucket_d.size(); ++i)
+ {
+ p = bucket_d[i];
+ if (output(p) < d)
+ continue;
+
+ for_all(q)
+ if (output.domain().has(q) && output(q) > d)
+ {
+ if (unsigned(Max - q.w()) < d) // Saturation => Stop!
+ {
+ // trace::warning...
+ trace::exiting("transform::impl::generic::distance");
+ return output;
+ }
+ unsigned d_ = d + q.w();
+
+ if (d_ < output(q))
+ {
+ output(q) = d_;
+ bucket[d_ % mod].push_back(q);
+ ++bucket_size;
+ }
+ }
+ }
+ bucket_size -= bucket_d.size();
+ bucket_d.clear();
+ }
+ }
+
+ trace::exiting("transform::impl::generic::distance");
+ return output;
+
+ }
+
+ } // end of namespace mln::transform::impl::generic
+
+ } // end of namespace mln::transform::impl
+
+
+ // Facade.
+
+ template <typename D, typename I, typename N, typename W>
+ inline
+ mln_ch_value(I, D)
+ distance(D, const Image<I>& input,
+ const Neighborhood<N>& nbh, const Weighted_Window<W>& w_win)
+ {
+ trace::entering("transform::distance");
+
+ // FIXME: tests.
+ mln_ch_value(I, D) output = impl::generic::distance(D(), input,
+ nbh, w_win);
+
+ trace::exiting("transform::distance");
+ return output;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::transform
+
+} // end of namespace mln
+
+
+#endif // ! MLN_TRANSFORM_DISTANCE_HH
Index: milena/sandbox/geraud/skel.cc
--- milena/sandbox/geraud/skel.cc (revision 2738)
+++ milena/sandbox/geraud/skel.cc (working copy)
@@ -12,7 +12,6 @@
# include <mln/debug/println.hh>
-
namespace mln
{
@@ -75,6 +74,9 @@
return output;
}
+*/
+
+
} // mln
Index: milena/sandbox/geraud/dmap.cc
--- milena/sandbox/geraud/dmap.cc (revision 2738)
+++ milena/sandbox/geraud/dmap.cc (working copy)
@@ -21,14 +21,14 @@
const W& win = exact(win_);
mln_precondition(input.has_data());
- typedef std::vector<mln_point(I)> bucket_t;
+ typedef std::vector<mln_site(I)> bucket_t;
// Initialization of distance.
mln_ch_value(I, unsigned) distance;
initialize(distance, input);
// Mod determination.
- mln_accu_with_(accu::max, unsigned) max;
+ accu::max<unsigned> max;
for (unsigned i = 0; i < win.size(); ++i)
max.take(win.w(i));
unsigned mod = unsigned(max) + 1;
@@ -59,7 +59,7 @@
// Propagation.
{
- mln_point(I) p;
+ mln_site(I) p;
mln_qiter(W) q(win, p);
for (unsigned d = 0; bucket_size != 0; ++d)
@@ -104,26 +104,27 @@
using namespace mln;
using value::int_u8;
- const unsigned n = 256;
+ const unsigned n = 9;
image2d<bool> ima(n, n);
level::fill(ima, false);
ima.at(n / 2, n / 2) = true;
- int ws[] = { 3, 2, 3,
- 2, 0, 2,
- 3, 2, 3 };
-
-// int ws[] = { 0, 9, 0, 9, 0,
-// 9, 6, 4, 6, 9,
-// 0, 4, 0, 4, 0,
-// 9, 6, 4, 6, 9,
-// 0, 9, 0, 9, 0 }; // coef = 4.1203
+// int ws[] = { 3, 2, 3,
+// 2, 0, 2,
+// 3, 2, 3 };
+
+ int ws[] = { 0, 9, 0, 9, 0,
+ 9, 6, 4, 6, 9,
+ 0, 4, 0, 4, 0,
+ 9, 6, 4, 6, 9,
+ 0, 9, 0, 9, 0 }; // coef = 4.1203
w_window2d_int win = make::w_window2d(ws);
image2d<unsigned> d = dmap(ima, win);
+ debug::println(d);
- image2d<int_u8> out(d.domain());
- level::stretch(d, out);
- io::pgm::save(out, "out.pgm");
+// image2d<int_u8> out;
+// level::stretch(d, out);
+// io::pgm::save(out, "out.pgm");
}
1
0
From: Maxime van Noppen <yabo(a)lrde.epita.fr>
To: transformers-patches(a)lrde.epita.fr, olena-patches(a)lrde.epita.fr
Subject: scool r123: Fix the way verbatim C++ is handled
URL: https://svn.lrde.epita.fr/svn/scool/branches/scool-ng
ChangeLog:
2008-10-30 Maxime van Noppen <yabo(a)lrde.epita.fr>
Fix the way verbatim C++ is handled.
* pp-cxx/CxxDecl.str: Handle the CxxProgram constructor.
* scl-syn/Lexical.sdf: Fix an ambiguity on layout.
* scl-syn/Statement.sdf: Add verbatim C++ as statements.
* scoolt/Expression.str: Don't un-double-quote strings.
* scoolt/Statement.str: Handle the CxxProgram constructor as a
declaration.
---
pp-cxx/CxxDecl.str | 3 +++
scl-syn/Lexical.sdf | 1 +
scl-syn/Statement.sdf | 4 ++++
scoolt/Expression.str | 3 ++-
scoolt/Statement.str | 7 ++++++-
5 files changed, 16 insertions(+), 2 deletions(-)
Index: branches/scool-ng/src/pp-cxx/CxxDecl.str
===================================================================
--- branches/scool-ng/src/pp-cxx/CxxDecl.str (revision 122)
+++ branches/scool-ng/src/pp-cxx/CxxDecl.str (revision 123)
@@ -57,6 +57,9 @@
CxxComment(txt) ->
H hs=1 [ "//" ~S(txt) ]
+ CxxTopLevelToAbox:
+ CxxProgram(c) -> S(c)
+
CxxBodyToAbox:
CxxPublic(b) -> V is=2 [ "public:" V [ ~*<map(CxxTopLevelToAbox)> b ] ]
Index: branches/scool-ng/src/scoolt/Expression.str
===================================================================
--- branches/scool-ng/src/scoolt/Expression.str (revision 122)
+++ branches/scool-ng/src/scoolt/Expression.str (revision 123)
@@ -25,7 +25,8 @@
<BaseExpressionToCxx> bexp => cxx_bexp
ExpressionToCxx:
- String(str) -> <un-double-quote> str
+ String(str) -> str
+ //String(str) -> <un-double-quote> str
ExpressionToCxx:
Sum(e1, e2) -> CxxSum(cxx_e1, cxx_e2)
Index: branches/scool-ng/src/scoolt/Statement.str
===================================================================
--- branches/scool-ng/src/scoolt/Statement.str (revision 122)
+++ branches/scool-ng/src/scoolt/Statement.str (revision 123)
@@ -2,6 +2,11 @@
imports libstratego-lib Cxx Scool Declaration
+rules
+
+ RawCxx:
+ Cxx(cxx_code) -> CxxProgram(cxx_code)
+
strategies
- StatementToCxx = DeclarationToCxx
+ StatementToCxx = DeclarationToCxx <+ RawCxx
Index: branches/scool-ng/src/scl-syn/Statement.sdf
===================================================================
--- branches/scool-ng/src/scl-syn/Statement.sdf (revision 122)
+++ branches/scool-ng/src/scl-syn/Statement.sdf (revision 123)
@@ -9,6 +9,10 @@
Declaration -> Statement
+ Cxx -> CxxStatement
+ CxxStatement -> Statement
+ CxxStatement -> FunctionStatement
+
Expression ";" -> FunctionStatement {cons("ExpressionStatement")}
SimpleDeclaration -> FunctionStatement
"->" Expression ";" -> FunctionStatement {cons("ReturnStatement")}
Index: branches/scool-ng/src/scl-syn/Lexical.sdf
===================================================================
--- branches/scool-ng/src/scl-syn/Lexical.sdf (revision 122)
+++ branches/scool-ng/src/scl-syn/Lexical.sdf (revision 123)
@@ -63,6 +63,7 @@
Id -/- [A-Za-z0-9\_]
Asterisk -/- [\/]
Slash -/- [\*]
+ RawCxx -/- [\ \t\n]
context-free restrictions
LAYOUT? -/- [\ \t\n]
1
0
From: Maxime van Noppen <yabo(a)lrde.epita.fr>
To: transformers-patches(a)lrde.epita.fr, olena-patches(a)lrde.epita.fr
Subject: scool r122: Add reference files for tests on functions
URL: https://svn.lrde.epita.fr/svn/scool/branches/scool-ng
ChangeLog:
2008-10-30 Maxime van Noppen <yabo(a)lrde.epita.fr>
Add reference files for tests on functions.
* function/c++_build/call_001.g++: New.
* function/c++_build/call_002.g++: New.
* function/c++_build/call_003.g++: New.
* function/c++_build/call_004.g++: New.
* function/c++_build/call_005.g++: New.
* function/c++_build/call_006.g++: New.
* function/c++_build/declaration_003.g++: New.
* function/c++_build/declaration_004.g++: New.
* function/c++_build/definition_002.g++: New.
* function/c++_ast/call_001.aterm,
* function/c++_ast/call_002.aterm,
* function/c++_ast/call_003.aterm,
* function/c++_ast/call_004.aterm,
* function/c++_ast/call_005.aterm,
* function/c++_ast/call_006.aterm,
* function/c++_ast/declaration_003.aterm,
* function/c++_ast/declaration_004.aterm,
* function/c++_ast/definition_002.aterm,
* function/c++_src/call_001.cc,
* function/c++_src/call_002.cc,
* function/c++_src/call_003.cc,
* function/c++_src/call_004.cc,
* function/c++_src/call_005.cc,
* function/c++_src/call_006.cc,
* function/c++_src/declaration_003.cc,
* function/c++_src/declaration_004.cc,
* function/c++_src/definition_002.cc,
* function/scool_ast/call_001.aterm,
* function/scool_ast/call_002.aterm,
* function/scool_ast/call_003.aterm,
* function/scool_ast/call_004.aterm,
* function/scool_ast/call_005.aterm,
* function/scool_ast/call_006.aterm,
* function/scool_ast/declaration_003.aterm,
* function/scool_ast/declaration_004.aterm,
* function/scool_ast/definition_002.aterm,
* function/scool_src/call_001.scl,
* function/scool_src/call_002.scl,
* function/scool_src/call_003.scl,
* function/scool_src/call_004.scl,
* function/scool_src/call_005.scl,
* function/scool_src/call_006.scl,
* function/scool_src/declaration_003.scl,
* function/scool_src/declaration_004.scl,
* function/scool_src/definition_002.scl: Here.
---
c++_ast/call_001.aterm | 2 +-
c++_ast/call_002.aterm | 2 +-
c++_ast/call_003.aterm | 2 +-
c++_ast/call_004.aterm | 2 +-
c++_ast/call_005.aterm | 2 +-
c++_ast/call_006.aterm | 2 +-
c++_ast/declaration_003.aterm | 2 +-
c++_ast/declaration_004.aterm | 2 +-
c++_ast/definition_002.aterm | 2 +-
c++_src/call_001.cc | 2 +-
c++_src/call_002.cc | 4 ++--
c++_src/call_003.cc | 8 ++++++--
c++_src/call_004.cc | 2 ++
c++_src/call_005.cc | 2 ++
c++_src/call_006.cc | 2 ++
c++_src/declaration_003.cc | 1 +
c++_src/declaration_004.cc | 1 +
c++_src/definition_002.cc | 2 +-
scool_ast/call_001.aterm | 2 +-
scool_ast/call_002.aterm | 2 +-
scool_ast/call_003.aterm | 2 +-
scool_ast/call_004.aterm | 2 +-
scool_ast/call_005.aterm | 2 +-
scool_ast/call_006.aterm | 2 +-
scool_ast/declaration_003.aterm | 2 +-
scool_ast/declaration_004.aterm | 2 +-
scool_ast/definition_002.aterm | 2 +-
scool_src/call_001.scl | 2 +-
scool_src/call_002.scl | 4 ++--
scool_src/call_003.scl | 10 ++++++++--
scool_src/call_004.scl | 2 ++
scool_src/call_005.scl | 2 ++
scool_src/call_006.scl | 2 ++
scool_src/declaration_003.scl | 2 ++
scool_src/declaration_004.scl | 2 ++
scool_src/definition_002.scl | 2 +-
36 files changed, 58 insertions(+), 30 deletions(-)
Index: branches/scool-ng/tests/function/c++_ast/declaration_004.aterm
===================================================================
--- branches/scool-ng/tests/function/c++_ast/declaration_004.aterm (revision 121)
+++ branches/scool-ng/tests/function/c++_ast/declaration_004.aterm (revision 122)
@@ -1 +1 @@
-CxxProgram([CxxFun([],CxxType("void"),CxxId("foo"),None,[]),CxxFun([],CxxType("float"),CxxId("foo"),None,[(CxxType("int"),CxxId("arg1"))]),CxxFun([],CxxType("char"),CxxId("foo"),None,[(CxxConstType(CxxRefType(CxxType("toto"))),CxxId("arg1")),(CxxRefType(CxxType("double")),CxxId("arg2"))])])
+CxxProgram([CxxClassDecl([],CxxId("toto"),[]),CxxFun([],CxxType("void"),CxxId("foo"),None,[]),CxxFun([],CxxType("float"),CxxId("foo"),None,[(CxxType("int"),CxxId("arg1"))]),CxxFun([],CxxType("char"),CxxId("foo"),None,[(CxxConstType(CxxRefType(CxxType("toto"))),CxxId("arg1")),(CxxRefType(CxxType("double")),CxxId("arg2"))])])
Index: branches/scool-ng/tests/function/c++_ast/definition_002.aterm
===================================================================
--- branches/scool-ng/tests/function/c++_ast/definition_002.aterm (revision 121)
+++ branches/scool-ng/tests/function/c++_ast/definition_002.aterm (revision 122)
@@ -1 +1 @@
-CxxProgram([CxxFun([],CxxType("void"),CxxId("answer"),[],None,[CxxDecl(CxxConstType(CxxType("int")),CxxId("i"))])])
+CxxProgram([CxxFun([],CxxType("void"),CxxId("answer"),[],None,[CxxDecl(CxxConstType(CxxType("int")),CxxId("i"),CxxInt("42"))])])
Index: branches/scool-ng/tests/function/c++_ast/call_001.aterm
===================================================================
--- branches/scool-ng/tests/function/c++_ast/call_001.aterm (revision 121)
+++ branches/scool-ng/tests/function/c++_ast/call_001.aterm (revision 122)
@@ -1 +1 @@
-CxxProgram([CxxFun([],CxxType("void"),CxxId("doit"),[],None,[CxxExpStm(CxxFunCall([],CxxId("foo"),[]))])])
+CxxProgram([CxxFun([],CxxType("void"),CxxId("doit"),[],None,[CxxExpStm(CxxFunCall([],CxxId("doit"),[]))])])
Index: branches/scool-ng/tests/function/c++_ast/call_002.aterm
===================================================================
--- branches/scool-ng/tests/function/c++_ast/call_002.aterm (revision 121)
+++ branches/scool-ng/tests/function/c++_ast/call_002.aterm (revision 122)
@@ -1 +1 @@
-CxxProgram([CxxFun([],CxxType("void"),CxxId("doit"),[],None,[CxxExpStm(CxxFunCall([],CxxId("foo"),[CxxInt("42")]))])])
+CxxProgram([CxxFun([],CxxType("void"),CxxId("doit"),[(CxxType("int"),CxxId("i"))],None,[CxxExpStm(CxxFunCall([],CxxId("doit"),[CxxInt("42")]))])])
Index: branches/scool-ng/tests/function/c++_ast/call_003.aterm
===================================================================
--- branches/scool-ng/tests/function/c++_ast/call_003.aterm (revision 121)
+++ branches/scool-ng/tests/function/c++_ast/call_003.aterm (revision 122)
@@ -1 +1 @@
-CxxProgram([CxxFun([],CxxType("void"),CxxId("doit"),[],None,[CxxExpStm(CxxFunCall([],CxxId("foo"),["bar",CxxInt("42")]))])])
+CxxProgram([CxxProgram("#include <string>\n\nusing std::string;\n"),CxxFun([],CxxType("void"),CxxId("doit"),[(CxxConstType(CxxRefType(CxxType("string"))),CxxId("s")),(CxxType("int"),CxxId("i"))],None,[CxxExpStm(CxxFunCall([],CxxId("doit"),["\"bar\"",CxxInt("42")]))])])
Index: branches/scool-ng/tests/function/c++_ast/call_004.aterm
===================================================================
--- branches/scool-ng/tests/function/c++_ast/call_004.aterm (revision 121)
+++ branches/scool-ng/tests/function/c++_ast/call_004.aterm (revision 122)
@@ -1 +1 @@
-CxxProgram([CxxFun([],CxxType("void"),CxxId("doit"),[],None,[CxxExpStm(CxxFunCall([CxxType("int")],CxxId("foo"),[]))])])
+CxxProgram([CxxFun([(CxxType("typename"),CxxId("T"))],CxxType("void"),CxxId("foo"),None,[]),CxxFun([],CxxType("void"),CxxId("doit"),[],None,[CxxExpStm(CxxFunCall([CxxType("int")],CxxId("foo"),[]))])])
Index: branches/scool-ng/tests/function/c++_ast/call_005.aterm
===================================================================
--- branches/scool-ng/tests/function/c++_ast/call_005.aterm (revision 121)
+++ branches/scool-ng/tests/function/c++_ast/call_005.aterm (revision 122)
@@ -1 +1 @@
-CxxProgram([CxxFun([],CxxType("void"),CxxId("doit"),[],None,[CxxExpStm(CxxFunCall([CxxInt("42")],CxxId("foo"),[]))])])
+CxxProgram([CxxFun([(CxxType("int"),CxxId("i"))],CxxType("void"),CxxId("foo"),None,[]),CxxFun([],CxxType("void"),CxxId("doit"),[],None,[CxxExpStm(CxxFunCall([CxxInt("42")],CxxId("foo"),[]))])])
Index: branches/scool-ng/tests/function/c++_ast/call_006.aterm
===================================================================
--- branches/scool-ng/tests/function/c++_ast/call_006.aterm (revision 121)
+++ branches/scool-ng/tests/function/c++_ast/call_006.aterm (revision 122)
@@ -1 +1 @@
-CxxProgram([CxxFun([],CxxType("void"),CxxId("doit"),[],None,[CxxExpStm(CxxFunCall([CxxType("int"),CxxInt("42")],CxxId("foo"),[CxxInt("42")]))])])
+CxxProgram([CxxFun([(CxxType("typename"),CxxId("T")),(CxxType("int"),CxxId("i"))],CxxType("void"),CxxId("foo"),None,[(CxxType("int"),CxxId("j"))]),CxxFun([],CxxType("void"),CxxId("doit"),[],None,[CxxExpStm(CxxFunCall([CxxType("int"),CxxInt("42")],CxxId("foo"),[CxxInt("42")]))])])
Index: branches/scool-ng/tests/function/c++_ast/declaration_003.aterm
===================================================================
--- branches/scool-ng/tests/function/c++_ast/declaration_003.aterm (revision 121)
+++ branches/scool-ng/tests/function/c++_ast/declaration_003.aterm (revision 122)
@@ -1 +1 @@
-CxxProgram([CxxFun([],CxxType("void"),CxxId("foo"),None,[(CxxType("int"),CxxId("a")),(CxxConstType(CxxRefType(CxxType("bar"))),CxxId("b"))])])
+CxxProgram([CxxClassDecl([],CxxId("bar"),[]),CxxFun([],CxxType("void"),CxxId("foo"),None,[(CxxType("int"),CxxId("a")),(CxxConstType(CxxRefType(CxxType("bar"))),CxxId("b"))])])
Index: branches/scool-ng/tests/function/c++_src/call_001.cc
===================================================================
--- branches/scool-ng/tests/function/c++_src/call_001.cc (revision 121)
+++ branches/scool-ng/tests/function/c++_src/call_001.cc (revision 122)
@@ -1,4 +1,4 @@
void doit()
{
- foo();
+ doit();
}
Index: branches/scool-ng/tests/function/c++_src/call_002.cc
===================================================================
--- branches/scool-ng/tests/function/c++_src/call_002.cc (revision 121)
+++ branches/scool-ng/tests/function/c++_src/call_002.cc (revision 122)
@@ -1,4 +1,4 @@
-void doit()
+void doit(int i)
{
- foo(42);
+ doit(42);
}
Index: branches/scool-ng/tests/function/c++_src/call_003.cc
===================================================================
--- branches/scool-ng/tests/function/c++_src/call_003.cc (revision 121)
+++ branches/scool-ng/tests/function/c++_src/call_003.cc (revision 122)
@@ -1,4 +1,8 @@
-void doit()
+#include <string>
+
+using std::string;
+
+void doit(const string& s, int i)
{
- foo(bar, 42);
+ doit("bar", 42);
}
Index: branches/scool-ng/tests/function/c++_src/call_004.cc
===================================================================
--- branches/scool-ng/tests/function/c++_src/call_004.cc (revision 121)
+++ branches/scool-ng/tests/function/c++_src/call_004.cc (revision 122)
@@ -1,3 +1,5 @@
+template < typename T >
+void foo();
void doit()
{
foo< int >();
Index: branches/scool-ng/tests/function/c++_src/call_005.cc
===================================================================
--- branches/scool-ng/tests/function/c++_src/call_005.cc (revision 121)
+++ branches/scool-ng/tests/function/c++_src/call_005.cc (revision 122)
@@ -1,3 +1,5 @@
+template < int i >
+void foo();
void doit()
{
foo< 42 >();
Index: branches/scool-ng/tests/function/c++_src/call_006.cc
===================================================================
--- branches/scool-ng/tests/function/c++_src/call_006.cc (revision 121)
+++ branches/scool-ng/tests/function/c++_src/call_006.cc (revision 122)
@@ -1,3 +1,5 @@
+template < typename T, int i >
+void foo(int j);
void doit()
{
foo< int, 42 >(42);
Index: branches/scool-ng/tests/function/c++_src/declaration_003.cc
===================================================================
--- branches/scool-ng/tests/function/c++_src/declaration_003.cc (revision 121)
+++ branches/scool-ng/tests/function/c++_src/declaration_003.cc (revision 122)
@@ -1 +1,2 @@
+class bar;
void foo(int a, const bar& b);
Index: branches/scool-ng/tests/function/c++_src/declaration_004.cc
===================================================================
--- branches/scool-ng/tests/function/c++_src/declaration_004.cc (revision 121)
+++ branches/scool-ng/tests/function/c++_src/declaration_004.cc (revision 122)
@@ -1,3 +1,4 @@
+class toto;
void foo();
float foo(int arg1);
char foo(const toto& arg1, double& arg2);
Index: branches/scool-ng/tests/function/c++_src/definition_002.cc
===================================================================
--- branches/scool-ng/tests/function/c++_src/definition_002.cc (revision 121)
+++ branches/scool-ng/tests/function/c++_src/definition_002.cc (revision 122)
@@ -1,4 +1,4 @@
void answer()
{
- const int i;
+ const int i = 42;
}
Index: branches/scool-ng/tests/function/scool_ast/declaration_004.aterm
===================================================================
--- branches/scool-ng/tests/function/scool_ast/declaration_004.aterm (revision 121)
+++ branches/scool-ng/tests/function/scool_ast/declaration_004.aterm (revision 122)
@@ -1 +1 @@
-Program([FunctionDeclaration(None,Identifier("foo"),FunctionType(None,ArgumentsDeclaration([]),SimpleType("void"))),FunctionDeclaration(None,Identifier("foo"),FunctionType(None,ArgumentsDeclaration([TypedId(Identifier("arg1"),SimpleType("int"))]),SimpleType("float"))),FunctionDeclaration(None,Identifier("foo"),FunctionType(None,ArgumentsDeclaration([TypedId(Identifier("arg1"),SimpleType("toto")),TypedId(Identifier("arg2"),ReferenceType(SimpleType("double")))]),SimpleType("char")))])
+Program([ClassDeclaration(Some("final"),Identifier("toto"),None),FunctionDeclaration(None,Identifier("foo"),FunctionType(None,ArgumentsDeclaration([]),SimpleType("void"))),FunctionDeclaration(None,Identifier("foo"),FunctionType(None,ArgumentsDeclaration([TypedId(Identifier("arg1"),SimpleType("int"))]),SimpleType("float"))),FunctionDeclaration(None,Identifier("foo"),FunctionType(None,ArgumentsDeclaration([TypedId(Identifier("arg1"),SimpleType("toto")),TypedId(Identifier("arg2"),ReferenceType(SimpleType("double")))]),SimpleType("char")))])
Index: branches/scool-ng/tests/function/scool_ast/definition_002.aterm
===================================================================
--- branches/scool-ng/tests/function/scool_ast/definition_002.aterm (revision 121)
+++ branches/scool-ng/tests/function/scool_ast/definition_002.aterm (revision 122)
@@ -1 +1 @@
-Program([FunctionDefinition(None,Identifier("answer"),FunctionType(None,ArgumentsDeclaration([]),SimpleType("void")),FunctionBlock([SimpleDeclaration(None,Identifier("i"),SimpleType("int"),None)]))])
+Program([FunctionDefinition(None,Identifier("answer"),FunctionType(None,ArgumentsDeclaration([]),SimpleType("void")),FunctionBlock([SimpleDeclaration(None,Identifier("i"),SimpleType("int"),Some(Initialiser(Integer("42"))))]))])
Index: branches/scool-ng/tests/function/scool_ast/call_001.aterm
===================================================================
--- branches/scool-ng/tests/function/scool_ast/call_001.aterm (revision 121)
+++ branches/scool-ng/tests/function/scool_ast/call_001.aterm (revision 122)
@@ -1 +1 @@
-Program([FunctionDefinition(None,Identifier("doit"),FunctionType(None,ArgumentsDeclaration([]),SimpleType("void")),FunctionBlock([ExpressionStatement(FunctionCall(Identifier("foo"),None,Arguments([])))]))])
+Program([FunctionDefinition(None,Identifier("doit"),FunctionType(None,ArgumentsDeclaration([]),SimpleType("void")),FunctionBlock([ExpressionStatement(FunctionCall(Identifier("doit"),None,Arguments([])))]))])
Index: branches/scool-ng/tests/function/scool_ast/call_002.aterm
===================================================================
--- branches/scool-ng/tests/function/scool_ast/call_002.aterm (revision 121)
+++ branches/scool-ng/tests/function/scool_ast/call_002.aterm (revision 122)
@@ -1 +1 @@
-Program([FunctionDefinition(None,Identifier("doit"),FunctionType(None,ArgumentsDeclaration([]),SimpleType("void")),FunctionBlock([ExpressionStatement(FunctionCall(Identifier("foo"),None,Arguments([Integer("42")])))]))])
+Program([FunctionDefinition(None,Identifier("doit"),FunctionType(None,ArgumentsDeclaration([TypedId(Identifier("i"),SimpleType("int"))]),SimpleType("void")),FunctionBlock([ExpressionStatement(FunctionCall(Identifier("doit"),None,Arguments([Integer("42")])))]))])
Index: branches/scool-ng/tests/function/scool_ast/call_003.aterm
===================================================================
--- branches/scool-ng/tests/function/scool_ast/call_003.aterm (revision 121)
+++ branches/scool-ng/tests/function/scool_ast/call_003.aterm (revision 122)
@@ -1 +1 @@
-Program([FunctionDefinition(None,Identifier("doit"),FunctionType(None,ArgumentsDeclaration([]),SimpleType("void")),FunctionBlock([ExpressionStatement(FunctionCall(Identifier("foo"),None,Arguments([String("\"bar\""),Integer("42")])))]))])
+Program([Cxx("#include <string>\n\nusing std::string;\n"),FunctionDefinition(None,Identifier("doit"),FunctionType(None,ArgumentsDeclaration([TypedId(Identifier("s"),SimpleType("string")),TypedId(Identifier("i"),SimpleType("int"))]),SimpleType("void")),FunctionBlock([ExpressionStatement(FunctionCall(Identifier("doit"),None,Arguments([String("\"bar\""),Integer("42")])))]))])
Index: branches/scool-ng/tests/function/scool_ast/call_004.aterm
===================================================================
--- branches/scool-ng/tests/function/scool_ast/call_004.aterm (revision 121)
+++ branches/scool-ng/tests/function/scool_ast/call_004.aterm (revision 122)
@@ -1 +1 @@
-Program([FunctionDefinition(None,Identifier("doit"),FunctionType(None,ArgumentsDeclaration([]),SimpleType("void")),FunctionBlock([ExpressionStatement(FunctionCall(Identifier("foo"),Some(Parameters([SimpleType("int")])),Arguments([])))]))])
+Program([FunctionDeclaration(None,Identifier("foo"),FunctionType(Some(ParametersDeclaration([TypedId(Identifier("T"),"type")])),ArgumentsDeclaration([]),SimpleType("void"))),FunctionDefinition(None,Identifier("doit"),FunctionType(None,ArgumentsDeclaration([]),SimpleType("void")),FunctionBlock([ExpressionStatement(FunctionCall(Identifier("foo"),Some(Parameters([SimpleType("int")])),Arguments([])))]))])
Index: branches/scool-ng/tests/function/scool_ast/call_005.aterm
===================================================================
--- branches/scool-ng/tests/function/scool_ast/call_005.aterm (revision 121)
+++ branches/scool-ng/tests/function/scool_ast/call_005.aterm (revision 122)
@@ -1 +1 @@
-Program([FunctionDefinition(None,Identifier("doit"),FunctionType(None,ArgumentsDeclaration([]),SimpleType("void")),FunctionBlock([ExpressionStatement(FunctionCall(Identifier("foo"),Some(Parameters([Integer("42")])),Arguments([])))]))])
+Program([FunctionDeclaration(None,Identifier("foo"),FunctionType(Some(ParametersDeclaration([TypedId(Identifier("i"),SimpleType("int"))])),ArgumentsDeclaration([]),SimpleType("void"))),FunctionDefinition(None,Identifier("doit"),FunctionType(None,ArgumentsDeclaration([]),SimpleType("void")),FunctionBlock([ExpressionStatement(FunctionCall(Identifier("foo"),Some(Parameters([Integer("42")])),Arguments([])))]))])
Index: branches/scool-ng/tests/function/scool_ast/call_006.aterm
===================================================================
--- branches/scool-ng/tests/function/scool_ast/call_006.aterm (revision 121)
+++ branches/scool-ng/tests/function/scool_ast/call_006.aterm (revision 122)
@@ -1 +1 @@
-Program([FunctionDefinition(None,Identifier("doit"),FunctionType(None,ArgumentsDeclaration([]),SimpleType("void")),FunctionBlock([ExpressionStatement(FunctionCall(Identifier("foo"),Some(Parameters([SimpleType("int"),Integer("42")])),Arguments([Integer("42")])))]))])
+Program([FunctionDeclaration(None,Identifier("foo"),FunctionType(Some(ParametersDeclaration([TypedId(Identifier("T"),"type"),TypedId(Identifier("i"),SimpleType("int"))])),ArgumentsDeclaration([TypedId(Identifier("j"),SimpleType("int"))]),SimpleType("void"))),FunctionDefinition(None,Identifier("doit"),FunctionType(None,ArgumentsDeclaration([]),SimpleType("void")),FunctionBlock([ExpressionStatement(FunctionCall(Identifier("foo"),Some(Parameters([SimpleType("int"),Integer("42")])),Arguments([Integer("42")])))]))])
Index: branches/scool-ng/tests/function/scool_ast/declaration_003.aterm
===================================================================
--- branches/scool-ng/tests/function/scool_ast/declaration_003.aterm (revision 121)
+++ branches/scool-ng/tests/function/scool_ast/declaration_003.aterm (revision 122)
@@ -1 +1 @@
-Program([FunctionDeclaration(None,Identifier("foo"),FunctionType(None,ArgumentsDeclaration([TypedId(Identifier("a"),SimpleType("int")),TypedId(Identifier("b"),SimpleType("bar"))]),SimpleType("void")))])
+Program([ClassDeclaration(Some("final"),Identifier("bar"),None),FunctionDeclaration(None,Identifier("foo"),FunctionType(None,ArgumentsDeclaration([TypedId(Identifier("a"),SimpleType("int")),TypedId(Identifier("b"),SimpleType("bar"))]),SimpleType("void")))])
Index: branches/scool-ng/tests/function/scool_src/call_005.scl
===================================================================
--- branches/scool-ng/tests/function/scool_src/call_005.scl (revision 121)
+++ branches/scool-ng/tests/function/scool_src/call_005.scl (revision 122)
@@ -1,3 +1,5 @@
+foo : [i : int]() -> void;
+
doit : () -> void =
{
foo[42]();
Index: branches/scool-ng/tests/function/scool_src/call_006.scl
===================================================================
--- branches/scool-ng/tests/function/scool_src/call_006.scl (revision 121)
+++ branches/scool-ng/tests/function/scool_src/call_006.scl (revision 122)
@@ -1,3 +1,5 @@
+foo : [T : type, i : int](j : int) -> void;
+
doit : () -> void =
{
foo[int, 42](42);
Index: branches/scool-ng/tests/function/scool_src/declaration_003.scl
===================================================================
--- branches/scool-ng/tests/function/scool_src/declaration_003.scl (revision 121)
+++ branches/scool-ng/tests/function/scool_src/declaration_003.scl (revision 122)
@@ -1 +1,3 @@
+final bar : class;
+
foo : (a : int, b : bar) -> void;
Index: branches/scool-ng/tests/function/scool_src/declaration_004.scl
===================================================================
--- branches/scool-ng/tests/function/scool_src/declaration_004.scl (revision 121)
+++ branches/scool-ng/tests/function/scool_src/declaration_004.scl (revision 122)
@@ -1,3 +1,5 @@
+final toto : class;
+
foo : () -> void;
foo : (arg1 : int) -> float;
foo : (arg1 : toto, arg2 : ref double) -> char;
Index: branches/scool-ng/tests/function/scool_src/definition_002.scl
===================================================================
--- branches/scool-ng/tests/function/scool_src/definition_002.scl (revision 121)
+++ branches/scool-ng/tests/function/scool_src/definition_002.scl (revision 122)
@@ -1,4 +1,4 @@
answer : () -> void =
{
- i : int;
+ i : int = 42;
}
Index: branches/scool-ng/tests/function/scool_src/call_001.scl
===================================================================
--- branches/scool-ng/tests/function/scool_src/call_001.scl (revision 121)
+++ branches/scool-ng/tests/function/scool_src/call_001.scl (revision 122)
@@ -1,4 +1,4 @@
doit : () -> void =
{
- foo();
+ doit();
}
Index: branches/scool-ng/tests/function/scool_src/call_002.scl
===================================================================
--- branches/scool-ng/tests/function/scool_src/call_002.scl (revision 121)
+++ branches/scool-ng/tests/function/scool_src/call_002.scl (revision 122)
@@ -1,4 +1,4 @@
-doit : () -> void =
+doit : (i : int) -> void =
{
- foo(42);
+ doit(42);
}
Index: branches/scool-ng/tests/function/scool_src/call_003.scl
===================================================================
--- branches/scool-ng/tests/function/scool_src/call_003.scl (revision 121)
+++ branches/scool-ng/tests/function/scool_src/call_003.scl (revision 122)
@@ -1,4 +1,10 @@
-doit : () -> void =
+|[
+#include <string>
+
+using std::string;
+]|
+
+doit : (s : string, i : int) -> void =
{
- foo("bar", 42);
+ doit("bar", 42);
}
Index: branches/scool-ng/tests/function/scool_src/call_004.scl
===================================================================
--- branches/scool-ng/tests/function/scool_src/call_004.scl (revision 121)
+++ branches/scool-ng/tests/function/scool_src/call_004.scl (revision 122)
@@ -1,3 +1,5 @@
+foo : [T : type] () -> void;
+
doit : () -> void =
{
foo[int]();
Index: branches/scool-ng/tests/function/c++_build/declaration_003.g++
===================================================================
Index: branches/scool-ng/tests/function/c++_build/declaration_004.g++
===================================================================
Index: branches/scool-ng/tests/function/c++_build/definition_002.g++
===================================================================
Index: branches/scool-ng/tests/function/c++_build/call_001.g++
===================================================================
Index: branches/scool-ng/tests/function/c++_build/call_002.g++
===================================================================
Index: branches/scool-ng/tests/function/c++_build/call_003.g++
===================================================================
Index: branches/scool-ng/tests/function/c++_build/call_004.g++
===================================================================
Index: branches/scool-ng/tests/function/c++_build/call_005.g++
===================================================================
Index: branches/scool-ng/tests/function/c++_build/call_006.g++
===================================================================
1
0
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena/sandbox
Index: ChangeLog
from Alexandre Abraham <abraham(a)lrde.epita.fr>
Add co-occurence matrix computing.
* nature/co_occurence.hh: New
(mln::co_occurence) : compute co-occurence matrix.
* nature/mco.cc: New
Dummy test.
co_occurence.hh | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
mco.cc | 45 +++++++++++++++++++++++++++++++++
2 files changed, 120 insertions(+)
Index: nature/co_occurence.hh
--- nature/co_occurence.hh (revision 0)
+++ nature/co_occurence.hh (revision 0)
@@ -0,0 +1,75 @@
+// Copyright (C) 2007, 2008 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, 51 Franklin Street, Fifth Floor,
+// 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 MLN_CO_OCCURENCE_HH
+# define MLN_CO_OCCURENCE_HH
+
+/*! \file ??
+ *
+ * \brief FIXME
+ */
+
+# include <mln/core/concept/image.hh>
+# include <mln/core/dpoint.hh>
+# include <mln/core/image/image2d.hh>
+# include <mln/level/fill.hh>
+
+
+namespace mln
+{
+
+
+ template <typename I, typename D>
+ // image2d<unsigned> co_occurence (const Image<I>&, const Dpoint<D>&);
+ image2d<unsigned> co_occurence (const Image<I>&, const Gdpoint<D>&);
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I, typename D>
+ image2d<unsigned> co_occurence (const Image<I> &ima_, const Gdpoint<D> &dp_)
+ {
+ mln::metal::equal<mln_psite(I), mln_psite(D)>::check();
+
+ const I &ima = exact(ima_);
+ const D &dp = exact(dp_);
+ image2d<unsigned> mco(mln_card(mln_value(I)), mln_card(mln_value(I)), 0);
+ level::fill(mco, 0);
+
+
+ mln_piter(I) p(ima.domain());
+ for_all(p)
+ if (ima.domain().has(p + dp))
+ mco(point2d(ima(p), ima(p + dp)))++;
+
+ return mco;
+ }
+
+#endif // MLN_INCLUDE_ONLY
+
+}
+
+#endif // MLN_CO_OCCURENCE_HH
Index: nature/mco.cc
--- nature/mco.cc (revision 0)
+++ nature/mco.cc (revision 0)
@@ -0,0 +1,45 @@
+#include <iostream>
+
+#include <mln/value/int_u.hh>
+#include <mln/core/image/image2d.hh>
+#include "co_occurence.hh"
+#include <mln/core/alias/dpoint2d.hh>
+
+int main ()
+{
+ using namespace mln;
+ using namespace value;
+
+ typedef image2d< int_u<3> > I;
+
+ int_u<3> vs[6][5] = {
+
+ { 3, 3, 4, 4, 4 },
+ { 2, 1, 1, 1, 1 },
+ { 1, 4, 4, 4, 6 },
+ { 1, 4, 3, 4, 1 },
+ { 7, 4, 5, 3, 1 },
+ { 7, 7, 1, 1, 0 }
+
+ };
+
+ I ima(make::image2d(vs));
+
+ dpoint2d d(0, 1);
+
+ // std::cout << co_occurence(ima, d) << std::endl;
+
+ image2d<unsigned> co(co_occurence(ima, d));
+
+ unsigned cpt = 0;
+
+ mln_piter_(image2d<unsigned>) p(co.domain());
+ for_all(p)
+ {
+ std::cout << p << " = " << co(p) << std::endl;
+ cpt += co(p);
+ }
+
+ std::cout << cpt << std::endl;
+
+}
1
0