* mln/level/stretch.hh: Use double variables instead of float because
of precision issues. See ticket #179.
---
milena/ChangeLog | 7 +++++++
milena/mln/level/stretch.hh | 16 ++++++++++------
2 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 6364251..d08a017 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,12 @@
2009-01-09 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Fix level::stretch.
+
+ * mln/level/stretch.hh: Use double variables instead of float because
+ of precision issues. See ticket #179.
+
+2009-01-09 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Add from_double_to_value dispatch in from_to.
* mln/convert/from_to.hxx: add more forward declarations.
diff --git a/milena/mln/level/stretch.hh b/milena/mln/level/stretch.hh
index e91dbe7..80190b4 100644
--- a/milena/mln/level/stretch.hh
+++ b/milena/mln/level/stretch.hh
@@ -1,5 +1,5 @@
-// Copyright (C) 2007, 2008 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
@@ -44,6 +44,8 @@
# include <mln/level/transform.hh>
+# include <mln/value/internal/encoding.hh>
+# include <iomanip>
namespace mln
{
@@ -84,21 +86,23 @@ namespace mln
estim::min_max(input, min_, max_);
if (max_ != min_)
{
- float
+ //FIXME: we would like to use float instead of double but we
+ //can't for precision reasons. See ticket #179.
+ double
min = float(min_),
max = float(max_),
epsilon = mln_epsilon(float),
- m = 0.0f - 0.5f + epsilon,
M = mln_max(V) + 0.5f - epsilon,
+ m = 0.0f - 0.5f + epsilon,
a = (M - m) / (max - min),
b = (m * max - M * min) / (max - min);
- fun::v2v::linear<float, float, V> f(a, b);
+ fun::v2v::linear<double, double, V> f(a, b);
output = level::transform(input, f);
}
else
{
initialize(output, input);
- // trace::warning("output has no significative data!");
+ trace::warning("output has no significative data!");
}
trace::exiting("level::impl::stretch");
--
1.5.6.5
Show replies by date