* mln/value/is_degenerated.hh,
* tests/value/is_degenerated.cc: New.
* tests/value/Makefile.am: New target.
---
milena/ChangeLog | 9 +++
milena/mln/value/{prev.hh => is_degenerated.hh} | 59 +++++++++----------
milena/tests/value/Makefile.am | 4 +-
.../{math/mean.cc => value/is_degenerated.cc} | 26 ++++-----
4 files changed, 51 insertions(+), 47 deletions(-)
copy milena/mln/value/{prev.hh => is_degenerated.hh} (69%)
copy milena/tests/{math/mean.cc => value/is_degenerated.cc} (77%)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 9edfec7..656968b 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,14 @@
2012-10-29 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Add value::is_degenerated.
+
+ * mln/value/is_degenerated.hh,
+ * tests/value/is_degenerated.cc: New.
+
+ * tests/value/Makefile.am: New target.
+
+2012-10-29 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Small fixes.
* mln/util/hqueue.hh: Rename 'priority' arguments to 'bucket'.
diff --git a/milena/mln/value/prev.hh b/milena/mln/value/is_degenerated.hh
similarity index 69%
copy from milena/mln/value/prev.hh
copy to milena/mln/value/is_degenerated.hh
index 93221c5..17794e1 100644
--- a/milena/mln/value/prev.hh
+++ b/milena/mln/value/is_degenerated.hh
@@ -23,15 +23,17 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef MLN_VALUE_PREV_HH
-# define MLN_VALUE_PREV_HH
+#ifndef MLN_VALUE_IS_DEGENERATED_HH
+# define MLN_VALUE_IS_DEGENERATED_HH
/// \file
///
-/// Return the prev value.
+/// Return True if a given value is degenerated.
-# include <mln/value/iota.hh>
-# include <mln/value/label.hh>
+# include <mln/metal/abort.hh>
+# include <mln/value/concept/scalar.hh>
+# include <mln/value/scalar.hh>
+# include <mln/value/interval.hh>
namespace mln
@@ -41,8 +43,8 @@ namespace mln
{
template <typename V>
- V
- prev(const V&);
+ bool
+ is_degenerated(const V&);
# ifndef MLN_INCLUDE_ONLY
@@ -57,24 +59,22 @@ namespace mln
{
template <typename V>
- inline
- V
- prev(const V& v)
+ bool
+ is_degenerated(const V&)
{
- return v - mln::value::iota<V>::value();
+ return true;
}
- } // end of namespace mln::value::implementation::generic
-
+ }
template <typename V>
- inline
- V
- prev_method(const V& v)
+ bool
+ is_degenerated_interval(const interval<V>& v)
{
- return v.prev();
+ return v.is_degenerated();
}
+
} // end of namespace mln::value::implementation
@@ -84,20 +84,18 @@ namespace mln
namespace internal
{
- template <unsigned n>
- inline
- label<n>
- prev_dispatch(const label<n>& v)
+ template <typename V>
+ bool
+ is_degenerated_dispatch(const interval<V>& v)
{
- return implementation::prev_method(v);
+ return implementation::is_degenerated_interval(v);
}
template <typename V>
- inline
- V
- prev_dispatch(const V& v)
+ bool
+ is_degenerated_dispatch(const V& v)
{
- return implementation::generic::prev(v);
+ return implementation::generic::is_degenerated(v);
}
} // end of namespace mln::value::internal
@@ -107,11 +105,10 @@ namespace mln
// Facade
template <typename V>
- inline
- V
- prev(const V& v)
+ bool
+ is_degenerated(const V& v)
{
- return internal::prev_dispatch(v);
+ return internal::is_degenerated_dispatch(exact(v));
}
@@ -122,4 +119,4 @@ namespace mln
} // end of namespace mln
-#endif // ! MLN_VALUE_PREV_HH
+#endif // ! MLN_VALUE_IS_DEGENERATED_HH
diff --git a/milena/tests/value/Makefile.am b/milena/tests/value/Makefile.am
index 537eb76..4b71064 100644
--- a/milena/tests/value/Makefile.am
+++ b/milena/tests/value/Makefile.am
@@ -36,7 +36,8 @@ check_PROGRAMS = \
scalar \
set \
sign \
- intsub
+ intsub \
+ is_degenerated
# float01
# float01_bis
# float01_f
@@ -62,6 +63,7 @@ scalar_SOURCES = scalar.cc
set_SOURCES = set.cc
sign_SOURCES = sign.cc
intsub_SOURCES = intsub.cc
+is_degenerated_SOURCES = is_degenerated.cc
#<<lrde
# FIXME: Not distributed (yet).
diff --git a/milena/tests/math/mean.cc b/milena/tests/value/is_degenerated.cc
similarity index 77%
copy from milena/tests/math/mean.cc
copy to milena/tests/value/is_degenerated.cc
index a62cab6..348912b 100644
--- a/milena/tests/math/mean.cc
+++ b/milena/tests/value/is_degenerated.cc
@@ -23,25 +23,21 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#include <mln/math/mean.hh>
+#include <cassert>
+#include <mln/value/is_degenerated.hh>
+#include <mln/value/interval.hh>
#include <mln/value/intsub.hh>
+#include <mln/value/int_u8.hh>
+
int main()
{
using namespace mln;
+ using namespace mln::value;
- mln_assertion(math::mean(2,3) == 2.5);
-
- {
- value::intsub<2> v1(1.5);
- value::intsub<2> v2(2);
- mln_assertion(math::mean(v1, v2) == 1.75);
- }
-
- mln_assertion(math::mean(1,2,3,4) == 2.5);
-
- {
- value::intsub<2> v1(1), v2(2), v3(3), v4(5);
- mln_assertion(math::mean(v1, v2, v3, v4) == 2.75);
- }
+ mln_assertion(is_degenerated(2));
+ mln_assertion(is_degenerated(interval<int>(2,2)));
+ mln_assertion(!is_degenerated(interval<int>(2,6)));
+ mln_assertion(is_degenerated(intsub<2>(6)));
+ mln_assertion(is_degenerated(int_u8(6)));
}
--
1.7.2.5
Show replies by date