URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-11-27 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Add convertion of a tree into tree_fast.
* mln/util/tree_to_fast.hh: Add convertion of tree into tree_fast.
Tests
* tests/util/tree_to_fast.cc: New tests for this.
* tests/util/Makefile.am: Update.
---
mln/util/tree_fast_to_image.hh | 2
mln/util/tree_to_fast.hh | 110 +++++++++++++++++++++++++++++++++++++++++
tests/util/Makefile.am | 4 +
tests/util/tree_to_fast.cc | 74 +++++++++++++++++++++++++++
4 files changed, 188 insertions(+), 2 deletions(-)
Index: trunk/milena/tests/util/tree_to_fast.cc
===================================================================
--- trunk/milena/tests/util/tree_to_fast.cc (revision 0)
+++ trunk/milena/tests/util/tree_to_fast.cc (revision 1553)
@@ -0,0 +1,74 @@
+// Copyright (C) 2007 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.
+
+/*!
+ * \file tests/util/tree_to_fast.cc
+ *
+ * \brief test of mln::util::tree_to_fast
+ *
+ */
+
+#include <mln/util/tree.hh>
+#include <mln/util/tree_to_fast.hh>
+#include <mln/util/tree_fast.hh>
+
+int main ()
+{
+ using namespace mln;
+
+ unsigned elt1 = 1;
+ unsigned elt2 = 2;
+ unsigned elt3 = 3;
+ unsigned elt4 = 4;
+ unsigned elt5 = 5;
+ unsigned elt6= 42;
+
+ util::node<unsigned> node(elt1);
+ util::node<unsigned>* node2 = node.add_child(elt2);
+ node.add_child(elt3);
+ mln_assertion(node2);
+ node2->add_child(elt4);
+ node2->add_child(elt5);
+ util::node<unsigned>* node3 = node.search(elt4);
+ mln_assertion(node3);
+ node3 = node2->search(elt1);
+ mln_assertion(!node3);
+ util::tree<unsigned>* tre = new util::tree<unsigned>(&node);
+ mln_assertion(tre);
+ tre->add_tree_up(elt6);
+ mln_assertion (tre->check_consistency());
+
+
+ util::tree_fast<unsigned> tree_fast = util::tree_to_fast(*tre);
+ mln_assertion(tree_fast.has (elt1));
+ mln_assertion(tree_fast.has (elt2));
+ mln_assertion(tree_fast.has (elt3));
+ mln_assertion(tree_fast.has (elt4));
+ mln_assertion(tree_fast.has (elt5));
+ mln_assertion(tree_fast.has (elt6));
+ mln_assertion(tree_fast.search(elt6) == tree_fast.root_);
+}
Index: trunk/milena/tests/util/Makefile.am
===================================================================
--- trunk/milena/tests/util/Makefile.am (revision 1552)
+++ trunk/milena/tests/util/Makefile.am (revision 1553)
@@ -13,7 +13,8 @@
tree \
tree_fast \
tree_fast_to_image \
- tree_to_image
+ tree_to_image \
+ tree_to_fast
all_headers_SOURCES = all_headers.cc
branch_iter_SOURCES = branch_iter.cc
@@ -25,5 +26,6 @@
tree_fast_SOURCES = tree_fast.cc
tree_fast_to_image_SOURCES = tree_to_image.cc
tree_to_image_SOURCES = tree_to_image.cc
+tree_to_fast_SOURCES = tree_to_fast.cc
TESTS = $(check_PROGRAMS)
Index: trunk/milena/mln/util/tree_to_fast.hh
===================================================================
--- trunk/milena/mln/util/tree_to_fast.hh (revision 0)
+++ trunk/milena/mln/util/tree_to_fast.hh (revision 1553)
@@ -0,0 +1,110 @@
+// Copyright (C) 2007 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_UTIL_TREE_TO_FAST_HH
+# define MLN_UTIL_TREE_TO_FAST_HH
+
+/*!
+ * \file mln/util/tree_to_fast.hh
+ *
+ * \brief Definition of function which converts a tree into tree_fast.
+ *
+ */
+
+# include <mln/util/tree.hh>
+# include <mln/util/tree_fast.hh>
+# include <mln/trace/all.hh>
+
+
+namespace mln
+{
+
+ namespace util
+ {
+
+
+ /*! Convert a tree into an tree_fast.
+ *
+ * \param[in] input The tree to convert.
+ *
+ * \return The tree_fast containing tree informations.
+ *
+ */
+ template<typename T>
+ tree_fast<T>
+ tree_to_fast(tree<T>& input);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ namespace impl
+ {
+
+ template<typename T>
+ void
+ tree_to_fast_(node<T>* input, tree_fast<T>& tree, unsigned p, unsigned& i)
+ {
+ typename node<T>::children_t child = input->children ();
+ typename node<T>::children_t::iterator it = child.begin ();
+
+ for (; it != child.end (); ++it)
+ {
+ tree.add_child(p, (*it)->elt ());
+ ++i;
+ impl::tree_to_fast_((*it), tree, i, i);
+ }
+ }
+
+ }
+
+ /// Facade.
+
+ template<typename T>
+ tree_fast<T>
+ tree_to_fast(tree<T>& input)
+ {
+ trace::entering("util::tree_to_fast");
+
+ unsigned i = 0;
+ tree_fast<T> tree (input.root ()->elt ());
+
+ impl::tree_to_fast_(input.root (), tree, 0, i);
+
+ trace::exiting("util::tree_to_fast");
+ return tree;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::util
+
+} // end of namespace mln
+
+
+#endif // !MLN_UTIL_TREE_TO_FAST_HH
+
Index: trunk/milena/mln/util/tree_fast_to_image.hh
===================================================================
--- trunk/milena/mln/util/tree_fast_to_image.hh (revision 1552)
+++ trunk/milena/mln/util/tree_fast_to_image.hh (revision 1553)
@@ -89,7 +89,7 @@
trace::exiting("util::impl::tree_fast_to_image");
}
- } // end of mln::util::impl
+ } // end of namespace mln::util::impl
URL: https://svn.lrde.epita.fr/svn/oln/trunk
OK to apply?
(Use Reply-All, I'm not subscribed to this ML, thanks)
ChangeLog:
2007-11-27 Benoit Sigoure <tsuna(a)lrde.epita.fr>
Fix typos in the tutorial.
* milena/doc/tutorial/slides.tex: Various typos everywhere.
---
slides.tex | 47 ++++++++++++++++++++++++-----------------------
1 files changed, 24 insertions(+), 23 deletions(-)
Index: milena/doc/tutorial/slides.tex
===================================================================
--- milena/doc/tutorial/slides.tex (revision 1543)
+++ milena/doc/tutorial/slides.tex (working copy)
@@ -243,7 +243,7 @@
\item Many libraries exist that can fulfill one's needs.
\item If you're happy with your favorite tool, we cannot force you
to change for \mln...
- \item Though, you might have a look at \mln and being seduced!
+ \item Though, you might have a look at \mln and be seduced!
\end{itemize}
\end{block}
@@ -253,7 +253,7 @@
\begin{block}{No!}
\begin{itemize}
\item \mln is rather different than available libraries.
- \item A lot of convenient data structures that \emph{really} helps
+ \item A lot of convenient data structures that \emph{really} help
you in developing IP solutions.
\end{itemize}
\end{block}
@@ -310,7 +310,8 @@
\smallskip
\begin{lstlisting}[basicstyle={\tiny\sffamily}]
template <typename I, typename H>
-void transform_inplace(Image<I>& f_, const Function_v2v<H>& h_)
+void transform_inplace(Image<I>& f_,
+ const Function_v2v<H>& h_)
{
I& f = exact(f);
const H& h = exact(h_);
@@ -361,7 +362,7 @@
%........................................................................
\begin{frame}%[<+->]
- \frametitle{What's In a Library}
+ \frametitle{What's In The Library}
\begin{itemize}
\item algorithms:\\
@@ -389,7 +390,7 @@
\begin{itemize}
\item Generic...
\item Efficient so that one can process large images.
- \item Quite as easy to use as a C or Java library.
+ \item Almost as easy to use as a C or Java library.
\item Many tools to help writing readable algorithms in a concise way.
\end{itemize}
@@ -552,7 +553,7 @@
\texttt{arith} & arithmetical operators \\
\texttt{border} & routines about virtual border &
\texttt{canvas} & canvases \\
-\texttt{convert} & conversions routines &
+\texttt{convert} & conversion routines &
\texttt{core} & the library core \\
\texttt{debug} & debugging tools &
\texttt{display} & display tools \\
@@ -605,7 +606,7 @@
not on implementation details about how to do it
\smallskip
%
- \item you do not have found yet a library to easily process your
+ \item you have not yet found a library to easily process your
particular types of data
\end{itemize}
@@ -824,9 +825,9 @@
\begin{frame}[fragile]
\frametitle{Modifying the State of an Object (2/2)}
- accessing and modifying through method calls allow some control:
+ accessing and modifying through method calls allows for some control:
\begin{itemize}
- \item one cannot do everything with an object
+ \item one cannot do anything with an object
\item especially putting it in an invalid state
\end{itemize}
@@ -888,7 +889,7 @@
\begin{itemize}
\item no need to take the address (with \&) of an object
\item no pointer arithmetics
- \item no $->$ in use
+ \item no $->$ to access members
\end{itemize}
\item it \emph{always} designates the same object
\begin{itemize}
@@ -995,7 +996,7 @@
accessible from the user
\begin{itemize}
\item thanks to the keyword \kw{private}
- \item writing \code{p.row\_} outside this class is not allowed (do
+ \item writing \code{p.row\_} outside this class is not allowed (does
not compile)
\end{itemize}
\smallskip
@@ -1003,7 +1004,7 @@
\item the method \code{row()} is accessible (keyword \kw{public})
\begin{itemize}
\item in the method body we have some room to add code
- \item a simple access to data can performs some clever stuff that
+ \item a simple access to data can perform some clever stuff that
you do not really have to know (neither want to)!
\end{itemize}
\end{itemize}
@@ -1121,7 +1122,7 @@
\end{lstlisting}
\begin{itemize}
-\item the variable \code{r} represents an object which type is
+\item the variable \code{r} represents an object the type of which is
precisely \code{rabbit}
\begin{center}
we say that it is the \emph{exact} type behind this variable
@@ -1165,7 +1166,7 @@
\item In that case
\begin{itemize}
\item at compile-time: there are many possible types of objects represented
- \item at run-time: there is one object represented so just type.
+ \item at run-time: there is one object represented so just one type.
\end{itemize}
\end{itemize}
@@ -1184,7 +1185,7 @@
About ``classical'' object-orientation:
\begin{itemize}
- \item abstractions (like \code{animal}) leads to poor
+ \item abstractions (like \code{animal}) lead to poor
performance at run-time when involved in intensive scientific code.
%
\item it is due to the fact that the exact type is lost\\
@@ -1340,7 +1341,7 @@
\begin{frame}[fragile]
\frametitle{A rationale for Genericity}
-Suppose that you want a routine that computes twice the input:
+Suppose that you want a routine that computes twice its input:
\begin{lstlisting}
int twice(int i) { return 2 * i; }
\end{lstlisting}
@@ -1434,7 +1435,7 @@
one of the procedure argument ``\code{(T t)}''
%
\item the nature of \code{t} is \code{T}, the nature of \code{T} is
- \code{typename} (so designates a type)
+ \code{typename} (so it designates a type)
%
\item the \cpp keyword introducing a generic piece of code is
\kw{template}
@@ -1476,7 +1477,7 @@
\item \code{int twice(int t) { return 2 * t; }} and
\item \code{float twice(float t) { return 2 * t; }}
\end{itemize}
-\item so it is not so different than with overloading
+\item so it is not so different than overloading
\end{itemize}
except that:
@@ -1762,7 +1763,7 @@
}
\end{lstlisting}
-How can we ensure that the delta-point type \code{D} really correspond
+How can we ensure that the delta-point type \code{D} really corresponds
to \code{P}? {\scriptsize (we really do not want \code{P} and
\code{D} resp. being \code{point3d} and \code{dpoint2d}!)}
@@ -1803,7 +1804,7 @@
}
\end{lstlisting}
-What is the problem? (Hint: read both signatures in natural language)
+What is the problem? (Hint: read both signatures out loud)
\end{frame}
@@ -1829,7 +1830,7 @@
\end{lstlisting}
which is clearly not ambiguous (but slow at run-time...)
-where \code{Dpoint} and \code{Image} are abstract class.
+where \code{Dpoint} and \code{Image} are abstract classes.
\end{frame}
@@ -2140,11 +2141,11 @@
\scriptsize{it works for any delta-point type}
\smallskip
%
-\item is fast
+\item is fast,
\scriptsize{you cannot get more efficient code}
\smallskip
%
-\item is user-friendly
+\item is user-friendly,
\scriptsize{just write ``\code{dp1 + dp2}'' to add a couple of delta-points}
\end{itemize}
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Add norm functors.
* mln/fun/v2v/norm.hh: New.
Provide norm functors.
* mln/fun/all.hh: Fix namespace description.
* tests/fun/v2v/norm.cc: New.
* tests/fun/v2v/Makefile.am (check_PROGRAMS): New.
Add norm.
(norm_SOURCES): New.
(TESTS): New.
* tests/fun/Makefile.am (SUBDIRS): Add v2v.
mln/fun/all.hh | 2
mln/fun/v2v/norm.hh | 125 ++++++++++++++++++++++++++++++++++++++++++++++
tests/fun/Makefile.am | 2
tests/fun/v2v/Makefile.am | 6 ++
tests/fun/v2v/norm.cc | 69 +++++++++++++++++++++++++
5 files changed, 202 insertions(+), 2 deletions(-)
Index: mln/fun/v2v/norm.hh
--- mln/fun/v2v/norm.hh (revision 0)
+++ mln/fun/v2v/norm.hh (revision 0)
@@ -0,0 +1,125 @@
+// Copyright (C) 2007 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_FUN_V2V_NORM_HH
+# define MLN_FUN_V2V_NORM_HH
+
+/*! \file mln/fun/v2v/norm.hh
+ *
+ * \brief Norm functors.
+ *
+ * \see mln/norm/.
+ */
+
+# include <mln/core/concept/function.hh>
+# include <mln/trait/value_.hh>
+
+# include <mln/norm/all.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace v2v
+ {
+
+ /*! \brief L1-norm.
+ *
+ * \c V is the type of input values; \c R is the result type.
+ *
+ * \see mln::norm::l1.
+ */
+ template <typename V, typename R>
+ struct l1_norm : public Function_v2v< l1_norm<V, R> >
+ {
+ typedef R result;
+ R operator()(const V& v) const;
+ };
+
+ /*! \brief L2-norm.
+ *
+ * \c V is the type of input values; \c R is the result type.
+ *
+ * \see mln::norm::l2.
+ */
+ template <typename V, typename R>
+ struct l2_norm : public Function_v2v< l2_norm<V, R> >
+ {
+ typedef R result;
+ R operator()(const V& v) const;
+ };
+
+ /*! \brief L-infty norm.
+ *
+ * \c V is the type of input values; \c R is the result type.
+ *
+ * \see mln::norm::linfty.
+ */
+ template <typename V, typename R>
+ struct linfty_norm : public Function_v2v< linfty_norm<V, R> >
+ {
+ typedef R result;
+ R operator()(const V& v) const;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename V, typename R>
+ R
+ l1_norm<V, R>::operator()(const V& v) const
+ {
+ return mln::norm::l1 (v);
+ }
+
+ template <typename V, typename R>
+ R
+ l2_norm<V, R>::operator()(const V& v) const
+ {
+ return mln::norm::l2 (v);
+ }
+
+ template <typename V, typename R>
+ R
+ linfty_norm<V, R>::operator()(const V& v) const
+ {
+ return mln::norm::linfty (v);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::v2v
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_V2V_NORM_HH
Index: mln/fun/all.hh
--- mln/fun/all.hh (revision 1550)
+++ mln/fun/all.hh (working copy)
@@ -37,7 +37,7 @@
namespace mln
{
- /// Namespace of image processing routines related to pixel funs.
+ /// Namespace of image processing routines related to functions.
namespace fun
{
Index: tests/fun/v2v/norm.cc
--- tests/fun/v2v/norm.cc (revision 0)
+++ tests/fun/v2v/norm.cc (revision 0)
@@ -0,0 +1,69 @@
+// Copyright (C) 2007 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.
+
+/*! \file tests/norm/l1.hh
+ *
+ * \brief Test the norm functors.
+ */
+
+#include <mln/metal/vec.hh>
+#include <mln/fun/v2v/norm.hh>
+
+#include <tests/norm/common.hh>
+
+
+int main()
+{
+ typedef mln::metal::vec<3, int> vec_t;
+
+ // L1-norm.
+ {
+ vec_t t, u;
+ t.set (1, -2, 3);
+ u.set (5, 1, 0);
+ mln::fun::v2v::l1_norm<vec_t, float> l1;
+ test::check_norm(l1, t, u);
+ }
+
+ // L2-norm.
+ {
+ vec_t t, u;
+ t.set (2, -2, 3);
+ u.set (4, 1, 0);
+ mln::fun::v2v::l2_norm<vec_t, float> l2;
+ test::check_norm(l2, t, u);
+ }
+
+ // L-infinity-norm.
+ {
+ vec_t t, u;
+ t.set (2, -2, 4);
+ u.set (4, 1, 0);
+ mln::fun::v2v::linfty_norm<vec_t, int> linfty;
+ test::check_norm(linfty, t, u);
+ }
+}
Index: tests/fun/v2v/Makefile.am
--- tests/fun/v2v/Makefile.am (revision 1550)
+++ tests/fun/v2v/Makefile.am (working copy)
@@ -1,3 +1,9 @@
## Process this file through Automake to create Makefile.in -*- Makefile -*-
include $(top_srcdir)/milena/tests/tests.mk
+
+check_PROGRAMS = norm
+
+norm_SOURCES = norm.cc
+
+TESTS = $(check_PROGRAMS)
Index: tests/fun/Makefile.am
--- tests/fun/Makefile.am (revision 1550)
+++ tests/fun/Makefile.am (working copy)
@@ -2,4 +2,4 @@
include $(top_srcdir)/milena/tests/tests.mk
-SUBDIRS = x2x
+SUBDIRS = v2v x2x