* milena/mln/core/alias/dpoint2d.hh: add typedef dpoint2df.
* milena/mln/core/image/attribute_image.hh: add explicit
constructor.
* milena/mln/morpho/tree/leaf_last.hh: energy minimization instead
of maximization.
* milena/mln/util/ctree/ctree.hh: bug fix.
* milena/mln/util/ctree/node.hh: put operators outside namespace.
---
milena/ChangeLog | 11 ++++
milena/mln/core/alias/dpoint2d.hh | 1 +
milena/mln/core/image/attribute_image.hh | 2 +-
milena/mln/morpho/tree/leaf_last.hh | 4 +-
milena/mln/util/ctree/ctree.hh | 8 ++-
milena/mln/util/ctree/node.hh | 90 +++++++++++++++---------------
6 files changed, 68 insertions(+), 48 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index d07d036..9065378 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,14 @@
+2011-03-02 edwin carlinet <carlinet(a)lrde.epita.fr>
+Minor updates to make things compile.
+
+ * milena/mln/core/alias/dpoint2d.hh: add typedef dpoint2df.
+ * milena/mln/core/image/attribute_image.hh: add explicit
+ constructor.
+ * milena/mln/morpho/tree/leaf_last.hh: energy minimization instead
+ of maximization.
+ * milena/mln/util/ctree/ctree.hh: bug fix.
+ * milena/mln/util/ctree/node.hh: put operators outside namespace.
+
2010-05-21 edwin carlinet <carlinet(a)lrde.epita.fr>
Add MLN_WO_GLOBAL_VARS directive that prevents globals vars to be
diff --git a/milena/mln/core/alias/dpoint2d.hh b/milena/mln/core/alias/dpoint2d.hh
index 1120154..cf07423 100644
--- a/milena/mln/core/alias/dpoint2d.hh
+++ b/milena/mln/core/alias/dpoint2d.hh
@@ -43,6 +43,7 @@ namespace mln
/// grid with integer coordinates.
typedef dpoint<mln::grid::square, mln::def::coord> dpoint2d;
+ typedef dpoint<mln::grid::square, mln::def::coordf> dpoint2df;
} // end of namespace mln
diff --git a/milena/mln/core/image/attribute_image.hh
b/milena/mln/core/image/attribute_image.hh
index 1331a6f..cc2d760 100644
--- a/milena/mln/core/image/attribute_image.hh
+++ b/milena/mln/core/image/attribute_image.hh
@@ -160,7 +160,7 @@ namespace mln
/// Constructor without argument.
attribute_image();
/// Allocate an attribute image respecting the size of the tree.
- attribute_image(const Tree<T>& tree);
+ explicit attribute_image(const Tree<T>& tree);
/// \}
/// Initialize an empty image.
diff --git a/milena/mln/morpho/tree/leaf_last.hh b/milena/mln/morpho/tree/leaf_last.hh
index 2f283d5..07ad8a1 100644
--- a/milena/mln/morpho/tree/leaf_last.hh
+++ b/milena/mln/morpho/tree/leaf_last.hh
@@ -61,7 +61,7 @@ namespace mln
bool operator() (const node_t& lhs, const node_t& rhs)
{
- return f_(lhs) > f_(rhs);
+ return f_(lhs) < f_(rhs);
}
private:
@@ -77,6 +77,8 @@ namespace mln
typedef typename T::node_t node_t;
p_array<node_t> sorted_sites = convert::to_p_array(ima);
+ mln_invariant(sorted_sites.nsites() == ima.nsites());
+
std::vector<node_t>& hook = sorted_sites.hook_std_vector_();
std::sort(hook.begin(), hook.end(), internal::less_<T, V> (ima));
diff --git a/milena/mln/util/ctree/ctree.hh b/milena/mln/util/ctree/ctree.hh
index e1c7148..39e7170 100644
--- a/milena/mln/util/ctree/ctree.hh
+++ b/milena/mln/util/ctree/ctree.hh
@@ -39,9 +39,11 @@
# include <mln/core/concept/site_set.hh>
# include <mln/util/ctree/internal/tree_base.hh>
# include <mln/util/array.hh>
+# include <mln/data/fill.hh>
# include <mln/core/image/attribute_image.hh>
# include <algorithm>
+
# define mln_node(T) typename T::node_t
namespace mln
@@ -101,7 +103,7 @@ namespace mln
std::vector<unsigned> length_;
std::vector<mln_value(I)> values_;
- const mln_domain(I)& domain_;
+ mln_domain(I) domain_;
int nnodes;
};
@@ -244,10 +246,13 @@ namespace mln
/// Equivalent to desc(tree.node_at(i)).nsites().
unsigned length_at_(index_t i) const;
unsigned& length_at_(index_t i);
+
rvalue f_at_(index_t i) const;
lvalue f_at_(index_t i);
+
index_t parent_at_(index_t i) const;
index_t& parent_at_(index_t i);
+
index_t node_at_(const psite& p) const;
index_t& node_at_(const psite& p);
/// \}
@@ -342,6 +347,7 @@ namespace mln
this->data_ = new mln::internal::data< ctree<I> >(f);
initialize(this->data_->map_, f);
+ this->data_->domain_ = f.domain();
this->data_->parent_.resize(nnodes);
this->data_->length_.resize(nnodes);
this->data_->values_.resize(nnodes);
diff --git a/milena/mln/util/ctree/node.hh b/milena/mln/util/ctree/node.hh
index ebdc955..8bfc356 100644
--- a/milena/mln/util/ctree/node.hh
+++ b/milena/mln/util/ctree/node.hh
@@ -47,8 +47,8 @@ namespace mln
{
namespace ctree
{
- template <typename T>
- class node;
+ template <typename T>
+ class node;
}
}
@@ -119,26 +119,26 @@ namespace mln
int idx_;
};
- /*
- ** Operators.
- */
- template <typename T>
- bool
- operator== (const node<T>& n1, const node<T>& n2);
+ } // end of namespace mln::util::ctree
- template <typename T>
- bool
- operator!= (const node<T>& n1, const node<T>& n2);
+ } // end of namespace mln::util
- /// Test if the node \p n1 is a descendant of \p n2
- ///
- template <typename T>
- bool
- operator< (const node<T>& n1, const node<T>& n2);
+ /*
+ ** Operators.
+ */
+ template <typename T>
+ bool
+ operator== (const util::ctree::node<T>& n1, const
util::ctree::node<T>& n2);
- } // end of namespace mln::util::ctree
+ template <typename T>
+ bool
+ operator!= (const util::ctree::node<T>& n1, const
util::ctree::node<T>& n2);
- } // end of namespace mln::util
+ /// Test if the node \p n1 is a descendant of \p n2
+ ///
+ template <typename T>
+ bool
+ operator< (const util::ctree::node<T>& n1, const
util::ctree::node<T>& n2);
namespace internal
@@ -260,36 +260,36 @@ namespace mln
return tree_ != 0 && tree_->is_valid();
}
- /*
- ** Operators
- */
- template <typename T>
- inline
- bool
- operator== (const node<T>& n1, const node<T>& n2)
- {
- return n1.index() == n2.index();
- }
+ } // end of namespace mln::util::ctree
- template <typename T>
- inline
- bool
- operator!= (const node<T>& n1, const node<T>& n2)
- {
- return n1.index() != n2.index();
- }
+ } // end of namespace mln::util
- template <typename T>
- inline
- bool
- operator< (const node<T>& n1, const node<T>& n2)
- {
- return n1.index() > n2.index();
- }
+ /*
+ ** Operators
+ */
+ template <typename T>
+ inline
+ bool
+ operator== (const util::ctree::node<T>& n1, const
util::ctree::node<T>& n2)
+ {
+ return n1.index() == n2.index();
+ }
- } // end of namespace mln::util::ctree
+ template <typename T>
+ inline
+ bool
+ operator!= (const util::ctree::node<T>& n1, const
util::ctree::node<T>& n2)
+ {
+ return n1.index() != n2.index();
+ }
- } // end of namespace mln::util
+ template <typename T>
+ inline
+ bool
+ operator< (const util::ctree::node<T>& n1, const
util::ctree::node<T>& n2)
+ {
+ return n1.index() > n2.index();
+ }
namespace internal
{
@@ -322,7 +322,7 @@ namespace mln
return exact_().get_subject().tree();
}
- /*------------------------------------------`
+ /*------------------------------------------`
| subject_impl< util::ctree::node<T> |
\-----------------------------------------*/
--
1.5.6.5