summaryrefslogtreecommitdiffstats
path: root/tools/lib
diff options
context:
space:
mode:
Diffstat (limited to 'tools/lib')
-rw-r--r--tools/lib/h5diff.h31
-rw-r--r--tools/lib/h5diff_array.c76
2 files changed, 42 insertions, 65 deletions
diff --git a/tools/lib/h5diff.h b/tools/lib/h5diff.h
index e0f2ad0..df264dd 100644
--- a/tools/lib/h5diff.h
+++ b/tools/lib/h5diff.h
@@ -25,21 +25,22 @@
*/
typedef struct {
- int m_quiet; /* quiet mide: no output at all */
- int m_report; /* report mode: print the data */
- int m_verbose; /* verbose mode: print the data, list of objcets, warnings */
- int d; /* delta, absolute value to compare */
- double delta; /* delta value */
- int p; /* relative error to compare*/
- double percent; /* relative error value */
- int n; /* count, compare up to count */
- hsize_t count; /* count value */
- int err_stat; /* an error ocurred (1, error, 0, no error) */
- int cmn_objs; /* do we have common objects */
- int not_cmp; /* are the objects comparable */
- int contents; /* equal contents */
- int do_nans; /* consider Nans while diffing floats */
- int m_list_not_cmp; /* list not comparable messages */
+ int m_quiet; /* quiet mide: no output at all */
+ int m_report; /* report mode: print the data */
+ int m_verbose; /* verbose mode: print the data, list of objcets, warnings */
+ int d; /* delta, absolute value to compare */
+ double delta; /* delta value */
+ int p; /* relative error to compare*/
+ int use_system_epsilon; /* flag to use system epsilon (1 or 0) */
+ double percent; /* relative error value */
+ int n; /* count, compare up to count */
+ hsize_t count; /* count value */
+ int err_stat; /* an error ocurred (1, error, 0, no error) */
+ int cmn_objs; /* do we have common objects */
+ int not_cmp; /* are the objects comparable */
+ int contents; /* equal contents */
+ int do_nans; /* consider Nans while diffing floats */
+ int m_list_not_cmp; /* list not comparable messages */
} diff_opt_t;
diff --git a/tools/lib/h5diff_array.c b/tools/lib/h5diff_array.c
index 735ea70..77ee74a 100644
--- a/tools/lib/h5diff_array.c
+++ b/tools/lib/h5diff_array.c
@@ -74,9 +74,16 @@
#define ULLI_FORMAT_P_NOTCOMP "%-15"H5_PRINTF_LL_WIDTH"u %-15"H5_PRINTF_LL_WIDTH"u %-15"H5_PRINTF_LL_WIDTH"d not comparable\n"
-/* values for FLT_EPSILON same as C Reference manual */
-#define H5DIFF_FLT_EPSILON .00001
-#define H5DIFF_DBL_EPSILON .000000001
+/* if system EPSILON is defined, use the system EPSILON; otherwise, use
+ constants that are close to most EPSILON values */
+
+#ifndef FLT_EPSILON
+#define FLT_EPSILON 1.19209E-07
+#endif
+
+#ifndef DBL_EPSILON
+#define DBL_EPSILON 2.22045E-16
+#endif
/*-------------------------------------------------------------------------
@@ -5502,10 +5509,6 @@ error:
static
hbool_t equal_double(double value, double expected, diff_opt_t *options)
{
- int both_zero;
- int is_zero;
-
-
if ( options->do_nans )
{
@@ -5535,22 +5538,15 @@ hbool_t equal_double(double value, double expected, diff_opt_t *options)
}
}
- BOTH_ZERO(value,expected)
- if (both_zero)
- return TRUE;
-
- IS_ZERO(expected)
- if (is_zero)
- return(equal_double(expected,value,options));
-
if (value == expected)
return TRUE;
- if ( ABS( (value-expected) / expected) < H5DIFF_DBL_EPSILON)
- return TRUE;
- else
- return FALSE;
+ if (options->use_system_epsilon) {
+ if ( ABS( (value-expected) ) < DBL_EPSILON)
+ return TRUE;
+ }
+ return FALSE;
}
/*-------------------------------------------------------------------------
@@ -5566,10 +5562,6 @@ hbool_t equal_double(double value, double expected, diff_opt_t *options)
static
hbool_t equal_ldouble(long double value, long double expected, diff_opt_t *options)
{
- int both_zero;
- int is_zero;
-
-
if ( options->do_nans )
{
@@ -5599,22 +5591,15 @@ hbool_t equal_ldouble(long double value, long double expected, diff_opt_t *optio
}
}
- BOTH_ZERO(value,expected)
- if (both_zero)
- return TRUE;
-
- IS_ZERO(expected)
- if (is_zero)
- return(equal_ldouble(expected,value,options));
-
if (value == expected)
return TRUE;
- if ( ABS( (value-expected) / expected) < H5DIFF_DBL_EPSILON)
- return TRUE;
- else
- return FALSE;
+ if (options->use_system_epsilon) {
+ if ( ABS( (value-expected) / expected) < DBL_EPSILON)
+ return TRUE;
+ }
+ return FALSE;
}
#endif /* #if H5_SIZEOF_LONG_DOUBLE !=0 */
@@ -5634,9 +5619,6 @@ hbool_t equal_ldouble(long double value, long double expected, diff_opt_t *optio
static
hbool_t equal_float(float value, float expected, diff_opt_t *options)
{
- int both_zero;
- int is_zero;
-
if ( options->do_nans )
{
@@ -5666,21 +5648,15 @@ hbool_t equal_float(float value, float expected, diff_opt_t *options)
}
}
- BOTH_ZERO(value,expected)
- if (both_zero)
- return TRUE;
-
- IS_ZERO(expected)
- if (is_zero)
- return(equal_float(expected,value,options));
-
if (value == expected)
return TRUE;
- if ( ABS( (value-expected) / expected) < H5DIFF_FLT_EPSILON)
- return TRUE;
- else
- return FALSE;
+ if (options->use_system_epsilon) {
+ if ( ABS( (value-expected) / expected) < FLT_EPSILON)
+ return TRUE;
+ }
+
+ return FALSE;
}