summaryrefslogtreecommitdiffstats
path: root/tools/h5diff
diff options
context:
space:
mode:
authorPedro Vicente Nunes <pvn@hdfgroup.org>2006-11-27 20:10:53 (GMT)
committerPedro Vicente Nunes <pvn@hdfgroup.org>2006-11-27 20:10:53 (GMT)
commit124ef64faf9e3feecdc0d3d28967a222859f915d (patch)
treed3f37c6d74bbe73ac471dfda3e22bfceb3f6edfe /tools/h5diff
parent957a5082d12873eb4238a962ce0193adeac5a1dc (diff)
downloadhdf5-124ef64faf9e3feecdc0d3d28967a222859f915d.zip
hdf5-124ef64faf9e3feecdc0d3d28967a222859f915d.tar.gz
hdf5-124ef64faf9e3feecdc0d3d28967a222859f915d.tar.bz2
[svn-r12984]
Added a relative error formula to deal with floating point uncertainty in the comparison of floats and double types. Added new tests for this feature to the file generator program and to the shell script
Diffstat (limited to 'tools/h5diff')
-rw-r--r--tools/h5diff/h5diffgentest.c16
-rwxr-xr-xtools/h5diff/testh5diff.sh10
2 files changed, 22 insertions, 4 deletions
diff --git a/tools/h5diff/h5diffgentest.c b/tools/h5diff/h5diffgentest.c
index ecce3c6..e7cff69 100644
--- a/tools/h5diff/h5diffgentest.c
+++ b/tools/h5diff/h5diffgentest.c
@@ -132,8 +132,8 @@ int test_basic(const char *fname1,
hsize_t dims[2] = { 3,2 };
/* Test */
- double data1[3][2] = {{1,1},{1,1},{1,1}};
- double data2[3][2] = {{1,1.1},{1.01,1.001},{1.0001,1}};
+ double data1[3][2] = {{1,1}, {1,1}, {0,0}};
+ double data2[3][2] = {{0,1.1},{1.01,1.001},{0,1}};
int data5[3][2] = {{100,100},{100,100},{100,100}};
int data6[3][2] = {{101,102},{103,104},{150,200}};
unsigned long_long data7[3][2] = {{100,100},{100,100},{100,100}};
@@ -154,6 +154,12 @@ A B 1-B/A %
100 50 0.5 50
*/
+ /* floating point comparison , 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}};
+
/*-------------------------------------------------------------------------
* Create two files
*-------------------------------------------------------------------------
@@ -184,6 +190,12 @@ A B 1-B/A %
write_dset(gid1,2,dims,"dset9",H5T_NATIVE_DOUBLE,data9);
write_dset(gid1,2,dims,"dset10",H5T_NATIVE_DOUBLE,data10);
+ /* test floating point comparison */
+ write_dset(gid1,2,dims,"fp1",H5T_NATIVE_FLOAT,data11);
+ write_dset(gid1,2,dims,"fp2",H5T_NATIVE_FLOAT,data12);
+ write_dset(gid1,2,dims,"d1",H5T_NATIVE_DOUBLE,data13);
+ write_dset(gid1,2,dims,"d2",H5T_NATIVE_DOUBLE,data14);
+
/*-------------------------------------------------------------------------
* Close
*-------------------------------------------------------------------------
diff --git a/tools/h5diff/testh5diff.sh b/tools/h5diff/testh5diff.sh
index ce16ecc..255f201 100755
--- a/tools/h5diff/testh5diff.sh
+++ b/tools/h5diff/testh5diff.sh
@@ -19,8 +19,9 @@
# Added the SKIP feature.
# Albert Cheng, 2005/2/3
# Added -p option for parallel h5diff tests.
-# Pedro Vicente Nunes, 10/25/2005
-# Added test #9
+# Pedro Vicente Nunes:
+# 10/25/2005: Added test #9
+# 11/27/2006: Added test #10, #11
###############################################################################
@@ -503,6 +504,11 @@ TOOLTEST h5diff_90.txt $FILE1 $FILE1
TOOLTEST h5diff_100.txt $FILE9 $FILE10 -v
+# 11. floating point comparison
+
+TOOLTEST h5diff_101.txt $FILE1 $FILE1 /g1/d1 g1/d2 -v
+TOOLTEST h5diff_102.txt $FILE1 $FILE1 /g1/fp1 g1/fp2 -v
+
# ##############################################################################
# # END
# ##############################################################################