summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaymond Lu <songyulu@hdfgroup.org>2013-04-03 16:30:46 (GMT)
committerRaymond Lu <songyulu@hdfgroup.org>2013-04-03 16:30:46 (GMT)
commit97caaff719f6916c255c56101d4528676784e406 (patch)
treef89a45db57de3326f451012d08a0f3cce7f8e069
parentf03301ce82e4fb4cd5ace537d8eab408f3238f27 (diff)
downloadhdf5-97caaff719f6916c255c56101d4528676784e406.zip
hdf5-97caaff719f6916c255c56101d4528676784e406.tar.gz
hdf5-97caaff719f6916c255c56101d4528676784e406.tar.bz2
[svn-r23533] I changed the operation in dynlib2.c from math operations pow and sqrt to simpler multiplication and division
to avoid potential rounding problem in math operations. Tested on jam - simple change.
-rw-r--r--test/dynlib2.c19
-rw-r--r--test/plugin.c5
2 files changed, 12 insertions, 12 deletions
diff --git a/test/dynlib2.c b/test/dynlib2.c
index 1ee6ed7..df5d91c 100644
--- a/test/dynlib2.c
+++ b/test/dynlib2.c
@@ -22,10 +22,10 @@
#include <stdlib.h>
#include <stdio.h>
-#include <math.h>
#include <hdf5.h>
#define H5Z_FILTER_DYNLIB2 258
+#define MULTIPLIER 3
static size_t H5Z_filter_dynlib2(unsigned int flags, size_t cd_nelmts,
const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf);
@@ -47,11 +47,10 @@ const H5Z_class2_t* H5PL_get_plugin_info(void) {return H5Z_DYNLIB2;}
/*-------------------------------------------------------------------------
* Function: H5Z_filter_dynlib2
*
- * Purpose: A dynlib2 filter method that assigns the power of 2 of the
- * original value during write and calculates the square root
- * of the original value during read. It will be built as a
- * shared library. plugin.c test will load and use this filter
- * library.
+ * Purpose: A dynlib2 filter method that multiplies the original value
+ * during write and divide the original value during read. It
+ * will be built as a shared library. plugin.c test will load
+ * and use this filter library.
*
* Return: Success: Data chunk size
*
@@ -75,17 +74,17 @@ H5Z_filter_dynlib2(unsigned int flags, size_t cd_nelmts,
return(0);
if(flags & H5Z_FLAG_REVERSE) { /*read*/
- /* Calculate and assign the square root for all the data values */
+ /* Divide the original value with MULTIPLIER */
while(buf_left>0) {
- *int_ptr = (int)sqrt((double)*int_ptr);
+ *int_ptr /= MULTIPLIER;
*int_ptr++;
buf_left -= sizeof(int);
} /* end while */
} /* end if */
else { /*write*/
- /* Calculate and assign the power of 2 to all the data values */
+ /* Multiply the original value with MULTIPLIER */
while(buf_left>0) {
- *int_ptr = (int)pow((double)*int_ptr, 2);
+ *int_ptr *= MULTIPLIER;
*int_ptr++;
buf_left -= sizeof(int);
} /* end while */
diff --git a/test/plugin.c b/test/plugin.c
index 4f28520..92be6ce 100644
--- a/test/plugin.c
+++ b/test/plugin.c
@@ -691,9 +691,10 @@ main(void)
TEST_ERROR
/* Test dynamically loaded filters for chunked dataset */
- nerrors += (test_filters_for_datasets(file, my_fapl) < 0 ? 1 : 0);
+ nerrors += (test_filters_for_datasets(file, my_fapl) < 0 ? 1 : 0);
- nerrors += (test_filters_for_groups(file, my_fapl) < 0 ? 1 : 0);
+ /* Test dynamically loaded filters for groups */
+ nerrors += (test_filters_for_groups(file, my_fapl) < 0 ? 1 : 0);
if(H5Fclose(file) < 0)
TEST_ERROR