summaryrefslogtreecommitdiffstats
path: root/tools/lib/h5diff_array.c
diff options
context:
space:
mode:
authorPeter Cao <xcao@hdfgroup.org>2009-09-11 20:09:34 (GMT)
committerPeter Cao <xcao@hdfgroup.org>2009-09-11 20:09:34 (GMT)
commit5f3a7254c11733038f595f4af4b0ecbbdac2ab2b (patch)
tree4032c779e5a8abf2fbbc8a16b983dba6179b7f05 /tools/lib/h5diff_array.c
parentf41b8ab87bfc9702f12a3df10911960731556bed (diff)
downloadhdf5-5f3a7254c11733038f595f4af4b0ecbbdac2ab2b.zip
hdf5-5f3a7254c11733038f595f4af4b0ecbbdac2ab2b.tar.gz
hdf5-5f3a7254c11733038f595f4af4b0ecbbdac2ab2b.tar.bz2
[svn-r17466] " Use strict equality as default
" Use "--use-system-epsilon" for system EPSILON " Use "-p" or "-d" for whatever user's choice of epsilon " Use "-p 0" or "-d 0" for strict equality (same as default)
Diffstat (limited to 'tools/lib/h5diff_array.c')
-rw-r--r--tools/lib/h5diff_array.c76
1 files changed, 26 insertions, 50 deletions
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;
}