diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2009-01-14 16:29:10 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2009-01-14 16:29:10 (GMT) |
commit | 0894356a3c6e17b00c7911d8199b64eefca7aa3a (patch) | |
tree | 9e9ab954ab103b64aa6ba87da4fbe30127f4035f /tools/lib/h5diff_array.c | |
parent | e0bb475838f0c31743018e5c1c770b30b9373440 (diff) | |
download | hdf5-0894356a3c6e17b00c7911d8199b64eefca7aa3a.zip hdf5-0894356a3c6e17b00c7911d8199b64eefca7aa3a.tar.gz hdf5-0894356a3c6e17b00c7911d8199b64eefca7aa3a.tar.bz2 |
[svn-r16311] Description:
Bring revisions 16280:16307 back from trunk.
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (jam) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/Intel compilers w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
Mac OS X/32 10.5.6 (amazon) in debug mode
Mac OS X/32 10.5.6 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
Diffstat (limited to 'tools/lib/h5diff_array.c')
-rw-r--r-- | tools/lib/h5diff_array.c | 206 |
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; |