33 static const double *
const elx[3]={
x,
y,
z};
40 double a = (b.min+b.max)/2, l = (b.max-b.min)*(1+tol)/2;
51 double *lob_bnd_data_r =
tmalloc(
double,
62 unsigned n;
double *x_ =
x, *y_ =
y;
74 for(j=0;j<
NR*
NS;++j) {
75 const double dx=x_[j]-ob->
c0[0], dy=y_[j]-ob->
c0[1];
76 tx[0][j] = ob->
A[0]*dx+ob->
A[1]*dy;
77 tx[1][j] = ob->
A[2]*dx+ob->
A[3]*dy;
78 if( (x_[j]-ob->
x[0].
min)*(ob->
x[0].
max-x_[j]) < 0
79 || (y_[j]-ob->
x[1].
min)*(ob->
x[1].
max-y_[j]) < 0 )
81 printf(
"%d %d (%g,%g) not in [%g,%g] x [%g,%g]\n", n, j,
83 if( (
tx[0][j]+1)*(1-
tx[0][j]) < 0
84 || (
tx[1][j]+1)*(1-
tx[1][j]) < 0 )
86 printf(
"%d %d (%g,%g) not in [-1,1]^2\n", n, j,
100 if( ob->
x[0].
min < xr.
min - DBL_EPSILON*128
101 || ob->
x[0].
max > xr.
max + DBL_EPSILON*128 ) failure = 1;
102 if( ob->
x[1].
min < yr.
min - DBL_EPSILON*128
103 || ob->
x[1].
max > yr.
max + DBL_EPSILON*128 ) failure = 1;
106 if( tr[j].
min > -1 + DBL_EPSILON*128
107 || tr[j].
max < 1 - DBL_EPSILON*128 ) failure = 1;
109 if((i==0&&n==0) || failure) {
110 printf(
"x: [%g,%g] in [%g,%g]\n", ob->
x[0].
min, ob->
x[0].
max,
112 printf(
"y: [%g,%g] in [%g,%g]\n", ob->
x[1].
min, ob->
x[1].
max,
115 printf(
"r %d: [%g,%g]\n", j, tr[j].
min, tr[j].
max);
120 printf(
"."); fflush(stdout);
125 for(i=0;!failure && i<
REPEAT;++
i) {
126 unsigned n;
double *x_ =
x, *y_ =
y, *z_ =
z;
139 const double dx=x_[j]-ob->
c0[0], dy=y_[j]-ob->
c0[1], dz=z_[j]-ob->
c0[2];
140 tx[0][j] = ob->
A[0]*dx+ob->
A[1]*dy+ob->
A[2]*dz;
141 tx[1][j] = ob->
A[3]*dx+ob->
A[4]*dy+ob->
A[5]*dz;
142 tx[2][j] = ob->
A[6]*dx+ob->
A[7]*dy+ob->
A[8]*dz;
143 if( (x_[j]-ob->
x[0].
min)*(ob->
x[0].
max-x_[j]) < 0
144 || (y_[j]-ob->
x[1].
min)*(ob->
x[1].
max-y_[j]) < 0
145 || (z_[j]-ob->
x[2].
min)*(ob->
x[2].
max-z_[j]) < 0 )
147 printf(
"%d %d (%g,%g,%g) not in [%g,%g] x [%g,%g] x [%g,%g]\n", n, j,
148 x_[j],y_[j],z_[j], ob->
x[0].
min,ob->
x[0].
max,
150 if( (
tx[0][j]+1)*(1-
tx[0][j]) < 0
151 || (
tx[1][j]+1)*(1-
tx[1][j]) < 0
152 || (
tx[2][j]+1)*(1-
tx[2][j]) < 0 )
154 printf(
"%d %d (%g,%g,%g) not in [-1,1]^3\n", n, j,
155 tx[0][j],
tx[1][j],
tx[2][j]);
160 lob_bnd_data_s,
NS,
MS,
163 lob_bnd_data_s,
NS,
MS,
166 lob_bnd_data_s,
NS,
MS,
174 if( ob->
x[0].
min < xr.
min - DBL_EPSILON*128
175 || ob->
x[0].
max > xr.
max + DBL_EPSILON*128 ) failure = 1;
176 if( ob->
x[1].
min < yr.
min - DBL_EPSILON*128
177 || ob->
x[1].
max > yr.
max + DBL_EPSILON*128 ) failure = 1;
178 if( ob->
x[2].
min < zr.
min - DBL_EPSILON*128
179 || ob->
x[2].
max > zr.
max + DBL_EPSILON*128 ) failure = 1;
182 if( tr[j].
min > -1 + DBL_EPSILON*128
183 || tr[j].
max < 1 - DBL_EPSILON*128 ) failure = 1;
185 if((i==0&&n==0) || failure) {
186 printf(
"x: [%g,%g] in [%g,%g]\n", ob->
x[0].
min, ob->
x[0].
max,
188 printf(
"y: [%g,%g] in [%g,%g]\n", ob->
x[1].
min, ob->
x[1].
max,
190 printf(
"z: [%g,%g] in [%g,%g]\n", ob->
x[2].
min, ob->
x[2].
max,
193 printf(
"r %d: [%g,%g]\n", j, tr[j].
min, tr[j].
max);
198 printf(
"."); fflush(stdout);
202 free(lob_bnd_data_r);
204 printf(
"Tests %s\n", failure?
"failed":
"successful");
#define tmalloc(type, count)
void bubble_elt(double *x, double *y, double *z, const double *zr, unsigned nr, const double *zs, unsigned ns, const double *zt, unsigned nt, int type)
static struct obbox_2 ob2[N *NT]
static double tx[3][NR *NS *NT]
void rand_elt_2(double *x, double *y, const double *zr, unsigned nr, const double *zs, unsigned ns)
void rand_elt_3(double *x, double *y, double *z, const double *zr, unsigned nr, const double *zs, unsigned ns, const double *zt, unsigned nt)
static const double *const elx[3]
static struct obbox_3 ob3[N]
static unsigned lob_bnd_size(unsigned n, unsigned m)
static struct dbl_range dbl_range_expand(struct dbl_range b, double tol)
static double x[NR *NS *NT *N]
static const unsigned mr[3]
static double work[TNR *NS]
establishes some macros to establish naming conventions
static double y[NR *NS *NT *N]
static const unsigned nr[3]
static double z[NR *NS *NT *N]