summaryrefslogtreecommitdiffstats
path: root/tools/lib/h5diff_array.c
diff options
context:
space:
mode:
authorPedro Vicente Nunes <pvn@hdfgroup.org>2009-01-13 16:33:31 (GMT)
committerPedro Vicente Nunes <pvn@hdfgroup.org>2009-01-13 16:33:31 (GMT)
commit108699a7a8e3fd459cf29ac1dea9a9623de9a561 (patch)
tree14c3d606767b364664c3d5ee1abe5e06614a0edd /tools/lib/h5diff_array.c
parent050ded21d307de35b0394614aa0962e8bca2f850 (diff)
downloadhdf5-108699a7a8e3fd459cf29ac1dea9a9623de9a561.zip
hdf5-108699a7a8e3fd459cf29ac1dea9a9623de9a561.tar.gz
hdf5-108699a7a8e3fd459cf29ac1dea9a9623de9a561.tar.bz2
[svn-r16300] Added an option to avoid dealing with NaNs
-N, --nan Avoid NaNs detection Note: there is no shell script run for datasets with NaN because the output is non portable (different results and NaN strings for different systems) Tested: windows, linux
Diffstat (limited to 'tools/lib/h5diff_array.c')
-rw-r--r--tools/lib/h5diff_array.c206
1 files changed, 111 insertions, 95 deletions
diff --git a/tools/lib/h5diff_array.c b/tools/lib/h5diff_array.c
index 5d187cd..e5f065c 100644
--- a/tools/lib/h5diff_array.c
+++ b/tools/lib/h5diff_array.c
@@ -141,10 +141,10 @@ static hbool_t all_zero(const void *_mem, size_t size);
static int ull2float(unsigned long_long ull_value, float *f_value);
static hsize_t character_compare(unsigned char *mem1,unsigned char *mem2,hsize_t i,unsigned u,int rank,hsize_t *dims,hsize_t *acc,hsize_t *pos,diff_opt_t *options,const char *obj1,const char *obj2,int *ph);
static hsize_t character_compare_opt(unsigned char *mem1,unsigned char *mem2,hsize_t i,int rank,hsize_t *dims,hsize_t *acc,hsize_t *pos,diff_opt_t *options,const char *obj1,const char *obj2,int *ph);
-static hbool_t equal_float(float value, float expected);
-static hbool_t equal_double(double value, double expected);
+static hbool_t equal_float(float value, float expected, diff_opt_t *options);
+static hbool_t equal_double(double value, double expected, diff_opt_t *options);
#if H5_SIZEOF_LONG_DOUBLE !=0
-static hbool_t equal_ldouble(long double value, long double expected);
+static hbool_t equal_ldouble(long double value, long double expected, diff_opt_t *options);
#endif
static int print_data(diff_opt_t *options);
static void print_pos(int *ph,int pp,hsize_t curr_pos,hsize_t *acc,hsize_t *pos,int rank,hsize_t *dims,const char *obj1,const char *obj2 );
@@ -1970,7 +1970,7 @@ hsize_t diff_datum(void *_mem1,
* no -d and -p
*-------------------------------------------------------------------------
*/
- else if (equal_float(temp1_float,temp2_float)==FALSE)
+ else if (equal_float(temp1_float,temp2_float,options)==FALSE)
{
if ( print_data(options) )
@@ -2139,7 +2139,7 @@ hsize_t diff_datum(void *_mem1,
* no -d and -p
*-------------------------------------------------------------------------
*/
- else if (equal_double(temp1_double,temp2_double)==FALSE)
+ else if (equal_double(temp1_double,temp2_double,options)==FALSE)
{
if ( print_data(options) )
{
@@ -2310,7 +2310,7 @@ hsize_t diff_datum(void *_mem1,
* no -d and -p
*-------------------------------------------------------------------------
*/
- else if (equal_ldouble(temp1_double,temp2_double)==FALSE)
+ else if (equal_ldouble(temp1_double,temp2_double,options)==FALSE)
{
if ( print_data(options) )
{
@@ -2931,7 +2931,7 @@ hsize_t diff_float(unsigned char *mem1,
memcpy(&temp2_float, mem2, sizeof(float));
- if (equal_float(temp1_float,temp2_float)==FALSE)
+ if (equal_float(temp1_float,temp2_float,options)==FALSE)
{
if ( print_data(options) )
{
@@ -3114,7 +3114,7 @@ hsize_t diff_double(unsigned char *mem1,
memcpy(&temp1_double, mem1, sizeof(double));
memcpy(&temp2_double, mem2, sizeof(double));
- if (equal_double(temp1_double,temp2_double)==FALSE)
+ if (equal_double(temp1_double,temp2_double,options)==FALSE)
{
if ( print_data(options) )
{
@@ -3293,7 +3293,7 @@ hsize_t diff_ldouble(unsigned char *mem1,
memcpy(&temp1_double, mem1, sizeof(long double));
memcpy(&temp2_double, mem2, sizeof(long double));
- if (equal_ldouble(temp1_double,temp2_double)==FALSE)
+ if (equal_ldouble(temp1_double,temp2_double,options)==FALSE)
{
if ( print_data(options) )
{
@@ -5183,48 +5183,53 @@ error:
*-------------------------------------------------------------------------
*/
static
-hbool_t equal_double(double value, double expected)
+hbool_t equal_double(double value, double expected, diff_opt_t *options)
{
int both_zero;
int is_zero;
-/*-------------------------------------------------------------------------
- * detect NaNs
- *-------------------------------------------------------------------------
- */
- int isnan1 = my_isnan(FLT_DOUBLE,&value);
- int isnan2 = my_isnan(FLT_DOUBLE,&expected);
-
- /*-------------------------------------------------------------------------
- * we consider NaN == NaN to be true
- *-------------------------------------------------------------------------
- */
- if ( isnan1 && isnan2 )
- {
- return TRUE;
- }
- /*-------------------------------------------------------------------------
- * one is a NaN, do not compare but assume difference
- *-------------------------------------------------------------------------
- */
- if ( (isnan1 && !isnan2) || ( !isnan1 && isnan2 ) )
+ if ( options->do_nans )
{
- return FALSE;
+
+ /*-------------------------------------------------------------------------
+ * detect NaNs
+ *-------------------------------------------------------------------------
+ */
+ int isnan1 = my_isnan(FLT_DOUBLE,&value);
+ int isnan2 = my_isnan(FLT_DOUBLE,&expected);
+
+ /*-------------------------------------------------------------------------
+ * we consider NaN == NaN to be true
+ *-------------------------------------------------------------------------
+ */
+ if ( isnan1 && isnan2 )
+ {
+ return TRUE;
+ }
+
+ /*-------------------------------------------------------------------------
+ * one is a NaN, do not compare but assume difference
+ *-------------------------------------------------------------------------
+ */
+ if ( (isnan1 && !isnan2) || ( !isnan1 && isnan2 ) )
+ {
+ return FALSE;
+ }
+
+ /*-------------------------------------------------------------------------
+ * both are not NaNs, compare
+ *-------------------------------------------------------------------------
+ */
}
- /*-------------------------------------------------------------------------
- * both are not NaNs, compare
- *-------------------------------------------------------------------------
- */
-
BOTH_ZERO(value,expected)
if (both_zero)
return TRUE;
IS_ZERO(expected)
if (is_zero)
- return(equal_double(expected,value));
+ return(equal_double(expected,value,options));
if ( ABS( (value-expected) / expected) < H5DIFF_DBL_EPSILON)
return TRUE;
@@ -5244,48 +5249,54 @@ hbool_t equal_double(double value, double expected)
#if H5_SIZEOF_LONG_DOUBLE !=0
static
-hbool_t equal_ldouble(long double value, long double expected)
+hbool_t equal_ldouble(long double value, long double expected, diff_opt_t *options)
{
int both_zero;
int is_zero;
-/*-------------------------------------------------------------------------
- * detect NaNs
- *-------------------------------------------------------------------------
- */
- int isnan1 = my_isnan(FLT_LDOUBLE,&value);
- int isnan2 = my_isnan(FLT_LDOUBLE,&expected);
-
- /*-------------------------------------------------------------------------
- * we consider NaN == NaN to be true
- *-------------------------------------------------------------------------
- */
- if ( isnan1 && isnan2 )
- {
- return TRUE;
- }
-
- /*-------------------------------------------------------------------------
- * one is a NaN, do not compare but assume difference
- *-------------------------------------------------------------------------
- */
- if ( (isnan1 && !isnan2) || ( !isnan1 && isnan2 ) )
+
+ if ( options->do_nans )
{
- return FALSE;
+
+ /*-------------------------------------------------------------------------
+ * detect NaNs
+ *-------------------------------------------------------------------------
+ */
+ int isnan1 = my_isnan(FLT_LDOUBLE,&value);
+ int isnan2 = my_isnan(FLT_LDOUBLE,&expected);
+
+ /*-------------------------------------------------------------------------
+ * we consider NaN == NaN to be true
+ *-------------------------------------------------------------------------
+ */
+ if ( isnan1 && isnan2 )
+ {
+ return TRUE;
+ }
+
+ /*-------------------------------------------------------------------------
+ * one is a NaN, do not compare but assume difference
+ *-------------------------------------------------------------------------
+ */
+ if ( (isnan1 && !isnan2) || ( !isnan1 && isnan2 ) )
+ {
+ return FALSE;
+ }
+
+ /*-------------------------------------------------------------------------
+ * both are not NaNs, compare
+ *-------------------------------------------------------------------------
+ */
+
}
- /*-------------------------------------------------------------------------
- * both are not NaNs, compare
- *-------------------------------------------------------------------------
- */
-
BOTH_ZERO(value,expected)
if (both_zero)
return TRUE;
IS_ZERO(expected)
if (is_zero)
- return(equal_ldouble(expected,value));
+ return(equal_ldouble(expected,value,options));
if ( ABS( (value-expected) / expected) < H5DIFF_DBL_EPSILON)
return TRUE;
@@ -5309,48 +5320,53 @@ hbool_t equal_ldouble(long double value, long double expected)
*-------------------------------------------------------------------------
*/
static
-hbool_t equal_float(float value, float expected)
+hbool_t equal_float(float value, float expected, diff_opt_t *options)
{
int both_zero;
int is_zero;
-/*-------------------------------------------------------------------------
- * detect NaNs
- *-------------------------------------------------------------------------
- */
- int isnan1 = my_isnan(FLT_FLOAT,&value);
- int isnan2 = my_isnan(FLT_FLOAT,&expected);
-
- /*-------------------------------------------------------------------------
- * we consider NaN == NaN to be true
- *-------------------------------------------------------------------------
- */
- if ( isnan1 && isnan2 )
+ if ( options->do_nans )
{
- return TRUE;
- }
-
- /*-------------------------------------------------------------------------
- * one is a NaN, do not compare but assume difference
- *-------------------------------------------------------------------------
- */
- if ( (isnan1 && !isnan2) || ( !isnan1 && isnan2 ) )
- {
- return FALSE;
+
+ /*-------------------------------------------------------------------------
+ * detect NaNs
+ *-------------------------------------------------------------------------
+ */
+ int isnan1 = my_isnan(FLT_FLOAT,&value);
+ int isnan2 = my_isnan(FLT_FLOAT,&expected);
+
+ /*-------------------------------------------------------------------------
+ * we consider NaN == NaN to be true
+ *-------------------------------------------------------------------------
+ */
+ if ( isnan1 && isnan2 )
+ {
+ return TRUE;
+ }
+
+ /*-------------------------------------------------------------------------
+ * one is a NaN, do not compare but assume difference
+ *-------------------------------------------------------------------------
+ */
+ if ( (isnan1 && !isnan2) || ( !isnan1 && isnan2 ) )
+ {
+ return FALSE;
+ }
+
+ /*-------------------------------------------------------------------------
+ * both are not NaNs, compare
+ *-------------------------------------------------------------------------
+ */
+
}
- /*-------------------------------------------------------------------------
- * both are not NaNs, compare
- *-------------------------------------------------------------------------
- */
-
BOTH_ZERO(value,expected)
if (both_zero)
return TRUE;
IS_ZERO(expected)
if (is_zero)
- return(equal_float(expected,value));
+ return(equal_float(expected,value,options));
if ( ABS( (value-expected) / expected) < H5DIFF_FLT_EPSILON)
return TRUE;