From 97caaff719f6916c255c56101d4528676784e406 Mon Sep 17 00:00:00 2001 From: Raymond Lu Date: Wed, 3 Apr 2013 11:30:46 -0500 Subject: [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. --- test/dynlib2.c | 19 +++++++++---------- test/plugin.c | 5 +++-- 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 #include -#include #include #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 -- cgit v0.12