summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorRaymond Lu <songyulu@hdfgroup.org>2013-04-03 16:34:40 (GMT)
committerRaymond Lu <songyulu@hdfgroup.org>2013-04-03 16:34:40 (GMT)
commit8d885f6388b432ff1d9c657267a96e2b5820d46a (patch)
tree711089b0375fb8401f620258d49ee87395d1165c /test
parent98db39f847586d5c6335dcaeb060b22b5681f834 (diff)
downloadhdf5-8d885f6388b432ff1d9c657267a96e2b5820d46a.zip
hdf5-8d885f6388b432ff1d9c657267a96e2b5820d46a.tar.gz
hdf5-8d885f6388b432ff1d9c657267a96e2b5820d46a.tar.bz2
[svn-r23534] 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 koala - simple change.
Diffstat (limited to 'test')
-rw-r--r--test/dynlib2.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/test/dynlib2.c b/test/dynlib2.c
index d82a44d..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 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 */