aboutsummaryrefslogtreecommitdiff
path: root/src/GeneralizedPolynomial-Uniform/test_molecule_posn.c
diff options
context:
space:
mode:
authorjthorn <jthorn@df1f8a13-aa1d-4dd4-9681-27ded5b42416>2002-08-19 14:30:44 +0000
committerjthorn <jthorn@df1f8a13-aa1d-4dd4-9681-27ded5b42416>2002-08-19 14:30:44 +0000
commit6f561b6c721a72830342b0eebe204635d6167987 (patch)
treeac977703eb1469bf898ec79721fafb3c52dad2af /src/GeneralizedPolynomial-Uniform/test_molecule_posn.c
parent25498e53288336c7f176305f036ecad05a87913c (diff)
This commit changes the semantics of the out_of_range_tolerance[]
parameter-table entry to allow the min/max ends of the grid to be handled differently. (We'll need this for the multiprocessor interpolation.) ***** IMPORTANT ***** This change is *NOT* backwards-compatible: if you are calling CCTK_InterpLocalUniform() from this thorn (CactusBase/LocalInterp), and you have set out_of_range_tolerance[] to a non-default value, you must (slightly) change your code, or else you'll get an error return from the interpolator. If you don't use out_of_range_tolerance[] , then you don't need to do anything. The semantics of out_of_range_tolerance[] are now as follows: @var out_of_range_tolerance @vdesc Specifies how out-of-range interpolation points should be handled. The array elements are matched up with the axes and minimum/maximum ends of the grid in the order [x_min, x_max, y_min, y_max, z_min, z_max, ...]. An array value TOL is interpreted as follows: If TOL >= 0.0, then an interpolation point is considered to be "out of range" if and only if the interpolation point is > TOL * coord_delta[axis] outside the grid in this coordinate direction. If TOL == -1.0, then an interpolation point is considered to be "out of range" if and only if a centered molecule (or more generally, a molecule whose centering is chosen pretending that the grid is of infinite extent), would require data from outside the grid in this direction. Other values of TOL are illegal (reserved for future use). @vtype const CCTK_REAL out_of_range_tolerance[2*N_dims] @endvar The change is that it used to have only N_dims elements, one for each axis -- now there are 2*N_dims elements, one for each min/max end of each axis. ---------------------------------------------------------------------- Modified Files: doc/documentation.tex src/GeneralizedPolynomial-Uniform/InterpLocalUniform.c src/GeneralizedPolynomial-Uniform/InterpLocalUniform.h src/GeneralizedPolynomial-Uniform/interpolate.maple src/GeneralizedPolynomial-Uniform/molecule_posn.c src/GeneralizedPolynomial-Uniform/template.c src/GeneralizedPolynomial-Uniform/test_molecule_posn.c git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/LocalInterp/trunk@88 df1f8a13-aa1d-4dd4-9681-27ded5b42416
Diffstat (limited to 'src/GeneralizedPolynomial-Uniform/test_molecule_posn.c')
-rw-r--r--src/GeneralizedPolynomial-Uniform/test_molecule_posn.c388
1 files changed, 223 insertions, 165 deletions
diff --git a/src/GeneralizedPolynomial-Uniform/test_molecule_posn.c b/src/GeneralizedPolynomial-Uniform/test_molecule_posn.c
index b4c2379..bd3a1f9 100644
--- a/src/GeneralizedPolynomial-Uniform/test_molecule_posn.c
+++ b/src/GeneralizedPolynomial-Uniform/test_molecule_posn.c
@@ -6,10 +6,14 @@
*
* Usage:
* test_molecule_posn # run a preset set of tests
- * test_molecule_posn molecule_size x # do a single test as specified
+ * test_molecule_posn molecule_size \
+ * out_of_range_tolerance_min \
+ * out_of_range_tolerance_max \
+ * x # do a single test as specified
*/
#include <math.h>
+#include <string.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
@@ -22,10 +26,6 @@
#define fuzzy_EQ(x,y) (fabs(x-y) <= 1.0e-10)
-/* prototypes */
-void run_interactive_test(fp out_of_range_tolerance, int molecule_size, fp x);
-int run_batch_tests(void);
-
/* hard-wired arguments for LocalInterp_molecule_posn() */
const fp grid_x0 = 3.1;
const fp grid_dx = 0.1;
@@ -35,6 +35,19 @@ const int grid_i_max = 105; /* x_max = 13.6 */
/******************************************************************************/
/*
+ * prototypes for functions local to this file
+*/
+static
+ void run_interactive_test(int molecule_size,
+ fp out_of_range_tolerance_min,
+ fp out_of_range_tolerance_max,
+ fp x);
+static
+ int run_batch_tests(void);
+
+/******************************************************************************/
+
+/*
* test data for batch tests
*/
@@ -42,8 +55,9 @@ const int grid_i_max = 105; /* x_max = 13.6 */
struct args_results
{
/* args */
- fp out_of_range_tolerance;
int molecule_size;
+ fp out_of_range_tolerance_min;
+ fp out_of_range_tolerance_max;
fp x;
/* results */
int i_center;
@@ -53,139 +67,142 @@ struct args_results
/* test data */
static const struct args_results test_data[] =
- {
- /* molecule size 2 */
- { 1.0, 2, 7.19, INT_MIN, -1.1, 0,+1 },
- { 1.0, 2, 7.21, 42, -0.9, 0,+1 },
- { 1.0, 2, 7.24, 42, -0.6, 0,+1 },
- { 1.0, 2, 7.26, 42, -0.4, 0,+1 },
- { 1.0, 2, 7.29, 42, -0.1, 0,+1 },
- {-1.0, 2, 7.29, INT_MIN, -0.1, 0,+1 },
- { 1.0e-12, 2, 7.3, 42, 0.0, 0,+1 }, /* x == grid_x_min */
- { 1.0e-12, 2, 7.31, 42, +0.1, 0,+1 },
- {-1.0 , 2, 7.31, 42, +0.1, 0,+1 },
- { 1.0e-12, 2, 7.35, 42, +0.5, 0,+1 },
- { 1.0e-12, 2, 7.39, 42, +0.9, 0,+1 },
- { 1.0e-12, 2, 7.41, 43, 0.1, 0,+1 },
- { 1.0e-12, 2, 9.81, 67, +0.1, 0,+1 },
- { 1.0e-12, 2, 9.85, 67, +0.5, 0,+1 },
- { 1.0e-12, 2, 9.89, 67, +0.9, 0,+1 },
- { 1.0e-12, 2, 13.45, 103, +0.5, 0,+1 },
- { 1.0e-12, 2, 13.51, 104, +0.1, 0,+1 },
- { 1.0e-12, 2, 13.55, 104, +0.5, 0,+1 },
- { 1.0e-12, 2, 13.59, 104, +0.9, 0,+1 },
- {-1.0, 2, 13.59, 104, +0.9, 0,+1 },
- { 1.0e-12, 2, 13.6, 104, +1.0, 0,+1 }, /* x == grid_x_max */
- { 1.0, 2, 13.61, 104, +1.1, 0,+1 },
- {-1.0, 2, 13.61, INT_MAX, +1.1, 0,+1 },
- { 1.0, 2, 13.65, 104, +1.5, 0,+1 },
- { 1.0, 2, 13.69, 104, +1.9, 0,+1 },
- { 1.0, 2, 13.71, INT_MAX, +2.1, 0,+1 },
- /* molecule size 3 */
- { 1.0, 3, 7.19, INT_MIN, -2.1, -1,+1 },
- { 1.0, 3, 7.21, 43, -1.9, -1,+1 },
- { 1.0, 3, 7.24, 43, -1.6, -1,+1 },
- { 1.0, 3, 7.26, 43, -1.4, -1,+1 },
- { 1.0, 3, 7.29, 43, -1.1, -1,+1 },
- {-1.0, 3, 7.29, INT_MIN, -1.1, -1,+1 },
- { 1.0e-12, 3, 7.3, 43, -1.0, -1,+1 }, /* x == grid_x_min */
- { 1.0e-12, 3, 7.31, 43, -0.9, -1,+1 },
- { 1.0e-12, 3, 7.34, 43, -0.6, -1,+1 },
- {-1.0, 3, 7.34, INT_MIN, -0.6, -1,+1 },
- { 1.0e-12, 3, 7.36, 43, -0.4, -1,+1 },
- {-1.0, 3, 7.36, 43, -0.4, -1,+1 },
- { 1.0e-12, 3, 7.39, 43, -0.1, -1,+1 },
- { 1.0e-12, 3, 7.4, 43, 0.0, -1,+1 },
- { 1.0e-12, 3, 7.44, 43, +0.4, -1,+1 },
- { 1.0e-12, 3, 7.46, 44, -0.4, -1,+1 },
- { 1.0e-12, 3, 9.8, 67, 0.0, -1,+1 },
- { 1.0e-12, 3, 9.81, 67, +0.1, -1,+1 },
- { 1.0e-12, 3, 9.84, 67, +0.4, -1,+1 },
- { 1.0e-12, 3, 9.86, 68, -0.4, -1,+1 },
- { 1.0e-12, 3, 9.89, 68, -0.1, -1,+1 },
- { 1.0e-12, 3, 9.9, 68, 0.0, -1,+1 },
- { 1.0e-12, 3, 13.44, 103, +0.4, -1,+1 },
- { 1.0e-12, 3, 13.46, 104, -0.4, -1,+1 },
- { 1.0e-12, 3, 13.5, 104, 0.0, -1,+1 },
- { 1.0e-12, 3, 13.51, 104, +0.1, -1,+1 },
- { 1.0e-12, 3, 13.54, 104, +0.4, -1,+1 },
- {-1.0, 3, 13.54, 104, +0.4, -1,+1 },
- { 1.0e-12, 3, 13.56, 104, +0.6, -1,+1 },
- {-1.0, 3, 13.56, INT_MAX, +0.6, -1,+1 },
- { 1.0e-12, 3, 13.59, 104, +0.9, -1,+1 },
- { 1.0e-12, 3, 13.6, 104, +1.0, -1,+1 }, /* x == grid_x_max */
- { 1.0, 3, 13.61, 104, +1.1, -1,+1 },
- { 1.0, 3, 13.65, 104, +1.5, -1,+1 },
- { 1.0, 3, 13.69, 104, +1.9, -1,+1 },
- { 1.0, 3, 13.71, INT_MAX, +2.1, -1,+1 },
- /* molecule size 4 */
- { 0.2, 4, 7.27, INT_MIN, -1.3, -1,+2 },
- { 0.2, 4, 7.29, 43, -1.1, -1,+2 },
- { 1.0e-12, 4, 7.3, 43, -1.0, -1,+2 }, /* x == grid_x_min */
- { 1.0e-12, 4, 7.33, 43, -0.7, -1,+2 },
- { 1.0e-12, 4, 7.39, 43, -0.1, -1,+2 },
- {-1.0, 4, 7.39, INT_MIN, -0.1, -1,+2 },
- { 1.0e-12, 4, 7.4, 43, 0.0, -1,+2 },
- {-1.0, 4, 7.41, 43, +0.1, -1,+2 },
- { 1.0e-12, 4, 7.42, 43, +0.2, -1,+2 },
- { 1.0e-12, 4, 7.48, 43, +0.8, -1,+2 },
- { 1.0e-12, 4, 7.51, 44, +0.1, -1,+2 },
- { 1.0e-12, 4, 9.81, 67, +0.1, -1,+2 },
- { 1.0e-12, 4, 9.85, 67, +0.5, -1,+2 },
- { 1.0e-12, 4, 9.89, 67, +0.9, -1,+2 },
- { 1.0e-12, 4, 13.39, 102, +0.9, -1,+2 },
- { 1.0e-12, 4, 13.41, 103, +0.1, -1,+2 },
- { 1.0e-12, 4, 13.48, 103, +0.8, -1,+2 },
- {-1.0, 4, 13.48, 103, +0.8, -1,+2 },
- { 1.0e-12, 4, 13.5, 103, +1.0, -1,+2 },
- { 1.0e-12, 4, 13.51, 103, +1.1, -1,+2 },
- {-1.0, 4, 13.51, INT_MAX, +1.1, -1,+2 },
- { 1.0e-12, 4, 13.55, 103, +1.5, -1,+2 },
- { 1.0e-12, 4, 13.59, 103, +1.9, -1,+2 },
- { 1.0e-12, 4, 13.6, 103, +2.0, -1,+2 }, /* x == grid_x_max */
- { 2.0, 4, 13.79, 103, +3.9, -1,+2 },
- { 2.0, 4, 13.81, INT_MAX, +4.1, -1,+2 },
- /* molecule size 5 */
- { 3.0, 5, 6.99, INT_MIN, -5.1, -2,+2 },
- { 3.0, 5, 7.01, 44, -4.9, -2,+2 },
- { 1.0e-12, 5, 7.3, 44, -2.0, -2,+2 }, /* x == grid_x_min */
- { 1.0e-12, 5, 7.4, 44, -1.0, -2,+2 },
- { 1.0e-12, 5, 7.44, 44, -0.6, -2,+2 },
- {-1.0, 5, 7.44, INT_MIN, -0.6, -2,+2 },
- { 1.0e-12, 5, 7.46, 44, -0.4, -2,+2 },
- {-1.0, 5, 7.46, 44, -0.4, -2,+2 },
- { 1.0e-12, 5, 7.49, 44, -0.1, -2,+2 },
- { 1.0e-12, 5, 7.5, 44, 0.0, -2,+2 },
- { 1.0e-12, 5, 7.54, 44, +0.4, -2,+2 },
- { 1.0e-12, 5, 7.56, 45, -0.4, -2,+2 },
- { 1.0e-12, 5, 7.6, 45, 0.0, -2,+2 },
- { 1.0e-12, 5, 7.64, 45, +0.4, -2,+2 },
- { 1.0e-12, 5, 9.8, 67, 0.0, -2,+2 },
- { 1.0e-12, 5, 9.81, 67, +0.1, -2,+2 },
- { 1.0e-12, 5, 9.84, 67, +0.4, -2,+2 },
- { 1.0e-12, 5, 9.86, 68, -0.4, -2,+2 },
- { 1.0e-12, 5, 9.89, 68, -0.1, -2,+2 },
- { 1.0e-12, 5, 9.9, 68, 0.0, -2,+2 },
- { 1.0e-12, 5, 13.34, 102, +0.4, -2,+2 },
- { 1.0e-12, 5, 13.36, 103, -0.4, -2,+2 },
- { 1.0e-12, 5, 13.39, 103, -0.1, -2,+2 },
- { 1.0e-12, 5, 13.41, 103, +0.1, -2,+2 },
- { 1.0e-12, 5, 13.44, 103, +0.4, -2,+2 },
- {-1.0, 5, 13.44, 103, +0.4, -2,+2 },
- { 1.0e-12, 5, 13.46, 103, +0.6, -2,+2 },
- {-1.0, 5, 13.46, INT_MAX, +0.6, -2,+2 },
- { 1.0e-12, 5, 13.48, 103, +0.8, -2,+2 },
- { 1.0e-12, 5, 13.5, 103, +1.0, -2,+2 },
- { 1.0e-12, 5, 13.51, 103, +1.1, -2,+2 },
- { 1.0e-12, 5, 13.54, 103, +1.4, -2,+2 },
- {-1.0, 5, 13.54, INT_MAX, +1.4, -2,+2 },
- { 1.0e-12, 5, 13.56, 103, +1.6, -2,+2 },
- {-1.0, 5, 13.56, INT_MAX, +1.6, -2,+2 },
- { 1.0e-12, 5, 13.59, 103, +1.9, -2,+2 },
- { 1.0e-12, 5, 13.6, 103, +2.0, -2,+2 }, /* x == grid_x_max */
- { 1.5, 5, 13.74, 103, +3.4, -2,+2 },
- { 1.5, 5, 13.76, INT_MAX, +3.6, -2,+2 },
- };
+ {
+ /* molecule size 2 */
+ { 2, 1.0, 1.0e-12, 7.19, INT_MIN, -1.1, 0,+1 },
+ { 2, 1.0, 1.0e-12, 7.21, 42, -0.9, 0,+1 },
+ { 2, 1.0, 1.0e-12, 7.24, 42, -0.6, 0,+1 },
+ { 2, 1.0, 1.0e-12, 7.26, 42, -0.4, 0,+1 },
+ { 2, 1.0, 1.0e-12, 7.29, 42, -0.1, 0,+1 },
+ { 2, -1.0, 1.0e-12, 7.29, INT_MIN, -0.1, 0,+1 },
+ { 2, 1.0e-12, 1.0e-12, 7.3, 42, 0.0, 0,+1 },/* grid_x_min */
+ { 2, 1.0e-12, 1.0e-12, 7.31, 42, +0.1, 0,+1 },
+ { 2, -1.0 , 1.0e-12, 7.31, 42, +0.1, 0,+1 },
+ { 2, 1.0e-12, 1.0e-12, 7.35, 42, +0.5, 0,+1 },
+ { 2, 1.0e-12, 1.0e-12, 7.39, 42, +0.9, 0,+1 },
+ { 2, 1.0e-12, 1.0e-12, 7.41, 43, 0.1, 0,+1 },
+ { 2, 1.0e-12, 1.0e-12, 9.81, 67, +0.1, 0,+1 },
+ { 2, 1.0e-12, 1.0e-12, 9.85, 67, +0.5, 0,+1 },
+ { 2, 1.0e-12, 1.0e-12, 9.89, 67, +0.9, 0,+1 },
+ { 2, 1.0e-12, 1.0e-12, 13.45, 103, +0.5, 0,+1 },
+ { 2, 1.0e-12, 1.0e-12, 13.51, 104, +0.1, 0,+1 },
+ { 2, 1.0e-12, 1.0e-12, 13.55, 104, +0.5, 0,+1 },
+ { 2, 1.0e-12, 1.0e-12, 13.59, 104, +0.9, 0,+1 },
+ { 2, 1.0e-12, -1.0, 13.59, 104, +0.9, 0,+1 },
+ { 2, 1.0e-12, 1.0e-12, 13.6, 104, +1.0, 0,+1 },/* grid_x_max */
+ { 2, 1.0e-12, 1.0, 13.61, 104, +1.1, 0,+1 },
+ { 2, 1.0e-12, -1.0, 13.61, INT_MAX, +1.1, 0,+1 },
+ { 2, 1.0e-12, 1.0, 13.65, 104, +1.5, 0,+1 },
+ { 2, 1.0e-12, 1.0, 13.69, 104, +1.9, 0,+1 },
+ { 2, 1.0e-12, 1.0, 13.71, INT_MAX, +2.1, 0,+1 },
+
+ /* molecule size 3 */
+ { 3, 1.0, 1.0e-12, 7.19, INT_MIN, -2.1, -1,+1 },
+ { 3, 1.0, 1.0e-12, 7.21, 43, -1.9, -1,+1 },
+ { 3, 1.0, 1.0e-12, 7.24, 43, -1.6, -1,+1 },
+ { 3, 1.0, 1.0e-12, 7.26, 43, -1.4, -1,+1 },
+ { 3, 1.0, 1.0e-12, 7.29, 43, -1.1, -1,+1 },
+ { 3, -1.0, 1.0e-12, 7.29, INT_MIN, -1.1, -1,+1 },
+ { 3, 1.0e-12, 1.0e-12, 7.3, 43, -1.0, -1,+1 },/* grid_x_min */
+ { 3, 1.0e-12, 1.0e-12, 7.31, 43, -0.9, -1,+1 },
+ { 3, 1.0e-12, 1.0e-12, 7.34, 43, -0.6, -1,+1 },
+ { 3, -1.0, 1.0e-12, 7.34, INT_MIN, -0.6, -1,+1 },
+ { 3, 1.0e-12, 1.0e-12, 7.36, 43, -0.4, -1,+1 },
+ { 3, -1.0, 1.0e-12, 7.36, 43, -0.4, -1,+1 },
+ { 3, 1.0e-12, 1.0e-12, 7.39, 43, -0.1, -1,+1 },
+ { 3, 1.0e-12, 1.0e-12, 7.4, 43, 0.0, -1,+1 },
+ { 3, 1.0e-12, 1.0e-12, 7.44, 43, +0.4, -1,+1 },
+ { 3, 1.0e-12, 1.0e-12, 7.46, 44, -0.4, -1,+1 },
+ { 3, 1.0e-12, 1.0e-12, 9.8, 67, 0.0, -1,+1 },
+ { 3, 1.0e-12, 1.0e-12, 9.81, 67, +0.1, -1,+1 },
+ { 3, 1.0e-12, 1.0e-12, 9.84, 67, +0.4, -1,+1 },
+ { 3, 1.0e-12, 1.0e-12, 9.86, 68, -0.4, -1,+1 },
+ { 3, 1.0e-12, 1.0e-12, 9.89, 68, -0.1, -1,+1 },
+ { 3, 1.0e-12, 1.0e-12, 9.9, 68, 0.0, -1,+1 },
+ { 3, 1.0e-12, 1.0e-12, 13.44, 103, +0.4, -1,+1 },
+ { 3, 1.0e-12, 1.0e-12, 13.46, 104, -0.4, -1,+1 },
+ { 3, 1.0e-12, 1.0e-12, 13.5, 104, 0.0, -1,+1 },
+ { 3, 1.0e-12, 1.0e-12, 13.51, 104, +0.1, -1,+1 },
+ { 3, 1.0e-12, 1.0e-12, 13.54, 104, +0.4, -1,+1 },
+ { 3, 1.0e-12, -1.0, 13.54, 104, +0.4, -1,+1 },
+ { 3, 1.0e-12, 1.0e-12, 13.56, 104, +0.6, -1,+1 },
+ { 3, 1.0e-12, -1.0, 13.56, INT_MAX, +0.6, -1,+1 },
+ { 3, 1.0e-12, 1.0e-12, 13.59, 104, +0.9, -1,+1 },
+ { 3, 1.0e-12, 1.0e-12, 13.6, 104, +1.0, -1,+1 },/* grid_x_max */
+ { 3, 1.0e-12, 1.0, 13.61, 104, +1.1, -1,+1 },
+ { 3, 1.0e-12, 1.0, 13.65, 104, +1.5, -1,+1 },
+ { 3, 1.0e-12, 1.0, 13.69, 104, +1.9, -1,+1 },
+ { 3, 1.0e-12, 1.0, 13.71, INT_MAX, +2.1, -1,+1 },
+
+ /* molecule size 4 */
+ { 4, 0.2, 1.0e-12, 7.27, INT_MIN, -1.3, -1,+2 },
+ { 4, 0.2, 1.0e-12, 7.29, 43, -1.1, -1,+2 },
+ { 4, 1.0e-12, 1.0e-12, 7.3, 43, -1.0, -1,+2 },/* grid_x_min */
+ { 4, 1.0e-12, 1.0e-12, 7.33, 43, -0.7, -1,+2 },
+ { 4, 1.0e-12, 1.0e-12, 7.39, 43, -0.1, -1,+2 },
+ { 4, -1.0, 1.0e-12, 7.39, INT_MIN, -0.1, -1,+2 },
+ { 4, 1.0e-12, 1.0e-12, 7.4, 43, 0.0, -1,+2 },
+ { 4, -1.0, 1.0e-12, 7.41, 43, +0.1, -1,+2 },
+ { 4, 1.0e-12, 1.0e-12, 7.42, 43, +0.2, -1,+2 },
+ { 4, 1.0e-12, 1.0e-12, 7.48, 43, +0.8, -1,+2 },
+ { 4, 1.0e-12, 1.0e-12, 7.51, 44, +0.1, -1,+2 },
+ { 4, 1.0e-12, 1.0e-12, 9.81, 67, +0.1, -1,+2 },
+ { 4, 1.0e-12, 1.0e-12, 9.85, 67, +0.5, -1,+2 },
+ { 4, 1.0e-12, 1.0e-12, 9.89, 67, +0.9, -1,+2 },
+ { 4, 1.0e-12, 1.0e-12, 13.39, 102, +0.9, -1,+2 },
+ { 4, 1.0e-12, 1.0e-12, 13.41, 103, +0.1, -1,+2 },
+ { 4, 1.0e-12, 1.0e-12, 13.48, 103, +0.8, -1,+2 },
+ { 4, 1.0e-12, -1.0, 13.48, 103, +0.8, -1,+2 },
+ { 4, 1.0e-12, 1.0e-12, 13.5, 103, +1.0, -1,+2 },
+ { 4, 1.0e-12, 1.0e-12, 13.51, 103, +1.1, -1,+2 },
+ { 4, 1.0e-12, -1.0, 13.51, INT_MAX, +1.1, -1,+2 },
+ { 4, 1.0e-12, 1.0e-12, 13.55, 103, +1.5, -1,+2 },
+ { 4, 1.0e-12, 1.0e-12, 13.59, 103, +1.9, -1,+2 },
+ { 4, 1.0e-12, 1.0e-12, 13.6, 103, +2.0, -1,+2 },/* grid_x_max */
+ { 4, 1.0e-12, 2.0, 13.79, 103, +3.9, -1,+2 },
+ { 4, 1.0e-12, 2.0, 13.81, INT_MAX, +4.1, -1,+2 },
+
+ /* molecule size 5 */
+ { 5, 3.0, 1.0e-12, 6.99, INT_MIN, -5.1, -2,+2 },
+ { 5, 3.0, 1.0e-12, 7.01, 44, -4.9, -2,+2 },
+ { 5, 1.0e-12, 1.0e-12, 7.3, 44, -2.0, -2,+2 },/* grid_x_min */
+ { 5, 1.0e-12, 1.0e-12, 7.4, 44, -1.0, -2,+2 },
+ { 5, 1.0e-12, 1.0e-12, 7.44, 44, -0.6, -2,+2 },
+ { 5, -1.0, 1.0e-12, 7.44, INT_MIN, -0.6, -2,+2 },
+ { 5, 1.0e-12, 1.0e-12, 7.46, 44, -0.4, -2,+2 },
+ { 5, -1.0, 1.0e-12, 7.46, 44, -0.4, -2,+2 },
+ { 5, 1.0e-12, 1.0e-12, 7.49, 44, -0.1, -2,+2 },
+ { 5, 1.0e-12, 1.0e-12, 7.5, 44, 0.0, -2,+2 },
+ { 5, 1.0e-12, 1.0e-12, 7.54, 44, +0.4, -2,+2 },
+ { 5, 1.0e-12, 1.0e-12, 7.56, 45, -0.4, -2,+2 },
+ { 5, 1.0e-12, 1.0e-12, 7.6, 45, 0.0, -2,+2 },
+ { 5, 1.0e-12, 1.0e-12, 7.64, 45, +0.4, -2,+2 },
+ { 5, 1.0e-12, 1.0e-12, 9.8, 67, 0.0, -2,+2 },
+ { 5, 1.0e-12, 1.0e-12, 9.81, 67, +0.1, -2,+2 },
+ { 5, 1.0e-12, 1.0e-12, 9.84, 67, +0.4, -2,+2 },
+ { 5, 1.0e-12, 1.0e-12, 9.86, 68, -0.4, -2,+2 },
+ { 5, 1.0e-12, 1.0e-12, 9.89, 68, -0.1, -2,+2 },
+ { 5, 1.0e-12, 1.0e-12, 9.9, 68, 0.0, -2,+2 },
+ { 5, 1.0e-12, 1.0e-12, 13.34, 102, +0.4, -2,+2 },
+ { 5, 1.0e-12, 1.0e-12, 13.36, 103, -0.4, -2,+2 },
+ { 5, 1.0e-12, 1.0e-12, 13.39, 103, -0.1, -2,+2 },
+ { 5, 1.0e-12, 1.0e-12, 13.41, 103, +0.1, -2,+2 },
+ { 5, 1.0e-12, 1.0e-12, 13.44, 103, +0.4, -2,+2 },
+ { 5, 1.0e-12, -1.0, 13.44, 103, +0.4, -2,+2 },
+ { 5, 1.0e-12, 1.0e-12, 13.46, 103, +0.6, -2,+2 },
+ { 5, 1.0e-12, -1.0, 13.46, INT_MAX, +0.6, -2,+2 },
+ { 5, 1.0e-12, 1.0e-12, 13.48, 103, +0.8, -2,+2 },
+ { 5, 1.0e-12, 1.0e-12, 13.5, 103, +1.0, -2,+2 },
+ { 5, 1.0e-12, 1.0e-12, 13.51, 103, +1.1, -2,+2 },
+ { 5, 1.0e-12, 1.0e-12, 13.54, 103, +1.4, -2,+2 },
+ { 5, 1.0e-12, -1.0, 13.54, INT_MAX, +1.4, -2,+2 },
+ { 5, 1.0e-12, 1.0e-12, 13.56, 103, +1.6, -2,+2 },
+ { 5, 1.0e-12, -1.0, 13.56, INT_MAX, +1.6, -2,+2 },
+ { 5, 1.0e-12, 1.0e-12, 13.59, 103, +1.9, -2,+2 },
+ { 5, 1.0e-12, 1.0e-12, 13.6, 103, +2.0, -2,+2 },/* grid_x_max */
+ { 5, 1.0e-12, 1.5, 13.74, 103, +3.4, -2,+2 },
+ { 5, 1.0e-12, 1.5, 13.76, INT_MAX, +3.6, -2,+2 },
+ };
#define N_TESTS ((int) (sizeof(test_data)/sizeof(test_data[0])))
@@ -194,9 +211,9 @@ static const struct args_results test_data[] =
int main(int argc, const char *const argv[])
{
bool N_fail;
-fp out_of_range_tolerance;
int molecule_size;
-fp x;
+double out_of_range_tolerance_min, out_of_range_tolerance_max;
+double x;
switch (argc)
{
@@ -213,54 +230,88 @@ case 1:
return 1;
}
-case 4:
- if ( (sscanf(argv[1], "%lf", &out_of_range_tolerance) == 1)
- && (sscanf(argv[2], "%d", &molecule_size) == 1)
- && (sscanf(argv[3], "%lf", &x) == 1) )
+case 5:
+ if ( (sscanf(argv[1], "%d", &molecule_size) == 1)
+ && (sscanf(argv[2], "%lf", &out_of_range_tolerance_min) == 1)
+ && (sscanf(argv[3], "%lf", &out_of_range_tolerance_max) == 1)
+ && (sscanf(argv[4], "%lf", &x) == 1) )
then {
- run_interactive_test(out_of_range_tolerance, molecule_size, x);
+ run_interactive_test(molecule_size,
+ out_of_range_tolerance_min,
+ out_of_range_tolerance_max,
+ x);
return 0;
}
/* fall through */
+
default:
fprintf(stderr,
"usage:\n"
"# run a single test as specified:\n"
- " %s out_of_range_tolerance molecule_size x\n"
+ " %s molecule_size \\\n"
+ " %*s out_of_range_tolerance_min \\\n"
+ " %*s out_of_range_tolerance_max \\\n"
+ " %*s x\n"
"# run a preset set of tests:\n"
" %s\n"
,
- argv[0], argv[0]);
+ argv[0],
+ (int) strlen(argv[0]), "",
+ (int) strlen(argv[0]), "",
+ (int) strlen(argv[0]), "",
+ argv[0]);
return 1;
}
}
/******************************************************************************/
-/* run a single test as specified */
-void run_interactive_test(fp out_of_range_tolerance, int molecule_size, fp x)
+/*
+ * This function runs a single test as specified.
+ */
+static
+ void run_interactive_test(int molecule_size,
+ fp out_of_range_tolerance_min,
+ fp out_of_range_tolerance_max,
+ fp x)
{
fp x_rel;
int m_min, m_max;
-int i_center = LocalInterp_molecule_posn(grid_x0, grid_dx,
- grid_i_min, grid_i_max,
- out_of_range_tolerance,
- molecule_size,
- x,
- &x_rel,
- &m_min, &m_max);
+printf("testing with molecule_size=%d\n", molecule_size);
+printf(" out_of_range_tolerance_[min,max]=[%g,%g]\n",
+ (double) out_of_range_tolerance_min,
+ (double) out_of_range_tolerance_max);
+printf(" x=%g\n", (double) x);
+
+ {
+const int i_center = LocalInterp_molecule_posn(grid_x0, grid_dx,
+ grid_i_min, grid_i_max,
+ molecule_size,
+ out_of_range_tolerance_min,
+ out_of_range_tolerance_max,
+ x,
+ &x_rel,
+ &m_min, &m_max);
if ((i_center == INT_MIN) || (i_center == INT_MAX))
then printf("i_center=%d\n", i_center);
else printf("i_center=%d x_rel=%g m_[min,max]=[%d,%d] i_[min,max]=[%d,%d]\n",
i_center, x_rel, m_min, m_max, i_center+m_min, i_center+m_max);
+ }
}
/******************************************************************************/
-/* run a preset set of tests, return number of failures */
-int run_batch_tests(void)
+/*
+ * This function run the preset set of tests specified by the
+ * test_data array
+ *
+ * Results:
+ * This function returns the number of test failures.
+ */
+static
+ int run_batch_tests(void)
{
int i;
int failure_count = 0;
@@ -272,8 +323,9 @@ int failure_count = 0;
int m_min = 0, m_max = 0;
int i_center = LocalInterp_molecule_posn(grid_x0, grid_dx,
grid_i_min, grid_i_max,
- p->out_of_range_tolerance,
p->molecule_size,
+ p->out_of_range_tolerance_min,
+ p->out_of_range_tolerance_max,
p->x,
&x_rel,
&m_min, &m_max);
@@ -283,10 +335,16 @@ int failure_count = 0;
&& fuzzy_EQ(x_rel, p->x_rel)
&& (m_min == p->m_min)
&& (m_max == p->m_max) );
- int msglen = printf("tol=%g size=%d x=%g ==> ",
- p->out_of_range_tolerance, p->molecule_size, p->x);
- printf("i_center=%d x_rel=%g m_[min,max]=[%d,%d]\n",
- i_center, x_rel, m_min, m_max);
+
+ int msglen =
+ printf("size=%d tol=[%g,%g] x=%g ==> ",
+ p->molecule_size,
+ (double) p->out_of_range_tolerance_min,
+ (double) p->out_of_range_tolerance_max,
+ (double) p->x);
+ printf("i_center=%d x_rel=%g m=[%d,%d]\n",
+ i_center, (double) x_rel, m_min, m_max);
+
if (! ok)
then {
++failure_count;
@@ -294,7 +352,7 @@ int failure_count = 0;
int error_msglen = printf("***** FAIL: ");
printf("%-*s", msglen-error_msglen, "expected");
printf("i_center=%d x_rel=%g m_[min,max]=[%d,%d]\n",
- p->i_center, p->x_rel, p->m_min, p->m_max);
+ p->i_center, (double) p->x_rel, p->m_min, p->m_max);
}
}
}