URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2009-03-25 Fabien Freling <fabien.freling(a)lrde.epita.fr>
Add IO section.
* doc/ref_guide/ref_guide.tex: Add a Input / Output section.
---
ref_guide.tex | 2 ++
1 file changed, 2 insertions(+)
Index: trunk/milena/doc/ref_guide/ref_guide.tex
===================================================================
--- trunk/milena/doc/ref_guide/ref_guide.tex (revision 3574)
+++ trunk/milena/doc/ref_guide/ref_guide.tex (revision 3575)
@@ -323,6 +323,7 @@
- \backslash subpage iterators
- \backslash subpage imamemmgmt
- \backslash subpage basicops
+- \backslash subpage inputoutput
- \backslash subpage graphandima
- \backslash subpage funs
- \backslash subpage arithmops
@@ -1920,6 +1921,44 @@
%====================================
+\clearpage
+\newpage
+\doxychapter{inputoutput}{Input / Output}
+
+Olena offers a builtin support for PNM (PBM, PGM & PPM), PFM and dump file formats.
+
+You can extend the range of supported files by installing third-parties libraries such as:
+
+\begin{itemize}
+ \item ImageMagick: support for usual images (PNG, TIFF, JPEG, ...)
+ \item GDCM: support for DICOM medical images
+\end{itemize}
+
+\doxysection{ioim}{ImageMagick}
+ http://www.imagemagick.org/
+
+ You have to install ImageMagick with Magick++ support. You will be able to
+ load every file recognized as an image by ImageMagick.
+
+ Olena only support binary and 8 bits images through ImageMagick.
+
+ During the compilation, you will have to specify the ImageMagick flags and
+ libraries.
+
+ To do so, just add the following line to your compilation:
+
+ `Magick++-config --cppflags --cxxflags --ldflags --libs`
+
+ Magick++-config will automatically fill the dependencies depending of your
+ installation.
+
+\doxysection{iodcm}{GDCM}
+ http://apps.sourceforge.net/mediawiki/gdcm/
+
+ GDCM is a library for manipulating DICOM files. DICOM files are used in
+ medical imaging.
+
+%====================================
\newpage
\clearpage
%Ugly workaround to avoid missing chapter references in doxygen.
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2009-03-25 Fabien Freling <fabien.freling(a)lrde.epita.fr>
Add ImageMagick save() support.
* mln/io/magick/all.hh: Update.
* mln/io/magick/load.hh: Update.
* mln/io/magick/save.hh: Implement save() routine.
---
all.hh | 1
load.hh | 2
save.hh | 137 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 139 insertions(+), 1 deletion(-)
Index: trunk/milena/mln/io/magick/all.hh
===================================================================
--- trunk/milena/mln/io/magick/all.hh (revision 3573)
+++ trunk/milena/mln/io/magick/all.hh (revision 3574)
@@ -46,5 +46,6 @@
}
# include <mln/io/magick/load.hh>
+# include <mln/io/magick/save.hh>
#endif // ! MLN_IO_MAGICK_ALL_HH
Index: trunk/milena/mln/io/magick/save.hh
===================================================================
--- trunk/milena/mln/io/magick/save.hh (revision 0)
+++ trunk/milena/mln/io/magick/save.hh (revision 3574)
@@ -0,0 +1,137 @@
+// Copyright (C) 2009 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_IO_MAGICK_SAVE_HH
+# define MLN_IO_MAGICK_SAVE_HH
+
+///
+/// \file mln/io/magick/save.hh
+///
+/// Define a function which saves an image of kind magick with
+/// given path.
+
+# include <mln/core/image/image2d.hh>
+# include <mln/metal/equal.hh>
+# include <mln/value/int_u8.hh>
+# include <mln/value/rgb8.hh>
+# include <Magick++.h>
+
+
+namespace mln
+{
+
+ namespace io
+ {
+
+ namespace magick
+ {
+
+ /*! Save a Milena image in a magick image.
+ *
+ * \param[out] ima A reference to the image to save.
+ * \param[in] filename The output.
+ */
+ template <typename I>
+ void save(Image<I>& ima,
+ const std::string& filename);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ inline
+ Magick::Color get_color(bool value)
+ {
+ if (value)
+ return Magick::Color("white");
+ else
+ return Magick::Color("black");
+ }
+
+ inline
+ Magick::Color get_color(value::int_u8 value)
+ {
+ return Magick::Color((unsigned) value * MaxRGB / 256,
+ (unsigned) value * MaxRGB / 256,
+ (unsigned) value * MaxRGB / 256,
+ 0);
+ }
+
+ inline
+ Magick::Color get_color(value::rgb8 value)
+ {
+ return Magick::Color((unsigned) value.red() * MaxRGB / 256,
+ (unsigned) value.green() * MaxRGB / 256,
+ (unsigned) value.blue() * MaxRGB / 256,
+ 0);
+ }
+
+ template <typename I>
+ inline
+ void save(Image<I>& ima_, const std::string& filename)
+ {
+ trace::entering("mln::io::magick::save");
+
+ mln_precondition(mln_site_(I)::dim == 2);
+ I& ima = exact(ima_);
+ if (!(mln::metal::equal<mln_value(I), bool>::value ||
+ mln::metal::equal<mln_value(I), value::int_u8>::value ||
+ mln::metal::equal<mln_value(I), value::rgb8>::value))
+ {
+ std::cerr << "error: trying to save an unsupported format" << std::endl;
+ std::cerr << "formats supported: binary, 8bits grayscale (int_u8), 8bits truecolor (rgb8)" << std::endl;
+ abort();
+ }
+
+ Magick::Image im_file(Magick::Geometry(ima.nrows(), ima.ncols()),
+ Magick::Color(0, 0, 0, 0));
+ Magick::PixelPacket* pixel_cache = im_file.getPixels(0, 0, ima.nrows(), ima.ncols());
+ Magick::PixelPacket* pixel;
+ mln_piter(I) p(ima.domain());
+ unsigned columns = ima.ncols();
+ for_all(p)
+ {
+ pixel = pixel_cache + (int) p.to_site().to_vec()[0] * columns
+ + (int) p.to_site().to_vec()[1];
+ *pixel = get_color(ima(p));
+ }
+ im_file.syncPixels();
+ im_file.write(filename);
+
+ trace::exiting("mln::io::magick::save");
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::io::magick
+
+ } // end of namespace mln::io
+
+} // end of namespace mln
+
+
+#endif // ! MLN_IO_MAGICK_SAVE_HH
Index: trunk/milena/mln/io/magick/load.hh
===================================================================
--- trunk/milena/mln/io/magick/load.hh (revision 3573)
+++ trunk/milena/mln/io/magick/load.hh (revision 3574)
@@ -147,7 +147,7 @@
{
const Magick::PixelPacket *pixel = pixel_cache + (int) p.to_site().to_vec()[0] * columns
+ (int) p.to_site().to_vec()[1];
- value::rgb8 pix(pixel->red % 256, pixel->green % 256, pixel->blue % 256); // WARNING: Quantum = 16bits but rgb is 8bits
+ value::rgb8 pix(pixel->red % 256, pixel->green % 256, pixel->blue % 256); // FIXME: Quantum = 16bits but rgb is 8bits
mln_value(I) res;
if (!do_it(pix, res, filename))
abort();
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
ChangeLog:
2009-03-24 Frederic Bour <bour(a)lrde.epita.fr>
Add inf, sup accumulator and accu_result function.
* mln/accu/inf.hh: New.
* mln/accu/sup.hh: New.
* mln/accu: New.
* mln/fun/accu_result.hh: New.
* mln/fun/from_accu.hh: Correct some typo errors.
---
accu/inf.hh | 166 +++++++++++++++++++++++++++++++++++++++++++++++++++++
accu/sup.hh | 166 +++++++++++++++++++++++++++++++++++++++++++++++++++++
fun/accu_result.hh | 69 ++++++++++++++++++++++
fun/from_accu.hh | 7 --
4 files changed, 404 insertions(+), 4 deletions(-)
Index: trunk/milena/sandbox/fred/mln/fun/accu_result.hh
===================================================================
--- trunk/milena/sandbox/fred/mln/fun/accu_result.hh (revision 0)
+++ trunk/milena/sandbox/fred/mln/fun/accu_result.hh (revision 3571)
@@ -0,0 +1,69 @@
+// Copyright (C) 2007, 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 F 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_ACCU_RESULT_HH
+# define MLN_FUN_ACCU_RESULT_HH
+
+# include <mln/fun/unary.hh>
+# include <mln/core/concept/accumulator.hh>
+# include <mln/math/acos.hh>
+# include <mln/math/cos.hh>
+
+namespace mln
+{
+
+ // accu_result: return result of given accumulator.
+ namespace fun
+ {
+ struct accu_result : unary<accu_result> {};
+ }
+
+ namespace trait
+ {
+
+ namespace next
+ {
+ template <typename E>
+ struct set_unary_<mln::fun::accu_result, mln::Accumulator, E>
+ {
+ typedef set_unary_ ret;
+ typedef typename E::result result;
+ typedef mln::Accumulator<E> argument;
+
+ static result read(const argument& x)
+ {
+ return exact(x).to_result();
+ }
+ };
+
+ }
+
+ }
+
+}
+
+#endif /* ! MLN_FUN_ACCU_RESULT_HH */
\ No newline at end of file
Index: trunk/milena/sandbox/fred/mln/fun/from_accu.hh
===================================================================
--- trunk/milena/sandbox/fred/mln/fun/from_accu.hh (revision 3570)
+++ trunk/milena/sandbox/fred/mln/fun/from_accu.hh (revision 3571)
@@ -25,8 +25,8 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_FUN_FROMACCU_HH
-# define MLN_FUN_FROMACCU_HH
+#ifndef MLN_FUN_FROM_ACCU_HH
+# define MLN_FUN_FROM_ACCU_HH
# include <mln/fun/unary.hh>
# include <mln/core/concept/accumulator.hh>
@@ -36,7 +36,7 @@
namespace mln
{
- // Cosinus, bijective
+ // from_accu: wrap an accumulator into a function
namespace fun
{
template <typename A>
@@ -92,4 +92,4 @@
}
-#endif /* ! MLN_FUN_MATH_COS_HH */
\ No newline at end of file
+#endif /* ! MLN_FUN_FROM_ACCU_HH */
\ No newline at end of file
Index: trunk/milena/sandbox/fred/mln/accu/sup.hh
===================================================================
--- trunk/milena/sandbox/fred/mln/accu/sup.hh (revision 0)
+++ trunk/milena/sandbox/fred/mln/accu/sup.hh (revision 3571)
@@ -0,0 +1,166 @@
+// Copyright (C) 2007, 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_ACCU_SUP_HH
+# define MLN_ACCU_SUP_HH
+
+/// \file mln/accu/sup.hh
+///
+/// Define an accumulator that computes a sup.
+
+# include <mln/accu/internal/base.hh>
+# include <mln/core/concept/meta_accumulator.hh>
+# include <mln/trait/value_.hh>
+# include <mln/util/pix.hh>
+# include <mln/fun/math/sup.hh>
+
+namespace mln
+{
+
+ namespace accu
+ {
+
+
+ /// Generic sup accumulator class.
+ /*!
+ * The parameter \c T is the type of values.
+ */
+ template <typename T>
+ struct sup : public mln::accu::internal::base< const T&, sup<T> >
+ {
+ typedef T argument;
+
+ sup();
+
+ /// Manipulators.
+ /// \{
+ void init();
+ void take_as_init(const argument& t);
+ void take(const argument& t);
+ void take(const sup<T>& other);
+ /// \}
+
+ /// Get the value of the accumulator.
+ const T& to_result() const;
+
+ /// Check whether this accu is able to return a result.
+ /// Always true here.
+ bool is_valid() const;
+
+ protected:
+
+ T t_;
+ mln::fun::sup::with<T, T>::ret fun_;
+ };
+
+
+ template <typename I> struct sup< util::pix<I> >;
+
+
+
+ namespace meta
+ {
+
+ /// Meta accumulator for sup.
+
+ struct sup : public Meta_Accumulator< sup >
+ {
+ template <typename T>
+ struct with
+ {
+ typedef accu::sup<T> ret;
+ };
+ };
+
+ } // end of namespace mln::accu::meta
+
+
+
+ # ifndef MLN_INCLUDE_ONLY
+
+ template <typename T>
+ inline
+ sup<T>::sup()
+ {
+ init();
+ }
+
+ template <typename T>
+ inline
+ void
+ sup<T>::init()
+ {
+ t_ = mln_min(T);
+ }
+
+ template <typename T>
+ inline
+ void sup<T>::take_as_init(const argument& t)
+ {
+ t_ = t;
+ }
+
+ template <typename T>
+ inline
+ void sup<T>::take(const argument& t)
+ {
+ this->t_ = this->fun_(t_, t);
+ }
+
+ template <typename T>
+ inline
+ void
+ sup<T>::take(const sup<T>& other)
+ {
+ this->t_ = this->fun_(t_, other.t_);
+ }
+
+ template <typename T>
+ inline
+ const T&
+ sup<T>::to_result() const
+ {
+ return t_;
+ }
+
+ template <typename T>
+ inline
+ bool
+ sup<T>::is_valid() const
+ {
+ return true;
+ }
+
+ # endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::accu
+
+} // end of namespace mln
+
+
+#endif // ! MLN_ACCU_SUP_HH
Index: trunk/milena/sandbox/fred/mln/accu/inf.hh
===================================================================
--- trunk/milena/sandbox/fred/mln/accu/inf.hh (revision 0)
+++ trunk/milena/sandbox/fred/mln/accu/inf.hh (revision 3571)
@@ -0,0 +1,166 @@
+// Copyright (C) 2007, 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_ACCU_INF_HH
+# define MLN_ACCU_INF_HH
+
+/// \file mln/accu/inf.hh
+///
+/// Define an accumulator that computes a inf.
+
+# include <mln/accu/internal/base.hh>
+# include <mln/core/concept/meta_accumulator.hh>
+# include <mln/trait/value_.hh>
+# include <mln/util/pix.hh>
+# include <mln/fun/math/inf.hh>
+
+namespace mln
+{
+
+ namespace accu
+ {
+
+
+ /// Generic inf accumulator class.
+ /*!
+ * The parameter \c T is the type of values.
+ */
+ template <typename T>
+ struct inf : public mln::accu::internal::base< const T&, inf<T> >
+ {
+ typedef T argument;
+
+ inf();
+
+ /// Manipulators.
+ /// \{
+ void init();
+ void take_as_init(const argument& t);
+ void take(const argument& t);
+ void take(const inf<T>& other);
+ /// \}
+
+ /// Get the value of the accumulator.
+ const T& to_result() const;
+
+ /// Check whether this accu is able to return a result.
+ /// Always true here.
+ bool is_valid() const;
+
+ protected:
+
+ T t_;
+ mln::fun::inf::with<T, T>::ret fun_;
+ };
+
+
+ template <typename I> struct inf< util::pix<I> >;
+
+
+
+ namespace meta
+ {
+
+ /// Meta accumulator for inf.
+
+ struct inf : public Meta_Accumulator< inf >
+ {
+ template <typename T>
+ struct with
+ {
+ typedef accu::inf<T> ret;
+ };
+ };
+
+ } // end of namespace mln::accu::meta
+
+
+
+ # ifndef MLN_INCLUDE_ONLY
+
+ template <typename T>
+ inline
+ inf<T>::inf()
+ {
+ init();
+ }
+
+ template <typename T>
+ inline
+ void
+ inf<T>::init()
+ {
+ t_ = mln_max(T);
+ }
+
+ template <typename T>
+ inline
+ void inf<T>::take_as_init(const argument& t)
+ {
+ t_ = t;
+ }
+
+ template <typename T>
+ inline
+ void inf<T>::take(const argument& t)
+ {
+ this->t_ = this->fun_(t_, t);
+ }
+
+ template <typename T>
+ inline
+ void
+ inf<T>::take(const inf<T>& other)
+ {
+ this->t_ = this->fun_(t_, other.t_);
+ }
+
+ template <typename T>
+ inline
+ const T&
+ inf<T>::to_result() const
+ {
+ return t_;
+ }
+
+ template <typename T>
+ inline
+ bool
+ inf<T>::is_valid() const
+ {
+ return true;
+ }
+
+ # endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::accu
+
+} // end of namespace mln
+
+
+#endif // ! MLN_ACCU_INF_HH
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Relax a couple of contraints related to labels and integers.
* mln/debug/colorize.hh: Relax the Symbolic constraint.
That allows for colorizing images containing integers.
* mln/value/int_u.hh (next): New.
That allows for images containing integers to be processed
as labeled images.
debug/colorize.hh | 4 ++--
value/int_u.hh | 15 +++++++++++++--
2 files changed, 15 insertions(+), 4 deletions(-)
Index: mln/debug/colorize.hh
--- mln/debug/colorize.hh (revision 3565)
+++ mln/debug/colorize.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory
// (LRDE)
//
// This file is part of the Olena Library. This library is free
@@ -109,7 +109,7 @@
mln_precondition(exact(input).is_valid());
// FIXME: check that V is a color type.
// FIXME: we want to be sure that this is a label.
- mlc_is_a(mln_value(L), mln::value::Symbolic)::check();
+ // mlc_is_a(mln_value(L), mln::value::Symbolic)::check();
(void) value;
unsigned label_count = nlabels.next();
Index: mln/value/int_u.hh
--- mln/value/int_u.hh (revision 3565)
+++ mln/value/int_u.hh (working copy)
@@ -1,5 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory
-// (LRDE)
+// Copyright (C) 2007, 2008, 2009 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
@@ -154,6 +154,9 @@
/// Assignment from an integer.
int_u<n>& operator=(int i);
+
+ /// Give the next value (i.e., i + 1).
+ int_u<n> next() const;
};
@@ -256,6 +259,14 @@
template <unsigned n>
inline
+ int_u<n>
+ int_u<n>::next() const
+ {
+ return this->v_ + 1;
+ }
+
+ template <unsigned n>
+ inline
std::ostream& operator<<(std::ostream& ostr, const int_u<n>& i)
{
// FIXME: This code could be factored for almost every Value<*>...
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
ChangeLog:
2009-03-24 Frederic Bour <bour(a)lrde.epita.fr>
Add from_accu functional wrapper.
* fred/mln/fun/from_accu.hh: New.
* fred/mln/fun/math/cos.hh: Support for integer value as argument.
---
from_accu.hh | 95 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
math/cos.hh | 15 +++++++++
2 files changed, 110 insertions(+)
Index: trunk/milena/sandbox/fred/mln/fun/math/cos.hh
===================================================================
--- trunk/milena/sandbox/fred/mln/fun/math/cos.hh (revision 3565)
+++ trunk/milena/sandbox/fred/mln/fun/math/cos.hh (revision 3566)
@@ -30,6 +30,7 @@
# include <mln/fun/unary.hh>
# include <mln/value/builtin/floatings.hh>
+# include <mln/value/builtin/integers.hh>
# include <mln/math/acos.hh>
# include <mln/math/cos.hh>
@@ -67,6 +68,20 @@
}
};
+ template <typename T>
+ struct set_unary_<mln::fun::cos, mln::value::Integer, T>
+ {
+ typedef set_unary_ ret;
+ typedef double result;
+ typedef T argument;
+
+ static result read(const argument& x)
+ {
+ return math::cos((result)x);
+ }
+
+ };
+
}
}
Index: trunk/milena/sandbox/fred/mln/fun/from_accu.hh
===================================================================
--- trunk/milena/sandbox/fred/mln/fun/from_accu.hh (revision 0)
+++ trunk/milena/sandbox/fred/mln/fun/from_accu.hh (revision 3566)
@@ -0,0 +1,95 @@
+// Copyright (C) 2007, 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 F 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_FROMACCU_HH
+# define MLN_FUN_FROMACCU_HH
+
+# include <mln/fun/unary.hh>
+# include <mln/core/concept/accumulator.hh>
+# include <mln/math/acos.hh>
+# include <mln/math/cos.hh>
+
+namespace mln
+{
+
+ // Cosinus, bijective
+ namespace fun
+ {
+ template <typename A>
+ struct from_accu : unary_param<from_accu<A>, A*>
+ {
+ from_accu() : unary_param<from_accu<A>, A*>() {};
+ from_accu(A* a) : unary_param<from_accu<A>, A*>(a) {};
+ };
+ }
+
+ namespace trait
+ {
+
+ namespace next
+ {
+ template <typename A, typename T>
+ struct set_unary_<mln::fun::from_accu<A>, mln::Object, T>
+ {
+ typedef set_unary_ ret;
+ typedef typename A::result result;
+ typedef typename A::argument argument;
+ typedef A* param;
+
+ set_unary_()
+ {
+ }
+
+ set_unary_(const param& accu)
+ : accu_(accu)
+ {
+ }
+
+ result read(const argument& x) const
+ {
+ mln_precondition(accu_ != 0);
+
+ accu_->take(x);
+ return accu_->to_result ();
+ }
+
+ void init(const param& accu)
+ {
+ accu_ = accu;
+ }
+
+ protected:
+ A* accu_;
+ };
+
+ }
+
+ }
+
+}
+
+#endif /* ! MLN_FUN_MATH_COS_HH */
\ No newline at end of file