[gegl] lohalo: prevent floating point disaster
- From: Nicolas Robidoux <nrobidoux src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] lohalo: prevent floating point disaster
- Date: Wed, 12 Dec 2012 00:29:11 +0000 (UTC)
commit 4d73aadb5a681706941bd8209e00aca0ea28c5ac
Author: Nicolas Robidoux <nrobidoux git gnome org>
Date: Tue Dec 11 19:29:07 2012 -0500
lohalo: prevent floating point disaster
gegl/buffer/gegl-sampler-lohalo.c | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
---
diff --git a/gegl/buffer/gegl-sampler-lohalo.c b/gegl/buffer/gegl-sampler-lohalo.c
index 895ea47..46a7a98 100644
--- a/gegl/buffer/gegl-sampler-lohalo.c
+++ b/gegl/buffer/gegl-sampler-lohalo.c
@@ -1980,7 +1980,13 @@ gegl_sampler_lohalo_get ( GeglSampler* restrict self,
const gdouble frobenius_squared = n11 + n22;
const gdouble discriminant =
( frobenius_squared + twice_det ) * ( frobenius_squared - twice_det );
- const gdouble sqrt_discriminant = sqrt( discriminant );
+ /*
+ * In exact arithmetic, the discriminant cannot be negative. In
+ * floating point, it can, leading a non-deterministic bug in
+ * ImageMagick (now fixed, thanks to Cristy).
+ */
+ const gdouble sqrt_discriminant =
+ sqrt (((double) discriminant > 0.) ? (double) discriminant : 0.);
/*
* Initially, we only compute the squares of the singular
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]