LibRan  0.1
Pseudo-random number distribution generator
LRtest.c
1 #include <stdio.h>
2 #include <math.h>
3 #include "libran.h"
4 #include "urand/urand.h"
5 #include <CUnit/CUnit.h>
6 #include <CUnit/Basic.h>
7 #include <CUnit/Console.h>
8 
9 #define max(a,b) (a > b ? a : b)
10 
11 #define LR_DEBUG
12 
13 #ifdef LR_DEBUG
14 # define CX_ASSERT_DOUBLE_EQUAL(val,exp,tol) \
15 { printf("value, expect = % 9.5f,% 9.5f\n",val,exp); \
16  CU_ASSERT_DOUBLE_EQUAL(val,exp,tol); }
17 # define CX_ASSERT_EQUAL(val, exp); \
18 { printf("value, expect = % ld,% ld\n",(long) val,(long) exp); \
19  CU_ASSERT_EQUAL(val,exp); }
20 #else
21 # define CX_ASSERT_DOUBLE_EQUAL(val,exp,tol) \
22  CU_ASSERT_DOUBLE_EQUAL(val,exp,tol);
23 # define CX_ASSERT_EQUAL(val, exp); \
24  CU_ASSERT_EQUAL(val,exp);
25 #endif
26 
27 int init_suite(void) { return 0; }
28 int clean_suite(void) { return 0; }
29 
30 /* LibRan error routines */
31 void test_LR_errors(void) {
32  FILE *oldstderr = stderr, *newstderr;
33  char strbuf[200], *ptr;
34  struct errset {
35  int err;
36  char *msg;
37  } es[] = {
38 0x00, "LRerr_OK : LibRan - No Error\n",
39 0x01, "LRerr_Unspecified : LibRan - Unspecified Error\n",
40 0x03, "LRerr_BadDataType : LibRan - Bad Data Type given\n",
41 0x05, "LRerr_BadLRType : LibRan - Bad Random Variate Type given\n",
42 0x09, "LRerr_NoAuxiliaryObject : LibRan - Required Auxiliary Object not found\n",
43 0x0B, "LRerr_NoAuxNormalizeDone : LibRan - Auxiliary Object requires normalization\n",
44 0x0D, "LRerr_BadAuxSetup : LibRan - Auxiliary Object incorrectly set-up\n",
45 0x11, "LRerr_BinGeneric : LibRan - Binning Object Unspecified Error\n",
46 0x13, "LRerr_TooManyValues : LibRan - Too Many Values given\n",
47 0x15, "LRerr_InvalidInputValue : LibRan - Invalid Input Value Error\n",
48 0x17, "LRerr_InvalidRange : LibRan - Invalid Range Value Error\n",
49 0x19, "LRerr_UnmetPreconditions : LibRan - Preconditions Not Performed\n",
50 0x1B, "LRerr_SuspiciousValues : LibRan - Suspicious Value - Normalization Error?\n",
51 0x1D, "LRerr_AllocFail : LibRan - Memory Allocation Error\n"};
52 
53 /* capture stderr to file */
54  newstderr = stderr = tmpfile();
55 
56  for (int i = 0; i < sizeof(es)/sizeof(es[0]); i++) {
57  stderr = newstderr;
58  (void) fseek(stderr,0,SEEK_SET);
59  LRperror(LRstrerrno(es[i].err),es[i].err);
60  (void) fseek(stderr,0,SEEK_SET);
61  ptr = fgets(strbuf, sizeof(strbuf), stderr);
62  stderr = oldstderr;
63 /*
64 fprintf(stderr, "<<< %x,%d\n:%s:%s",es[i].err,strcmp(ptr,es[i].msg), ptr, es[i].msg);
65 */
66  CU_ASSERT_STRING_EQUAL(ptr, es[i].msg);
67  (void) sscanf(es[i].msg,"%s : ",strbuf);
68  CU_ASSERT_STRING_EQUAL(LRstrerrno(es[i].err), strbuf);
69 /*
70 fprintf(stderr, ">>> %x,%d\n:%s:%s\n",es[i].err,
71  strcmp(LRstrerrno(es[i].err), strbuf),
72  LRstrerrno(es[i].err), strbuf);
73 */
74  }
75 /* restore stderr */
76  stderr = oldstderr;
77 }
78 
79 /* LibRan version */
80 #define STRINGIFY(arg) #arg
81 #define STRVAL(arg) STRINGIFY(arg)
82 void test_LR_version(void) {
83  CU_ASSERT_STRING_EQUAL(LRversion("vers"), STRVAL(LR_VERSION));
84  CU_ASSERT_STRING_EQUAL(LRversion("version"), STRVAL(LR_VERSION));
85  CU_ASSERT_STRING_EQUAL(LRversion("major"), STRVAL(LR_VER_MAJOR));
86  CU_ASSERT_STRING_EQUAL(LRversion("MAJOR"), STRVAL(LR_VER_MAJOR));
87  CU_ASSERT_STRING_EQUAL(LRversion("minor"), STRVAL(LR_VER_MINOR));
88  CU_ASSERT_STRING_EQUAL(LRversion("mInOr"), STRVAL(LR_VER_MINOR));
89  CU_ASSERT_STRING_EQUAL(LRversion("patch"), STRVAL(LR_VER_PATCH));
90  CU_ASSERT_STRING_EQUAL(LRversion("PaTcH"), STRVAL(LR_VER_PATCH));
91  CU_ASSERT_STRING_EQUAL(LRversion("date"), STRVAL(LR_DATE));
92  CU_ASSERT_STRING_EQUAL(LRversion("Date"), STRVAL(LR_DATE));
93 /* make sure major.minor.patch are right */
94  CU_ASSERT_STRING_EQUAL(
95  LRversion("vers"),
96  STRVAL(LR_VER_MAJOR) "."
97  STRVAL(LR_VER_MINOR) "."
98  STRVAL(LR_VER_PATCH));
99  CU_ASSERT_STRING_EQUAL(LRversion("foobar"), "");
100 }
101 
102 #define testLRnew(tt) void test_new_##tt(void) { \
103  LR_obj *o = LR_new(gausbm, LR_##tt); \
104  CU_ASSERT_PTR_NOT_NULL(o); \
105  CU_ASSERT_EQUAL(o->d, LR_##tt); \
106  CU_ASSERT_PTR_EQUAL(o->ui, LR_irand); \
107  CU_ASSERT_PTR_EQUAL(o->ul, LR_lrand); \
108  CU_ASSERT_PTR_EQUAL(o->uf, LR_frand); \
109  CU_ASSERT_PTR_EQUAL(o->ud, LR_drand); \
110  CU_ASSERT_EQUAL(sizeof (*o), sizeof (LR_obj)); \
111  LR_rm(&o); \
112  CU_ASSERT_PTR_NULL(o); \
113 }
114 
115 testLRnew(int)
116 testLRnew(float)
117 testLRnew(long)
118 testLRnew(double)
119 
120 /* test when individual parameters are set */
121 #define testLRset(tt, ptt, att) void test_set_##tt(void) { \
122  LR_obj *o = LR_new(gausbm, LR_##tt); \
123  CU_ASSERT_EQUAL(LR_set(o, 'a', -1##ptt),0); \
124  CU_ASSERT_EQUAL(LR_set(o, 'b', 3##ptt),0); \
125  CU_ASSERT_EQUAL(LR_set(o, 'm', 2##ptt),0); \
126  CU_ASSERT_EQUAL(LR_set(o, 's', 1##ptt),0); \
127  CU_ASSERT_EQUAL(LR_set(o, 'x', 5##ptt),0); \
128  CU_ASSERT_EQUAL(LR_set(o, 'k', 7),0); \
129  CU_ASSERT_EQUAL(LR_set(o, 'n', 11),0); \
130  CU_ASSERT_NOT_EQUAL(LR_set(o, 'z', 9##ptt),0); \
131  CU_ASSERT_EQUAL(o->a.att, -1##ptt); \
132  CU_ASSERT_EQUAL(o->b.att, 3##ptt); \
133  CU_ASSERT_EQUAL(o->m.att, 2##ptt); \
134  CU_ASSERT_EQUAL(o->s.att, 1##ptt); \
135  CU_ASSERT_EQUAL(o->x.att, 5##ptt); \
136  CU_ASSERT_EQUAL(o->k, 7); \
137  CU_ASSERT_EQUAL(o->n, 11); \
138  LR_rm(&o); \
139 }
140 
141 testLRset(int,,i)
142 testLRset(float,.,f)
143 testLRset(long,L,l)
144 testLRset(double,.,d)
145 
146 /* test when all the parameters are given */
147 #define testLRsetall(tt, ptt, att) void test_set_all_##tt(void) { \
148  LR_obj *o = LR_new(gausbm, LR_##tt); \
149  CU_ASSERT_EQUAL( \
150  LR_set_all(o,"abmsxknpq", \
151  -1##ptt,3##ptt,2##ptt,1##ptt,5##ptt,7,11,4.,16.),0); \
152  CU_ASSERT_EQUAL(o->a.att, -1##ptt); \
153  CU_ASSERT_EQUAL(o->b.att, 3##ptt); \
154  CU_ASSERT_EQUAL(o->m.att, 2##ptt); \
155  CU_ASSERT_EQUAL(o->s.att, 1##ptt); \
156  CU_ASSERT_EQUAL(o->x.att, 5##ptt); \
157  CU_ASSERT_EQUAL(o->k, 7); \
158  CU_ASSERT_EQUAL(o->n, 11); \
159  CU_ASSERT_EQUAL(o->p, 4.); \
160  CU_ASSERT_EQUAL(o->q, 16.); \
161  LR_rm(&o); \
162 }
163 
164 testLRsetall(int,,i)
165 testLRsetall(float,.,f)
166 testLRsetall(long,L,l)
167 testLRsetall(double,.,d)
168 
169 /* test a different order of parameters */
170 #define testLRsetall2(tt, ptt, att) void test_set_all2_##tt(void) { \
171  LR_obj *o = LR_new(gausbm, LR_##tt); \
172  CU_ASSERT_EQUAL( \
173  LR_set_all(o,"mpnaxksqb", \
174  2##ptt,4.,11,-1##ptt,5##ptt,7,1##ptt,16.,3##ptt),0); \
175  CU_ASSERT_EQUAL(o->a.att, -1##ptt); \
176  CU_ASSERT_EQUAL(o->b.att, 3##ptt); \
177  CU_ASSERT_EQUAL(o->m.att, 2##ptt); \
178  CU_ASSERT_EQUAL(o->s.att, 1##ptt); \
179  CU_ASSERT_EQUAL(o->x.att, 5##ptt); \
180  CU_ASSERT_EQUAL(o->k, 7); \
181  CU_ASSERT_EQUAL(o->n, 11); \
182  CU_ASSERT_EQUAL(o->p, 4.); \
183  CU_ASSERT_EQUAL(o->q, 16.); \
184  LR_rm(&o); \
185 }
186 
187 testLRsetall2(int,,i)
188 testLRsetall2(float,.,f)
189 testLRsetall2(long,L,l)
190 testLRsetall2(double,.,d)
191 
192 /* test when extra parameters are given */
193 #define testLRsetall3(tt, ptt, att) void test_set_all3_##tt(void) { \
194  LR_obj *o = LR_new(gausbm, LR_##tt); \
195  CU_ASSERT_NOT_EQUAL( \
196  LR_set_all(o,"mpnaxzksqby", \
197  2##ptt,4.,11,-1##ptt,5##ptt,33##ptt,7,1##ptt,16.,3##ptt,9##ptt),0); \
198  CU_ASSERT_EQUAL(o->a.att, -1##ptt); \
199  CU_ASSERT_EQUAL(o->b.att, 3##ptt); \
200  CU_ASSERT_EQUAL(o->m.att, 2##ptt); \
201  CU_ASSERT_EQUAL(o->s.att, 1##ptt); \
202  CU_ASSERT_EQUAL(o->x.att, 5##ptt); \
203  CU_ASSERT_EQUAL(o->k, 7); \
204  CU_ASSERT_EQUAL(o->n, 11); \
205  CU_ASSERT_EQUAL(o->p, 4.); \
206  CU_ASSERT_EQUAL(o->q, 16.); \
207  LR_rm(&o); \
208 }
209 
210 testLRsetall3(int,,i)
211 testLRsetall3(float,.,f)
212 testLRsetall3(long,L,l)
213 testLRsetall3(double,.,d)
214 
215 /* test the check method */
216 #define testLRcheck(nn, dist, tt, ttt, setup) \
217 void test_check_ ## dist ## _##tt ## _##nn(void) { \
218  LR_obj *o = LR_new(dist, LR_ ##ttt); \
219  setup; \
220  LR_rm(&o); \
221 }
222 
223 void test_check_bad_0(void) {
224  LR_obj *o = NULL;
225  CU_ASSERT_EQUAL(LR_check(o), LRerr_Unspecified);
226 }
227 
228 testLRcheck(0, unif, d, double,
229  LR_set_all(o, "ab", 2.0,-1.5);
230  CU_ASSERT_EQUAL(LR_check(o), LRerr_OK);
231  CU_ASSERT_EQUAL(o->a.d, -1.5);
232  CU_ASSERT_EQUAL(o->b.d, 2.0);
233 )
234 testLRcheck(1, unif, d, double,
235  LR_set_all(o, "ab", 2.0, 2.0);
236  CU_ASSERT_EQUAL(LR_check(o), LRerr_InvalidRange);
237 )
238 testLRcheck(2, gausbm, d, double,
239  LR_set_all(o, "sm",-2.0, 1.5);
240  CU_ASSERT_EQUAL(LR_check(o), LRerr_OK);
241  CU_ASSERT_EQUAL(o->m.d, 1.5);
242  CU_ASSERT_EQUAL(o->s.d, 2.0);
243 )
244 testLRcheck(3, gausbm, d, double,
245  LR_set_all(o, "sm", 0., 1.5);
246  CU_ASSERT_EQUAL(LR_check(o), LRerr_InvalidInputValue);
247 )
248 testLRcheck(4, uinvcdf, d, double,
249  CU_ASSERT_EQUAL(LR_check(o), LRerr_UnmetPreconditions);
250 )
251 testLRcheck(5, uinvcdf, d, double,
252  LR_set_all(o, "ab", 2.0,-1.0);
253  CU_ASSERT_EQUAL(LR_check(o), LRerr_OK);
254 )
255 testLRcheck(6, uinvcdf, d, double,
256  LR_set_all(o, "ams", 2.0,3.0,-1.0);
257  CU_ASSERT_EQUAL(LR_check(o), LRerr_OK);
258 )
259 testLRcheck(7, uinvcdf, d, double,
260  LR_set_all(o, "ams", 2.0,3.0,0.);
261  CU_ASSERT_EQUAL(LR_check(o), LRerr_InvalidInputValue);
262 )
263 testLRcheck(8, uinvcdf, d, double,
264  LR_set_all(o, "ab", 2.0,2.0);
265  CU_ASSERT_EQUAL(LR_check(o), LRerr_InvalidRange);
266 )
267 /* uinvcdf d 9 */
268 
269 testLRcheck(0, unif, f, float,
270  LR_set_all(o, "ab", 2.0,-1.5);
271  CU_ASSERT_EQUAL(LR_check(o), LRerr_OK);
272  CU_ASSERT_EQUAL(o->a.f, -1.5);
273  CU_ASSERT_EQUAL(o->b.f, 2.0);
274 )
275 testLRcheck(1, unif, f, float,
276  LR_set_all(o, "ab", 2.0, 2.0);
277  CU_ASSERT_EQUAL(LR_check(o), LRerr_InvalidRange);
278 )
279 testLRcheck(2, gausbm, f, float,
280  LR_set_all(o, "sm",-2.0, 1.5);
281  CU_ASSERT_EQUAL(LR_check(o), LRerr_OK);
282  CU_ASSERT_EQUAL(o->m.f, 1.5);
283  CU_ASSERT_EQUAL(o->s.f, 2.0);
284 )
285 testLRcheck(3, gausbm, f, float,
286  LR_set_all(o, "sm", 0., 1.5);
287  CU_ASSERT_EQUAL(LR_check(o), LRerr_InvalidInputValue);
288 )
289 testLRcheck(4, uinvcdf, f, float,
290  CU_ASSERT_EQUAL(LR_check(o), LRerr_UnmetPreconditions);
291 )
292 testLRcheck(5, uinvcdf, f, float,
293  LR_set_all(o, "ab", 2.0,-1.0);
294  CU_ASSERT_EQUAL(LR_check(o), LRerr_OK);
295 )
296 testLRcheck(6, uinvcdf, f, float,
297  LR_set_all(o, "ams", 2.0,3.0,-1.0);
298  CU_ASSERT_EQUAL(LR_check(o), LRerr_OK);
299 )
300 testLRcheck(7, uinvcdf, f, float,
301  LR_set_all(o, "ams", 2.0,3.0,0.);
302  CU_ASSERT_EQUAL(LR_check(o), LRerr_InvalidInputValue);
303 )
304 testLRcheck(8, uinvcdf, f, float,
305  LR_set_all(o, "ab", 2.0,2.0);
306  CU_ASSERT_EQUAL(LR_check(o), LRerr_InvalidRange);
307 )
308 
309 /* independent pseudo-random sequences */
310 #define testLRindep(dist, nn, num, incr, setup) \
311 void test_indep_seq_##nn(void) { \
312  LR_obj *o1 = LR_new(dist, LR_double); \
313  LR_obj *o2 = LR_new(dist, LR_double); \
314  double y1, y2; \
315  setup; \
316  for (int i = 0; i < num; i++) { \
317  for (int j = 0; j < incr; j++) { \
318  y1 = LRd_RAN(o1); y2 = LRd_RAN(o2); \
319  } \
320  CU_ASSERT_DOUBLE_EQUAL(y1, y2,.0000001); \
321  } \
322  LR_rm(&o1); LR_rm(&o2); \
323 }
324 
325 testLRindep(unif, 1, 10, 5000,)
326 testLRindep(unif, 2, 10, 5000,
327  LR_lsetseed(o1, 19580512l);
328  LR_lsetseed(o2, 19580512l);
329 )
330 testLRindep(gausbm, 3, 10, 5000,)
331 testLRindep(gausbm, 4, 10, 5000,
332  LR_lsetseed(o1, 19580512l);
333  LR_lsetseed(o2, 19580512l);
334 )
335 testLRindep(gsn2, 5, 10, 5000,)
336 testLRindep(gsn2, 6, 10, 5000,
337  LR_lsetseed(o1, 19580512l);
338  LR_lsetseed(o2, 19580512l);
339 )
340 
341 /* binning object */
342 #define testLRbinnew(tt) void test_bin_new_##tt(void) { \
343  LR_bin *b = LR_bin_new(10); \
344  CU_ASSERT_PTR_NOT_NULL(b); \
345  CU_ASSERT_EQUAL(b->n, 10); \
346  CU_ASSERT_EQUAL(b->nn, 1); \
347  CU_ASSERT_EQUAL(sizeof(b), sizeof(LR_bin *)); \
348  CU_ASSERT_EQUAL(sizeof(*b), sizeof(LR_bin)); \
349  CU_ASSERT_EQUAL(sizeof(b->bdrs[0]), sizeof(double)); \
350  CU_ASSERT_EQUAL(sizeof(b->bins[0]), sizeof(long)); \
351  LR_bin_rm(&b); \
352  CU_ASSERT_PTR_NULL(b); \
353 }
354 
355 /*
356 testLRbinnew(int)
357 testLRbinnew(long)
358 testLRbinnew(float)
359 */
360 testLRbinnew(double)
361 
362 #define testLRbinset(nn,aa,bb,cc,dd) void test_bin_set_##nn(void) { \
363  LR_bin *b = LR_bin_new(5); \
364  CU_ASSERT_EQUAL(LR_bin_set(b, aa),0); \
365  CU_ASSERT_EQUAL(LR_bin_set(b, bb),0); \
366  CU_ASSERT_EQUAL(LR_bin_set(b, cc),0); \
367  CU_ASSERT_EQUAL(LR_bin_set(b, dd),0); \
368  CU_ASSERT_NOT_EQUAL(LR_bin_set(b, aa+bb),0); \
369  CU_ASSERT_DOUBLE_EQUAL(b->bdrs[0],-1.0,.0001); \
370  CU_ASSERT_DOUBLE_EQUAL(b->bdrs[1], 0.0,.0001); \
371  CU_ASSERT_DOUBLE_EQUAL(b->bdrs[2], 3.3,.0001); \
372  CU_ASSERT_DOUBLE_EQUAL(b->bdrs[3], 4.5,.0001); \
373  CU_ASSERT_DOUBLE_EQUAL(b->bdrs[4], 0.0,.0001); \
374  LR_bin_rm(&b); \
375 }
376 
377 testLRbinset(1,-1.0,0.0,3.3,4.5)
378 testLRbinset(2,4.5,3.3,0.0,-1.0)
379 testLRbinset(3,-1.0,4.5,3.3,0.0)
380 testLRbinset(4,3.3,-1.0,4.5,0.0)
381 
382 #define testLRbinadd(nn,aa) void test_bin_add_##nn(void) { \
383  LR_bin *b = LR_bin_new(aa+2); \
384  for (int i = 1; i < aa; i++) { \
385  CU_ASSERT_EQUAL(LR_bin_set(b, i/(double) aa),0); \
386  } \
387  for (int i = 0; i < 10000; i++) { \
388  CU_ASSERT_EQUAL(LR_bin_add(b, 0.0001*i),0); \
389  } \
390  for (int i = 0; i < aa; i++) { \
391  CU_ASSERT_DOUBLE_EQUAL(b->bins[i],10000./(double) aa, 1.);\
392  } \
393  LR_bin_rm(&b); \
394 }
395 
396 testLRbinadd(1,10)
397 testLRbinadd(2,30)
398 testLRbinadd(3,50)
399 testLRbinadd(4,100)
400 
401 /* distributions */
402 #define compCdfPdf(tt,oo,xx,xxh,tol) \
403 CU_ASSERT_DOUBLE_EQUAL( \
404  ((LR##tt ## _CDF(oo,xxh))-(LR##tt ## _CDF(oo,xx)))/((xxh)-(xx)),\
405  LR##tt ## _PDF(oo,xx),tol)
406 
407 /* testCdfPdf
408  * nn - test number
409  * tt - LR data type (d or f)
410  * ttt - LR data type (double or float)
411  * dist - LR variate type
412  * nnt - number of test values
413  * del - delta
414  * tol - absolute tolerance
415  * setup- LR object parameter set-up
416  */
417 #define testCdfPdf(nn,tt,ttt,dist,nnt,del,tol,setup) \
418 void test_cdf_pdf_ ## tt ## _ ##dist ## _##nn(void) { \
419  LR_obj *o = LR_new(dist, LR_##ttt); \
420  double incr; \
421  setup; \
422  incr = (o->b.tt - o->a.tt)/nnt; \
423  CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,o->a.tt-2*incr),0.,tol) \
424  CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,o->a.tt-2*incr),0.,tol) \
425  for (int i = 1; i < nnt; i++) { \
426  compCdfPdf(tt,o,o->a.tt+i*incr,o->a.tt+i*incr+del,tol) \
427  } \
428  CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,o->b.tt+2*incr),1.,tol) \
429  CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,o->b.tt+2*incr),0.,tol) \
430 }
431 
432 /* testSymDF - test symetric values
433  * nn - test number
434  * tt - LR data type (d or f)
435  * ttt - LR data type (double or float)
436  * dist - LR variate type
437  * x1 - first value
438  * x2 - second symmetric value
439  * tol - absolute tolerance
440  * setup- LR object parameter set-up
441  */
442 #define testSymDF(nn,tt,ttt,dist,x1,x2,tol,setup) \
443 void test_sym_ ## tt ## _ ##dist ## _##nn(void) { \
444  LR_obj *o = LR_new(dist, LR_##ttt); \
445  setup; \
446  ttt c1,p1,c2,p2, one = 1; \
447  c1 = LR##tt ## _CDF(o,x1); \
448  p1 = LR##tt ## _PDF(o,x1); \
449  c2 = LR##tt ## _CDF(o,x2); \
450  p2 = LR##tt ## _PDF(o,x2); \
451  CU_ASSERT_DOUBLE_EQUAL(p1,p2,tol) \
452  CU_ASSERT_DOUBLE_EQUAL(c1+c2,one,tol) \
453 }
454 
455 /* test some well defined points */
456 #define testCdfPdf0unif(nn,tt,ttt,tol,setup) \
457 void test_cdf_pdf_##tt ## _unif ## _##nn(void) { \
458  LR_obj *o = LR_new(unif, LR_##ttt); \
459  double ival,pval; \
460  setup; \
461  ival = (o->b.tt - o->a.tt); \
462  pval = 1.0/ival; \
463 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,o->a.tt-.1),0.,tol) \
464 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,o->a.tt-.1),0.,tol) \
465 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,o->a.tt),0.,tol) \
466 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,o->a.tt),pval,tol) \
467 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,o->a.tt+.25*ival),.25,tol) \
468 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,o->a.tt+.25*ival),pval,tol) \
469 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,o->a.tt+.5*ival),.5,tol) \
470 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,o->a.tt+.5*ival),pval,tol) \
471 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,o->a.tt+.75*ival),.75,tol) \
472 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,o->a.tt+.75*ival),pval,tol) \
473 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,o->b.tt),1.,tol) \
474 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,o->b.tt),0.,tol) \
475 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,o->b.tt+.1),1.,tol) \
476 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,o->b.tt+.1),0.,tol) \
477 }
478 
479 /* random variate generation & binning */
480 /* the last bin will have one less then rest ... so may be off by 2. */
481 #define testLRunif(nn,tt,ttt,dist,bn,setup) \
482 void test_##dist ## _##tt ## _##nn(void) {\
483  LR_obj *o = LR_new(dist, LR_##ttt); \
484  LR_bin *b = LR_bin_new(bn); \
485  double x, cdf[bn], tot = 10007.; \
486  setup; \
487  double incr = (o->b.tt - o->a.tt) / bn; \
488  o->uf = tfrand; o->ud = tdrand; \
489  for (int i = 1; i < bn; i++) { \
490  LR_bin_set(b,o->a.tt + i*incr); \
491  cdf[i-1] = tot*(LR##tt ## _CDF(o,o->a.tt+i*incr) \
492  - LR##tt ## _CDF(o,o->a.tt+(i-1)*incr)); \
493  } \
494  cdf[bn-1] = tot*(LR##tt ## _CDF(o,o->b.tt) \
495  - LR##tt ## _CDF(o,o->b.tt - incr)); \
496  for (int i = 0; i < tot; i++) { \
497  LR_bin_add(b,LR##tt ## _RAN(o)); \
498  } \
499  for (int i = 0; i < bn; i++) { \
500  CU_ASSERT_DOUBLE_EQUAL(b->bins[i],cdf[i],2.); \
501  } \
502 }
503 
504 /* more complicated random variates do not have "uniform" coverage */
505 /* make tolerance adjustable */
506 /* vty - LR distribution
507  * nn - test #
508  * tt - type letter (f or d)
509  * ttt - type (float or double)
510  * bn - bin number
511  * vsc - % error tolerance (.1 = 10%)
512  * vab - absolute error tolerance
513  * setup - set-up code
514  */
515 #define testLRvar(vty,nn,tt,ttt,bn,vsc,vab,setup) \
516 void test_##vty ## _##tt ## _##nn(void) { \
517  LR_obj *o = LR_new(vty, LR_##ttt); \
518  LR_bin *b = LR_bin_new(bn); \
519  double x, cdf[bn], tol, tot = 10007.; \
520  setup; \
521  double incr = (o->b.tt - o->a.tt) / bn; \
522  o->uf = tfrand; o->ud = tdrand; \
523  for (int i = 1; i < bn; i++) { \
524  LR_bin_set(b,o->a.tt + i*incr); \
525  cdf[i-1] = tot*(LR##tt ## _CDF(o,o->a.tt+i*incr) \
526  - LR##tt ## _CDF(o,o->a.tt+(i-1)*incr)); \
527  } \
528  cdf[bn-1] = tot*(LR##tt ## _CDF(o,o->b.tt) \
529  - LR##tt ## _CDF(o,o->b.tt - incr)); \
530  for (int i = 0; i < tot; i++) { \
531  LR_bin_add(b,LR##tt ## _RAN(o)); \
532  } \
533  for (int i = 0; i < bn; i++) { \
534  tol = max(cdf[i]*vsc,vab); \
535  CU_ASSERT_DOUBLE_EQUAL(b->bins[i],cdf[i],tol); \
536  } \
537 }
538 
539 /* even more complicated random variates do not have "uniform" coverage */
540 /* also the limited test t*rand functions do not adequately span space */
541 /* make tolerance adjustable */
542 /* vty - LR distribution
543  * nn - test #
544  * tt - type letter (f or d)
545  * ttt - type (float or double)
546  * bn - bin number
547  * xtot - total number of samples (should be large)
548  * vsc - % error tolerance (.1 = 10%)
549  * vab - absolute error tolerance
550  * setup - set-up code
551  */
552 #define testLRvarx(vty,nn,tt,ttt,bn,xtot,vsc,vab,setup) \
553 void test_##vty ## _##tt ## _##nn(void) { \
554  LR_obj *o = LR_new(vty, LR_##ttt); \
555  LR_bin *b = LR_bin_new(bn); \
556  double x, cdf[bn], tol; \
557  setup; \
558  double incr = (o->b.tt - o->a.tt) / bn; \
559  /* o->uf = tfrand; o->ud = tdrand; */ \
560  for (int i = 1; i < bn; i++) { \
561  LR_bin_set(b,o->a.tt + i*incr); \
562  cdf[i-1] = xtot*(LR##tt ## _CDF(o,o->a.tt+i*incr) \
563  - LR##tt ## _CDF(o,o->a.tt+(i-1)*incr)); \
564  } \
565  cdf[bn-1] = xtot*(LR##tt ## _CDF(o,o->b.tt) \
566  - LR##tt ## _CDF(o,o->b.tt - incr)); \
567  for (int i = 0; i < xtot; i++) { \
568  LR_bin_add(b,LR##tt ## _RAN(o)); \
569  } \
570  for (int i = 0; i < bn; i++) { \
571  tol = max(cdf[i]*vsc,vab); \
572  CU_ASSERT_DOUBLE_EQUAL(b->bins[i],cdf[i],tol); \
573  } \
574 }
575 
576 /* more complicated random variates do not have "uniform" coverage */
577 /* also the limited test t*rand functions do not adequately span space */
578 /* make tolerance adjustable */
579 /* vty - LR distribution
580  * nn - test #
581  * tt - type letter (f or d)
582  * ttt - type (float or double)
583  * end - the highest value of range
584  * bn - bin number
585  * xtot - total number of samples (should be large)
586  * vsc - % error tolerance (.1 = 10%)
587  * vab - absolute error tolerance
588  * setup- set-up code
589  */
590 #define testLRhalf(vty,nn,tt,ttt,end,bn,xtot,vsc,vab,setup) \
591 void test_##vty ## _##tt ## _##nn(void) { \
592  LR_obj *o = LR_new(vty, LR_##ttt); \
593  LR_bin *b = LR_bin_new(bn+2); \
594  double x, cdf[bn+2], tol; \
595  setup; \
596  double begin = 0.0, \
597  incr = end / bn; \
598  /* o->uf = tfrand; o->ud = tdrand; */ \
599  for (int i = 0; i < bn; i++) { \
600  x = begin + i*incr; \
601  LR_bin_set(b,x); \
602  cdf[i] = xtot*(LR##tt ## _CDF(o,x) \
603  - LR##tt ## _CDF(o,x - incr)); \
604  } \
605  cdf[bn] = xtot * (1.0 - LR##tt ## _CDF(o,begin+bn*incr)); \
606  for (int i = 0; i < xtot; i++) { \
607  LR_bin_add(b,LR##tt ## _RAN(o)); \
608  } \
609  for (int i = 0; i <= bn; i++) { \
610  tol = max(cdf[i]*vsc,vab); \
611  CU_ASSERT_DOUBLE_EQUAL(1.0*b->bins[i],cdf[i],tol); \
612  } \
613 }
614 
615 /* more complicated random variates do not have "uniform" coverage */
616 /* also the limited test t*rand functions do not adequately span space */
617 /* make tolerance adjustable */
618 /* vty - LR distribution
619  * nn - test #
620  * tt - type letter (f or d)
621  * ttt - type (float or double)
622  * ww - number of std.dev on either side of mean.
623  * bn - bin number
624  * xtot - total number of samples (should be large)
625  * vsc - % error tolerance (.1 = 10%)
626  * vab - absolute error tolerance
627  * setup- set-up code
628  */
629 #define testLRfull(vty,nn,tt,ttt,ww,bn,xtot,vsc,vab,setup) \
630 void test_##vty ## _##tt ## _##nn(void) { \
631  LR_obj *o = LR_new(vty, LR_##ttt); \
632  LR_bin *b = LR_bin_new(bn+2); \
633  double x, cdf[bn+2], tol; \
634  setup; \
635  double begin = o->m.tt - ww*o->s.tt, \
636  incr = 2.0*ww*o->s.tt / bn; \
637  /* o->uf = tfrand; o->ud = tdrand; */ \
638  cdf[0] = xtot * LR##tt ## _CDF(o,begin); \
639  LR_bin_set(b,begin); \
640  for (int i = 1; i <= bn; i++) { \
641  x = begin + i*incr; \
642  LR_bin_set(b,x); \
643  cdf[i] = xtot*(LR##tt ## _CDF(o,x) \
644  - LR##tt ## _CDF(o,x - incr)); \
645  } \
646  cdf[bn+1] = xtot * (1.0 - LR##tt ## _CDF(o,begin+bn*incr)); \
647  for (int i = 0; i < xtot; i++) { \
648  LR_bin_add(b,LR##tt ## _RAN(o)); \
649  } \
650  for (int i = 0; i <= bn+1; i++) { \
651  tol = max(cdf[i]*vsc,vab); \
652  CU_ASSERT_DOUBLE_EQUAL(1.0*b->bins[i],cdf[i],tol); \
653  } \
654 }
655 
656 /* test bad data type errors */
657 /* vty - LR distribution
658  * nn - test #
659  * tt - type letter (f or d)
660  * ttt - type (float or double)
661  * btt - bad type letter (d or f)
662  * xx - value
663  * setup- set-up code
664  */
665 #define testBADdt(vty,nn,tt,ttt, btt, xx, setup) \
666 void test_bad_##tt ## _dt_ ##nn(void) { \
667  LR_obj *o = LR_new(vty, LR_##ttt); \
668  setup; \
669  CU_ASSERT(isnan(LR##btt ## _RAN(o))); \
670  CU_ASSERT(isnan(LR##btt ## _PDF(o,xx))); \
671  CU_ASSERT(isnan(LR##btt ## _CDF(o,xx))); \
672  CU_ASSERT_EQUAL(LR_aux_new(o,9),LRerr_NoAuxiliaryObject); \
673  CU_ASSERT_EQUAL(LR_aux_rm(o),LRerr_NoAuxiliaryObject); \
674  CU_ASSERT_EQUAL(LR_aux_set(o,1.,1.),LRerr_NoAuxiliaryObject); \
675  CU_ASSERT_EQUAL(LR_aux_norm(o),LRerr_NoAuxiliaryObject); \
676 }
677 
678 /* uniform distribution */
679 int tirand(LR_obj *);
680 long tlrand(LR_obj *);
681 float tfrand(LR_obj *);
682 double tdrand(LR_obj *);
683 
684 testCdfPdf0unif(0,d,double,.001,)
685 testCdfPdf(1,d,double,unif,20,.0001,.001,)
686 testCdfPdf(2,d,double,unif,50,.0001,.001,)
687 testCdfPdf(3,d,double,unif,90,.0001,.001,)
688 
689 testCdfPdf0unif(4,d,double,.001,LR_set_all(o,"ab",-2.,2.))
690 testCdfPdf(5,d,double,unif,33,.0001,.001,LR_set_all(o,"ab",-1.,3.))
691 
692 testCdfPdf0unif(0,f,float,.001,)
693 testCdfPdf(1,f,float,unif,20,.0001,.001,)
694 testCdfPdf(2,f,float,unif,50,.0001,.001,)
695 testCdfPdf(3,f,float,unif,90,.0001,.001,)
696 
697 testCdfPdf0unif(4,f,float,.001,LR_set_all(o,"ab",-2.,2.))
698 testCdfPdf(5,f,float,unif,33,.0001,.001,LR_set_all(o,"ab",-1.,3.))
699 
700 testLRunif(1,d,double,unif,10,)
701 testLRunif(2,d,double,unif,25,)
702 testLRunif(3,d,double,unif,20,LR_set_all(o,"ab",-2.,2.))
703 testLRunif(4,d,double,unif,60,LR_set_all(o,"ab",-5.,1.))
704 
705 testLRunif(1,f,float,unif,10,)
706 testLRunif(2,f,float,unif,25,)
707 testLRunif(3,f,float,unif,20,LR_set_all(o,"ab",-2.,2.))
708 testLRunif(4,f,float,unif,60,LR_set_all(o,"ab",-5.,1.))
709 
710 /* piece */
711 /* test some well defined points */
712 
713 #define testCdfPdf0piece(nn,tt,ttt,tol,lo,hi) \
714 void test_cdf_pdf_##tt ## _piece ## _##nn(void) { \
715  LR_obj *o = LR_new(piece, LR_##ttt); \
716  LR_aux_new(o,6); \
717  ttt xlo = lo, xhi = hi, xlen = (xhi - xlo), xun = xlen/8.; \
718  LR_set_all(o,"abx", xlo, xhi, 4.0); \
719 CU_ASSERT_EQUAL(LR_aux_set(o,xlo+2.0*xun, 1.0),0) \
720 CU_ASSERT_EQUAL(LR_aux_set(o,xlo+2.5*xun,-1.0),LRerr_InvalidInputValue) \
721  LR_aux_set(o, xlo + 3.0*xun, 3.0); \
722  LR_aux_set(o, xlo + 4.0*xun, 0.0); \
723  LR_aux_set(o, xlo + 5.0*xun, 5.0); \
724  LR_aux_set(o, xlo + 7.0*xun, 2.0); \
725  LR_aux_norm(o); \
726 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,xlo- .1),0.,tol) \
727 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,xlo- .1),0.,tol) \
728 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,xlo+ .5*xun),.0833,tol) \
729 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,xlo+ .5*xun),.1667/xun,tol) \
730 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,xlo+1.5*xun),.25,tol) \
731 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,xlo+1.5*xun),.1667/xun,tol) \
732 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,xlo+2.5*xun),.3542,tol) \
733 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,xlo+2.5*xun),.0417/xun,tol) \
734 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,xlo+3.5*xun),.4375,tol) \
735 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,xlo+3.5*xun),.125/xun,tol) \
736 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,xlo+4.5*xun),.5,tol) \
737 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,xlo+4.5*xun),.0,tol) \
738 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,xlo+5.5*xun),.6042,tol) \
739 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,xlo+5.5*xun),.2083/xun,tol) \
740 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,xlo+6.5*xun),.8125,tol) \
741 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,xlo+6.5*xun),.2083/xun,tol) \
742 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,xlo+7.5*xun),.9583,tol) \
743 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,xlo+7.5*xun),.0833/xun,tol) \
744 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,xhi+.1),1.,tol) \
745 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,xhi+.1),0.,tol) \
746 }
747 
748 testCdfPdf(0,d,double,piece,75,.0001,.001,
749  LR_aux_new(o,6);
750  LR_set_all(o,"abx", -2., 6., 4.);
751  LR_aux_set(o, o->a.d + 2.0, 1.0);
752  LR_aux_set(o, o->a.d + 3.0, 3.0);
753  LR_aux_set(o, o->a.d + 4.0, 0.0);
754  LR_aux_set(o, o->a.d + 5.0, 5.0);
755  LR_aux_set(o, o->a.d + 7.0, 2.0);
756  LR_aux_norm(o);
757 )
758 testCdfPdf(1,d,double,piece,55,.0001,.001,
759  LR_aux_new(o,6);
760  LR_set_all(o,"abx", -2., 6., 4.);
761  LR_aux_set(o, o->a.d + 2.0, 1.0);
762  LR_aux_set(o, o->a.d + 3.0, 3.0);
763  LR_aux_set(o, o->a.d + 4.0, 0.0);
764  LR_aux_set(o, o->a.d + 5.0, 5.0);
765  LR_aux_set(o, o->a.d + 7.0, 2.0);
766  LR_aux_norm(o);
767 )
768 testCdfPdf0piece(2,d,double,.001,-2.,6.);
769 testCdfPdf0piece(3,d,double,.001,0.,8.);
770 
771 testCdfPdf(0,f,float,piece,75,.0001,.001,
772  LR_aux_new(o,6);
773  LR_set_all(o,"abx", -2., 6., 4.);
774  LR_aux_set(o, o->a.d + 2.0, 1.0);
775  LR_aux_set(o, o->a.d + 3.0, 3.0);
776  LR_aux_set(o, o->a.d + 4.0, 0.0);
777  LR_aux_set(o, o->a.d + 5.0, 5.0);
778  LR_aux_set(o, o->a.d + 7.0, 2.0);
779  LR_aux_norm(o);
780 )
781 testCdfPdf(1,f,float,piece,55,.0001,.001,
782  LR_aux_new(o,6);
783  LR_set_all(o,"abx", -2., 6., 4.);
784  LR_aux_set(o, o->a.d + 2.0, 1.0);
785  LR_aux_set(o, o->a.d + 3.0, 3.0);
786  LR_aux_set(o, o->a.d + 4.0, 0.0);
787  LR_aux_set(o, o->a.d + 5.0, 5.0);
788  LR_aux_set(o, o->a.d + 7.0, 2.0);
789  LR_aux_norm(o);
790 )
791 testCdfPdf0piece(2,f,float,.001,-2.,6.);
792 testCdfPdf0piece(3,f,float,.001,2.,12.);
793 
794 testLRunif(1,d,double,piece,32,
795  LR_aux_new(o,6);
796  LR_set_all(o,"abx", -2., 6., 4.);
797  LR_aux_set(o, o->a.d + 2.0, 1.0);
798  LR_aux_set(o, o->a.d + 3.0, 3.0);
799  LR_aux_set(o, o->a.d + 4.0, 0.0);
800  LR_aux_set(o, o->a.d + 5.0, 5.0);
801  LR_aux_set(o, o->a.d + 7.0, 2.0);
802  LR_aux_norm(o);
803 )
804 testLRunif(2,d,double,piece,75,
805  LR_aux_new(o,6);
806  LR_set_all(o,"abx", -4., 4., 4.);
807  LR_aux_set(o, o->a.d + 2.0, 1.0);
808  LR_aux_set(o, o->a.d + 3.0, 3.0);
809  LR_aux_set(o, o->a.d + 4.0, 0.0);
810  LR_aux_set(o, o->a.d + 5.0, 5.0);
811  LR_aux_set(o, o->a.d + 7.0, 2.0);
812  LR_aux_norm(o);
813 )
814 testLRunif(3,d,double,piece,50,
815  LR_aux_new(o,6);
816  LR_set_all(o,"abx", -1., 4., 3.);
817  LR_aux_set(o, o->a.d + 2.0, 1.0);
818  LR_aux_set(o, o->a.d + 3.0, 3.0);
819  LR_aux_norm(o);
820 )
821 testLRunif(4,d,double,piece,60,
822  LR_aux_new(o,6);
823  LR_set_all(o,"abx", 0., 3., 1.);
824  LR_aux_set(o, o->a.d + 1.0, 2.0);
825  LR_aux_set(o, o->a.d + 2.0, 3.0);
826  LR_aux_norm(o);
827 )
828 testLRunif(1,f,float,piece,32,
829  LR_aux_new(o,6);
830  LR_set_all(o,"abx", -2., 6., 4.);
831  LR_aux_set(o, o->a.f + 2.0, 1.0);
832  LR_aux_set(o, o->a.f + 3.0, 3.0);
833  LR_aux_set(o, o->a.f + 4.0, 0.0);
834  LR_aux_set(o, o->a.f + 5.0, 5.0);
835  LR_aux_set(o, o->a.f + 7.0, 2.0);
836  LR_aux_norm(o);
837 )
838 testLRunif(2,f,float,piece,75,
839  LR_aux_new(o,6);
840  LR_set_all(o,"abx", -4., 4., 4.);
841  LR_aux_set(o, o->a.f + 2.0, 1.0);
842  LR_aux_set(o, o->a.f + 3.0, 3.0);
843  LR_aux_set(o, o->a.f + 4.0, 0.0);
844  LR_aux_set(o, o->a.f + 5.0, 5.0);
845  LR_aux_set(o, o->a.f + 7.0, 2.0);
846  LR_aux_norm(o);
847 )
848 testLRunif(3,f,float,piece,50,
849  LR_aux_new(o,6);
850  LR_set_all(o,"abx", -1., 4., 3.);
851  LR_aux_set(o, o->a.f + 2.0, 1.0);
852  LR_aux_set(o, o->a.f + 3.0, 3.0);
853  LR_aux_norm(o);
854 )
855 testLRunif(4,f,float,piece,60,
856  LR_aux_new(o,6);
857  LR_set_all(o,"abx", 0., 3., 1.);
858  LR_aux_set(o, o->a.f + 1.0, 2.0);
859  LR_aux_set(o, o->a.f + 2.0, 3.0);
860  LR_aux_norm(o);
861 )
862 
863 /* test some errors */
864 #define testBADpiece(nn,tt,ttt,lo,hi,xx,code) \
865 void test_bad_##tt ## _piece ## _##nn(void) { \
866  LR_obj *o = LR_new(piece, LR_##ttt); \
867  LR_aux_new(o,6); \
868  LR_set_all(o,"abx", lo, hi, xx); \
869  code; \
870 }
871 
872 testBADpiece(0,d,double,2.,4.,1.,
873  CU_ASSERT_TRUE(LR_aux_set(o,0.,2.));
874  CU_ASSERT_TRUE(LR_aux_set(o,5.,1.));
875  CU_ASSERT_TRUE(LR_aux_set(o,3.,-2.));
876  CU_ASSERT(isnan(LRd_RAN(o)));
877  CU_ASSERT(isnan(LRd_PDF(o,3.)));
878  CU_ASSERT(isnan(LRd_CDF(o,3.)));
879 )
880 
881 testBADpiece(0,f,float,2.,4.,1.,
882  CU_ASSERT_TRUE(LR_aux_set(o,0.,2.));
883  CU_ASSERT_TRUE(LR_aux_set(o,5.,1.));
884  CU_ASSERT_TRUE(LR_aux_set(o,3.,-2.));
885  CU_ASSERT(isnan(LRf_RAN(o)));
886  CU_ASSERT(isnan(LRf_PDF(o,3.)));
887  CU_ASSERT(isnan(LRf_CDF(o,3.)));
888 )
889 
890 /* gsn2 */
891 #define testCdfPdf0gsn2(nn,tt,ttt,tol,setup) \
892 void test_cdf_pdf_##tt ## _gsn2 ## _##nn(void) { \
893  LR_obj *o = LR_new(gsn2, LR_##ttt); \
894  double ival,pval; \
895  setup; \
896  ival = (o->b.tt - o->a.tt); \
897  pval = 2.0/ival; \
898 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,o->a.tt-.1),0.,tol) \
899 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,o->a.tt-.1),0.,tol) \
900 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,o->a.tt),0.,tol) \
901 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,o->a.tt),0.,tol) \
902 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,o->a.tt+.25*ival),.125,tol) \
903 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,o->a.tt+.25*ival),pval*.5,tol) \
904 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,o->a.tt+.5*ival),.5,tol) \
905 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,o->a.tt+.5*ival),pval,tol) \
906 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,o->a.tt+.75*ival),.875,tol) \
907 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,o->a.tt+.75*ival),pval*.5,tol) \
908 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,o->b.tt),1.,tol) \
909 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,o->b.tt),0.,tol) \
910 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,o->b.tt+.1),1.,tol) \
911 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,o->b.tt+.1),0.,tol) \
912 }
913 
914 testCdfPdf0gsn2(0,d,double,.001,)
915 testCdfPdf(1,d,double,gsn2,20,.0001,.001,)
916 testCdfPdf(2,d,double,gsn2,50,.0001,.001,)
917 testCdfPdf(3,d,double,gsn2,90,.0001,.001,)
918 
919 testCdfPdf0gsn2(4,d,double,.001,LR_set_all(o,"ab",-3.,1.))
920 testCdfPdf(5,d,double,gsn2,33,.0001,.001,LR_set_all(o,"ab",-1.,3.))
921 
922 testSymDF(6,d, double, gsn2, -.9, .9, .0001,);
923 testSymDF(7,d, double, gsn2, -.6, .6, .0001,);
924 testSymDF(8,d, double, gsn2, -.3, .3, .0001,);
925 
926 testCdfPdf0gsn2(0,f,float,.001,)
927 testCdfPdf(1,f,float,gsn2,20,.0001,.003,)
928 testCdfPdf(2,f,float,gsn2,50,.0001,.003,)
929 testCdfPdf(3,f,float,gsn2,90,.0001,.003,)
930 
931 testCdfPdf0gsn2(4,f,float,.003,LR_set_all(o,"ab",-3.,1.))
932 testCdfPdf(5,f,float,gsn2,33,.0001,.003,LR_set_all(o,"ab",-1.,3.))
933 
934 testSymDF(6,f, float, gsn2, -.9, .9, .0001,);
935 testSymDF(7,f, float, gsn2, -.6, .6, .0001,);
936 testSymDF(8,f, float, gsn2, -.3, .3, .0001,);
937 
938 #define testLRgsn2(nn,tt,ttt,bn,setup) \
939  testLRvar(gsn2,nn,tt,ttt,bn,.1,27,setup)
940 
941 testLRgsn2(1,d,double,10,)
942 testLRgsn2(2,d,double,25,)
943 testLRgsn2(3,d,double,20,LR_set_all(o,"ab",-2.,2.))
944 testLRgsn2(4,d,double,30,LR_set_all(o,"ab",-5.,1.))
945 
946 testLRgsn2(1,f,float,10,)
947 testLRgsn2(2,f,float,25,)
948 testLRgsn2(3,f,float,20,LR_set_all(o,"ab",-2.,2.))
949 testLRgsn2(4,f,float,30,LR_set_all(o,"ab",-5.,1.))
950 
951 /* gsn4 */
952 #define testCdfPdf0gsn4(nn,tt,ttt,tol,setup) \
953 void test_cdf_pdf_##tt ## _gsn4 ## _##nn(void) { \
954  LR_obj *o = LR_new(gsn4, LR_##ttt); \
955  double ival,pval; \
956  setup; \
957  ival = (o->b.tt - o->a.tt); \
958  pval = 4.0/ival; \
959 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,o->a.tt-.1),0.,tol) \
960 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,o->a.tt-.1),0.,tol) \
961 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,o->a.tt),0.,tol) \
962 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,o->a.tt),0.,tol) \
963 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,o->a.tt+.25*ival),.041667,tol) \
964 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,o->a.tt+.25*ival),pval*.16666,tol)\
965 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,o->a.tt+.5*ival),.5,tol) \
966 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,o->a.tt+.5*ival),pval*.66666,tol)\
967 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,o->a.tt+.75*ival),.95833,tol) \
968 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,o->a.tt+.75*ival),pval*.16666,tol)\
969 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,o->b.tt),1.,tol) \
970 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,o->b.tt),0.,tol) \
971 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,o->b.tt+.1),1.,tol) \
972 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,o->b.tt+.1),0.,tol) \
973 }
974 
975 testCdfPdf0gsn4(0,d,double,.001,)
976 testCdfPdf(1,d,double,gsn4,20,.0001,.001,)
977 testCdfPdf(2,d,double,gsn4,50,.0001,.001,)
978 testCdfPdf(3,d,double,gsn4,90,.0001,.001,)
979 
980 testCdfPdf0gsn4(4,d,double,.0001,LR_set_all(o,"ab",-3.,1.))
981 testCdfPdf(5,d,double,gsn4,33,.0001,.003,LR_set_all(o,"ab", -1.,4.))
982 
983 testSymDF(6,d, double, gsn4, -1.9, 1.9, .0001,);
984 testSymDF(7,d, double, gsn4, -1.6, 1.6, .0001,);
985 testSymDF(8,d, double, gsn4, -1.3, 1.3, .0001,);
986 testSymDF( 9,d, double, gsn4, -.9, .9, .0001,);
987 testSymDF(10,d, double, gsn4, -.6, .6, .0001,);
988 testSymDF(11,d, double, gsn4, -.3, .3, .0001,);
989 
990 testCdfPdf0gsn4(0,f,float,.001,)
991 testCdfPdf(1,f,float,gsn4,20,.0001,.003,)
992 testCdfPdf(2,f,float,gsn4,50,.0001,.003,)
993 testCdfPdf(3,f,float,gsn4,90,.0001,.003,)
994 
995 testCdfPdf0gsn4(4,f,float,.001,LR_set_all(o,"ab",-3.,1.))
996 testCdfPdf(5,f,float,gsn4,33,.0001,.003,LR_set_all(o,"ab", -1.,4.))
997 
998 testSymDF(6,f, float, gsn4, -1.9, 1.9, .0001,);
999 testSymDF(7,f, float, gsn4, -1.6, 1.6, .0001,);
1000 testSymDF(8,f, float, gsn4, -1.3, 1.3, .0001,);
1001 testSymDF( 9,f, float, gsn4, -.9, .9, .0001,);
1002 testSymDF(10,f, float, gsn4, -.6, .6, .0001,);
1003 testSymDF(11,f, float, gsn4, -.3, .3, .0001,);
1004 
1005 
1006 #define testLRgsn4(nn,tt,ttt,bn,setup) \
1007  testLRvarx(gsn4,nn,tt,ttt,bn,100*10007,.1,100,setup)
1008 
1009 testLRgsn4(1,d,double,10,)
1010 testLRgsn4(2,d,double,25,)
1011 testLRgsn4(3,d,double,20,LR_set_all(o,"ab",-4.,-1.))
1012 testLRgsn4(4,d,double,30,LR_set_all(o,"ab",0.,6.))
1013 
1014 testLRgsn4(1,f,float,10,)
1015 testLRgsn4(2,f,float,25,)
1016 testLRgsn4(3,f,float,20,LR_set_all(o,"ab",-4.,-1.))
1017 testLRgsn4(4,f,float,30,LR_set_all(o,"ab",0.,6.))
1018 
1019 /* gsn12 */
1020 #define testCdfPdf0gsn12(nn,tt,ttt,tol,setup) \
1021 void test_cdf_pdf_##tt ## _gsn12 ## _##nn(void) { \
1022  LR_obj *o = LR_new(gsn12, LR_##ttt); \
1023  setup; \
1024  double m = o->m.tt, s = o->s.tt, iv,pv; \
1025  iv = 2.0*s; \
1026  pv = 2.0/iv; \
1027 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,m-6.1*s),0.,tol) \
1028 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,m-6.1*s),0.,tol) \
1029 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,m-6.0*s),0.,tol) \
1030 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,m-6.0*s),0.,tol) \
1031 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,m-3.0*s),pv*50879./13305600.,tol)\
1032 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,m-3.0*s),397./394240.,tol) \
1033 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,m-2.0*s),pv*1093./19800.,tol) \
1034 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,m-2.0*s),29639./1330560.,tol) \
1035 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,m-s),pv*1623019./6652800.,tol) \
1036 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,m-s),12831419./79833600.,tol) \
1037 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,m),0.5,tol) \
1038 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,m),pv*655177./1663200.,tol) \
1039 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,m+s),pv*1623019./6652800.,tol) \
1040 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,m+s),67002181./79833600.,tol) \
1041 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,m+2.0*s),pv*1093./19800.,tol) \
1042 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,m+2.0*s),1300921./1330560.,tol) \
1043 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,m+3.0*s),pv*50879./13305600.,tol)\
1044 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,m+3.0*s),393843./394240.,tol) \
1045 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,m+6.0*s),0.,tol) \
1046 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,m+6.0*s),1.,tol) \
1047 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,m+6.1*s),0.,tol) \
1048 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,m+6.1*s),1.,tol) \
1049 }
1050 
1051 #define testLRgsn12(nn,tt,ttt,bn,setup) \
1052  testLRfull(gsn12,nn,tt,ttt,4.,bn,100*10007,.1,20,setup)
1053 
1054 testCdfPdf0gsn12(0,d,double,.001,)
1055 testCdfPdf(1,d,double,gsn12,20,.0001,.001,)
1056 testCdfPdf(2,d,double,gsn12,50,.0001,.001,)
1057 testCdfPdf(3,d,double,gsn12,90,.0001,.001,)
1058 
1059 testCdfPdf0gsn12(4,d,double,.0001,LR_set_all(o,"ms",-3.,.5))
1060 testCdfPdf(5,d,double,gsn12,33,.0001,.003,LR_set_all(o,"ms", -1.,2.))
1061 
1062 testSymDF(6,d, double, gsn12, -4.9, 4.9, .0001,);
1063 testSymDF(7,d, double, gsn12, -3.6, 3.6, .0001,);
1064 testSymDF(8,d, double, gsn12, -2.3, 2.3, .0001,);
1065 testSymDF(9,d, double, gsn12, -1.9, 1.9, .0001,);
1066 testSymDF(10,d, double, gsn12, -1.6, 1.6, .0001,);
1067 testSymDF(11,d, double, gsn12, -1.3, 1.3, .0001,);
1068 testSymDF(12,d, double, gsn12, -.9, .9, .0001,);
1069 testSymDF(13,d, double, gsn12, -.6, .6, .0001,);
1070 testSymDF(14,d, double, gsn12, -.3, .3, .0001,);
1071 
1072 testLRgsn12(1,d,double,10,)
1073 testLRgsn12(2,d,double,25,)
1074 testLRgsn12(3,d,double,20,LR_set_all(o,"ms",-2.,2.))
1075 testLRgsn12(4,d,double,30,LR_set_all(o,"ms",1.,.5))
1076 
1077 testCdfPdf0gsn12(0,f,float,.002,)
1078 testCdfPdf(1,f,float,gsn12,20,.0001,.002,)
1079 testCdfPdf(2,f,float,gsn12,50,.0001,.002,)
1080 testCdfPdf(3,f,float,gsn12,90,.0001,.002,)
1081 
1082 testCdfPdf0gsn12(4,f,float,.0001,LR_set_all(o,"ms",-3.,.5))
1083 testCdfPdf(5,f,float,gsn12,33,.0001,.003,LR_set_all(o,"ms", -1.,2.))
1084 
1085 testSymDF(6,f, float, gsn12, -4.9, 4.9, .0001,);
1086 testSymDF(7,f, float, gsn12, -3.6, 3.6, .0001,);
1087 testSymDF(8,f, float, gsn12, -2.3, 2.3, .0001,);
1088 testSymDF(9,f, float, gsn12, -1.9, 1.9, .0001,);
1089 testSymDF(10,f, float, gsn12, -1.6, 1.6, .0001,);
1090 testSymDF(11,f, float, gsn12, -1.3, 1.3, .0001,);
1091 testSymDF(12,f, float, gsn12, -.9, .9, .0001,);
1092 testSymDF(13,f, float, gsn12, -.6, .6, .0001,);
1093 testSymDF(14,f, float, gsn12, -.3, .3, .0001,);
1094 
1095 testLRgsn12(1,f,float,10,)
1096 testLRgsn12(2,f,float,25,)
1097 testLRgsn12(3,f,float,20,LR_set_all(o,"ms",-2.,2.))
1098 testLRgsn12(4,f,float,30,LR_set_all(o,"ms",1.,.5))
1099 
1100 /* lspline */
1101 /* test some well defined points */
1102 #define testCdfPdf0lspline(nn,tt,ttt,tol,lo,hi) \
1103 void test_cdf_pdf_##tt ## _lspline ## _##nn(void) { \
1104  LR_obj *o = LR_new(lspline, LR_##ttt); \
1105  LR_aux_new(o,6); \
1106  ttt xlo = lo, xhi = hi, xlen = (xhi - xlo), xun = xlen/8.; \
1107  LR_set_all(o,"ab", xlo, xhi); \
1108 CU_ASSERT_EQUAL(LR_aux_set(o,xlo+2.0*xun, 1.0),0) \
1109 CU_ASSERT_EQUAL(LR_aux_set(o,xlo+2.5*xun,-1.0),LRerr_InvalidInputValue) \
1110  LR_aux_set(o, xlo + 3.0*xun, 3.0); \
1111  LR_aux_set(o, xlo + 4.0*xun, 0.0); \
1112  LR_aux_set(o, xlo + 5.0*xun, 5.0); \
1113  LR_aux_set(o, xlo + 7.0*xun, 2.0); \
1114  LR_aux_norm(o); \
1115 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,xlo- .1),0.,tol) \
1116 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,xlo- .1),0.,tol) \
1117 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,xlo+ .6*xun),.006,tol) \
1118 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,xlo+ .6*xun),.020/xun,tol) \
1119 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,xlo+1.8*xun),.054,tol) \
1120 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,xlo+1.8*xun),.060/xun,tol) \
1121 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,xlo+2.4*xun),.104,tol) \
1122 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,xlo+2.4*xun),.120/xun,tol) \
1123 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,xlo+3.6*xun),.284,tol) \
1124 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,xlo+3.6*xun),.080/xun,tol) \
1125 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,xlo+4.6*xun),.360,tol) \
1126 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,xlo+4.6*xun),.200/xun,tol) \
1127 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,xlo+5.4*xun),.592,tol) \
1128 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,xlo+5.4*xun),.2933/xun,tol) \
1129 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,xlo+6.6*xun),.872,tol) \
1130 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,xlo+6.6*xun),.1733/xun,tol) \
1131 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,xlo+7.4*xun),.976,tol) \
1132 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,xlo+7.4*xun),.080/xun,tol) \
1133 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,xhi+.1),1.,tol) \
1134 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,xhi+.1),0.,tol) \
1135 }
1136 
1137 testCdfPdf(0,d,double,lspline,75,.0001,.001,
1138  LR_aux_new(o,6);
1139  LR_set_all(o,"ab", -2., 6.);
1140  LR_aux_set(o, o->a.d + 2.0, 1.0);
1141  LR_aux_set(o, o->a.d + 3.0, 3.0);
1142  LR_aux_set(o, o->a.d + 4.0, 0.0);
1143  LR_aux_set(o, o->a.d + 5.0, 5.0);
1144  LR_aux_set(o, o->a.d + 7.0, 2.0);
1145  LR_aux_norm(o);
1146 )
1147 testCdfPdf(1,d,double,lspline,55,.0001,.001,
1148  LR_aux_new(o,6);
1149  LR_set_all(o,"ab", -2., 6.);
1150  LR_aux_set(o, o->a.d + 2.0, 1.0);
1151  LR_aux_set(o, o->a.d + 3.0, 3.0);
1152  LR_aux_set(o, o->a.d + 4.0, 0.0);
1153  LR_aux_set(o, o->a.d + 5.0, 5.0);
1154  LR_aux_set(o, o->a.d + 7.0, 2.0);
1155  LR_aux_norm(o);
1156 )
1157 
1158 testCdfPdf0lspline(2,d,double,.001,-2.,6.);
1159 testCdfPdf0lspline(3,d,double,.001,2.,12.);
1160 
1161 testCdfPdf(0,f,float,lspline,75,.0001,.001,
1162  LR_aux_new(o,6);
1163  LR_set_all(o,"ab", -2., 6.);
1164  LR_aux_set(o, o->a.f + 2.0, 1.0);
1165  LR_aux_set(o, o->a.f + 3.0, 3.0);
1166  LR_aux_set(o, o->a.f + 4.0, 0.0);
1167  LR_aux_set(o, o->a.f + 5.0, 5.0);
1168  LR_aux_set(o, o->a.f + 7.0, 2.0);
1169  LR_aux_norm(o);
1170 )
1171 testCdfPdf(1,f,float,lspline,55,.0001,.001,
1172  LR_aux_new(o,6);
1173  LR_set_all(o,"ab", -2., 6.);
1174  LR_aux_set(o, o->a.f + 2.0, 1.0);
1175  LR_aux_set(o, o->a.f + 3.0, 3.0);
1176  LR_aux_set(o, o->a.f + 4.0, 0.0);
1177  LR_aux_set(o, o->a.f + 5.0, 5.0);
1178  LR_aux_set(o, o->a.f + 7.0, 2.0);
1179  LR_aux_norm(o);
1180 )
1181 
1182 testCdfPdf0lspline(2,f,float,.001,-2.,6.);
1183 testCdfPdf0lspline(3,f,float,.001,2.,12.);
1184 
1185 #define testLRlspl(nn,tt,ttt,bn,setup) \
1186  testLRvar(lspline,nn,tt,ttt,bn,.04,2,setup)
1187 
1188 testLRlspl(1,d,double,75,
1189  LR_aux_new(o,6);
1190  LR_set_all(o,"ab", -2., 6.);
1191  LR_aux_set(o, o->a.d + 2.0, 1.0);
1192  LR_aux_set(o, o->a.d + 3.0, 3.0);
1193  LR_aux_set(o, o->a.d + 4.0, 0.0);
1194  LR_aux_set(o, o->a.d + 5.0, 5.0);
1195  LR_aux_set(o, o->a.d + 7.0, 2.0);
1196  LR_aux_norm(o);
1197 )
1198 
1199 testLRlspl(2,d,double,55,
1200  LR_aux_new(o,6);
1201  LR_set_all(o,"ab", -4., 4.);
1202  LR_aux_set(o, o->a.d + 2.0, 1.0);
1203  LR_aux_set(o, o->a.d + 3.0, 3.0);
1204  LR_aux_set(o, o->a.d + 4.0, 0.0);
1205  LR_aux_set(o, o->a.d + 5.0, 5.0);
1206  LR_aux_set(o, o->a.d + 7.0, 2.0);
1207  LR_aux_norm(o);
1208 )
1209 
1210 /* this should be equivalent to default gsn2, but better tolerances */
1211 
1212 testLRlspl(3,d,double,80,
1213  LR_aux_new(o,2);
1214  LR_aux_set(o, o->a.d + 1.0, 1.0);
1215  LR_aux_norm(o);
1216 )
1217 
1218 testLRlspl(4,d,double,50,
1219  LR_aux_new(o,2);
1220  LR_aux_set(o, o->a.d + 1.0, 1.0);
1221  LR_aux_norm(o);
1222 )
1223 
1224 testLRlspl(1,f,float,75,
1225  LR_aux_new(o,6);
1226  LR_set_all(o,"ab", -2., 6.);
1227  LR_aux_set(o, o->a.f + 2.0, 1.0);
1228  LR_aux_set(o, o->a.f + 3.0, 3.0);
1229  LR_aux_set(o, o->a.f + 4.0, 0.0);
1230  LR_aux_set(o, o->a.f + 5.0, 5.0);
1231  LR_aux_set(o, o->a.f + 7.0, 2.0);
1232  LR_aux_norm(o);
1233 )
1234 
1235 testLRlspl(2,f,float,55,
1236  LR_aux_new(o,6);
1237  LR_set_all(o,"ab", -4., 4.);
1238  LR_aux_set(o, o->a.f + 2.0, 1.0);
1239  LR_aux_set(o, o->a.f + 3.0, 3.0);
1240  LR_aux_set(o, o->a.f + 4.0, 0.0);
1241  LR_aux_set(o, o->a.f + 5.0, 5.0);
1242  LR_aux_set(o, o->a.f + 7.0, 2.0);
1243  LR_aux_norm(o);
1244 )
1245 
1246 testLRlspl(3,f,float,80,
1247  LR_aux_new(o,2);
1248  LR_aux_set(o, o->a.f + 1.0, 1.0);
1249  LR_aux_norm(o);
1250 )
1251 
1252 testLRlspl(4,f,float,50,
1253  LR_aux_new(o,2);
1254  LR_aux_set(o, o->a.f + 1.0, 1.0);
1255  LR_aux_norm(o);
1256 )
1257 
1258 /* test some errors */
1259 #define testBADlspline(nn,tt,ttt,lo,hi,code) \
1260 void test_bad_##tt ## _lspline ## _##nn(void) { \
1261  LR_obj *o = LR_new(lspline, LR_##ttt); \
1262  LR_aux_new(o,6); \
1263  LR_set_all(o,"ab", lo, hi); \
1264  code; \
1265 }
1266 
1267 testBADlspline(0,d,double,2.,4.,
1268  CU_ASSERT_TRUE(LR_aux_set(o,0.,2.));
1269  CU_ASSERT_TRUE(LR_aux_set(o,5.,1.));
1270  CU_ASSERT_TRUE(LR_aux_set(o,3.,-2.));
1271  CU_ASSERT_TRUE(LR_aux_norm(o));
1272  CU_ASSERT(isnan(LRd_RAN(o)));
1273  CU_ASSERT(isnan(LRd_PDF(o,3.)));
1274  CU_ASSERT(isnan(LRd_CDF(o,3.)));
1275 )
1276 
1277 testBADlspline(0,f,float,2.,4.,
1278  CU_ASSERT_TRUE(LR_aux_set(o,0.,2.));
1279  CU_ASSERT_TRUE(LR_aux_set(o,5.,1.));
1280  CU_ASSERT_TRUE(LR_aux_set(o,3.,-2.));
1281  CU_ASSERT_TRUE(LR_aux_norm(o));
1282  CU_ASSERT(isnan(LRf_RAN(o)));
1283  CU_ASSERT(isnan(LRf_PDF(o,3.)));
1284  CU_ASSERT(isnan(LRf_CDF(o,3.)));
1285 )
1286 
1287 /* uinvcdf */
1288 double MyCDF(double x) {
1289  static double pi4 = NAN;
1290  double zero = 0.0, one = 1.0, two = 2.0;
1291  if (isnan(pi4))
1292  pi4 = atan(one);
1293 
1294  if (x <= zero) {
1295  return zero;
1296  } else if (x >= two) {
1297  return one;
1298  } else {
1299  double t = sin(pi4*x);
1300  return t*t;
1301  }
1302 }
1303 
1304 double MyCDF2(double x) {
1305  return MyCDF(x + 2.0);
1306 }
1307 
1308 double MyCDFc(double x) {
1309 /* Cauchy CDF (moved by 0.5) */
1310  double half = 0.5;
1311  return half + M_1_PI *atan(x - half);
1312 }
1313 
1314 float MyCDFf(float x) {
1315  static float pi4 = NAN;
1316  float zero = 0.0, one = 1.0, two = 2.0;
1317  if (isnan(pi4))
1318  pi4 = atan(one);
1319 
1320  if (x <= zero) {
1321  return zero;
1322  } else if (x >= two) {
1323  return one;
1324  } else {
1325  float t = sin(pi4*x);
1326  return t*t;
1327  }
1328 }
1329 
1330 float MyCDF2f(float x) {
1331  return MyCDF(x + 2.0);
1332 }
1333 
1334 float MyCDFcf(float x) {
1335 /* Cauchy CDF (moved by 0.5) */
1336  float half = 0.5;
1337  return half + M_1_PI *atan(x - half);
1338 }
1339 
1340 #define testCdfPdf0uinvcdf(nn,tt,ttt,cdf,tol,xlo,xhi) \
1341 void test_cdf_pdf_##tt ## _uinvcdf ## _##nn(void) { \
1342  LR_obj *o = LR_new(uinvcdf, LR_##ttt); \
1343  ttt xun = (xhi - xlo); \
1344  LR_set_all(o,"ab", xlo, xhi); \
1345  LR##tt ## _uinvcdf(o,cdf); \
1346 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,xlo-.1),0.,tol) \
1347 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,xlo-.1),0.,tol) \
1348 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,xlo+.25*xun),.146447,tol) \
1349 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,xlo+.25*xun),.555360,tol) \
1350 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,xlo+.50*xun),.500000,tol) \
1351 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,xlo+.50*xun),.785398,tol) \
1352 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,xlo+.60*xun),.654509,tol) \
1353 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,xlo+.60*xun),.746958,tol) \
1354 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,xlo+.80*xun),.904509,tol) \
1355 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,xlo+.80*xun),.461645,tol) \
1356 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,xlo+.95*xun),.993844,tol) \
1357 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,xlo+.95*xun),.122863,tol) \
1358 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,xhi+.1),1.,tol) \
1359 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,xhi+.1),0.,tol) \
1360 }
1361 
1362 testLRcheck(9, uinvcdf, d, double,
1363  CU_ASSERT_EQUAL(LRf_uinvcdf(o,MyCDFf), LRerr_BadDataType);
1364 )
1365 testLRcheck(9, uinvcdf, f, float,
1366  CU_ASSERT_EQUAL(LRd_uinvcdf(o,MyCDF), LRerr_BadDataType);
1367 )
1368 
1369 testCdfPdf0uinvcdf(0,d,double,MyCDF,.0001,0.,2.);
1370 testCdfPdf0uinvcdf(1,d,double,MyCDF2,.0001,-2.,0.);
1371 testSymDF(2,d,double,uinvcdf, .1, 1.9,.0001,
1372  LR_set_all(o,"ab", 0., 2.);
1373  LRd_uinvcdf(o,MyCDF);
1374 )
1375 testSymDF(3,d,double,uinvcdf, .25, 1.75,.0001,
1376  LR_set_all(o,"ab", 0., 2.);
1377  LRd_uinvcdf(o,MyCDF);
1378 )
1379 testSymDF(4,d,double,uinvcdf, .5, 1.5,.0001,
1380  LR_set_all(o,"ab", 0., 2.);
1381  LRd_uinvcdf(o,MyCDF);
1382 )
1383 testSymDF(5,d,double,uinvcdf, .75, 1.25,.0001,
1384  LR_set_all(o,"ab", 0., 2.);
1385  LRd_uinvcdf(o,MyCDF);
1386 )
1387 testSymDF(6,d,double,uinvcdf, .9, 1.1,.0001,
1388  LR_set_all(o,"ab", 0., 2.);
1389  LRd_uinvcdf(o,MyCDF);
1390 )
1391 testLRvar(uinvcdf,7,d,double, 40, .1, 10,
1392  LR_set_all(o,"ab", 0., 2.);
1393  LRd_uinvcdf(o,MyCDF);
1394 )
1395 testLRvar(uinvcdf,8,d,double, 60, .1, 10,
1396  LR_set_all(o,"ab", -2., 0.);
1397  LRd_uinvcdf(o,MyCDF2);
1398 )
1399 
1400 testCdfPdf0uinvcdf(0,f,float,MyCDFf,.001,0.,2.);
1401 testCdfPdf0uinvcdf(1,f,float,MyCDF2f,.001,-2.,0.);
1402 testSymDF(2,f,float,uinvcdf, .1, 1.9,.001,
1403  LR_set_all(o,"ab", 0., 2.);
1404  LRf_uinvcdf(o,MyCDFf);
1405 )
1406 testSymDF(3,f,float,uinvcdf, .25, 1.75,.001,
1407  LR_set_all(o,"ab", 0., 2.);
1408  LRf_uinvcdf(o,MyCDFf);
1409 )
1410 testSymDF(4,f,float,uinvcdf, .5, 1.5,.001,
1411  LR_set_all(o,"ab", 0., 2.);
1412  LRf_uinvcdf(o,MyCDFf);
1413 )
1414 testSymDF(5,f,float,uinvcdf, .75, 1.25,.001,
1415  LR_set_all(o,"ab", 0., 2.);
1416  LRf_uinvcdf(o,MyCDFf);
1417 )
1418 testSymDF(6,f,float,uinvcdf, .9, 1.1,.001,
1419  LR_set_all(o,"ab", 0., 2.);
1420  LRf_uinvcdf(o,MyCDFf);
1421 )
1422 testLRvar(uinvcdf,7,f,float, 40, .1, 10,
1423  LR_set_all(o,"ab", 0., 2.);
1424  LRf_uinvcdf(o,MyCDFf);
1425 )
1426 testLRvar(uinvcdf,8,f,float, 60, .1, 10,
1427  LR_set_all(o,"ab", -2., 0.);
1428  LRf_uinvcdf(o,MyCDF2f);
1429 )
1430 
1431 /* CDF/PDF tests for half range */
1432 /* testCdfPdfHR (half range)
1433  * nn - test number
1434  * tt - LR data type (d or f)
1435  * ttt - LR data type (double or float)
1436  * dist - LR variate type
1437  * end - upper value
1438  * nnt - number of test values
1439  * tol - absolute tolerance
1440  * setup- LR object parameter set-up
1441  */
1442 #define testCdfPdfHR(nn,tt,ttt,dist,end,nnt,tol,setup) \
1443 void test_cdf_pdf_##tt ## _##dist ## _##nn(void) { \
1444  LR_obj *o = LR_new(dist, LR_##ttt); \
1445  double incr = end/nnt, x = 0.0; \
1446  setup; \
1447  for (int i = 0; i < nnt; i++) { \
1448  compCdfPdf(tt,o,x,x+.0001,tol) \
1449  x += incr; \
1450  } \
1451 }
1452 
1453 /* negative exponential */
1454 /* nn - test #
1455  * tt - LR data type (d or f)
1456  * ttt - data type (double or float)
1457  * tol - tolerance
1458  * mean - mean value
1459  */
1460 #define testCdfPdf0nexp(dist,nn,tt,ttt,tol,mean) \
1461 void test_cdf_pdf_##tt ## _ ## dist ## _##nn(void) { \
1462  LR_obj *o = LR_new(dist, LR_##ttt); \
1463  LR_set_all(o,"m", mean); \
1464  ttt cc = 1.0/M_E; \
1465  ttt cc2 = sqrt(cc); \
1466 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,mean*0.5),1.0-cc2,tol) \
1467 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,mean*0.5),cc2/mean,tol) \
1468 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,mean),1.0-cc,tol) \
1469 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,mean),cc/mean,tol) \
1470 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,mean*2.0),1.0-cc*cc,tol) \
1471 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,mean*2.0),cc*cc/mean,tol) \
1472 }
1473 
1474 testCdfPdf0nexp(nexp,0,d,double,.0001,1.0)
1475 testCdfPdf0nexp(nexp,1,d,double,.0001,.3)
1476 testCdfPdf0nexp(nexp,2,d,double,.0001,3.0)
1477 
1478 testCdfPdfHR(3,d,double,nexp,3.,60,.0001,)
1479 testCdfPdfHR(4,d,double,nexp,3.,60,.0005,
1480  LR_set_all(o,"m", .5);
1481 )
1482 testCdfPdfHR(5,d,double,nexp,4.,80,.0001,
1483  LR_set_all(o,"m", 2.);
1484 )
1485 
1486 testCdfPdf0nexp(nexp,0,f,float,.001,1.0)
1487 testCdfPdf0nexp(nexp,1,f,float,.001,.3)
1488 testCdfPdf0nexp(nexp,2,f,float,.001,3.0)
1489 
1490 testCdfPdfHR(3,f,float,nexp,3.,60,.001,)
1491 testCdfPdfHR(4,f,float,nexp,3.,60,.005,
1492  LR_set_all(o,"m", .5);
1493 )
1494 testCdfPdfHR(5,f,float,nexp,4.,80,.001,
1495  LR_set_all(o,"m", 2.);
1496 )
1497 
1498 #define testLRnexp(nn,tt,ttt,end,bn,setup) \
1499  testLRhalf(nexp,nn,tt,ttt,end,bn,50*10007,.1,100,setup)
1500 
1501 testLRnexp(1,d,double,3.0,60, )
1502 testLRnexp(2,d,double,2.0,60,
1503  LR_set_all(o,"m", .5);
1504 )
1505 testLRnexp(3,d,double,4.0,80,
1506  LR_set_all(o,"m", 2.0);
1507 )
1508 
1509 testLRnexp(1,f,float,3.0,60, )
1510 testLRnexp(2,f,float,2.0,60,
1511  LR_set_all(o,"m", .5);
1512 )
1513 testLRnexp(3,f,float,4.0,80,
1514  LR_set_all(o,"m", 2.0);
1515 )
1516 
1517 /* erlang */
1518 #define testLRerlang(nn,tt,ttt,end,bn,setup) \
1519  testLRhalf(erlang,nn,tt,ttt,end,bn,50*10007,.1,100,setup)
1520 
1521 /* default k=1 => nexp */
1522 testCdfPdf0nexp(erlang,0,d,double,.0001,1.0)
1523 testCdfPdf0nexp(erlang,1,d,double,.0001,.3)
1524 testCdfPdf0nexp(erlang,2,d,double,.0001,3.0)
1525 
1526 testCdfPdfHR(3,d,double,erlang,3.,60,.0001,)
1527 testCdfPdfHR(4,d,double,erlang,3.,60,.0005,
1528  LR_set_all(o,"m", .5);
1529 )
1530 testCdfPdfHR(5,d,double,erlang,4.,80,.0001,
1531  LR_set_all(o,"m", 2.);
1532 )
1533 
1534 testLRerlang(1,d,double,3.0,60, )
1535 testLRerlang(2,d,double,2.0,60,
1536  LR_set_all(o,"m", .5);
1537 )
1538 testLRerlang(3,d,double,4.0,80,
1539  LR_set_all(o,"m", 2.0);
1540 )
1541 
1542 /* k=2 */
1543 #define testCdfPdf0erlang2(nn,tt,ttt,tol,mn) \
1544 void test_cdf_pdf_##tt ## _ ## erlang2 ## _##nn(void) { \
1545  LR_obj *o = LR_new(erlang, LR_##ttt); \
1546  LR_set_all(o,"mk", mn, 2); \
1547  ttt cc = 1.0/M_E; \
1548  ttt cc2 = sqrt(cc); \
1549  ttt xm = 1.0/mn; \
1550 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,-.1),0.,tol) \
1551 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,-.1),0.,tol) \
1552 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,mn*0.5),1.0-cc2*1.5,tol) \
1553 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,mn*0.5),.5*cc2*xm,tol) \
1554 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,mn),1.0-cc*2.0,tol) \
1555 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,mn),cc*xm,tol) \
1556 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,mn*2.0),1.0-cc*cc*3.0,tol) \
1557 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,mn*2.0),2.0*cc*cc*xm,tol) \
1558 }
1559 
1560 testCdfPdf0erlang2(0,d,double,.0001,1.0)
1561 testCdfPdf0erlang2(1,d,double,.0001,.3)
1562 testCdfPdf0erlang2(2,d,double,.0001,3.0)
1563 testLRerlang(4,d,double,3.0,60,
1564  LR_set_all(o,"k", 2);
1565 )
1566 testLRerlang(5,d,double,2.0,60,
1567  LR_set_all(o,"km", 2, .5);
1568 )
1569 testLRerlang(6,d,double,4.0,80,
1570  LR_set_all(o,"km", 2, 2.0);
1571 )
1572 
1573 /* k=3 */
1574 #define testCdfPdf0erlang3(nn,tt,ttt,tol,mn) \
1575 void test_cdf_pdf_##tt ## _ ## erlang3 ## _##nn(void) { \
1576  LR_obj *o = LR_new(erlang, LR_##ttt); \
1577  LR_set_all(o,"mk", mn, 3); \
1578  ttt cc = 1.0/M_E; \
1579  ttt cc2 = sqrt(cc); \
1580  ttt xm = 1.0/mn; \
1581 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,-.1),0.,tol) \
1582 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,-.1),0.,tol) \
1583 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,mn*0.5),1.0-cc2*1.625,tol) \
1584 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,mn*0.5),.125*cc2*xm,tol) \
1585 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,mn),1.0-cc*2.5,tol) \
1586 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,mn),.5*cc*xm,tol) \
1587 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,mn*2.0),1.0-cc*cc*5.0,tol) \
1588 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,mn*2.0),2.0*cc*cc*xm,tol) \
1589 }
1590 
1591 testCdfPdf0erlang3(0,d,double,.0001,1.0)
1592 testCdfPdf0erlang3(1,d,double,.0001,.3)
1593 testCdfPdf0erlang3(2,d,double,.0001,3.0)
1594 testLRerlang(7,d,double,3.0,60,
1595  LR_set_all(o,"k", 3);
1596 )
1597 testLRerlang(8,d,double,2.0,60,
1598  LR_set_all(o,"km", 3, .5);
1599 )
1600 testLRerlang(9,d,double,4.0,80,
1601  LR_set_all(o,"km", 3, 2.0);
1602 )
1603 
1604 /* k=4 */
1605 #define testCdfPdf0erlang4(nn,tt,ttt,tol,mn) \
1606 void test_cdf_pdf_##tt ## _ ## erlang4 ## _##nn(void) { \
1607  LR_obj *o = LR_new(erlang, LR_##ttt); \
1608  LR_set_all(o,"mk", mn, 4); \
1609  ttt cc = 1.0/M_E; \
1610  ttt cc2 = sqrt(cc); \
1611  ttt xm = 1.0/mn; \
1612 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,-.1),0.,tol) \
1613 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,-.1),0.,tol) \
1614 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,mn*0.5),1.0-cc2*1.645833,tol) \
1615 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,mn*0.5),.02083333*cc2*xm,tol) \
1616 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,mn),1.0-cc*2.666667,tol) \
1617 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,mn),.1666667*cc*xm,tol) \
1618 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,mn*2.0),1.0-cc*cc*6.333333,tol) \
1619 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,mn*2.0),1.3333333*cc*cc*xm,tol) \
1620 }
1621 
1622 testCdfPdf0erlang4(0,d,double,.0001,1.0)
1623 testCdfPdf0erlang4(1,d,double,.0001,.3)
1624 testCdfPdf0erlang4(2,d,double,.0001,3.0)
1625 testLRerlang(10,d,double,3.0,60,
1626  LR_set_all(o,"k", 4);
1627 )
1628 testLRerlang(11,d,double,2.0,60,
1629  LR_set_all(o,"km", 4, .5);
1630 )
1631 testLRerlang(12,d,double,4.0,80,
1632  LR_set_all(o,"km", 4, 2.0);
1633 )
1634 
1635 /* float erlang */
1636 testCdfPdf0nexp(erlang,0,f,float,.0001,1.0)
1637 testCdfPdf0nexp(erlang,1,f,float,.0001,.3)
1638 testCdfPdf0nexp(erlang,2,f,float,.0001,3.0)
1639 
1640 testCdfPdfHR(3,f,float,erlang,3.,60,.001,)
1641 testCdfPdfHR(4,f,float,erlang,3.,60,.005,
1642  LR_set_all(o,"m", .5);
1643 )
1644 testCdfPdfHR(5,f,float,erlang,4.,80,.001,
1645  LR_set_all(o,"m", 2.);
1646 )
1647 
1648 testLRerlang(1,f,float,3.0,60, )
1649 testLRerlang(2,f,float,2.0,60,
1650  LR_set_all(o,"m", .5);
1651 )
1652 testLRerlang(3,f,float,4.0,80,
1653  LR_set_all(o,"m", 2.0);
1654 )
1655 
1656 testCdfPdf0erlang2(0,f,float,.001,1.0)
1657 testCdfPdf0erlang2(1,f,float,.001,.3)
1658 testCdfPdf0erlang2(2,f,float,.001,3.0)
1659 testLRerlang(4,f,float,3.0,60,
1660  LR_set_all(o,"k", 2);
1661 )
1662 testLRerlang(5,f,float,2.0,60,
1663  LR_set_all(o,"km", 2, .5);
1664 )
1665 testLRerlang(6,f,float,4.0,80,
1666  LR_set_all(o,"km", 2, 2.0);
1667 )
1668 
1669 testCdfPdf0erlang3(0,f,float,.001,1.0)
1670 testCdfPdf0erlang3(1,f,float,.001,.3)
1671 testCdfPdf0erlang3(2,f,float,.001,3.0)
1672 testLRerlang(7,f,float,3.0,60,
1673  LR_set_all(o,"k", 3);
1674 )
1675 testLRerlang(8,f,float,2.0,60,
1676  LR_set_all(o,"km", 3, .5);
1677 )
1678 testLRerlang(9,f,float,4.0,80,
1679  LR_set_all(o,"km", 3, 2.0);
1680 )
1681 
1682 testCdfPdf0erlang4(0,f,float,.001,1.0)
1683 testCdfPdf0erlang4(1,f,float,.001,.3)
1684 testCdfPdf0erlang4(2,f,float,.001,3.0)
1685 testLRerlang(10,f,float,3.0,60,
1686  LR_set_all(o,"k", 4);
1687 )
1688 testLRerlang(11,f,float,2.0,60,
1689  LR_set_all(o,"km", 4, .5);
1690 )
1691 testLRerlang(12,f,float,4.0,80,
1692  LR_set_all(o,"km", 4, 2.0);
1693 )
1694 
1695 /* CDF/PDF tests for full range */
1696 /* testCdfPdfFR (full range)
1697  * nn - test number
1698  * tt - LR data type (d or f)
1699  * ttt - LR data type (double or float)
1700  * dist - LR variate type
1701  * ww - number of std.dev on either side of mean.
1702  * nnt - number of test values
1703  * tol - absolute tolerance
1704  * setup- LR object parameter set-up
1705  */
1706 #define testCdfPdfFR(nn,tt,ttt,dist,ww,nnt,tol,setup) \
1707 void test_cdf_pdf_##tt ## _##dist ## _##nn(void) { \
1708  LR_obj *o = LR_new(dist, LR_##ttt); \
1709  double incr, x; \
1710  setup; \
1711  incr = 2.*ww*o->s.tt/nnt; \
1712  x = o->m.tt - o->s.tt*ww; \
1713  for (int i = 0; i < nnt; i++) { \
1714  compCdfPdf(tt,o,x,x+.0001,tol) \
1715  x += incr; \
1716  } \
1717 }
1718 
1719 /* gaussian/normal */
1720 /* ggg - gaussian/normal type
1721  * nn - test #
1722  * tt - LR data type (d or f)
1723  * ttt - data type (double or float)
1724  * tol - tolerance
1725  * mean - central value
1726  * dev - std.deviation width
1727  */
1728 #define testCdfPdf0gaus(ggg,nn,tt,ttt,tol,mean,dev) \
1729 void test_cdf_pdf_##tt ## _##ggg ## _##nn(void) { \
1730  LR_obj *o = LR_new(ggg, LR_##ttt); \
1731  ttt cc = .5*M_2_SQRTPI*M_SQRT1_2/dev; \
1732  ttt ee = exp(-0.5); \
1733  ttt efm1 = .5*(1.0 + erf(-M_SQRT1_2)); \
1734  ttt efp1 = .5*(1.0 + erf(M_SQRT1_2)); \
1735  LR_set_all(o,"ms", mean, dev); \
1736 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,mean-dev),efm1,tol) \
1737 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,mean-dev),cc*ee,tol) \
1738 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,mean),.5,tol) \
1739 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,mean),cc,tol) \
1740 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,mean+dev),efp1,tol) \
1741 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,mean+dev),cc*ee,tol) \
1742 }
1743 
1744 testCdfPdf0gaus(gausbm,0,d,double,.0001,0.0, 1.0)
1745 testCdfPdf0gaus(gausbm,1,d,double,.0001,-1.0, 2.0)
1746 testCdfPdf0gaus(gausbm,2,d,double,.0001,1.5, .5)
1747 
1748 testCdfPdf0gaus(gausbm,0,f,float,.0001,0.0, 1.0)
1749 testCdfPdf0gaus(gausbm,1,f,float,.0001,-1.0, 2.0)
1750 testCdfPdf0gaus(gausbm,2,f,float,.0001,1.5, .5)
1751 
1752 testCdfPdfFR(3,d,double,gausbm,3,60,.0001,)
1753 testCdfPdfFR(4,d,double,gausbm,3,60,.0001,
1754  LR_set_all(o,"ms", -2., .75);
1755 )
1756 testCdfPdfFR(5,d,double,gausbm,4,80,.0001,
1757  LR_set_all(o,"ms", 2., 2.50);
1758 )
1759 
1760 testSymDF(6,d, double, gausbm, -5.5, 5.5, .0001,);
1761 testSymDF(7,d, double, gausbm, -4.6, 4.6, .0001,);
1762 testSymDF(8,d, double, gausbm, -3.3, 3.3, .0001,);
1763 testSymDF(9,d, double, gausbm, -2.9, 2.9, .0001,);
1764 testSymDF(10,d, double, gausbm,-1.4, 1.4, .0001,);
1765 testSymDF(11,d, double, gausbm, -.7, .7, .0001,);
1766 
1767 testCdfPdfFR(3,f,float,gausbm,3,60,.001,)
1768 testCdfPdfFR(4,f,float,gausbm,3,60,.001,
1769  LR_set_all(o,"ms", -2., .75);
1770 )
1771 testCdfPdfFR(5,f,float,gausbm,4,80,.001,
1772  LR_set_all(o,"ms", 2., 2.50);
1773 )
1774 testSymDF(6,f, float, gausbm, -5.5, 5.5, .0001,);
1775 testSymDF(7,f, float, gausbm, -4.6, 4.6, .0001,);
1776 testSymDF(8,f, float, gausbm, -3.3, 3.3, .0001,);
1777 testSymDF(9,f, float, gausbm, -2.9, 2.9, .0001,);
1778 testSymDF(10,f, float, gausbm,-1.4, 1.4, .0001,);
1779 testSymDF(11,f, float, gausbm, -.7, .7, .0001,);
1780 
1781 testCdfPdf0gaus(gausmar,0,d,double,.0001,0.0, 1.0)
1782 testCdfPdf0gaus(gausmar,0,f,float,.001,0.0, 1.0)
1783 testCdfPdfFR(1,d,double,gausmar,3,60,.0001,)
1784 testCdfPdfFR(1,f,float,gausmar,3,60,.001,)
1785 
1786 #define testLRgausbm(nn,tt,ttt,ww,bn,setup) \
1787  testLRfull(gausbm,nn,tt,ttt,ww,bn,50*10007,.1,100,setup)
1788 
1789 testLRgausbm(1,d,double,3.0,60, )
1790 testLRgausbm(2,d,double,3.0,60,
1791  LR_set_all(o,"ms", -2., .75);
1792 )
1793 testLRgausbm(3,d,double,3.0,60,
1794  LR_set_all(o,"ms", 2., 2.50);
1795 )
1796 
1797 testLRgausbm(1,f,float,3.0,60, )
1798 testLRgausbm(2,f,float,3.0,60,
1799  LR_set_all(o,"ms", -2., .75);
1800 )
1801 testLRgausbm(3,f,float,3.0,60,
1802  LR_set_all(o,"ms", 2., 2.50);
1803 )
1804 
1805 #define testLRgausmar(nn,tt,ttt,ww,bn,setup) \
1806  testLRfull(gausmar,nn,tt,ttt,ww,bn,50*10007,.1,100,setup)
1807 
1808 testLRgausmar(1,d,double,3.0,60, )
1809 testLRgausmar(2,d,double,3.0,60,
1810  LR_set_all(o,"ms", -2., .75);
1811 )
1812 testLRgausmar(3,d,double,3.0,60,
1813  LR_set_all(o,"ms", 2., 2.50);
1814 )
1815 
1816 testLRgausmar(1,f,float,3.0,60, )
1817 testLRgausmar(2,f,float,3.0,60,
1818  LR_set_all(o,"ms", -2., .75);
1819 )
1820 testLRgausmar(3,f,float,3.0,60,
1821  LR_set_all(o,"ms", 2., 2.50);
1822 )
1823 
1824 /* Cauchy/Lortentz */
1825 /* dist - LR_type
1826  * nn - test #
1827  * tt - LR data type (d or f)
1828  * ttt - data type (double or float)
1829  * tol - tolerance
1830  * peak - central value
1831  * wid - peak width
1832  * setup - added code
1833  */
1834 #define testCdfPdf0cauchy(dist,nn,tt,ttt,tol,peak,wid,setup) \
1835 void test_cdf_pdf_##tt ## _## dist ## _##nn(void) { \
1836  LR_obj *o = LR_new(dist, LR_##ttt); \
1837  setup; \
1838  ttt cc = M_1_PI/wid; \
1839  LR_set_all(o,"ms", peak, wid); \
1840 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,peak-wid),.25,tol) \
1841 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,peak-wid),cc*.5,tol) \
1842 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,peak),.5,tol) \
1843 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,peak),cc,tol) \
1844 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _CDF(o,peak+wid),.75,tol) \
1845 CU_ASSERT_DOUBLE_EQUAL(LR##tt ## _PDF(o,peak+wid),cc*.5,tol) \
1846 }
1847 
1848 testCdfPdf0cauchy(cauchy,0,d,double,.0001,0.0, 1.0, )
1849 testCdfPdf0cauchy(cauchy,1,d,double,.0001,-1.0, 2.0, )
1850 testCdfPdf0cauchy(cauchy,2,d,double,.0001,1.5, .5, )
1851 
1852 testCdfPdfFR(3,d,double,cauchy,3,60,.0001,)
1853 testCdfPdfFR(4,d,double,cauchy,3,60,.0001,
1854  LR_set_all(o,"ms", -2., .75);
1855 )
1856 testCdfPdfFR(5,d,double,cauchy,4,80,.0001,
1857  LR_set_all(o,"ms", 2., 2.50);
1858 )
1859 
1860 testSymDF(6,d, double, cauchy, -5.5, 5.5, .0001,);
1861 testSymDF(7,d, double, cauchy, -4.6, 4.6, .0001,);
1862 testSymDF(8,d, double, cauchy, -3.3, 3.3, .0001,);
1863 testSymDF(9,d, double, cauchy, -2.9, 2.9, .0001,);
1864 testSymDF(10,d, double, cauchy,-1.4, 1.4, .0001,);
1865 testSymDF(11,d, double, cauchy, -.7, .7, .0001,);
1866 
1867 testCdfPdf0cauchy(cauchy,0,f,float,.001,0.0, 1.0, )
1868 testCdfPdf0cauchy(cauchy,1,f,float,.001,-1.0, 2.0, )
1869 testCdfPdf0cauchy(cauchy,2,f,float,.001,1.5, .5, )
1870 
1871 testCdfPdfFR(3,f,float,cauchy,3,60,.001,)
1872 testCdfPdfFR(4,f,float,cauchy,3,60,.001,
1873  LR_set_all(o,"ms", -2., .75);
1874 )
1875 testCdfPdfFR(5,f,float,cauchy,4,80,.001,
1876  LR_set_all(o,"ms", 2., 2.50);
1877 )
1878 
1879 testSymDF(6,f, float, cauchy, -5.5, 5.5, .0001,);
1880 testSymDF(7,f, float, cauchy, -4.6, 4.6, .0001,);
1881 testSymDF(8,f, float, cauchy, -3.3, 3.3, .0001,);
1882 testSymDF(9,f, float, cauchy, -2.9, 2.9, .0001,);
1883 testSymDF(10,f, float, cauchy,-1.4, 1.4, .0001,);
1884 testSymDF(11,f, float, cauchy, -.7, .7, .0001,);
1885 
1886 testCdfPdf0cauchy(cauchymar,0,d,double,.0001,0.0, 1.0, )
1887 testCdfPdf0cauchy(cauchymar,1,d,double,.0001,-1.0, 2.0, )
1888 testCdfPdf0cauchy(cauchymar,0,f,float,.001,0.0, 1.0, )
1889 testCdfPdf0cauchy(cauchymar,1,f,float,.001,-1.0, 2.0, )
1890 
1891 #define testLRcauchy(nn,tt,ttt,ww,bn,setup) \
1892  testLRfull(cauchy,nn,tt,ttt,ww,bn,50*10007,.1,100,setup)
1893 
1894 testLRcauchy(1,d,double,3.0,60, )
1895 testLRcauchy(2,d,double,3.0,60,
1896  LR_set_all(o,"ms", -2., .75);
1897 )
1898 testLRcauchy(3,d,double,3.0,60,
1899  LR_set_all(o,"ms", 2., 2.50);
1900 )
1901 
1902 testLRcauchy(1,f,float,3.0,60, )
1903 testLRcauchy(2,f,float,3.0,60,
1904  LR_set_all(o,"ms", -2., .75);
1905 )
1906 testLRcauchy(3,f,float,3.0,60,
1907  LR_set_all(o,"ms", 2., 2.50);
1908 )
1909 
1910 #define testLRcauchymar(nn,tt,ttt,ww,bn,setup) \
1911  testLRfull(cauchymar,nn,tt,ttt,ww,bn,50*10007,.1,100,setup)
1912 
1913 testLRcauchymar(1,d,double,3.0,60, )
1914 testLRcauchymar(2,d,double,3.0,60,
1915  LR_set_all(o,"ms", -2., .75);
1916 )
1917 testLRcauchymar(3,d,double,3.0,60,
1918  LR_set_all(o,"ms", 2., 2.50);
1919 )
1920 
1921 testLRcauchymar(1,f,float,3.0,60, )
1922 testLRcauchymar(2,f,float,3.0,60,
1923  LR_set_all(o,"ms", -2., .75);
1924 )
1925 testLRcauchymar(3,f,float,3.0,60,
1926  LR_set_all(o,"ms", 2., 2.50);
1927 )
1928 
1929 /* uinvcdf version of cauchy */
1930 testCdfPdf0cauchy(uinvcdf, 9, d,double,.0001,0.5, 1.0,
1931  LRd_uinvcdf(o,MyCDFc);
1932 )
1933 
1934 testCdfPdfFR(10,d,double,uinvcdf,3,60,.0001,
1935  LRd_uinvcdf(o,MyCDFc);
1936  LR_set_all(o,"ms", .5, 1.);
1937 )
1938 
1939 testLRfull(uinvcdf,11,d,double,3.0,60,50*10007,.1,100,
1940  LRd_uinvcdf(o,MyCDFc);
1941  LR_set_all(o,"ms", .5, 1.);
1942 )
1943 
1944 testCdfPdf0cauchy(uinvcdf, 9, f,float,.001,0.5, 1.0,
1945  LRf_uinvcdf(o,MyCDFcf);
1946 )
1947 
1948 testCdfPdfFR(10,f,float,uinvcdf,3,60,.001,
1949  LRf_uinvcdf(o,MyCDFcf);
1950  LR_set_all(o,"ms", .5, 1.);
1951 )
1952 
1953 testLRfull(uinvcdf,11,f,float,3.0,60,50*10007,.1,100,
1954  LRf_uinvcdf(o,MyCDFcf);
1955  LR_set_all(o,"ms", .5, 1.);
1956 )
1957 
1958 /* data type errors */
1959 testBADdt(unif,1,d,double, f, .5, )
1960 testBADdt(unif,2,f,float, d, .5, )
1961 testBADdt(cauchy,3,d,double, f, .5, )
1962 testBADdt(cauchy,4,f,float, d, .5, )
1963 testBADdt(gausbm,5,d,double, f, .5, )
1964 testBADdt(gausbm,6,f,float, d, .5, )
1965 testBADdt(nexp,7,d,double, f, .5, )
1966 testBADdt(nexp,8,f,float, d, .5, )
1967 testBADdt(gsn12,9,d,double, f, .5, )
1968 testBADdt(gsn12,10,f,float, d, .5, )
1969 testBADdt(poisson,11,i,int, d, 2, )
1970 testBADdt(geometric,12,i,int, d, 2, )
1971 testBADdt(binomial,13,i,int, d, 2, )
1972 
1973 /* Poisson */
1974 #define tryPdfCdf(kk,pdf,cdf) \
1975 CU_ASSERT_DOUBLE_EQUAL(LRi_CDF(o,kk),cdf,.000001) \
1976 CU_ASSERT_DOUBLE_EQUAL(LRi_PDF(o,kk),pdf,.000001)
1977 
1978 #define testCdfPdf0pois(nn,xp,setup) \
1979 void test_cdf_pdf_##xp ## _poisson ## _##nn(void) { \
1980  LR_obj *o = LR_new(poisson, LR_int); \
1981  LR_set_all(o,"p", xp ## .); \
1982  setup; \
1983 }
1984 
1985 testCdfPdf0pois(1,1,
1986  tryPdfCdf(0,.3678794,.3678794)
1987  tryPdfCdf(1,.3678794,.7357589)
1988  tryPdfCdf(2,.1839397,.9196986)
1989  tryPdfCdf(4,.0153283,.9963402)
1990  tryPdfCdf(8,.0000091,.9999989)
1991 )
1992 testCdfPdf0pois(2,2,
1993  tryPdfCdf(0,.1353353,.1353353)
1994  tryPdfCdf(1,.2706706,.4060058)
1995  tryPdfCdf(2,.2706706,.6766764)
1996  tryPdfCdf(4,.0902235,.9473470)
1997  tryPdfCdf(8,.0008593,.9997626)
1998 )
1999 testCdfPdf0pois(3,4,
2000  tryPdfCdf(0,.0183156,.0183156)
2001  tryPdfCdf(1,.0732626,.0915782)
2002  tryPdfCdf(3,.1953668,.4334701)
2003  tryPdfCdf(4,.1953668,.6288369)
2004  tryPdfCdf(8,.0297702,.9786366)
2005  tryPdfCdf(12,.0006415,.9997263)
2006 )
2007 testCdfPdf0pois(4,8,
2008  tryPdfCdf(0,.0003355,.0003355)
2009  tryPdfCdf(1,.0026837,.0030192)
2010  tryPdfCdf(4,.0572523,.0996324)
2011  tryPdfCdf(7,.1395865,.4529608)
2012  tryPdfCdf(8,.1395865,.5925473)
2013  tryPdfCdf(12,.0481268,.9362028)
2014  tryPdfCdf(15,.0090260,.9917690)
2015 )
2016 
2017 /* more complicated random variates do not have "uniform" coverage */
2018 /* also the limited test t*rand functions do not adequately span space */
2019 /* make tolerance adjustable */
2020 /* vty - LR distribution
2021  * nn - test #
2022  * bn - bin number
2023  * xtot - total number of samples (should be large)
2024  * vsc - % error tolerance (.1 = 10%)
2025  * vab - absolute error tolerance
2026  * setup- set-up code
2027  */
2028 #define testLRdisc(vty,nn,bn,xtot,vsc,vab,setup) \
2029 void test_##vty ## _i ## _##nn(void) { \
2030  LR_obj *o = LR_new(vty, LR_int); \
2031  LR_bin *b = LR_bin_new(bn+1); \
2032  double x, cdf[bn+1], tol; \
2033  setup; \
2034  double begin = 0.5, \
2035  incr = 1.0; \
2036  for (int i = 0; i < bn; i++) { \
2037  x = begin + i; \
2038  LR_bin_set(b,x); \
2039  cdf[i] = xtot*(LRi_PDF(o,x)); \
2040  } \
2041  cdf[bn] = xtot * (1.0 - LRi_CDF(o,bn-1)); \
2042  for (int i = 0; i < xtot; i++) { \
2043  LR_bin_add(b,LRi_RAN(o)); \
2044  } \
2045  for (int i = 0; i <= bn; i++) { \
2046  tol = max(cdf[i]*vsc,vab); \
2047  CU_ASSERT_DOUBLE_EQUAL(1.0*b->bins[i],cdf[i],tol); \
2048  } \
2049  LR_rm(&o); LR_bin_rm(&b); \
2050 }
2051 
2052 #define testLRpoisson(nn,bn,setup) \
2053  testLRdisc(poisson,nn,bn,50*10007,.1,100,setup)
2054 
2055 testLRpoisson(1,20, LR_set_all(o,"p", 1.); )
2056 testLRpoisson(2,20, LR_set_all(o,"p", 2.); )
2057 testLRpoisson(3,20, LR_set_all(o,"p", 4.); )
2058 testLRpoisson(4,20, LR_set_all(o,"p", 8.); )
2059 testLRpoisson(5,20, LR_set_all(o,"p", 5.5); )
2060 
2061 testLRcheck(1, poisson, i, int,
2062  LR_set_all(o, "p", -1.0);
2063  CU_ASSERT_EQUAL(LR_check(o), LRerr_OK);
2064 )
2065 testLRcheck(2, poisson, i, int,
2066  LR_set_all(o, "p", 0.0);
2067  CU_ASSERT_EQUAL(LR_check(o), LRerr_InvalidInputValue);
2068 )
2069 
2070 /* Geometric */
2071 #define testCdfPdf0geom(nn,xp,setup) \
2072 void test_cdf_pdf_##xp ## _geometric ## _##nn(void) { \
2073  LR_obj *o = LR_new(geometric, LR_int); \
2074  LR_set_all(o,"p", . ## xp); \
2075  setup; \
2076 }
2077 
2078 testCdfPdf0geom(1,25,
2079  tryPdfCdf(1,.250000,.250000)
2080  tryPdfCdf(2,.187500,.437500)
2081  tryPdfCdf(3,.140625,.578125)
2082  tryPdfCdf(4,.105469,.683594)
2083  tryPdfCdf(8,.033371,.899887)
2084 )
2085 testCdfPdf0geom(2,50,
2086  tryPdfCdf(1,.500000,.500000)
2087  tryPdfCdf(2,.250000,.750000)
2088  tryPdfCdf(3,.125000,.875000)
2089  tryPdfCdf(4,.062500,.937500)
2090  tryPdfCdf(8,.003906,.996094)
2091 )
2092 testCdfPdf0geom(3,75,
2093  tryPdfCdf(1,.750000,.750000)
2094  tryPdfCdf(2,.187500,.937500)
2095  tryPdfCdf(3,.046875,.984375)
2096  tryPdfCdf(4,.011719,.996094)
2097  tryPdfCdf(5,.002930,.999023)
2098 )
2099 
2100 #define testLRgeom(nn,bn,setup) \
2101  testLRdisc(geometric,nn,bn,50*10007,.1,100,setup)
2102 
2103 testLRgeom(1,10, )
2104 testLRgeom(2,10, LR_set_all(o,"p", .5); )
2105 testLRgeom(3,10, LR_set_all(o,"p", .2); )
2106 testLRgeom(4,15, LR_set_all(o,"p", .35); )
2107 testLRgeom(5,20, LR_set_all(o,"p", .65); )
2108 testLRgeom(6,25, LR_set_all(o,"p", .8); )
2109 
2110 testLRcheck(1, geometric, i, int,
2111  LR_set_all(o, "p", -.5);
2112  CU_ASSERT_EQUAL(LR_check(o), LRerr_OK);
2113 )
2114 testLRcheck(2, geometric, i, int,
2115  LR_set_all(o, "p", 0.0);
2116  CU_ASSERT_EQUAL(LR_check(o), LRerr_InvalidInputValue);
2117 )
2118 testLRcheck(3, geometric, i, int,
2119  LR_set_all(o, "p", -2.0);
2120  CU_ASSERT_EQUAL(LR_check(o), LRerr_InvalidInputValue);
2121 )
2122 
2123 /* Binomial */
2124 #define testCdfPdf0binom(nn,xp,mm,setup) \
2125 void test_cdf_pdf_##xp ## _binomial ## _##nn(void) { \
2126  LR_obj *o = LR_new(binomial, LR_int); \
2127  LR_set_all(o,"pn", . ## xp, mm); \
2128  setup; \
2129 }
2130 testCdfPdf0binom(1,25, 10,
2131  tryPdfCdf(0,.056314,.056314)
2132  tryPdfCdf(2,.281568,.525593)
2133  tryPdfCdf(5,.058399,.980272)
2134  tryPdfCdf(7,.003090,.999584)
2135  tryPdfCdf(8,.000386,.999970)
2136 )
2137 testCdfPdf0binom(2,50, 10,
2138  tryPdfCdf(0,.000977,.000977)
2139  tryPdfCdf(2,.043945,.054688)
2140  tryPdfCdf(5,.246094,.623047)
2141  tryPdfCdf(7,.117188,.945313)
2142  tryPdfCdf(8,.043945,.989258)
2143 )
2144 testCdfPdf0binom(3,80, 10,
2145  tryPdfCdf(0,.000000,.000000)
2146  tryPdfCdf(2,.000074,.000078)
2147  tryPdfCdf(5,.026424,.032793)
2148  tryPdfCdf(7,.201327,.322200)
2149  tryPdfCdf(8,.301990,.624190)
2150  tryPdfCdf(10,.107374,1.000000)
2151 )
2152 
2153 #define testLRbinom(nn,bn,setup) \
2154  testLRdisc(binomial,nn,bn,50*10007,.1,100, \
2155  LR_set_all(o,"n", bn); \
2156  setup)
2157 
2158 testLRbinom(1,10, )
2159 testLRbinom(2,10, LR_set_all(o,"p", .5); )
2160 testLRbinom(3,10, LR_set_all(o,"p", .2); )
2161 testLRbinom(4,15, LR_set_all(o,"p", .35); )
2162 testLRbinom(5,20, LR_set_all(o,"p", .65); )
2163 testLRbinom(6,25, LR_set_all(o,"p", .8); )
2164 
2165 testLRcheck(1, binomial, i, int,
2166  LR_set_all(o, "np", 10, -.5);
2167  CU_ASSERT_EQUAL(LR_check(o), LRerr_OK);
2168 )
2169 testLRcheck(2, binomial, i, int,
2170  LR_set_all(o, "np", 10, 0.0);
2171  CU_ASSERT_EQUAL(LR_check(o), LRerr_InvalidInputValue);
2172 )
2173 testLRcheck(3, binomial, i, int,
2174  LR_set_all(o, "np", 10, -2.0);
2175  CU_ASSERT_EQUAL(LR_check(o), LRerr_InvalidInputValue);
2176 )
2177 testLRcheck(4, binomial, i, int,
2178  CU_ASSERT_EQUAL(LR_check(o), LRerr_InvalidInputValue);
2179 )
2180 testLRcheck(5, binomial, i, int,
2181  LR_set_all(o, "np", -10, -.5);
2182  CU_ASSERT_EQUAL(LR_check(o), LRerr_OK);
2183 )
2184 
2185 int main(int argc, char* argv[]) {
2186  CU_pSuite pS = NULL;
2187  CU_pSuite pSint = NULL;
2188  CU_pSuite pShalf = NULL;
2189  CU_pSuite pSfull = NULL;
2190  CU_pSuite pSdisc = NULL;
2191  CU_BasicRunMode mode = CU_BRM_VERBOSE;
2192  CU_ErrorAction error_action = CUEA_IGNORE;
2193  int i;
2194  int interact = 0;
2195 
2196  setvbuf(stdout, NULL, _IONBF, 0);
2197 
2198  for (i=1 ; i<argc ; i++) {
2199  if (!strcmp("-i", argv[i])) {
2200  error_action = CUEA_IGNORE;
2201  } else if (!strcmp("-f", argv[i])) {
2202  error_action = CUEA_FAIL;
2203  } else if (!strcmp("-A", argv[i])) {
2204  error_action = CUEA_ABORT;
2205  } else if (!strcmp("-s", argv[i])) {
2206  mode = CU_BRM_SILENT;
2207  } else if (!strcmp("-n", argv[i])) {
2208  mode = CU_BRM_NORMAL;
2209  } else if (!strcmp("-I", argv[i])) {
2210  interact = 1;
2211  } else if (!strcmp("-v", argv[i])) {
2212  mode = CU_BRM_VERBOSE;
2213  } else {
2214  printf(
2215 "\nUsage: %s [options]\n\n"
2216 "Options: -i ignore framework errors [default].\n"
2217 " -f fail on framework error.\n"
2218 " -A abort on framework error.\n\n"
2219 " -s silent mode - no output to screen.\n"
2220 " -n normal mode - standard output to screen.\n"
2221 " -I interactive mode - uses curses.\n"
2222 " -v verbose mode - max output to screen [default].\n\n"
2223 " -h print this message and exit.\n\n", argv[0]);
2224  return 0;
2225  }
2226  }
2227 
2228  if (CUE_SUCCESS != CU_initialize_registry()) {
2229  printf("\nTest Registry initialization failed.");
2230  return CU_get_error();
2231  }
2232  pS = CU_add_suite("LR_test_suite", init_suite, clean_suite);
2233  if (pS == NULL) {
2234  printf("\nTest Registry Suite failure.");
2235  CU_cleanup_registry();
2236  return CU_get_error();
2237  }
2238  pSint = CU_add_suite("LR_test_suite_interval",
2239  init_suite, clean_suite);
2240  if (pSint == NULL) {
2241  printf("\nTest Registry Suite Interval failure.");
2242  CU_cleanup_registry();
2243  return CU_get_error();
2244  }
2245  pShalf = CU_add_suite("LR_test_suite_half_range",
2246  init_suite, clean_suite);
2247  if (pShalf == NULL) {
2248  printf("\nTest Registry Suite Half Range failure.");
2249  CU_cleanup_registry();
2250  return CU_get_error();
2251  }
2252  pSfull = CU_add_suite("LR_test_suite_full_range",
2253  init_suite, clean_suite);
2254  if (pSfull == NULL) {
2255  printf("\nTest Registry Suite Full Range failure.");
2256  CU_cleanup_registry();
2257  return CU_get_error();
2258  }
2259  pSdisc = CU_add_suite("LR_test_suite_discrete",
2260  init_suite, clean_suite);
2261  if (pSdisc == NULL) {
2262  printf("\nTest Registry Suite Discrete failure.");
2263  CU_cleanup_registry();
2264  return CU_get_error();
2265  }
2266  /* add tests to the suite */
2267 if ((NULL == CU_add_test(pS,"errors", test_LR_errors))
2268 || (NULL == CU_add_test(pS,"version", test_LR_version))
2269 || (NULL == CU_add_test(pS,"new - int", test_new_int))
2270 || (NULL == CU_add_test(pS,"new - float", test_new_float))
2271 || (NULL == CU_add_test(pS,"new - long", test_new_long))
2272 || (NULL == CU_add_test(pS,"new - double", test_new_double))
2273 || (NULL == CU_add_test(pS,"set - int", test_set_int))
2274 || (NULL == CU_add_test(pS,"set - float", test_set_float))
2275 || (NULL == CU_add_test(pS,"set - long", test_set_long))
2276 || (NULL == CU_add_test(pS,"set - double", test_set_double))
2277 || (NULL == CU_add_test(pS,"set_all - int", test_set_all_int))
2278 || (NULL == CU_add_test(pS,"set_all - float", test_set_all_float))
2279 || (NULL == CU_add_test(pS,"set_all - long", test_set_all_long))
2280 || (NULL == CU_add_test(pS,"set_all - double",test_set_all_double))
2281 || (NULL == CU_add_test(pS,"set_all2 - int", test_set_all2_int))
2282 || (NULL == CU_add_test(pS,"set_all2 - float", test_set_all2_float))
2283 || (NULL == CU_add_test(pS,"set_all2 - long", test_set_all2_long))
2284 || (NULL == CU_add_test(pS,"set_all2 - double",test_set_all2_double))
2285 || (NULL == CU_add_test(pS,"set_all3 - int", test_set_all3_int))
2286 || (NULL == CU_add_test(pS,"set_all3 - float", test_set_all3_float))
2287 || (NULL == CU_add_test(pS,"set_all3 - long", test_set_all3_long))
2288 || (NULL == CU_add_test(pS,"set_all3 - double",test_set_all3_double))
2289 || (NULL == CU_add_test(pS,"check - bad",test_check_bad_0))
2290 || (NULL == CU_add_test(pS,"check - d - 0",test_check_unif_d_0))
2291 || (NULL == CU_add_test(pS,"check - d - 1",test_check_unif_d_1))
2292 || (NULL == CU_add_test(pS,"check - d - 2",test_check_gausbm_d_2))
2293 || (NULL == CU_add_test(pS,"check - d - 3",test_check_gausbm_d_3))
2294 || (NULL == CU_add_test(pS,"check - d - 4",test_check_uinvcdf_d_4))
2295 || (NULL == CU_add_test(pS,"check - d - 5",test_check_uinvcdf_d_5))
2296 || (NULL == CU_add_test(pS,"check - d - 6",test_check_uinvcdf_d_6))
2297 || (NULL == CU_add_test(pS,"check - d - 7",test_check_uinvcdf_d_7))
2298 || (NULL == CU_add_test(pS,"check - d - 8",test_check_uinvcdf_d_8))
2299 || (NULL == CU_add_test(pS,"check - d - 9",test_check_uinvcdf_d_9))
2300 || (NULL == CU_add_test(pS,"check - f - 0",test_check_unif_f_0))
2301 || (NULL == CU_add_test(pS,"check - f - 1",test_check_unif_f_1))
2302 || (NULL == CU_add_test(pS,"check - f - 2",test_check_gausbm_f_2))
2303 || (NULL == CU_add_test(pS,"check - f - 3",test_check_gausbm_f_3))
2304 || (NULL == CU_add_test(pS,"check - f - 4",test_check_uinvcdf_f_4))
2305 || (NULL == CU_add_test(pS,"check - f - 5",test_check_uinvcdf_f_5))
2306 || (NULL == CU_add_test(pS,"check - f - 6",test_check_uinvcdf_f_6))
2307 || (NULL == CU_add_test(pS,"check - f - 7",test_check_uinvcdf_f_7))
2308 || (NULL == CU_add_test(pS,"check - f - 8",test_check_uinvcdf_f_8))
2309 || (NULL == CU_add_test(pS,"check - f - 9",test_check_uinvcdf_f_9))
2310 || (NULL == CU_add_test(pS,"indep seq - 1",test_indep_seq_1))
2311 || (NULL == CU_add_test(pS,"indep seq - 2",test_indep_seq_2))
2312 || (NULL == CU_add_test(pS,"indep seq - 3",test_indep_seq_3))
2313 || (NULL == CU_add_test(pS,"indep seq - 4",test_indep_seq_4))
2314 || (NULL == CU_add_test(pS,"indep seq - 5",test_indep_seq_5))
2315 || (NULL == CU_add_test(pS,"indep seq - 6",test_indep_seq_6))
2316 /*
2317 || (NULL == CU_add_test(pS,"new_bin - int", test_bin_new_int))
2318 || (NULL == CU_add_test(pS,"new_bin - float", test_bin_new_float))
2319 || (NULL == CU_add_test(pS,"new_bin - long", test_bin_new_long))
2320 */
2321 || (NULL == CU_add_test(pS,"new_bin - double", test_bin_new_double))
2322 || (NULL == CU_add_test(pS,"new_bin_set - 1", test_bin_set_1))
2323 || (NULL == CU_add_test(pS,"new_bin_set - 2", test_bin_set_2))
2324 || (NULL == CU_add_test(pS,"new_bin_set - 3", test_bin_set_3))
2325 || (NULL == CU_add_test(pS,"new_bin_set - 4", test_bin_set_4))
2326 || (NULL == CU_add_test(pS,"new_bin_add - 1", test_bin_add_1))
2327 || (NULL == CU_add_test(pS,"new_bin_add - 2", test_bin_add_2))
2328 || (NULL == CU_add_test(pS,"new_bin_add - 3", test_bin_add_3))
2329 || (NULL == CU_add_test(pS,"new_bin_add - 4", test_bin_add_4))
2330 || (NULL == CU_add_test(pS,"bad data type - 1", test_bad_d_dt_1))
2331 || (NULL == CU_add_test(pS,"bad data type - 2", test_bad_f_dt_2))
2332 || (NULL == CU_add_test(pS,"bad data type - 3", test_bad_d_dt_3))
2333 || (NULL == CU_add_test(pS,"bad data type - 4", test_bad_f_dt_4))
2334 || (NULL == CU_add_test(pS,"bad data type - 5", test_bad_d_dt_5))
2335 || (NULL == CU_add_test(pS,"bad data type - 6", test_bad_f_dt_6))
2336 || (NULL == CU_add_test(pS,"bad data type - 7", test_bad_d_dt_7))
2337 || (NULL == CU_add_test(pS,"bad data type - 8", test_bad_f_dt_8))
2338 || (NULL == CU_add_test(pS,"bad data type - 9", test_bad_d_dt_9))
2339 || (NULL == CU_add_test(pS,"bad data type - 10", test_bad_f_dt_10))
2340 || (NULL == CU_add_test(pS,"bad data type - 11", test_bad_i_dt_11))
2341 || (NULL == CU_add_test(pS,"bad data type - 12", test_bad_i_dt_12))
2342 || (NULL == CU_add_test(pS,"bad data type - 13", test_bad_i_dt_13))
2343 ) {
2344  printf("\nTest Suite additions failure.");
2345  CU_cleanup_registry();
2346  return CU_get_error();
2347  }
2348 if ((NULL == CU_add_test(pSint,"Unif-P/CDF-d-0", test_cdf_pdf_d_unif_0))
2349 || (NULL == CU_add_test(pSint,"Unif-P/CDF-d-1", test_cdf_pdf_d_unif_1))
2350 || (NULL == CU_add_test(pSint,"Unif-P/CDF-d-2", test_cdf_pdf_d_unif_2))
2351 || (NULL == CU_add_test(pSint,"Unif-P/CDF-d-3", test_cdf_pdf_d_unif_3))
2352 || (NULL == CU_add_test(pSint,"Unif-P/CDF-d-4", test_cdf_pdf_d_unif_4))
2353 || (NULL == CU_add_test(pSint,"Unif-P/CDF-d-5", test_cdf_pdf_d_unif_5))
2354 || (NULL == CU_add_test(pSint,"Unif-Ran-d-1", test_unif_d_1))
2355 || (NULL == CU_add_test(pSint,"Unif-Ran-d-2", test_unif_d_2))
2356 || (NULL == CU_add_test(pSint,"Unif-Ran-d-3", test_unif_d_3))
2357 || (NULL == CU_add_test(pSint,"Unif-Ran-d-4", test_unif_d_4))
2358 || (NULL == CU_add_test(pSint,"Unif-P/CDF-f-0", test_cdf_pdf_f_unif_0))
2359 || (NULL == CU_add_test(pSint,"Unif-P/CDF-f-1", test_cdf_pdf_f_unif_1))
2360 || (NULL == CU_add_test(pSint,"Unif-P/CDF-f-2", test_cdf_pdf_f_unif_2))
2361 || (NULL == CU_add_test(pSint,"Unif-P/CDF-f-3", test_cdf_pdf_f_unif_3))
2362 || (NULL == CU_add_test(pSint,"Unif-P/CDF-f-4", test_cdf_pdf_f_unif_4))
2363 || (NULL == CU_add_test(pSint,"Unif-P/CDF-f-5", test_cdf_pdf_f_unif_5))
2364 || (NULL == CU_add_test(pSint,"Unif-Ran-f-1", test_unif_f_1))
2365 || (NULL == CU_add_test(pSint,"Unif-Ran-f-2", test_unif_f_2))
2366 || (NULL == CU_add_test(pSint,"Unif-Ran-f-3", test_unif_f_3))
2367 || (NULL == CU_add_test(pSint,"Unif-Ran-f-4", test_unif_f_4))
2368 || (NULL == CU_add_test(pSint,"Piece-P/CDF-d-0",test_cdf_pdf_d_piece_0))
2369 || (NULL == CU_add_test(pSint,"Piece-P/CDF-d-1",test_cdf_pdf_d_piece_1))
2370 || (NULL == CU_add_test(pSint,"Piece-P/CDF-d-2",test_cdf_pdf_d_piece_2))
2371 || (NULL == CU_add_test(pSint,"Piece-P/CDF-d-3",test_cdf_pdf_d_piece_3))
2372 || (NULL == CU_add_test(pSint,"Piece-Ran-d-1", test_piece_d_1))
2373 || (NULL == CU_add_test(pSint,"Piece-Ran-d-2", test_piece_d_2))
2374 || (NULL == CU_add_test(pSint,"Piece-Ran-d-3", test_piece_d_3))
2375 || (NULL == CU_add_test(pSint,"Piece-Ran-d-4", test_piece_d_4))
2376 || (NULL == CU_add_test(pSint,"Piece-P/CDF-f-0",test_cdf_pdf_f_piece_0))
2377 || (NULL == CU_add_test(pSint,"Piece-P/CDF-f-1",test_cdf_pdf_f_piece_1))
2378 || (NULL == CU_add_test(pSint,"Piece-P/CDF-f-2",test_cdf_pdf_f_piece_2))
2379 || (NULL == CU_add_test(pSint,"Piece-P/CDF-f-3",test_cdf_pdf_f_piece_3))
2380 || (NULL == CU_add_test(pSint,"Piece-Ran-f-1", test_piece_f_1))
2381 || (NULL == CU_add_test(pSint,"Piece-Ran-f-2", test_piece_f_2))
2382 || (NULL == CU_add_test(pSint,"Piece-Ran-f-3", test_piece_f_3))
2383 || (NULL == CU_add_test(pSint,"Piece-Ran-f-4", test_piece_f_4))
2384 || (NULL == CU_add_test(pSint,"Piece-Bad-d-0", test_bad_d_piece_0))
2385 || (NULL == CU_add_test(pSint,"Piece-Bad-f-0", test_bad_f_piece_0))
2386 || (NULL == CU_add_test(pSint,"Gsn2-P/CDF-d-0", test_cdf_pdf_d_gsn2_0))
2387 || (NULL == CU_add_test(pSint,"Gsn2-P/CDF-d-1", test_cdf_pdf_d_gsn2_1))
2388 || (NULL == CU_add_test(pSint,"Gsn2-P/CDF-d-2", test_cdf_pdf_d_gsn2_2))
2389 || (NULL == CU_add_test(pSint,"Gsn2-P/CDF-d-3", test_cdf_pdf_d_gsn2_3))
2390 || (NULL == CU_add_test(pSint,"Gsn2-P/CDF-d-4", test_cdf_pdf_d_gsn2_4))
2391 || (NULL == CU_add_test(pSint,"Gsn2-P/CDF-d-5", test_cdf_pdf_d_gsn2_5))
2392 || (NULL == CU_add_test(pSint,"Gsn2-Sym-d-6", test_sym_d_gsn2_6))
2393 || (NULL == CU_add_test(pSint,"Gsn2-Sym-d-7", test_sym_d_gsn2_7))
2394 || (NULL == CU_add_test(pSint,"Gsn2-Sym-d-8", test_sym_d_gsn2_8))
2395 || (NULL == CU_add_test(pSint,"Gsn2-Ran-d-1", test_gsn2_d_1))
2396 || (NULL == CU_add_test(pSint,"Gsn2-Ran-d-2", test_gsn2_d_2))
2397 || (NULL == CU_add_test(pSint,"Gsn2-Ran-d-3", test_gsn2_d_3))
2398 || (NULL == CU_add_test(pSint,"Gsn2-Ran-d-4", test_gsn2_d_4))
2399 || (NULL == CU_add_test(pSint,"Gsn2-P/CDF-f-0", test_cdf_pdf_f_gsn2_0))
2400 || (NULL == CU_add_test(pSint,"Gsn2-P/CDF-f-1", test_cdf_pdf_f_gsn2_1))
2401 || (NULL == CU_add_test(pSint,"Gsn2-P/CDF-f-2", test_cdf_pdf_f_gsn2_2))
2402 || (NULL == CU_add_test(pSint,"Gsn2-P/CDF-f-3", test_cdf_pdf_f_gsn2_3))
2403 || (NULL == CU_add_test(pSint,"Gsn2-P/CDF-f-4", test_cdf_pdf_f_gsn2_4))
2404 || (NULL == CU_add_test(pSint,"Gsn2-P/CDF-f-5", test_cdf_pdf_f_gsn2_5))
2405 || (NULL == CU_add_test(pSint,"Gsn2-Sym-f-6", test_sym_f_gsn2_6))
2406 || (NULL == CU_add_test(pSint,"Gsn2-Sym-f-7", test_sym_f_gsn2_7))
2407 || (NULL == CU_add_test(pSint,"Gsn2-Sym-f-8", test_sym_f_gsn2_8))
2408 || (NULL == CU_add_test(pSint,"Gsn2-Ran-f-1", test_gsn2_f_1))
2409 || (NULL == CU_add_test(pSint,"Gsn2-Ran-f-2", test_gsn2_f_2))
2410 || (NULL == CU_add_test(pSint,"Gsn2-Ran-f-3", test_gsn2_f_3))
2411 || (NULL == CU_add_test(pSint,"Gsn2-Ran-f-4", test_gsn2_f_4))
2412 || (NULL == CU_add_test(pSint,"Gsn4-P/CDF-d-0", test_cdf_pdf_d_gsn4_0))
2413 || (NULL == CU_add_test(pSint,"Gsn4-P/CDF-d-1", test_cdf_pdf_d_gsn4_1))
2414 || (NULL == CU_add_test(pSint,"Gsn4-P/CDF-d-2", test_cdf_pdf_d_gsn4_2))
2415 || (NULL == CU_add_test(pSint,"Gsn4-P/CDF-d-3", test_cdf_pdf_d_gsn4_3))
2416 || (NULL == CU_add_test(pSint,"Gsn4-P/CDF-d-4", test_cdf_pdf_d_gsn4_4))
2417 || (NULL == CU_add_test(pSint,"Gsn4-P/CDF-d-5", test_cdf_pdf_d_gsn4_5))
2418 || (NULL == CU_add_test(pSint,"Gsn4-Sym-d-6", test_sym_d_gsn4_6))
2419 || (NULL == CU_add_test(pSint,"Gsn4-Sym-d-7", test_sym_d_gsn4_7))
2420 || (NULL == CU_add_test(pSint,"Gsn4-Sym-d-8", test_sym_d_gsn4_8))
2421 || (NULL == CU_add_test(pSint,"Gsn4-Sym-d-9", test_sym_d_gsn4_9))
2422 || (NULL == CU_add_test(pSint,"Gsn4-Sym-d-10", test_sym_d_gsn4_10))
2423 || (NULL == CU_add_test(pSint,"Gsn4-Sym-d-11", test_sym_d_gsn4_11))
2424 || (NULL == CU_add_test(pSint,"Gsn4-Ran-d-1", test_gsn4_d_1))
2425 || (NULL == CU_add_test(pSint,"Gsn4-Ran-d-2", test_gsn4_d_2))
2426 || (NULL == CU_add_test(pSint,"Gsn4-Ran-d-3", test_gsn4_d_3))
2427 || (NULL == CU_add_test(pSint,"Gsn4-Ran-d-4", test_gsn4_d_4))
2428 || (NULL == CU_add_test(pSint,"Gsn4-P/CDF-f-0", test_cdf_pdf_f_gsn4_0))
2429 || (NULL == CU_add_test(pSint,"Gsn4-P/CDF-f-1", test_cdf_pdf_f_gsn4_1))
2430 || (NULL == CU_add_test(pSint,"Gsn4-P/CDF-f-2", test_cdf_pdf_f_gsn4_2))
2431 || (NULL == CU_add_test(pSint,"Gsn4-P/CDF-f-3", test_cdf_pdf_f_gsn4_3))
2432 || (NULL == CU_add_test(pSint,"Gsn4-P/CDF-f-4", test_cdf_pdf_f_gsn4_4))
2433 || (NULL == CU_add_test(pSint,"Gsn4-P/CDF-f-5", test_cdf_pdf_f_gsn4_5))
2434 || (NULL == CU_add_test(pSint,"Gsn4-Sym-f-6", test_sym_f_gsn4_6))
2435 || (NULL == CU_add_test(pSint,"Gsn4-Sym-f-7", test_sym_f_gsn4_7))
2436 || (NULL == CU_add_test(pSint,"Gsn4-Sym-f-8", test_sym_f_gsn4_8))
2437 || (NULL == CU_add_test(pSint,"Gsn4-Sym-f-9", test_sym_f_gsn4_9))
2438 || (NULL == CU_add_test(pSint,"Gsn4-Sym-f-10", test_sym_f_gsn4_10))
2439 || (NULL == CU_add_test(pSint,"Gsn4-Sym-f-11", test_sym_f_gsn4_11))
2440 || (NULL == CU_add_test(pSint,"Gsn4-Ran-f-1", test_gsn4_f_1))
2441 || (NULL == CU_add_test(pSint,"Gsn4-Ran-f-2", test_gsn4_f_2))
2442 || (NULL == CU_add_test(pSint,"Gsn4-Ran-f-3", test_gsn4_f_3))
2443 || (NULL == CU_add_test(pSint,"Gsn4-Ran-f-4", test_gsn4_f_4))
2444 || (NULL == CU_add_test(pSint,"Gsn12-P/CDF-f-0", test_cdf_pdf_f_gsn12_0))
2445 || (NULL == CU_add_test(pSint,"Gsn12-P/CDF-f-1", test_cdf_pdf_f_gsn12_1))
2446 || (NULL == CU_add_test(pSint,"Gsn12-P/CDF-f-2", test_cdf_pdf_f_gsn12_2))
2447 || (NULL == CU_add_test(pSint,"Gsn12-P/CDF-f-3", test_cdf_pdf_f_gsn12_3))
2448 || (NULL == CU_add_test(pSint,"Gsn12-P/CDF-f-4", test_cdf_pdf_f_gsn12_4))
2449 || (NULL == CU_add_test(pSint,"Gsn12-P/CDF-f-5", test_cdf_pdf_f_gsn12_5))
2450 || (NULL == CU_add_test(pSint,"Gsn12-Sym-f-6", test_sym_f_gsn12_6))
2451 || (NULL == CU_add_test(pSint,"Gsn12-Sym-f-7", test_sym_f_gsn12_7))
2452 || (NULL == CU_add_test(pSint,"Gsn12-Sym-f-8", test_sym_f_gsn12_8))
2453 || (NULL == CU_add_test(pSint,"Gsn12-Sym-f-9", test_sym_f_gsn12_9))
2454 || (NULL == CU_add_test(pSint,"Gsn12-Sym-f-10", test_sym_f_gsn12_10))
2455 || (NULL == CU_add_test(pSint,"Gsn12-Sym-f-11", test_sym_f_gsn12_11))
2456 || (NULL == CU_add_test(pSint,"Gsn12-Sym-f-12", test_sym_f_gsn12_12))
2457 || (NULL == CU_add_test(pSint,"Gsn12-Sym-f-13", test_sym_f_gsn12_13))
2458 || (NULL == CU_add_test(pSint,"Gsn12-Sym-f-14", test_sym_f_gsn12_14))
2459 || (NULL == CU_add_test(pSint,"Gsn12-Ran-f-1", test_gsn12_f_1))
2460 || (NULL == CU_add_test(pSint,"Gsn12-Ran-f-2", test_gsn12_f_2))
2461 || (NULL == CU_add_test(pSint,"Gsn12-Ran-f-3", test_gsn12_f_3))
2462 || (NULL == CU_add_test(pSint,"Gsn12-Ran-f-4", test_gsn12_f_4))
2463 || (NULL == CU_add_test(pSint,"Lspline-P/CDF-d-0",test_cdf_pdf_d_lspline_0))
2464 || (NULL == CU_add_test(pSint,"Lspline-P/CDF-d-1",test_cdf_pdf_d_lspline_1))
2465 || (NULL == CU_add_test(pSint,"Lspline-P/CDF-d-2",test_cdf_pdf_d_lspline_2))
2466 || (NULL == CU_add_test(pSint,"Lspline-P/CDF-d-3",test_cdf_pdf_d_lspline_3))
2467 || (NULL == CU_add_test(pSint,"Lspline-Ran-d-1", test_lspline_d_1))
2468 || (NULL == CU_add_test(pSint,"Lspline-Ran-d-2", test_lspline_d_2))
2469 || (NULL == CU_add_test(pSint,"Lspline-Ran-d-3", test_lspline_d_3))
2470 || (NULL == CU_add_test(pSint,"Lspline-Ran-d-4", test_lspline_d_4))
2471 || (NULL == CU_add_test(pSint,"Lspline-P/CDF-f-0",test_cdf_pdf_f_lspline_0))
2472 || (NULL == CU_add_test(pSint,"Lspline-P/CDF-f-1",test_cdf_pdf_f_lspline_1))
2473 || (NULL == CU_add_test(pSint,"Lspline-P/CDF-f-2",test_cdf_pdf_f_lspline_2))
2474 || (NULL == CU_add_test(pSint,"Lspline-P/CDF-f-3",test_cdf_pdf_f_lspline_3))
2475 || (NULL == CU_add_test(pSint,"Lspline-Ran-f-1", test_lspline_f_1))
2476 || (NULL == CU_add_test(pSint,"Lspline-Ran-f-2", test_lspline_f_2))
2477 || (NULL == CU_add_test(pSint,"Lspline-Ran-f-3", test_lspline_f_3))
2478 || (NULL == CU_add_test(pSint,"Lspline-Ran-f-4", test_lspline_f_4))
2479 || (NULL == CU_add_test(pSint,"Lspline-Bad-d-0", test_bad_d_lspline_0))
2480 || (NULL == CU_add_test(pSint,"Lspline-Bad-f-0", test_bad_f_lspline_0))
2481 || (NULL == CU_add_test(pSint,"Uinvcdf-P/CDF-d-0",test_cdf_pdf_d_uinvcdf_0))
2482 || (NULL == CU_add_test(pSint,"Uinvcdf-P/CDF-d-1",test_cdf_pdf_d_uinvcdf_1))
2483 || (NULL == CU_add_test(pSint,"Uinvcdf-Sym-d-2", test_sym_d_uinvcdf_2))
2484 || (NULL == CU_add_test(pSint,"Uinvcdf-Sym-d-3", test_sym_d_uinvcdf_3))
2485 || (NULL == CU_add_test(pSint,"Uinvcdf-Sym-d-4", test_sym_d_uinvcdf_4))
2486 || (NULL == CU_add_test(pSint,"Uinvcdf-Sym-d-5", test_sym_d_uinvcdf_5))
2487 || (NULL == CU_add_test(pSint,"Uinvcdf-Sym-d-6", test_sym_d_uinvcdf_6))
2488 || (NULL == CU_add_test(pSint,"Uinvcdf-Ran-d-7", test_uinvcdf_d_7))
2489 || (NULL == CU_add_test(pSint,"Uinvcdf-Ran-d-8", test_uinvcdf_d_8))
2490 || (NULL == CU_add_test(pSint,"Uinvcdf-P/CDF-f-0",test_cdf_pdf_f_uinvcdf_0))
2491 || (NULL == CU_add_test(pSint,"Uinvcdf-P/CDF-f-1",test_cdf_pdf_f_uinvcdf_1))
2492 || (NULL == CU_add_test(pSint,"Uinvcdf-Sym-f-2", test_sym_f_uinvcdf_2))
2493 || (NULL == CU_add_test(pSint,"Uinvcdf-Sym-f-3", test_sym_f_uinvcdf_3))
2494 || (NULL == CU_add_test(pSint,"Uinvcdf-Sym-f-4", test_sym_f_uinvcdf_4))
2495 || (NULL == CU_add_test(pSint,"Uinvcdf-Sym-f-5", test_sym_f_uinvcdf_5))
2496 || (NULL == CU_add_test(pSint,"Uinvcdf-Sym-f-6", test_sym_f_uinvcdf_6))
2497 || (NULL == CU_add_test(pSint,"Uinvcdf-Ran-f-7", test_uinvcdf_f_7))
2498 || (NULL == CU_add_test(pSint,"Uinvcdf-Ran-f-8", test_uinvcdf_f_8))
2499 ) {
2500  printf("\nTest Suite interval additions failure.");
2501  CU_cleanup_registry();
2502  return CU_get_error();
2503  }
2504 
2505 if ((NULL == CU_add_test(pShalf,"Nexp-P/CDF-d-0", test_cdf_pdf_d_nexp_0))
2506 || (NULL == CU_add_test(pShalf,"Nexp-P/CDF-d-1", test_cdf_pdf_d_nexp_1))
2507 || (NULL == CU_add_test(pShalf,"Nexp-P/CDF-d-2", test_cdf_pdf_d_nexp_2))
2508 || (NULL == CU_add_test(pShalf,"Nexp-P/CDF-d-3", test_cdf_pdf_d_nexp_3))
2509 || (NULL == CU_add_test(pShalf,"Nexp-P/CDF-d-4", test_cdf_pdf_d_nexp_4))
2510 || (NULL == CU_add_test(pShalf,"Nexp-P/CDF-d-5", test_cdf_pdf_d_nexp_5))
2511 || (NULL == CU_add_test(pShalf,"Nexp-Ran-d-1", test_nexp_d_1))
2512 || (NULL == CU_add_test(pShalf,"Nexp-Ran-d-2", test_nexp_d_2))
2513 || (NULL == CU_add_test(pShalf,"Nexp-Ran-d-3", test_nexp_d_3))
2514 || (NULL == CU_add_test(pShalf,"Nexp-P/CDF-f-0", test_cdf_pdf_f_nexp_0))
2515 || (NULL == CU_add_test(pShalf,"Nexp-P/CDF-f-1", test_cdf_pdf_f_nexp_1))
2516 || (NULL == CU_add_test(pShalf,"Nexp-P/CDF-f-2", test_cdf_pdf_f_nexp_2))
2517 || (NULL == CU_add_test(pShalf,"Nexp-P/CDF-f-3", test_cdf_pdf_f_nexp_3))
2518 || (NULL == CU_add_test(pShalf,"Nexp-P/CDF-f-4", test_cdf_pdf_f_nexp_4))
2519 || (NULL == CU_add_test(pShalf,"Nexp-P/CDF-f-5", test_cdf_pdf_f_nexp_5))
2520 || (NULL == CU_add_test(pShalf,"Nexp-Ran-f-1", test_nexp_f_1))
2521 || (NULL == CU_add_test(pShalf,"Nexp-Ran-f-2", test_nexp_f_2))
2522 || (NULL == CU_add_test(pShalf,"Nexp-Ran-f-3", test_nexp_f_3))
2523 || (NULL == CU_add_test(pShalf,"Erlang/Nexp-P/CDF-d-0", test_cdf_pdf_d_erlang_0))
2524 || (NULL == CU_add_test(pShalf,"Erlang/Nexp-P/CDF-d-1", test_cdf_pdf_d_erlang_1))
2525 || (NULL == CU_add_test(pShalf,"Erlang/Nexp-P/CDF-d-2", test_cdf_pdf_d_erlang_2))
2526 || (NULL == CU_add_test(pShalf,"Erlang/Nexp-P/CDF-d-3", test_cdf_pdf_d_erlang_3))
2527 || (NULL == CU_add_test(pShalf,"Erlang/Nexp-P/CDF-d-4", test_cdf_pdf_d_erlang_4))
2528 || (NULL == CU_add_test(pShalf,"Erlang/Nexp-P/CDF-d-5", test_cdf_pdf_d_erlang_5))
2529 || (NULL == CU_add_test(pShalf,"Erlang/Nexp-Ran-d-1", test_erlang_d_1))
2530 || (NULL == CU_add_test(pShalf,"Erlang/Nexp-Ran-d-2", test_erlang_d_2))
2531 || (NULL == CU_add_test(pShalf,"Erlang/Nexp-Ran-d-3", test_erlang_d_3))
2532 || (NULL == CU_add_test(pShalf,"Erlang2-P/CDF-d-0", test_cdf_pdf_d_erlang2_0))
2533 || (NULL == CU_add_test(pShalf,"Erlang2-P/CDF-d-1", test_cdf_pdf_d_erlang2_1))
2534 || (NULL == CU_add_test(pShalf,"Erlang2-P/CDF-d-2", test_cdf_pdf_d_erlang2_2))
2535 || (NULL == CU_add_test(pShalf,"Erlang2-Ran-d-4", test_erlang_d_4))
2536 || (NULL == CU_add_test(pShalf,"Erlang2-Ran-d-5", test_erlang_d_5))
2537 || (NULL == CU_add_test(pShalf,"Erlang2-Ran-d-6", test_erlang_d_6))
2538 || (NULL == CU_add_test(pShalf,"Erlang3-P/CDF-d-0", test_cdf_pdf_d_erlang3_0))
2539 || (NULL == CU_add_test(pShalf,"Erlang3-P/CDF-d-1", test_cdf_pdf_d_erlang3_1))
2540 || (NULL == CU_add_test(pShalf,"Erlang3-P/CDF-d-2", test_cdf_pdf_d_erlang3_2))
2541 || (NULL == CU_add_test(pShalf,"Erlang3-Ran-d-7", test_erlang_d_7))
2542 || (NULL == CU_add_test(pShalf,"Erlang3-Ran-d-8", test_erlang_d_8))
2543 || (NULL == CU_add_test(pShalf,"Erlang3-Ran-d-9", test_erlang_d_9))
2544 || (NULL == CU_add_test(pShalf,"Erlang4-P/CDF-d-0", test_cdf_pdf_d_erlang4_0))
2545 || (NULL == CU_add_test(pShalf,"Erlang4-P/CDF-d-1", test_cdf_pdf_d_erlang4_1))
2546 || (NULL == CU_add_test(pShalf,"Erlang4-P/CDF-d-2", test_cdf_pdf_d_erlang4_2))
2547 || (NULL == CU_add_test(pShalf,"Erlang4-Ran-d-10", test_erlang_d_10))
2548 || (NULL == CU_add_test(pShalf,"Erlang4-Ran-d-11", test_erlang_d_11))
2549 || (NULL == CU_add_test(pShalf,"Erlang4-Ran-d-12", test_erlang_d_12))
2550 || (NULL == CU_add_test(pShalf,"Erlang/Nexp-P/CDF-f-0", test_cdf_pdf_f_erlang_0))
2551 || (NULL == CU_add_test(pShalf,"Erlang/Nexp-P/CDF-f-1", test_cdf_pdf_f_erlang_1))
2552 || (NULL == CU_add_test(pShalf,"Erlang/Nexp-P/CDF-f-2", test_cdf_pdf_f_erlang_2))
2553 || (NULL == CU_add_test(pShalf,"Erlang/Nexp-P/CDF-f-3", test_cdf_pdf_f_erlang_3))
2554 || (NULL == CU_add_test(pShalf,"Erlang/Nexp-P/CDF-f-4", test_cdf_pdf_f_erlang_4))
2555 || (NULL == CU_add_test(pShalf,"Erlang/Nexp-P/CDF-f-5", test_cdf_pdf_f_erlang_5))
2556 || (NULL == CU_add_test(pShalf,"Erlang/Nexp-Ran-f-1", test_erlang_f_1))
2557 || (NULL == CU_add_test(pShalf,"Erlang/Nexp-Ran-f-2", test_erlang_f_2))
2558 || (NULL == CU_add_test(pShalf,"Erlang/Nexp-Ran-f-3", test_erlang_f_3))
2559 || (NULL == CU_add_test(pShalf,"Erlang2-P/CDF-f-0", test_cdf_pdf_f_erlang2_0))
2560 || (NULL == CU_add_test(pShalf,"Erlang2-P/CDF-f-1", test_cdf_pdf_f_erlang2_1))
2561 || (NULL == CU_add_test(pShalf,"Erlang2-P/CDF-f-2", test_cdf_pdf_f_erlang2_2))
2562 || (NULL == CU_add_test(pShalf,"Erlang2-Ran-f-4", test_erlang_f_4))
2563 || (NULL == CU_add_test(pShalf,"Erlang2-Ran-f-5", test_erlang_f_5))
2564 || (NULL == CU_add_test(pShalf,"Erlang2-Ran-f-6", test_erlang_f_6))
2565 || (NULL == CU_add_test(pShalf,"Erlang3-P/CDF-f-0", test_cdf_pdf_f_erlang3_0))
2566 || (NULL == CU_add_test(pShalf,"Erlang3-P/CDF-f-1", test_cdf_pdf_f_erlang3_1))
2567 || (NULL == CU_add_test(pShalf,"Erlang3-P/CDF-f-2", test_cdf_pdf_f_erlang3_2))
2568 || (NULL == CU_add_test(pShalf,"Erlang3-Ran-f-7", test_erlang_f_7))
2569 || (NULL == CU_add_test(pShalf,"Erlang3-Ran-f-8", test_erlang_f_8))
2570 || (NULL == CU_add_test(pShalf,"Erlang3-Ran-f-9", test_erlang_f_9))
2571 || (NULL == CU_add_test(pShalf,"Erlang4-P/CDF-f-0", test_cdf_pdf_f_erlang4_0))
2572 || (NULL == CU_add_test(pShalf,"Erlang4-P/CDF-f-1", test_cdf_pdf_f_erlang4_1))
2573 || (NULL == CU_add_test(pShalf,"Erlang4-P/CDF-f-2", test_cdf_pdf_f_erlang4_2))
2574 || (NULL == CU_add_test(pShalf,"Erlang4-Ran-f-10", test_erlang_f_10))
2575 || (NULL == CU_add_test(pShalf,"Erlang4-Ran-f-11", test_erlang_f_11))
2576 || (NULL == CU_add_test(pShalf,"Erlang4-Ran-f-12", test_erlang_f_12))
2577 ) {
2578  printf("\nTest Suite interval additions failure.");
2579  CU_cleanup_registry();
2580  return CU_get_error();
2581  }
2582 
2583 if ((NULL == CU_add_test(pSfull,"Gausbm-P/CDF-d-0", test_cdf_pdf_d_gausbm_0))
2584 || (NULL == CU_add_test(pSfull,"Gausbm-P/CDF-d-1", test_cdf_pdf_d_gausbm_1))
2585 || (NULL == CU_add_test(pSfull,"Gausbm-P/CDF-d-2", test_cdf_pdf_d_gausbm_2))
2586 || (NULL == CU_add_test(pSfull,"Gausbm-P/CDF-d-3", test_cdf_pdf_d_gausbm_3))
2587 || (NULL == CU_add_test(pSfull,"Gausbm-P/CDF-d-4", test_cdf_pdf_d_gausbm_4))
2588 || (NULL == CU_add_test(pSfull,"Gausbm-P/CDF-d-5", test_cdf_pdf_d_gausbm_5))
2589 || (NULL == CU_add_test(pSfull,"Gausbm-Sym-d-6", test_sym_d_gausbm_6))
2590 || (NULL == CU_add_test(pSfull,"Gausbm-Sym-d-7", test_sym_d_gausbm_7))
2591 || (NULL == CU_add_test(pSfull,"Gausbm-Sym-d-8", test_sym_d_gausbm_8))
2592 || (NULL == CU_add_test(pSfull,"Gausbm-Sym-d-9", test_sym_d_gausbm_9))
2593 || (NULL == CU_add_test(pSfull,"Gausbm-Sym-d-10", test_sym_d_gausbm_10))
2594 || (NULL == CU_add_test(pSfull,"Gausbm-Sym-d-11", test_sym_d_gausbm_11))
2595 || (NULL == CU_add_test(pSfull,"Gausbm-Ran-d-1", test_gausbm_d_1))
2596 || (NULL == CU_add_test(pSfull,"Gausbm-Ran-d-2", test_gausbm_d_2))
2597 || (NULL == CU_add_test(pSfull,"Gausbm-Ran-d-3", test_gausbm_d_3))
2598 || (NULL == CU_add_test(pSfull,"Gausbm-P/CDF-f-0", test_cdf_pdf_f_gausbm_0))
2599 || (NULL == CU_add_test(pSfull,"Gausbm-P/CDF-f-1", test_cdf_pdf_f_gausbm_1))
2600 || (NULL == CU_add_test(pSfull,"Gausbm-P/CDF-f-2", test_cdf_pdf_f_gausbm_2))
2601 || (NULL == CU_add_test(pSfull,"Gausbm-P/CDF-f-3", test_cdf_pdf_f_gausbm_3))
2602 || (NULL == CU_add_test(pSfull,"Gausbm-P/CDF-f-4", test_cdf_pdf_f_gausbm_4))
2603 || (NULL == CU_add_test(pSfull,"Gausbm-P/CDF-f-5", test_cdf_pdf_f_gausbm_5))
2604 || (NULL == CU_add_test(pSfull,"Gausbm-Sym-f-6", test_sym_f_gausbm_6))
2605 || (NULL == CU_add_test(pSfull,"Gausbm-Sym-f-7", test_sym_f_gausbm_7))
2606 || (NULL == CU_add_test(pSfull,"Gausbm-Sym-f-8", test_sym_f_gausbm_8))
2607 || (NULL == CU_add_test(pSfull,"Gausbm-Sym-f-9", test_sym_f_gausbm_9))
2608 || (NULL == CU_add_test(pSfull,"Gausbm-Sym-f-10", test_sym_f_gausbm_10))
2609 || (NULL == CU_add_test(pSfull,"Gausbm-Sym-f-11", test_sym_f_gausbm_11))
2610 || (NULL == CU_add_test(pSfull,"Gausbm-Ran-f-1", test_gausbm_f_1))
2611 || (NULL == CU_add_test(pSfull,"Gausbm-Ran-f-2", test_gausbm_f_2))
2612 || (NULL == CU_add_test(pSfull,"Gausbm-Ran-f-3", test_gausbm_f_3))
2613 || (NULL == CU_add_test(pSfull,"Gausmar-P/CDF-d-0", test_cdf_pdf_d_gausmar_0))
2614 || (NULL == CU_add_test(pSfull,"Gausmar-P/CDF-d-1", test_cdf_pdf_d_gausmar_1))
2615 || (NULL == CU_add_test(pSfull,"Gausmar-Ran-d-1", test_gausmar_d_1))
2616 || (NULL == CU_add_test(pSfull,"Gausmar-Ran-d-2", test_gausmar_d_2))
2617 || (NULL == CU_add_test(pSfull,"Gausmar-Ran-d-3", test_gausmar_d_3))
2618 || (NULL == CU_add_test(pSfull,"Gausmar-P/CDF-f-0", test_cdf_pdf_f_gausmar_0))
2619 || (NULL == CU_add_test(pSfull,"Gausmar-P/CDF-f-1", test_cdf_pdf_f_gausmar_1))
2620 || (NULL == CU_add_test(pSfull,"Gausmar-Ran-f-1", test_gausmar_f_1))
2621 || (NULL == CU_add_test(pSfull,"Gausmar-Ran-f-2", test_gausmar_f_2))
2622 || (NULL == CU_add_test(pSfull,"Gausmar-Ran-f-3", test_gausmar_f_3))
2623 || (NULL == CU_add_test(pSfull,"Cauchy-P/CDF-d-0", test_cdf_pdf_d_cauchy_0))
2624 || (NULL == CU_add_test(pSfull,"Cauchy-P/CDF-d-1", test_cdf_pdf_d_cauchy_1))
2625 || (NULL == CU_add_test(pSfull,"Cauchy-P/CDF-d-2", test_cdf_pdf_d_cauchy_2))
2626 || (NULL == CU_add_test(pSfull,"Cauchy-P/CDF-d-3", test_cdf_pdf_d_cauchy_3))
2627 || (NULL == CU_add_test(pSfull,"Cauchy-P/CDF-d-4", test_cdf_pdf_d_cauchy_4))
2628 || (NULL == CU_add_test(pSfull,"Cauchy-P/CDF-d-5", test_cdf_pdf_d_cauchy_5))
2629 || (NULL == CU_add_test(pSfull,"Cauchy-Sym-d-6", test_sym_d_cauchy_6))
2630 || (NULL == CU_add_test(pSfull,"Cauchy-Sym-d-7", test_sym_d_cauchy_7))
2631 || (NULL == CU_add_test(pSfull,"Cauchy-Sym-d-8", test_sym_d_cauchy_8))
2632 || (NULL == CU_add_test(pSfull,"Cauchy-Sym-d-9", test_sym_d_cauchy_9))
2633 || (NULL == CU_add_test(pSfull,"Cauchy-Sym-d-10", test_sym_d_cauchy_10))
2634 || (NULL == CU_add_test(pSfull,"Cauchy-Sym-d-11", test_sym_d_cauchy_11))
2635 || (NULL == CU_add_test(pSfull,"Cauchy-Ran-d-1", test_cauchy_d_1))
2636 || (NULL == CU_add_test(pSfull,"Cauchy-Ran-d-2", test_cauchy_d_2))
2637 || (NULL == CU_add_test(pSfull,"Cauchy-Ran-d-3", test_cauchy_d_3))
2638 || (NULL == CU_add_test(pSfull,"Cauchy-P/CDF-f-0", test_cdf_pdf_f_cauchy_0))
2639 || (NULL == CU_add_test(pSfull,"Cauchy-P/CDF-f-1", test_cdf_pdf_f_cauchy_1))
2640 || (NULL == CU_add_test(pSfull,"Cauchy-P/CDF-f-2", test_cdf_pdf_f_cauchy_2))
2641 || (NULL == CU_add_test(pSfull,"Cauchy-P/CDF-f-3", test_cdf_pdf_f_cauchy_3))
2642 || (NULL == CU_add_test(pSfull,"Cauchy-P/CDF-f-4", test_cdf_pdf_f_cauchy_4))
2643 || (NULL == CU_add_test(pSfull,"Cauchy-P/CDF-f-5", test_cdf_pdf_f_cauchy_5))
2644 || (NULL == CU_add_test(pSfull,"Cauchy-Sym-f-6", test_sym_f_cauchy_6))
2645 || (NULL == CU_add_test(pSfull,"Cauchy-Sym-f-7", test_sym_f_cauchy_7))
2646 || (NULL == CU_add_test(pSfull,"Cauchy-Sym-f-8", test_sym_f_cauchy_8))
2647 || (NULL == CU_add_test(pSfull,"Cauchy-Sym-f-9", test_sym_f_cauchy_9))
2648 || (NULL == CU_add_test(pSfull,"Cauchy-Sym-f-10", test_sym_f_cauchy_10))
2649 || (NULL == CU_add_test(pSfull,"Cauchy-Sym-f-11", test_sym_f_cauchy_11))
2650 || (NULL == CU_add_test(pSfull,"Cauchy-Ran-f-1", test_cauchy_f_1))
2651 || (NULL == CU_add_test(pSfull,"Cauchy-Ran-f-2", test_cauchy_f_2))
2652 || (NULL == CU_add_test(pSfull,"Cauchy-Ran-f-3", test_cauchy_f_3))
2653 || (NULL == CU_add_test(pSfull,"Cauchymar-P/CDF-d-0", test_cdf_pdf_d_cauchymar_0))
2654 || (NULL == CU_add_test(pSfull,"Cauchymar-P/CDF-d-1", test_cdf_pdf_d_cauchymar_1))
2655 || (NULL == CU_add_test(pSfull,"Cauchymar-Ran-d-1", test_cauchymar_d_1))
2656 || (NULL == CU_add_test(pSfull,"Cauchymar-Ran-d-2", test_cauchymar_d_2))
2657 || (NULL == CU_add_test(pSfull,"Cauchymar-Ran-d-3", test_cauchymar_d_3))
2658 || (NULL == CU_add_test(pSfull,"Cauchymar-P/CDF-f-0", test_cdf_pdf_f_cauchymar_0))
2659 || (NULL == CU_add_test(pSfull,"Cauchymar-P/CDF-f-1", test_cdf_pdf_f_cauchymar_1))
2660 || (NULL == CU_add_test(pSfull,"Cauchymar-Ran-f-1", test_cauchymar_f_1))
2661 || (NULL == CU_add_test(pSfull,"Cauchymar-Ran-f-2", test_cauchymar_f_2))
2662 || (NULL == CU_add_test(pSfull,"Cauchymar-Ran-f-3", test_cauchymar_f_3))
2663 || (NULL == CU_add_test(pSfull,"Cauchy/Uinvcdf-P/CDF-d-9",test_cdf_pdf_d_uinvcdf_9))
2664 || (NULL == CU_add_test(pSfull,"Cauchy/Uinvcdf-P/CDF-d-10",test_cdf_pdf_d_uinvcdf_10))
2665 || (NULL == CU_add_test(pSfull,"Cauchy/Uinvcdf-Ran-d-11", test_uinvcdf_d_11))
2666 || (NULL == CU_add_test(pSfull,"Cauchy/Uinvcdf-P/CDF-f-9",test_cdf_pdf_f_uinvcdf_9))
2667 || (NULL == CU_add_test(pSfull,"Cauchy/Uinvcdf-P/CDF-f-10",test_cdf_pdf_f_uinvcdf_10))
2668 || (NULL == CU_add_test(pSfull,"Cauchy/Uinvcdf-Ran-f-11", test_uinvcdf_f_11))
2669 ) {
2670  printf("\nTest Suite full range additions failure.");
2671  CU_cleanup_registry();
2672  return CU_get_error();
2673  }
2674 if ((NULL == CU_add_test(pSdisc,"Poisson-P/CDF-1-1", test_cdf_pdf_1_poisson_1))
2675 || (NULL == CU_add_test(pSdisc,"Poisson-P/CDF-2-2", test_cdf_pdf_2_poisson_2))
2676 || (NULL == CU_add_test(pSdisc,"Poisson-P/CDF-4-3", test_cdf_pdf_4_poisson_3))
2677 || (NULL == CU_add_test(pSdisc,"Poisson-P/CDF-8-4", test_cdf_pdf_8_poisson_4))
2678 || (NULL == CU_add_test(pSdisc,"Poisson-Ran-1-1", test_poisson_i_1))
2679 || (NULL == CU_add_test(pSdisc,"Poisson-Ran-2-2", test_poisson_i_2))
2680 || (NULL == CU_add_test(pSdisc,"Poisson-Ran-4-3", test_poisson_i_3))
2681 || (NULL == CU_add_test(pSdisc,"Poisson-Ran-8-4", test_poisson_i_4))
2682 || (NULL == CU_add_test(pSdisc,"Poisson-Ran-55-5", test_poisson_i_5))
2683 || (NULL == CU_add_test(pSdisc,"check - Poisson - 1",test_check_poisson_i_1))
2684 || (NULL == CU_add_test(pSdisc,"check - Poisson - 2",test_check_poisson_i_2))
2685 || (NULL == CU_add_test(pSdisc,"Geom-P/CDF-25-1", test_cdf_pdf_25_geometric_1))
2686 || (NULL == CU_add_test(pSdisc,"Geom-P/CDF-50-2", test_cdf_pdf_50_geometric_2))
2687 || (NULL == CU_add_test(pSdisc,"Geom-P/CDF-75-3", test_cdf_pdf_75_geometric_3))
2688 || (NULL == CU_add_test(pSdisc,"Geometric-Ran-def-1", test_geometric_i_1))
2689 || (NULL == CU_add_test(pSdisc,"Geometric-Ran-50-2", test_geometric_i_2))
2690 || (NULL == CU_add_test(pSdisc,"Geometric-Ran-20-3", test_geometric_i_3))
2691 || (NULL == CU_add_test(pSdisc,"Geometric-Ran-35-4", test_geometric_i_4))
2692 || (NULL == CU_add_test(pSdisc,"Geometric-Ran-65-5", test_geometric_i_5))
2693 || (NULL == CU_add_test(pSdisc,"Geometric-Ran-80-6", test_geometric_i_6))
2694 || (NULL == CU_add_test(pSdisc,"check - Geom - 1",test_check_geometric_i_1))
2695 || (NULL == CU_add_test(pSdisc,"check - Geom - 2",test_check_geometric_i_2))
2696 || (NULL == CU_add_test(pSdisc,"check - Geom - 3",test_check_geometric_i_3))
2697 || (NULL == CU_add_test(pSdisc,"Binom-P/CDF-25-1", test_cdf_pdf_25_binomial_1))
2698 || (NULL == CU_add_test(pSdisc,"Binom-P/CDF-50-2", test_cdf_pdf_50_binomial_2))
2699 || (NULL == CU_add_test(pSdisc,"Binom-P/CDF-75-3", test_cdf_pdf_80_binomial_3))
2700 || (NULL == CU_add_test(pSdisc,"Binomial-Ran-def-1", test_binomial_i_1))
2701 || (NULL == CU_add_test(pSdisc,"Binomial-Ran-50-1", test_binomial_i_2))
2702 || (NULL == CU_add_test(pSdisc,"Binomial-Ran-20-1", test_binomial_i_3))
2703 || (NULL == CU_add_test(pSdisc,"Binomial-Ran-35-1", test_binomial_i_4))
2704 || (NULL == CU_add_test(pSdisc,"Binomial-Ran-65-1", test_binomial_i_5))
2705 || (NULL == CU_add_test(pSdisc,"Binomial-Ran-80-1", test_binomial_i_6))
2706 || (NULL == CU_add_test(pSdisc,"check - Binomial - 1",test_check_binomial_i_1))
2707 || (NULL == CU_add_test(pSdisc,"check - Binomial - 2",test_check_binomial_i_2))
2708 || (NULL == CU_add_test(pSdisc,"check - Binomial - 3",test_check_binomial_i_3))
2709 || (NULL == CU_add_test(pSdisc,"check - Binomial - 4",test_check_binomial_i_4))
2710 || (NULL == CU_add_test(pSdisc,"check - Binomial - 5",test_check_binomial_i_5))
2711 ) {
2712  printf("\nTest Suite discrete additions failure.");
2713  CU_cleanup_registry();
2714  return CU_get_error();
2715  }
2716 
2717  /* Run all tests using the basic interface */
2718  CU_basic_set_mode(mode);
2719  CU_set_error_action(error_action);
2720  if (interact) {
2721  CU_console_run_tests();
2722  } else {
2723  CU_basic_run_tests();
2724  }
2725  printf("\n");
2726 
2727  /* Clean up and return */
2728  CU_cleanup_registry();
2729  return CU_get_error();
2730 }
int LR_aux_norm(LR_obj *o)
LR_aux_norm(LR_obj *o) - process given intervals and normalize values.
Definition: LRdf.c:301
LR_val b
Definition: libran.h:139
#define LRerr_OK
Definition: libran.h:32
Definition: libran.h:59
int LR_aux_set(LR_obj *o, double x, double p)
LR_aux_set(LR_obj *o, double x, double p) - add an interval boundary for the underlying distribution...
Definition: LRdf.c:282
Definition: libran.h:60
#define LR_VERSION
LibRan Library Version (X.Y.Z)
Definition: libran.h:23
double LRd_CDF(LR_obj *o, double x)
LRd_CDF(LR_obj *o, double x) - cumulative distribution function.
Definition: LRdf.c:101
int LRd_uinvcdf(LR_obj *o, double(*cdf)(double))
LRd_uinvcdf() - set the user defined CDF for this variate distribution.
Definition: LRuinvcdf.c:131
int LRf_uinvcdf(LR_obj *o, float(*cdf)(float))
LRf_uinvcdf() - set the user defined CDF for this variate distribution.
Definition: LRuinvcdf.c:413
int LR_check(LR_obj *o)
LR_check(LR_obj *o) - check and fix the LR object parameters if possible.
Definition: LRnew.c:470
#define LRerr_UnmetPreconditions
Definition: libran.h:43
float LRf_RAN(LR_obj *o)
LRf_RAN(LR_obj *o) - random variate generator.
Definition: LRdf.c:119
Definition: libran.h:70
float LRf_PDF(LR_obj *o, float x)
LRf_PDF(LR_obj *o, float x) - probability distribution function.
Definition: LRdf.c:140
Definition: libran.h:65
Definition: libran.h:66
#define LRerr_InvalidRange
Definition: libran.h:42
Definition: libran.h:62
Definition: libran.h:54
Definition: libran.h:64
Definition: libran.h:58
LR_obj * LR_new(LR_type t, LR_data_type d)
LR_new(LR_type t, LR_data_type d) - create the LR object and preset some default parameter values...
Definition: LRnew.c:60
double LRd_RAN(LR_obj *o)
LRd_RAN(LR_obj *o) - random variate generator.
Definition: LRdf.c:59
double LRd_PDF(LR_obj *o, double x)
LRd_PDF(LR_obj *o, double x) - probability distribution function.
Definition: LRdf.c:80
float LRf_CDF(LR_obj *o, float x)
LRf_CDF(LR_obj *o, float x) - cumulative distribution function.
Definition: LRdf.c:161
#define LRerr_BadDataType
Definition: libran.h:34
int LR_aux_new(LR_obj *o, int n)
LR_aux_new(LR_obj *o, int n) - initialize a new auxiliary object.
Definition: LRdf.c:241
int LR_rm(LR_obj **o)
LR_rm(LR_obj **o) - destroy the LR object and release allocated memory.
Definition: LRnew.c:432
char * LRstrerrno(int LRerrno)
LRstrerrno(int LRerrno) - return the errno code string for the given LibRan errno.
Definition: LRerror.c:112
#define LR_DATE
LibRan Library date (YYYYMMDD)
Definition: libran.h:27
Definition: libran.h:68
Definition: libran.h:69
LR_val s
Definition: libran.h:141
LR_val a
Definition: libran.h:138
double d
Definition: libran.h:87
float f
Definition: libran.h:86
void LRperror(char *str, int LRerrno)
LRperror(char *str, int LRerrno) - print out explanatory error message to stderr. ...
Definition: LRerror.c:157
Definition: libran.h:61
Definition: libran.h:63
int LR_set_all(LR_obj *o, char *x,...)
LR_set_all(LR_obj *o, char *x, ...) - set all given LR object parameters.
Definition: LRset.c:194
The LibRan common header file.
#define LRerr_Unspecified
Definition: libran.h:33
#define LRerr_InvalidInputValue
Definition: libran.h:41
the fundamental LibRan random variate distribution object
Definition: libran.h:134
LR_val m
Definition: libran.h:140
Definition: libran.h:99
void LR_lsetseed(LR_obj *, long lty)
LR_lsetseed(LR_obj *, long X) - set the seed to X.
Definition: urand.c:361