From d467c2ce717d4633185b063b58eff262126749b7 Mon Sep 17 00:00:00 2001 From: Jonathan Kim Date: Tue, 29 Mar 2011 11:20:19 -0500 Subject: [svn-r20369] Purpose: Fixed Bug 2184 - GMQS: h5diff - incorrect calculation code for --use-system-epsilon option Description: Fixed h5diff for --use-system-epsilon option: the calculation changed from ( |a - b| / b ) to ( |a - b| ). This was decided for better performance and was corrected only in HDF5 trunk, so 1.8 got updated. Also comments for equal_XXX() function were updated correctly. Also help page and RM got updated correctly. Also add test cases for testing the differences w/wo the option. Tested: jam (linux32-LE), amani (linux64-LE), heiwa (linuxppc64-BE), tejeda (mac32-LE), linew (solaris-BE), Windows (32-LE) --- MANIFEST | 9 ++++++-- release_docs/RELEASE.txt | 3 +++ tools/h5diff/CMakeLists.txt | 39 ++++++++++++++++++++++++++++++++ tools/h5diff/h5diff_common.c | 12 +++------- tools/h5diff/h5diffgentest.c | 15 ++++++++---- tools/h5diff/testfiles/h5diff_10.txt | 12 +++------- tools/h5diff/testfiles/h5diff_101.txt | 11 +++++---- tools/h5diff/testfiles/h5diff_101w.txt | 11 +++++---- tools/h5diff/testfiles/h5diff_102.txt | 8 +++---- tools/h5diff/testfiles/h5diff_102w.txt | 8 +++---- tools/h5diff/testfiles/h5diff_103.txt | 8 +++++++ tools/h5diff/testfiles/h5diff_103w.txt | 8 +++++++ tools/h5diff/testfiles/h5diff_104.txt | 8 +++++++ tools/h5diff/testfiles/h5diff_104w.txt | 8 +++++++ tools/h5diff/testfiles/h5diff_600.txt | 12 +++------- tools/h5diff/testfiles/h5diff_603.txt | 12 +++------- tools/h5diff/testfiles/h5diff_606.txt | 12 +++------- tools/h5diff/testfiles/h5diff_612.txt | 12 +++------- tools/h5diff/testfiles/h5diff_615.txt | 12 +++------- tools/h5diff/testfiles/h5diff_621.txt | 12 +++------- tools/h5diff/testfiles/h5diff_622.txt | 12 +++------- tools/h5diff/testfiles/h5diff_623.txt | 12 +++------- tools/h5diff/testfiles/h5diff_624.txt | 12 +++------- tools/h5diff/testfiles/h5diff_basic1.h5 | Bin 11432 -> 11432 bytes tools/h5diff/testh5diff.sh | 8 +++++++ tools/lib/h5diff_array.c | 10 ++++---- windows/tools/h5diff/testh5diff.bat | 14 ++++++++++-- 27 files changed, 169 insertions(+), 131 deletions(-) create mode 100644 tools/h5diff/testfiles/h5diff_103.txt create mode 100644 tools/h5diff/testfiles/h5diff_103w.txt create mode 100644 tools/h5diff/testfiles/h5diff_104.txt create mode 100644 tools/h5diff/testfiles/h5diff_104w.txt diff --git a/MANIFEST b/MANIFEST index a11202e..65ed101 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1608,6 +1608,13 @@ ./tools/h5diff/testfiles/h5diff_100.txt ./tools/h5diff/testfiles/h5diff_101.txt ./tools/h5diff/testfiles/h5diff_102.txt +./tools/h5diff/testfiles/h5diff_103.txt +./tools/h5diff/testfiles/h5diff_104.txt +# w for Windows-specific +./tools/h5diff/testfiles/h5diff_101w.txt +./tools/h5diff/testfiles/h5diff_102w.txt +./tools/h5diff/testfiles/h5diff_103w.txt +./tools/h5diff/testfiles/h5diff_104w.txt ./tools/h5diff/testfiles/h5diff_200.txt ./tools/h5diff/testfiles/h5diff_201.txt ./tools/h5diff/testfiles/h5diff_202.txt @@ -2039,8 +2046,6 @@ ./tools/CMakeLists.txt ./tools/h5copy/CMakeLists.txt ./tools/h5diff/CMakeLists.txt -./tools/h5diff/testfiles/h5diff_101w.txt -./tools/h5diff/testfiles/h5diff_102w.txt ./tools/h5dump/CMakeLists.txt ./tools/h5import/CMakeLists.txt ./tools/h5jam/CMakeLists.txt diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index 0db8671..60f0fcb 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -132,6 +132,9 @@ Bug Fixes since HDF5-1.8.6 Tools ----- + - Fix h5diff for --use-system-epsilon option: the calculation changed + from ( |a - b| / b ) to ( |a - b| ). This was decided for better + performance. Bug#2184 (JKM 2011/3/24) - Fixed output for H5T_REFERENCE in h5dump. According to the BNF document the output of a H5T_REFERENCE should be followed by the type; ::= H5T_REFERENCE { } diff --git a/tools/h5diff/CMakeLists.txt b/tools/h5diff/CMakeLists.txt index 48ba8e6..97c3a3c 100644 --- a/tools/h5diff/CMakeLists.txt +++ b/tools/h5diff/CMakeLists.txt @@ -45,6 +45,8 @@ IF (BUILD_TESTING) h5diff_100.txt #h5diff_101.txt #h5diff_102.txt + #h5diff_103.txt + #h5diff_104.txt h5diff_11.txt h5diff_12.txt h5diff_13.txt @@ -260,6 +262,19 @@ IF (BUILD_TESTING) COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${HDF5_TOOLS_H5DIFF_SOURCE_DIR}/testfiles/h5diff_102w.txt ${PROJECT_BINARY_DIR}/h5diff_102.txt ) + ADD_CUSTOM_COMMAND ( + TARGET h5diff + POST_BUILD + COMMAND ${CMAKE_COMMAND} + ARGS -E copy_if_different ${HDF5_TOOLS_H5DIFF_SOURCE_DIR}/testfiles/h5diff_103w.txt ${PROJECT_BINARY_DIR}/h5diff_103.txt + ) + + ADD_CUSTOM_COMMAND ( + TARGET h5diff + POST_BUILD + COMMAND ${CMAKE_COMMAND} + ARGS -E copy_if_different ${HDF5_TOOLS_H5DIFF_SOURCE_DIR}/testfiles/h5diff_104w.txt ${PROJECT_BINARY_DIR}/h5diff_104.txt + ) ELSE (WIN32 AND NOT CYGWIN) ADD_CUSTOM_COMMAND ( TARGET h5diff @@ -274,6 +289,19 @@ IF (BUILD_TESTING) COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${HDF5_TOOLS_H5DIFF_SOURCE_DIR}/testfiles/h5diff_102.txt ${PROJECT_BINARY_DIR}/h5diff_102.txt ) + ADD_CUSTOM_COMMAND ( + TARGET h5diff + POST_BUILD + COMMAND ${CMAKE_COMMAND} + ARGS -E copy_if_different ${HDF5_TOOLS_H5DIFF_SOURCE_DIR}/testfiles/h5diff_103.txt ${PROJECT_BINARY_DIR}/h5diff_103.txt + ) + + ADD_CUSTOM_COMMAND ( + TARGET h5diff + POST_BUILD + COMMAND ${CMAKE_COMMAND} + ARGS -E copy_if_different ${HDF5_TOOLS_H5DIFF_SOURCE_DIR}/testfiles/h5diff_104.txt ${PROJECT_BINARY_DIR}/h5diff_104.txt + ) ENDIF (WIN32 AND NOT CYGWIN) ############################################################################## @@ -371,6 +399,10 @@ IF (BUILD_TESTING) h5diff_101.out.err h5diff_102.out h5diff_102.out.err + h5diff_103.out + h5diff_103.out.err + h5diff_104.out + h5diff_104.out.err h5diff_11.out h5diff_11.out.err h5diff_12.out @@ -935,6 +967,13 @@ ADD_H5_TEST (h5diff_101 1 -v ${FILE1} ${FILE1} g1/d1 g1/d2) ADD_H5_TEST (h5diff_102 1 -v ${FILE1} ${FILE1} g1/fp1 g1/fp2) +# with --use-system-epsilon for double value. expect less differences +ADD_H5_TEST (h5diff_103 1 -v --use-system-epsilon ${FILE1} ${FILE1} g1/d1 +g1/d2) + +# with --use-system-epsilon for float value. expect less differences +ADD_H5_TEST (h5diff_104 1 -v --use-system-epsilon ${FILE1} ${FILE1} g1/fp1 +g1/fp2) # not comparable -c flag ADD_H5_TEST (h5diff_200 0 ${FILE2} ${FILE2} g2/dset1 g2/dset2) diff --git a/tools/h5diff/h5diff_common.c b/tools/h5diff/h5diff_common.c index da420b0..e0af7f6 100644 --- a/tools/h5diff/h5diff_common.c +++ b/tools/h5diff/h5diff_common.c @@ -485,17 +485,11 @@ void usage(void) printf(" number.\n"); printf(" -p R, --relative=R Print difference if (|(a-b)/b| > R), R is a positive\n"); printf(" number.\n"); - printf(" --use-system-epsilon Print difference if (|a-b| > EPSILON),\n"); - printf(" where EPSILON (FLT_EPSILON or FLT_EPSILON) is the\n"); - printf(" system epsilon value. \n"); - printf(" If the system epsilon is not defined, use the value\n"); - printf(" below:\n"); + printf(" --use-system-epsilon Print difference if (|a-b| > EPSILON), EPSILON is\n"); + printf(" a system epsilon value.\n"); + printf(" The system epsilon values are defined as below:\n"); printf(" FLT_EPSILON = 1.19209E-07 for float\n"); printf(" DBL_EPSILON = 2.22045E-16 for double\n"); - printf(" -d, -p, and --use-system-epsilon options are used for\n"); - printf(" comparing floating point values.\n"); - printf(" By default, strict equality is used. Use -p or -d to\n"); - printf(" set specific tolerance.\n"); printf(" --exclude-path \"path\" Exclude the specified path to an object when\n"); printf(" comparing files or groups. If a group is excluded,\n"); printf(" all member objects will also be excluded.\n"); diff --git a/tools/h5diff/h5diffgentest.c b/tools/h5diff/h5diffgentest.c index dcfe76a..66f1ce8 100644 --- a/tools/h5diff/h5diffgentest.c +++ b/tools/h5diff/h5diffgentest.c @@ -312,11 +312,16 @@ int test_basic(const char *fname1, const char *fname2, const char *fname3) *------------------------------------------------------------------------- */ { - /* epsilon = 0.00001 */ - float data11[3][2] ={{0.00000f,0.00001f},{0.00001f, 0.00000f},{0.00001f,0.00001f}}; - float data12[3][2] ={{0.00000f,0.00002f},{0.000009f,0.00001f},{0.00000f,0.00001f}}; - double data13[3][2] ={{0.000000000,0.000000001},{0.000000001, 0.000000000},{0.000000001,0.000000001}}; - double data14[3][2] ={{0.000000000,0.000000002},{0.0000000009,0.000000001},{0.000000000,0.000000001}}; + /* epsilon = 0.0000001 = 1e-7 + * system epsilon for float : FLT_EPSILON = 1.19209E-07 + */ + float data11[3][2] ={{0.000000f,0.0000001f},{0.0000001f, 0.00000022f},{0.0000001f,0.0000001f}}; + float data12[3][2] ={{0.000000f,0.0000002f},{0.0000003f,0.0000001f},{0.000000f,0.0000001f}}; + /* epsilon = 0.0000000000000001 = 1e-16 + * system epsilon for double : DBL_EPSILON = 2.22045E-16 + */ + double data13[3][2] ={{0.0000000000000000, 0.0000000000000001},{0.0000000000000001, 0.0000000000000000},{0.00000000000000033, 0.0000000000000001}}; + double data14[3][2] ={{0.0000000000000000, 0.0000000000000004},{0.0000000000000002, 0.0000000000000001},{0.0000000000000001, 0.00000000000000000}}; write_dset(gid1,2,dims2,"fp1",H5T_NATIVE_FLOAT,data11); write_dset(gid1,2,dims2,"fp2",H5T_NATIVE_FLOAT,data12); diff --git a/tools/h5diff/testfiles/h5diff_10.txt b/tools/h5diff/testfiles/h5diff_10.txt index 0b354df..8d6fc82 100644 --- a/tools/h5diff/testfiles/h5diff_10.txt +++ b/tools/h5diff/testfiles/h5diff_10.txt @@ -60,17 +60,11 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] number. -p R, --relative=R Print difference if (|(a-b)/b| > R), R is a positive number. - --use-system-epsilon Print difference if (|a-b| > EPSILON), - where EPSILON (FLT_EPSILON or FLT_EPSILON) is the - system epsilon value. - If the system epsilon is not defined, use the value - below: + --use-system-epsilon Print difference if (|a-b| > EPSILON), EPSILON is + a system epsilon value. + The system epsilon values are defined as below: FLT_EPSILON = 1.19209E-07 for float DBL_EPSILON = 2.22045E-16 for double - -d, -p, and --use-system-epsilon options are used for - comparing floating point values. - By default, strict equality is used. Use -p or -d to - set specific tolerance. --exclude-path "path" Exclude the specified path to an object when comparing files or groups. If a group is excluded, all member objects will also be excluded. diff --git a/tools/h5diff/testfiles/h5diff_101.txt b/tools/h5diff/testfiles/h5diff_101.txt index 1d0f38d..f915439 100644 --- a/tools/h5diff/testfiles/h5diff_101.txt +++ b/tools/h5diff/testfiles/h5diff_101.txt @@ -2,9 +2,10 @@ dataset: and size: [3x2] [3x2] position d1 d2 difference ------------------------------------------------------------ -[ 0 1 ] 1e-09 2e-09 1e-09 -[ 1 0 ] 1e-09 9e-10 1e-10 -[ 1 1 ] 0 1e-09 1e-09 -[ 2 0 ] 1e-09 0 1e-09 -4 differences found +[ 0 1 ] 1e-16 4e-16 3e-16 +[ 1 0 ] 1e-16 2e-16 1e-16 +[ 1 1 ] 0 1e-16 1e-16 +[ 2 0 ] 3.3e-16 1e-16 2.3e-16 +[ 2 1 ] 1e-16 0 1e-16 +5 differences found EXIT CODE: 1 diff --git a/tools/h5diff/testfiles/h5diff_101w.txt b/tools/h5diff/testfiles/h5diff_101w.txt index 59176a2..d1f49da 100755 --- a/tools/h5diff/testfiles/h5diff_101w.txt +++ b/tools/h5diff/testfiles/h5diff_101w.txt @@ -2,9 +2,10 @@ dataset: and size: [3x2] [3x2] position d1 d2 difference ------------------------------------------------------------ -[ 0 1 ] 1e-009 2e-009 1e-009 -[ 1 0 ] 1e-009 9e-010 1e-010 -[ 1 1 ] 0 1e-009 1e-009 -[ 2 0 ] 1e-009 0 1e-009 -4 differences found +[ 0 1 ] 1e-016 4e-016 3e-016 +[ 1 0 ] 1e-016 2e-016 1e-016 +[ 1 1 ] 0 1e-016 1e-016 +[ 2 0 ] 3.3e-016 1e-016 2.3e-016 +[ 2 1 ] 1e-016 0 1e-016 +5 differences found EXIT CODE: 1 diff --git a/tools/h5diff/testfiles/h5diff_102.txt b/tools/h5diff/testfiles/h5diff_102.txt index 30a2491..476067b 100644 --- a/tools/h5diff/testfiles/h5diff_102.txt +++ b/tools/h5diff/testfiles/h5diff_102.txt @@ -2,9 +2,9 @@ dataset: and size: [3x2] [3x2] position fp1 fp2 difference ------------------------------------------------------------ -[ 0 1 ] 1e-05 2e-05 1e-05 -[ 1 0 ] 1e-05 9e-06 9.99999e-07 -[ 1 1 ] 0 1e-05 1e-05 -[ 2 0 ] 1e-05 0 1e-05 +[ 0 1 ] 1e-07 2e-07 1e-07 +[ 1 0 ] 1e-07 3e-07 2e-07 +[ 1 1 ] 2.2e-07 1e-07 1.2e-07 +[ 2 0 ] 1e-07 0 1e-07 4 differences found EXIT CODE: 1 diff --git a/tools/h5diff/testfiles/h5diff_102w.txt b/tools/h5diff/testfiles/h5diff_102w.txt index 36a254e..dda3581 100755 --- a/tools/h5diff/testfiles/h5diff_102w.txt +++ b/tools/h5diff/testfiles/h5diff_102w.txt @@ -2,9 +2,9 @@ dataset: and size: [3x2] [3x2] position fp1 fp2 difference ------------------------------------------------------------ -[ 0 1 ] 1e-005 2e-005 1e-005 -[ 1 0 ] 1e-005 9e-006 9.99999e-007 -[ 1 1 ] 0 1e-005 1e-005 -[ 2 0 ] 1e-005 0 1e-005 +[ 0 1 ] 1e-007 2e-007 1e-007 +[ 1 0 ] 1e-007 3e-007 2e-007 +[ 1 1 ] 2.2e-007 1e-007 1.2e-007 +[ 2 0 ] 1e-007 0 1e-007 4 differences found EXIT CODE: 1 diff --git a/tools/h5diff/testfiles/h5diff_103.txt b/tools/h5diff/testfiles/h5diff_103.txt new file mode 100644 index 0000000..5700459 --- /dev/null +++ b/tools/h5diff/testfiles/h5diff_103.txt @@ -0,0 +1,8 @@ +dataset: and +size: [3x2] [3x2] +position d1 d2 difference +------------------------------------------------------------ +[ 0 1 ] 1e-16 4e-16 3e-16 +[ 2 0 ] 3.3e-16 1e-16 2.3e-16 +2 differences found +EXIT CODE: 1 diff --git a/tools/h5diff/testfiles/h5diff_103w.txt b/tools/h5diff/testfiles/h5diff_103w.txt new file mode 100644 index 0000000..b1abea2 --- /dev/null +++ b/tools/h5diff/testfiles/h5diff_103w.txt @@ -0,0 +1,8 @@ +dataset: and +size: [3x2] [3x2] +position d1 d2 difference +------------------------------------------------------------ +[ 0 1 ] 1e-016 4e-016 3e-016 +[ 2 0 ] 3.3e-016 1e-016 2.3e-016 +2 differences found +EXIT CODE: 1 diff --git a/tools/h5diff/testfiles/h5diff_104.txt b/tools/h5diff/testfiles/h5diff_104.txt new file mode 100644 index 0000000..2997f10 --- /dev/null +++ b/tools/h5diff/testfiles/h5diff_104.txt @@ -0,0 +1,8 @@ +dataset: and +size: [3x2] [3x2] +position fp1 fp2 difference +------------------------------------------------------------ +[ 1 0 ] 1e-07 3e-07 2e-07 +[ 1 1 ] 2.2e-07 1e-07 1.2e-07 +2 differences found +EXIT CODE: 1 diff --git a/tools/h5diff/testfiles/h5diff_104w.txt b/tools/h5diff/testfiles/h5diff_104w.txt new file mode 100644 index 0000000..28ef705 --- /dev/null +++ b/tools/h5diff/testfiles/h5diff_104w.txt @@ -0,0 +1,8 @@ +dataset: and +size: [3x2] [3x2] +position fp1 fp2 difference +------------------------------------------------------------ +[ 1 0 ] 1e-007 3e-007 2e-007 +[ 1 1 ] 2.2e-007 1e-007 1.2e-007 +2 differences found +EXIT CODE: 1 diff --git a/tools/h5diff/testfiles/h5diff_600.txt b/tools/h5diff/testfiles/h5diff_600.txt index efc05a8..e6e4607 100644 --- a/tools/h5diff/testfiles/h5diff_600.txt +++ b/tools/h5diff/testfiles/h5diff_600.txt @@ -60,17 +60,11 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] number. -p R, --relative=R Print difference if (|(a-b)/b| > R), R is a positive number. - --use-system-epsilon Print difference if (|a-b| > EPSILON), - where EPSILON (FLT_EPSILON or FLT_EPSILON) is the - system epsilon value. - If the system epsilon is not defined, use the value - below: + --use-system-epsilon Print difference if (|a-b| > EPSILON), EPSILON is + a system epsilon value. + The system epsilon values are defined as below: FLT_EPSILON = 1.19209E-07 for float DBL_EPSILON = 2.22045E-16 for double - -d, -p, and --use-system-epsilon options are used for - comparing floating point values. - By default, strict equality is used. Use -p or -d to - set specific tolerance. --exclude-path "path" Exclude the specified path to an object when comparing files or groups. If a group is excluded, all member objects will also be excluded. diff --git a/tools/h5diff/testfiles/h5diff_603.txt b/tools/h5diff/testfiles/h5diff_603.txt index c66c650..7b917d4 100644 --- a/tools/h5diff/testfiles/h5diff_603.txt +++ b/tools/h5diff/testfiles/h5diff_603.txt @@ -61,17 +61,11 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] number. -p R, --relative=R Print difference if (|(a-b)/b| > R), R is a positive number. - --use-system-epsilon Print difference if (|a-b| > EPSILON), - where EPSILON (FLT_EPSILON or FLT_EPSILON) is the - system epsilon value. - If the system epsilon is not defined, use the value - below: + --use-system-epsilon Print difference if (|a-b| > EPSILON), EPSILON is + a system epsilon value. + The system epsilon values are defined as below: FLT_EPSILON = 1.19209E-07 for float DBL_EPSILON = 2.22045E-16 for double - -d, -p, and --use-system-epsilon options are used for - comparing floating point values. - By default, strict equality is used. Use -p or -d to - set specific tolerance. --exclude-path "path" Exclude the specified path to an object when comparing files or groups. If a group is excluded, all member objects will also be excluded. diff --git a/tools/h5diff/testfiles/h5diff_606.txt b/tools/h5diff/testfiles/h5diff_606.txt index 705ae3e..110986a 100644 --- a/tools/h5diff/testfiles/h5diff_606.txt +++ b/tools/h5diff/testfiles/h5diff_606.txt @@ -61,17 +61,11 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] number. -p R, --relative=R Print difference if (|(a-b)/b| > R), R is a positive number. - --use-system-epsilon Print difference if (|a-b| > EPSILON), - where EPSILON (FLT_EPSILON or FLT_EPSILON) is the - system epsilon value. - If the system epsilon is not defined, use the value - below: + --use-system-epsilon Print difference if (|a-b| > EPSILON), EPSILON is + a system epsilon value. + The system epsilon values are defined as below: FLT_EPSILON = 1.19209E-07 for float DBL_EPSILON = 2.22045E-16 for double - -d, -p, and --use-system-epsilon options are used for - comparing floating point values. - By default, strict equality is used. Use -p or -d to - set specific tolerance. --exclude-path "path" Exclude the specified path to an object when comparing files or groups. If a group is excluded, all member objects will also be excluded. diff --git a/tools/h5diff/testfiles/h5diff_612.txt b/tools/h5diff/testfiles/h5diff_612.txt index d38e9d4..782f5b4 100644 --- a/tools/h5diff/testfiles/h5diff_612.txt +++ b/tools/h5diff/testfiles/h5diff_612.txt @@ -61,17 +61,11 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] number. -p R, --relative=R Print difference if (|(a-b)/b| > R), R is a positive number. - --use-system-epsilon Print difference if (|a-b| > EPSILON), - where EPSILON (FLT_EPSILON or FLT_EPSILON) is the - system epsilon value. - If the system epsilon is not defined, use the value - below: + --use-system-epsilon Print difference if (|a-b| > EPSILON), EPSILON is + a system epsilon value. + The system epsilon values are defined as below: FLT_EPSILON = 1.19209E-07 for float DBL_EPSILON = 2.22045E-16 for double - -d, -p, and --use-system-epsilon options are used for - comparing floating point values. - By default, strict equality is used. Use -p or -d to - set specific tolerance. --exclude-path "path" Exclude the specified path to an object when comparing files or groups. If a group is excluded, all member objects will also be excluded. diff --git a/tools/h5diff/testfiles/h5diff_615.txt b/tools/h5diff/testfiles/h5diff_615.txt index 4b95ea1..f816510 100644 --- a/tools/h5diff/testfiles/h5diff_615.txt +++ b/tools/h5diff/testfiles/h5diff_615.txt @@ -61,17 +61,11 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] number. -p R, --relative=R Print difference if (|(a-b)/b| > R), R is a positive number. - --use-system-epsilon Print difference if (|a-b| > EPSILON), - where EPSILON (FLT_EPSILON or FLT_EPSILON) is the - system epsilon value. - If the system epsilon is not defined, use the value - below: + --use-system-epsilon Print difference if (|a-b| > EPSILON), EPSILON is + a system epsilon value. + The system epsilon values are defined as below: FLT_EPSILON = 1.19209E-07 for float DBL_EPSILON = 2.22045E-16 for double - -d, -p, and --use-system-epsilon options are used for - comparing floating point values. - By default, strict equality is used. Use -p or -d to - set specific tolerance. --exclude-path "path" Exclude the specified path to an object when comparing files or groups. If a group is excluded, all member objects will also be excluded. diff --git a/tools/h5diff/testfiles/h5diff_621.txt b/tools/h5diff/testfiles/h5diff_621.txt index 56ed724..8dc8824 100644 --- a/tools/h5diff/testfiles/h5diff_621.txt +++ b/tools/h5diff/testfiles/h5diff_621.txt @@ -61,17 +61,11 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] number. -p R, --relative=R Print difference if (|(a-b)/b| > R), R is a positive number. - --use-system-epsilon Print difference if (|a-b| > EPSILON), - where EPSILON (FLT_EPSILON or FLT_EPSILON) is the - system epsilon value. - If the system epsilon is not defined, use the value - below: + --use-system-epsilon Print difference if (|a-b| > EPSILON), EPSILON is + a system epsilon value. + The system epsilon values are defined as below: FLT_EPSILON = 1.19209E-07 for float DBL_EPSILON = 2.22045E-16 for double - -d, -p, and --use-system-epsilon options are used for - comparing floating point values. - By default, strict equality is used. Use -p or -d to - set specific tolerance. --exclude-path "path" Exclude the specified path to an object when comparing files or groups. If a group is excluded, all member objects will also be excluded. diff --git a/tools/h5diff/testfiles/h5diff_622.txt b/tools/h5diff/testfiles/h5diff_622.txt index 6e2db1b..f2f2089 100644 --- a/tools/h5diff/testfiles/h5diff_622.txt +++ b/tools/h5diff/testfiles/h5diff_622.txt @@ -61,17 +61,11 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] number. -p R, --relative=R Print difference if (|(a-b)/b| > R), R is a positive number. - --use-system-epsilon Print difference if (|a-b| > EPSILON), - where EPSILON (FLT_EPSILON or FLT_EPSILON) is the - system epsilon value. - If the system epsilon is not defined, use the value - below: + --use-system-epsilon Print difference if (|a-b| > EPSILON), EPSILON is + a system epsilon value. + The system epsilon values are defined as below: FLT_EPSILON = 1.19209E-07 for float DBL_EPSILON = 2.22045E-16 for double - -d, -p, and --use-system-epsilon options are used for - comparing floating point values. - By default, strict equality is used. Use -p or -d to - set specific tolerance. --exclude-path "path" Exclude the specified path to an object when comparing files or groups. If a group is excluded, all member objects will also be excluded. diff --git a/tools/h5diff/testfiles/h5diff_623.txt b/tools/h5diff/testfiles/h5diff_623.txt index 910f4f0..840b127 100644 --- a/tools/h5diff/testfiles/h5diff_623.txt +++ b/tools/h5diff/testfiles/h5diff_623.txt @@ -61,17 +61,11 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] number. -p R, --relative=R Print difference if (|(a-b)/b| > R), R is a positive number. - --use-system-epsilon Print difference if (|a-b| > EPSILON), - where EPSILON (FLT_EPSILON or FLT_EPSILON) is the - system epsilon value. - If the system epsilon is not defined, use the value - below: + --use-system-epsilon Print difference if (|a-b| > EPSILON), EPSILON is + a system epsilon value. + The system epsilon values are defined as below: FLT_EPSILON = 1.19209E-07 for float DBL_EPSILON = 2.22045E-16 for double - -d, -p, and --use-system-epsilon options are used for - comparing floating point values. - By default, strict equality is used. Use -p or -d to - set specific tolerance. --exclude-path "path" Exclude the specified path to an object when comparing files or groups. If a group is excluded, all member objects will also be excluded. diff --git a/tools/h5diff/testfiles/h5diff_624.txt b/tools/h5diff/testfiles/h5diff_624.txt index e301645..1d433a7 100644 --- a/tools/h5diff/testfiles/h5diff_624.txt +++ b/tools/h5diff/testfiles/h5diff_624.txt @@ -61,17 +61,11 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] number. -p R, --relative=R Print difference if (|(a-b)/b| > R), R is a positive number. - --use-system-epsilon Print difference if (|a-b| > EPSILON), - where EPSILON (FLT_EPSILON or FLT_EPSILON) is the - system epsilon value. - If the system epsilon is not defined, use the value - below: + --use-system-epsilon Print difference if (|a-b| > EPSILON), EPSILON is + a system epsilon value. + The system epsilon values are defined as below: FLT_EPSILON = 1.19209E-07 for float DBL_EPSILON = 2.22045E-16 for double - -d, -p, and --use-system-epsilon options are used for - comparing floating point values. - By default, strict equality is used. Use -p or -d to - set specific tolerance. --exclude-path "path" Exclude the specified path to an object when comparing files or groups. If a group is excluded, all member objects will also be excluded. diff --git a/tools/h5diff/testfiles/h5diff_basic1.h5 b/tools/h5diff/testfiles/h5diff_basic1.h5 index 7a0b63a..4f3cf9a 100644 Binary files a/tools/h5diff/testfiles/h5diff_basic1.h5 and b/tools/h5diff/testfiles/h5diff_basic1.h5 differ diff --git a/tools/h5diff/testh5diff.sh b/tools/h5diff/testh5diff.sh index 926ea27..1a4d5e8 100755 --- a/tools/h5diff/testh5diff.sh +++ b/tools/h5diff/testh5diff.sh @@ -601,10 +601,18 @@ else fi # 11. floating point comparison +# double value TOOLTEST h5diff_101.txt -v $FILE1 $FILE1 g1/d1 g1/d2 +# float value TOOLTEST h5diff_102.txt -v $FILE1 $FILE1 g1/fp1 g1/fp2 +# with --use-system-epsilon for double value +TOOLTEST h5diff_103.txt -v --use-system-epsilon $FILE1 $FILE1 g1/d1 g1/d2 + +# with --use-system-epsilon for float value +TOOLTEST h5diff_104.txt -v --use-system-epsilon $FILE1 $FILE1 g1/fp1 g1/fp2 + # not comparable -c flag TOOLTEST h5diff_200.txt $FILE2 $FILE2 g2/dset1 g2/dset2 diff --git a/tools/lib/h5diff_array.c b/tools/lib/h5diff_array.c index 66cd580..c4c8dbf 100644 --- a/tools/lib/h5diff_array.c +++ b/tools/lib/h5diff_array.c @@ -5550,7 +5550,7 @@ error: /*------------------------------------------------------------------------- * Function: equal_double * - * Purpose: use a relative error formula to deal with floating point + * Purpose: use a absolute error formula to deal with floating point * uncertainty * * Modifications: @@ -5604,7 +5604,7 @@ hbool_t equal_double(double value, double expected, diff_opt_t *options) /*------------------------------------------------------------------------- * Function: equal_ldouble * - * Purpose: use a relative error formula to deal with floating point + * Purpose: use a absolute error formula to deal with floating point * uncertainty * *------------------------------------------------------------------------- @@ -5647,7 +5647,7 @@ hbool_t equal_ldouble(long double value, long double expected, diff_opt_t *optio return TRUE; if (options->use_system_epsilon) { - if ( ABS( (value-expected) / expected) < DBL_EPSILON) + if ( ABS( (value-expected) ) < DBL_EPSILON) return TRUE; } @@ -5660,7 +5660,7 @@ hbool_t equal_ldouble(long double value, long double expected, diff_opt_t *optio /*------------------------------------------------------------------------- * Function: equal_float * - * Purpose: use a relative error formula to deal with floating point + * Purpose: use a absolute error formula to deal with floating point * uncertainty * * Modifications: @@ -5704,7 +5704,7 @@ hbool_t equal_float(float value, float expected, diff_opt_t *options) return TRUE; if (options->use_system_epsilon) { - if ( ABS( (value-expected) / expected) < FLT_EPSILON) + if ( ABS( (value-expected) ) < FLT_EPSILON) return TRUE; } diff --git a/windows/tools/h5diff/testh5diff.bat b/windows/tools/h5diff/testh5diff.bat index e960dd7..9b73b60 100644 --- a/windows/tools/h5diff/testh5diff.bat +++ b/windows/tools/h5diff/testh5diff.bat @@ -602,8 +602,8 @@ rem ############################################################################ rem 11. floating point comparison rem Not tested on Windows due to difference in formatting of scientific - rem notation --SJW 8/23/07 - call :testing h5diff_101.txt -v %srcfile1% %srcfile1% g1/d1 g1/d2 + rem notation (101, 102) --SJW 8/23/07 + call :testing %h5diff% -v %srcfile1% %srcfile1% g1/d1 g1/d2 rem call :tooltest h5diff_101.txt -v %file1% %file1% g1/d1 g1/d2 call :results -SKIP- @@ -611,6 +611,16 @@ rem ############################################################################ rem call :tooltest h5diff_102.txt -v %file1% %file1% g1/fp1 g1/fp2 call :results -SKIP- + rem Not tested on Windows due to difference in formatting of scientific + rem notation with other OS. printf("%g") (103, 104) + call :testing %h5diff% -v --use-system-epsilon %srcfile1% %srcfile1% g1/d1 g1/d2 + rem call :tooltest h5diff_103.txt -v --use-system-epsilon %file1% %file1% g1/d1 g1/d2 + call :results -SKIP- + + call :testing %h5diff% -v --use-system-epsilon %srcfile1% %srcfile1% g1/fp1 g1/fp2 + rem call :tooltest h5diff_102.txt -v --use-system-epsilon %file1% %file1% g1/fp1 g1/fp2 + call :results -SKIP- + rem New option added #1368(E1) - ADB 2/5/2009 rem not compable -c flag call :testing %h5diff% %srcfile2% %srcfile2% g2/dset1 g2/dset2 -- cgit v0.12