Explorar el Código

Change default precision to float instead of double (need to investigate there)

Also add a way to dynamically change the precision (needed for some test that don't use non full precision result matrix)
Godzil hace 4 años
padre
commit
9f2a41e6f3
Se han modificado 2 ficheros con 9 adiciones y 1 borrados
  1. 1 0
      source/include/math_helper.h
  2. 8 1
      source/math_helper.cpp

+ 1 - 0
source/include/math_helper.h

@@ -10,6 +10,7 @@
 #ifndef DORAYME_MATH_HELPER_H
 #define DORAYME_MATH_HELPER_H
 
+void set_equal_precision(double v);
 bool double_equal(double a, double b);
 
 #endif //DORAYME_MATH_HELPER_H

+ 8 - 1
source/math_helper.cpp

@@ -11,7 +11,14 @@
 #include <float.h>
 #include <math_helper.h>
 
+static double current_precision = FLT_EPSILON;
+
+void set_equal_precision(double v)
+{
+    current_precision = v;
+}
+
 bool double_equal(double a, double b)
 {
-    return fabs(a - b) < DBL_EPSILON;
+    return fabs(a - b) < current_precision;
 }