[gegl] matrix: in gegl_matrix3_equal(), use fuzzy comparison



commit b4854062dcfb566f272d834a49b0706895dadb27
Author: Ell <ell_se yahoo com>
Date:   Fri Feb 22 02:49:52 2019 -0500

    matrix: in gegl_matrix3_equal(), use fuzzy comparison
    
    In gegl_matrix3_equal(), use fuzzy comparison for comparing the
    two matrices' coefficients, so that small errors are tolerated.
    This indirectly affects the various gegl_matrix3_is_foo()
    functions.

 gegl/gegl-matrix.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
---
diff --git a/gegl/gegl-matrix.c b/gegl/gegl-matrix.c
index 89703be29..adf52f21e 100644
--- a/gegl/gegl-matrix.c
+++ b/gegl/gegl-matrix.c
@@ -23,6 +23,8 @@
 
 #include "gegl-matrix.h"
 
+#define EPSILON 1e-6
+
 #if 0
 static void gegl_matrix3_debug (GeglMatrix3 *matrix)
 {
@@ -77,7 +79,7 @@ gegl_matrix3_equal (GeglMatrix3 *matrix1,
 
   for (y = 0; y < 3; y++)
     for (x = 0; x < 3; x++)
-      if (matrix1->coeff [y][x] != matrix2->coeff [y][x])
+      if (fabs (matrix1->coeff [y][x] - matrix2->coeff [y][x]) > EPSILON)
         return FALSE;
   return TRUE;
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]