
* mln/util/hqueue.hh: Rename 'priority' arguments to 'bucket'. * mln/world/k1/immerse_and_duplicate_2_to_1_faces.hh: Add comments. * mln/world/kn/border/compute_1_faces.hh: Remove debug output. * mln/world/kn/compute_tree_of_shapes.hh: Fix a typo. * tests/world/k1/fill_0_from_1_faces.cc, * tests/world/k1/immerse_with.cc: Fix tests. --- milena/ChangeLog | 15 ++++++ milena/mln/util/hqueue.hh | 32 ++++++------ .../world/k1/immerse_and_duplicate_2_to_1_faces.hh | 6 ++ milena/mln/world/kn/border/compute_1_faces.hh | 3 - milena/mln/world/kn/compute_tree_of_shapes.hh | 2 +- milena/tests/world/k1/fill_0_from_1_faces.cc | 49 +++++++------------ milena/tests/world/k1/immerse_with.cc | 11 ++-- 7 files changed, 61 insertions(+), 57 deletions(-) diff --git a/milena/ChangeLog b/milena/ChangeLog index 32f1991..9edfec7 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,5 +1,20 @@ 2012-10-29 Guillaume Lazzara <z@lrde.epita.fr> + Small fixes. + + * mln/util/hqueue.hh: Rename 'priority' arguments to 'bucket'. + + * mln/world/k1/immerse_and_duplicate_2_to_1_faces.hh: Add comments. + + * mln/world/kn/border/compute_1_faces.hh: Remove debug output. + + * mln/world/kn/compute_tree_of_shapes.hh: Fix a typo. + + * tests/world/k1/fill_0_from_1_faces.cc, + * tests/world/k1/immerse_with.cc: Fix tests. + +2012-10-29 Guillaume Lazzara <z@lrde.epita.fr> + * mln/world/kn/debug/println.hh: New. 2012-10-29 Guillaume Lazzara <z@lrde.epita.fr> diff --git a/milena/mln/util/hqueue.hh b/milena/mln/util/hqueue.hh index ab7660c..6d535cf 100644 --- a/milena/mln/util/hqueue.hh +++ b/milena/mln/util/hqueue.hh @@ -53,13 +53,13 @@ namespace mln unsigned size() const; - bool is_empty(const P& priority) const; - bool is_not_empty(const P& priority) const; + bool is_empty(const P& bucket) const; + bool is_not_empty(const P& bucket) const; -// const std::queue<T>& operator[](const P& priority) const; +// const std::queue<T>& operator[](const P& bucket) const; - void push(const T& t, const P& priority); - T pop(const P& priority); + void push(const T& t, const P& bucket); + T pop(const P& bucket); private: std::vector<std::queue<T> > v_; @@ -103,16 +103,16 @@ namespace mln template <typename T, typename P> bool - hqueue<T,P>::is_empty(const P& priority) const + hqueue<T,P>::is_empty(const P& bucket) const { - return v_[inter_.index_of(priority)].empty() == 0; + return v_[inter_.index_of(bucket)].empty() == 0; } template <typename T, typename P> bool - hqueue<T,P>::is_not_empty(const P& priority) const + hqueue<T,P>::is_not_empty(const P& bucket) const { - return ! is_empty(priority); + return ! is_empty(bucket); } // template <typename T, typename P> @@ -125,19 +125,19 @@ namespace mln template <typename T, typename P> void - hqueue<T,P>::push(const T& t, const P& priority) + hqueue<T,P>::push(const T& t, const P& bucket) { - v_[inter_.index_of(priority)].push(t); + v_[inter_.index_of(bucket)].push(t); } template <typename T, typename P> T - hqueue<T,P>::pop(const P& priority) + hqueue<T,P>::pop(const P& bucket) { - mln_precondition(!is_empty()); - mln_precondition(priority < v_.size()); - T front = v_[priority].front(); - v_[priority].pop(); + mln_precondition(!is_empty(bucket)); + mln_precondition(bucket < v_.size()); + T front = v_[bucket].front(); + v_[bucket].pop(); return front; } diff --git a/milena/mln/world/k1/immerse_and_duplicate_2_to_1_faces.hh b/milena/mln/world/k1/immerse_and_duplicate_2_to_1_faces.hh index 33ef3dd..81208a5 100644 --- a/milena/mln/world/k1/immerse_and_duplicate_2_to_1_faces.hh +++ b/milena/mln/world/k1/immerse_and_duplicate_2_to_1_faces.hh @@ -53,12 +53,18 @@ namespace mln Data is copied into 1 faces located at the bottom right of each 2 faces. + \verbatim -1 0 1 2 3 0 1 -1 . a . d . 0 a d 0 a a a d d 1 b c -> 1 . a . d . 2 b b b c c 3 . b . c . + \endverbatim + + Warning: image borders are not initialized. \sa + world::kn::border::duplicate_2_faces, + world::kn::border::compute_1_faces. */ template <typename I> diff --git a/milena/mln/world/kn/border/compute_1_faces.hh b/milena/mln/world/kn/border/compute_1_faces.hh index 9788efc..4e6bfcf 100644 --- a/milena/mln/world/kn/border/compute_1_faces.hh +++ b/milena/mln/world/kn/border/compute_1_faces.hh @@ -85,8 +85,6 @@ namespace mln // Fill horizontal border for (def::coord col = min_col_1; col <= max_col_1; ++col) - { - std::cout << min_row_1 << "," << col << std::endl; if (is_1_face_vertical(min_row_1, col)) { // First row @@ -96,7 +94,6 @@ namespace mln inout.at_(max_row_1, col) = f(inout.at_(max_row_1, col - 1), inout.at_(max_row_1, col + 1)); } - } // Fill vertical border for (def::coord row = min_row_1; row <= max_row_1; ++row) diff --git a/milena/mln/world/kn/compute_tree_of_shapes.hh b/milena/mln/world/kn/compute_tree_of_shapes.hh index 6726259..1596618 100644 --- a/milena/mln/world/kn/compute_tree_of_shapes.hh +++ b/milena/mln/world/kn/compute_tree_of_shapes.hh @@ -265,7 +265,7 @@ namespace mln EV l_ = lcur; for (; l_ > inter_.first(); value::dec(l_)) - if (q.is_not_empty(l_))) + if (q.is_not_empty(l_)) { found = true; return l_; diff --git a/milena/tests/world/k1/fill_0_from_1_faces.cc b/milena/tests/world/k1/fill_0_from_1_faces.cc index e667734..ed53466 100644 --- a/milena/tests/world/k1/fill_0_from_1_faces.cc +++ b/milena/tests/world/k1/fill_0_from_1_faces.cc @@ -29,47 +29,34 @@ #include <mln/make/box2d.hh> #include <mln/data/compare.hh> #include <mln/accu/math/sum.hh> +#include <mln/fun/vvvv2v/sum.hh> #include <mln/world/k1/fill_0_from_1_faces.hh> #include <mln/border/fill.hh> -namespace mln -{ - - struct sum_t : Function_vvvv2v<sum_t> - { - typedef int result; - - int operator()(const int& v1, const int& v2, const int& v3, const int& v4) const - { - return v1 + v2 + v3 + v4; - } - - }; - -} - - - int main() { using namespace mln; - int refvals[5][5] = { - {2, 1, 3, 1, 2}, - {1, 0, 1, 0, 1}, - {3, 1, 4, 1, 3}, - {1, 0, 1, 0, 1}, - {2, 1, 3, 1, 2} + int refvals[7][7] = { + {2, 1, 3, 1, 3, 1, 2 }, + {1, 0, 1, 0, 1, 0, 1 }, + {3, 1, 4, 1, 4, 1, 3 }, + {1, 0, 1, 0, 1, 0, 1 }, + {3, 1, 4, 1, 4, 1, 3 }, + {1, 0, 1, 0, 1, 0, 1 }, + {2, 1, 3, 1, 3, 1, 2 }, }; image2d<int> ref = make::image(refvals, point2d(-1, -1)); - int vals[5][5] = { - {0, 1, 0, 1, 0 }, - {1, 0, 1, 0, 1 }, - {0, 1, 0, 1, 0 }, - {1, 0, 1, 0, 1 }, - {0, 1, 0, 1, 0 } + int vals[7][7] = { + {0, 1, 0, 1, 0, 1, 0 }, + {1, 0, 1, 0, 1, 0, 1 }, + {0, 1, 0, 1, 0, 1, 0 }, + {1, 0, 1, 0, 1, 0, 1 }, + {0, 1, 0, 1, 0, 1, 0 }, + {1, 0, 1, 0, 1, 0, 1 }, + {0, 1, 0, 1, 0, 1, 0 }, }; image2d<int> imak1 = make::image(vals, point2d(-1, -1)); @@ -78,7 +65,7 @@ int main() // Overload with function { - sum_t f; + fun::vvvv2v::sum<int> f; world::k1::fill_0_from_1_faces(imak1, f); mln_assertion(ref == imak1); } diff --git a/milena/tests/world/k1/immerse_with.cc b/milena/tests/world/k1/immerse_with.cc index c6d4af7..93074b5 100644 --- a/milena/tests/world/k1/immerse_with.cc +++ b/milena/tests/world/k1/immerse_with.cc @@ -45,11 +45,11 @@ int main() // computation will handle borders. int fvals[][5] = { - {0, 2, 0, 4, 0}, - {2, 1, 3, 2, 4}, - {0, 4, 20, 6, 0}, - {6, 3, 7, 4, 8}, - {0, 6, 0, 8, 0} + {8, 2, 12, 4, 16}, + {2, 1, 3, 2, 4 }, + {16, 4, 20, 6, 24}, + {6, 3, 7, 4, 8 }, + {24, 6, 28, 8, 32} }; image2d<int> ref = make::image(fvals, point2d(-1,-1)); @@ -59,7 +59,6 @@ int main() immersed = world::k1::immerse_with(ima, long(), 0l, fun::vv2v::sum<long>(), fun::vvvv2v::sum<long>()); - mln_assertion(immersed == ref); } -- 1.7.2.5
participants (1)
-
Guillaume Lazzara