1 /*
2 	file automatically generated by make_test_files.pl
3 	Tue Apr 19 14:01:02 2011
4 */
5 
6 /*****************************************************************************
7  *                                                                           *
8  *          UNU.RAN -- Universal Non-Uniform Random number generator         *
9  *                                                                           *
10  *****************************************************************************/
11 
12 /**
13  ** Tests for DSROU
14  **/
15 
16 /*---------------------------------------------------------------------------*/
17 #include "testunuran.h"
18 
19 #ifdef UNUR_URNG_DEFAULT_RNGSTREAM
20 #include <RngStream.h>
21 #endif
22 /*---------------------------------------------------------------------------*/
23 
24 /*---------------------------------------------------------------------------*/
25 /* global variables                                                          */
26 
27 static FILE *TESTLOG;               /* test log file                         */
28 static FILE *UNURANLOG;             /* unuran log file                       */
29 
30 static int test_ok = TRUE;          /* all tests ok (boolean)                */
31 static int fullcheck = FALSE;       /* whether all checks are performed      */
32 
33 static TIMER watch;                 /* stop watch                            */
34 
35 /*---------------------------------------------------------------------------*/
36 
37 void run_verify_generator( FILE *LOG, int line, UNUR_PAR *par );
38 
39 
40 
41 /*---------------------------------------------------------------------------*/
42 
43 void test_new (void);
44 void test_set (void);
45 void test_get (void);
46 void test_chg (void);
47 void test_init (void);
48 void test_reinit (void);
49 void test_sample (void);
50 void test_validate (void);
51 void test_special(void);
52 
53 /*---------------------------------------------------------------------------*/
54 
55 
56 
57 /* prototypes */
58 int unur_dsrou_set_pedantic( struct unur_par *par, int pedantic );
59 
60 double pmf( int k, const UNUR_DISTR *distr );
61 double pmf_invalidmode( int k, const UNUR_DISTR *distr );
62 
63 double pmf_geom05( int k, const UNUR_DISTR *distr );
64 double cdf_geom05( int k, const UNUR_DISTR *distr );
65 
66 #define COMPARE_SAMPLE_SIZE   (10000)
67 #define VIOLATE_SAMPLE_SIZE   (10000)
68 
69 /* #define SEED   (298346) */
70 
71 
72 
73 
74 /*---------------------------------------------------------------------------*/
75 
76 #ifndef CHI2_FAILURES_TOLERATED
77 #  define CHI2_FAILURES_TOLERATED DEFAULT_CHI2_FAILURES_TOLERATED
78 #endif
79 
80 /*---------------------------------------------------------------------------*/
81 /* [verbatim] */
82 
83 
84 
85 /* pmf that does not work */
pmf(int k,const UNUR_DISTR * distr ATTRIBUTE__UNUSED)86 double pmf( int k, const UNUR_DISTR *distr ATTRIBUTE__UNUSED)
87 {
88 	return ((k==2) ? 0. : pow(0.5,(double)k));
89 } /* end of pmf */
90 
pmf_invalidmode(int k,const UNUR_DISTR * distr ATTRIBUTE__UNUSED)91 double pmf_invalidmode( int k, const UNUR_DISTR *distr ATTRIBUTE__UNUSED)
92 {
93 	return ((k==2) ? 0.01 : pow(0.5,(double)k));
94 } /* end of pmf */
95 
96 
97 /* pmf for geometric(0.5) distribution with domain (1,inf) */
pmf_geom05(int k,const UNUR_DISTR * distr ATTRIBUTE__UNUSED)98 double pmf_geom05( int k, const UNUR_DISTR *distr ATTRIBUTE__UNUSED)
99 {
100 	return (pow(0.5,(double)k));
101 }
102 
cdf_geom05(int k,const UNUR_DISTR * distr ATTRIBUTE__UNUSED)103 double cdf_geom05( int k, const UNUR_DISTR *distr ATTRIBUTE__UNUSED)
104 {
105 	return (1.-pow(0.5,(double)k));
106 }
107 
108 
109 /* dummy function */
unur_dsrou_set_pedantic(struct unur_par * par ATTRIBUTE__UNUSED,int pedantic ATTRIBUTE__UNUSED)110 int unur_dsrou_set_pedantic( struct unur_par *par ATTRIBUTE__UNUSED, int pedantic ATTRIBUTE__UNUSED)
111 { return 1; }
112 
113 /*---------------------------------------------------------------------------*/
114 /* [new] */
115 
test_new(void)116 void test_new (void)
117 {
118         int n_tests_failed;          /* number of failed tests */
119 
120 	/* start test */
121 	printf("[new "); fflush(stdout);
122 	fprintf(TESTLOG,"\n[new]\n");
123 
124 	/* reset counter */
125 	n_tests_failed = 0;
126 
127 	/* set stop watch */
128 	stopwatch_lap(&watch);
129 
130 { /* invalid NULL ptr */
131 UNUR_DISTR *distr = NULL;
132    distr = NULL;
133 
134 
135 unur_reset_errno();
136 n_tests_failed += (check_expected_NULL(TESTLOG,35,(unur_dsrou_new( distr )))==UNUR_SUCCESS)?0:1;
137 n_tests_failed += (check_errorcode(TESTLOG,35,UNUR_ERR_NULL)==UNUR_SUCCESS)?0:1;
138 unur_distr_free(distr);
139 }
140 
141 { /* invalid distribution type */
142 UNUR_DISTR *distr = NULL;
143    distr = unur_distr_cont_new();
144 
145 
146 unur_reset_errno();
147 n_tests_failed += (check_expected_NULL(TESTLOG,41,(unur_dsrou_new( distr )))==UNUR_SUCCESS)?0:1;
148 n_tests_failed += (check_errorcode(TESTLOG,41,UNUR_ERR_DISTR_INVALID)==UNUR_SUCCESS)?0:1;
149 unur_distr_free(distr);
150 }
151 
152 { /* data missing in distribution object */
153 UNUR_DISTR *distr = NULL;
154    distr = unur_distr_discr_new();
155 
156 
157 unur_reset_errno();
158 /* pmf, mode, pmfsum */
159 n_tests_failed += (check_expected_NULL(TESTLOG,48,(unur_dsrou_new( distr )))==UNUR_SUCCESS)?0:1;
160 n_tests_failed += (check_errorcode(TESTLOG,48,UNUR_ERR_DISTR_REQUIRED)==UNUR_SUCCESS)?0:1;
161 unur_distr_free(distr);
162 }
163 
164 
165 	/* timing */
166 	stopwatch_print(TESTLOG,"\n<*>time = %.3f ms\n\n", stopwatch_lap(&watch));
167 
168 	/* test finished */
169 	test_ok &= (n_tests_failed) ? 0 : 1;
170 	(n_tests_failed) ? printf(" ==> failed] ") : printf(" ==> ok] ");
171 
172 } /* end of test_new() */
173 
174 /*---------------------------------------------------------------------------*/
175 /* [set] */
176 
test_set(void)177 void test_set (void)
178 {
179         int n_tests_failed;          /* number of failed tests */
180 
181 	/* start test */
182 	printf("[set "); fflush(stdout);
183 	fprintf(TESTLOG,"\n[set]\n");
184 
185 	/* reset counter */
186 	n_tests_failed = 0;
187 
188 	/* set stop watch */
189 	stopwatch_lap(&watch);
190 
191 { /* invalid NULL ptr */
192 UNUR_PAR   *par = NULL;
193    par = NULL;
194 
195 
196 unur_reset_errno();
197 n_tests_failed += (check_expected_setfailed(TESTLOG,58,(unur_dsrou_set_cdfatmode(par,0.)))==UNUR_SUCCESS)?0:1;
198 n_tests_failed += (check_errorcode(TESTLOG,58,UNUR_ERR_NULL)==UNUR_SUCCESS)?0:1;
199 
200 unur_reset_errno();
201 n_tests_failed += (check_expected_setfailed(TESTLOG,61,(unur_dsrou_set_verify(par,1)))==UNUR_SUCCESS)?0:1;
202 n_tests_failed += (check_errorcode(TESTLOG,61,UNUR_ERR_NULL)==UNUR_SUCCESS)?0:1;
203 }
204 
205 { /* invalid parameter object */
206 UNUR_DISTR *distr = NULL;
207 UNUR_PAR   *par = NULL;
208    double fpar[2] = {10,0.63};
209    distr = unur_distr_binomial(fpar,2);
210    par = unur_dari_new(distr);
211 
212 
213 unur_reset_errno();
214 n_tests_failed += (check_expected_setfailed(TESTLOG,69,(unur_dsrou_set_cdfatmode(par,0.)))==UNUR_SUCCESS)?0:1;
215 n_tests_failed += (check_errorcode(TESTLOG,69,UNUR_ERR_PAR_INVALID)==UNUR_SUCCESS)?0:1;
216 
217 unur_reset_errno();
218 n_tests_failed += (check_expected_setfailed(TESTLOG,72,(unur_dsrou_set_verify(par,1)))==UNUR_SUCCESS)?0:1;
219 n_tests_failed += (check_errorcode(TESTLOG,72,UNUR_ERR_PAR_INVALID)==UNUR_SUCCESS)?0:1;
220 unur_par_free(par);
221 unur_distr_free(distr);
222 }
223 
224 { /* invalid parameters */
225 UNUR_DISTR *distr = NULL;
226 UNUR_PAR   *par = NULL;
227    double fpar[2] = {10.,0.63};
228    distr = unur_distr_binomial(fpar,2);
229    par = unur_dsrou_new(distr);
230 
231 
232 unur_reset_errno();
233 n_tests_failed += (check_expected_setfailed(TESTLOG,82,(unur_dsrou_set_cdfatmode(par,-1.)))==UNUR_SUCCESS)?0:1;
234 n_tests_failed += (check_errorcode(TESTLOG,82,UNUR_ERR_PAR_SET)==UNUR_SUCCESS)?0:1;
235 unur_par_free(par);
236 unur_distr_free(distr);
237 }
238 
239 
240 	/* timing */
241 	stopwatch_print(TESTLOG,"\n<*>time = %.3f ms\n\n", stopwatch_lap(&watch));
242 
243 	/* test finished */
244 	test_ok &= (n_tests_failed) ? 0 : 1;
245 	(n_tests_failed) ? printf(" ==> failed] ") : printf(" ==> ok] ");
246 
247 } /* end of test_set() */
248 
249 /*---------------------------------------------------------------------------*/
250 /* [chg] */
251 
test_chg(void)252 void test_chg (void)
253 {
254         int n_tests_failed;          /* number of failed tests */
255 
256 	/* start test */
257 	printf("[chg "); fflush(stdout);
258 	fprintf(TESTLOG,"\n[chg]\n");
259 
260 	/* reset counter */
261 	n_tests_failed = 0;
262 
263 	/* set stop watch */
264 	stopwatch_lap(&watch);
265 
266 { /* invalid generator object */
267 UNUR_DISTR *distr = NULL;
268 UNUR_PAR   *par = NULL;
269 UNUR_GEN   *gen = NULL;
270    double fpar[2] = {10.,0.63};
271    distr = unur_distr_binomial(fpar,2);
272    par = unur_dari_new(distr);
273    unur_set_debug(par,0);
274    gen = unur_init( par );
275 abort_if_NULL(TESTLOG, 98,    gen );
276 
277 
278 unur_reset_errno();
279 n_tests_failed += (check_expected_setfailed(TESTLOG,102,(unur_dsrou_chg_verify(gen,1)))==UNUR_SUCCESS)?0:1;
280 n_tests_failed += (check_errorcode(TESTLOG,102,UNUR_ERR_GEN_INVALID)==UNUR_SUCCESS)?0:1;
281 
282 unur_reset_errno();
283 n_tests_failed += (check_expected_setfailed(TESTLOG,105,(unur_dsrou_chg_cdfatmode(gen,1.)))==UNUR_SUCCESS)?0:1;
284 n_tests_failed += (check_errorcode(TESTLOG,105,UNUR_ERR_GEN_INVALID)==UNUR_SUCCESS)?0:1;
285 unur_distr_free(distr);
286 unur_free(gen);
287 }
288 
289 { /* invalid parameters */
290 UNUR_DISTR *distr = NULL;
291 UNUR_PAR   *par = NULL;
292 UNUR_GEN   *gen = NULL;
293    double fpar[2] = {10.,0.63};
294    distr = unur_distr_binomial(fpar,2);
295    par = unur_dsrou_new(distr);
296    gen = unur_init( par );
297 abort_if_NULL(TESTLOG, 111,    gen );
298 
299 
300 unur_reset_errno();
301 n_tests_failed += (check_expected_setfailed(TESTLOG,115,(unur_dsrou_chg_cdfatmode(gen,-1.)))==UNUR_SUCCESS)?0:1;
302 n_tests_failed += (check_errorcode(TESTLOG,115,UNUR_ERR_PAR_SET)==UNUR_SUCCESS)?0:1;
303 unur_distr_free(distr);
304 unur_free(gen);
305 }
306 
307 
308 	/* timing */
309 	stopwatch_print(TESTLOG,"\n<*>time = %.3f ms\n\n", stopwatch_lap(&watch));
310 
311 	/* test finished */
312 	test_ok &= (n_tests_failed) ? 0 : 1;
313 	(n_tests_failed) ? printf(" ==> failed] ") : printf(" ==> ok] ");
314 
315 } /* end of test_chg() */
316 
317 /*---------------------------------------------------------------------------*/
318 /* [init] */
319 
test_init(void)320 void test_init (void)
321 {
322         int n_tests_failed;          /* number of failed tests */
323 
324 	/* start test */
325 	printf("[init "); fflush(stdout);
326 	fprintf(TESTLOG,"\n[init]\n");
327 
328 	/* reset counter */
329 	n_tests_failed = 0;
330 
331 	/* set stop watch */
332 	stopwatch_lap(&watch);
333 
334 { /* invalid NULL ptr */
335 UNUR_PAR   *par = NULL;
336    par = NULL;
337 
338 
339 unur_reset_errno();
340 n_tests_failed += (check_expected_NULL(TESTLOG,126,(unur_init( par )))==UNUR_SUCCESS)?0:1;
341 n_tests_failed += (check_errorcode(TESTLOG,126,UNUR_ERR_NULL)==UNUR_SUCCESS)?0:1;
342 }
343 
344 { /* invalid data */
345 UNUR_DISTR *distr = NULL;
346 UNUR_PAR   *par = NULL;
347    distr = unur_distr_discr_new();
348    unur_distr_discr_set_pmf(distr,pmf);
349    unur_distr_discr_set_mode(distr,2);
350    unur_distr_discr_set_pmfsum(distr,1.);
351    par = unur_dsrou_new(distr);
352 
353 
354 unur_reset_errno();
355 n_tests_failed += (check_expected_NULL(TESTLOG,137,(unur_init( par )))==UNUR_SUCCESS)?0:1;
356 n_tests_failed += (check_errorcode(TESTLOG,137,UNUR_ERR_GEN_DATA)==UNUR_SUCCESS)?0:1;
357 unur_distr_free(distr);
358 }
359 
360 { /* data missing in distribution object */
361 UNUR_DISTR *distr = NULL;
362 UNUR_PAR   *par = NULL;
363    distr = unur_distr_discr_new();
364    par = NULL;
365 
366 
367 unur_reset_errno();
368 /* mode, pmfsum */
369 unur_distr_discr_set_pmf(distr,pmf);
370 par = unur_dsrou_new( distr );
371 n_tests_failed += (check_expected_NULL(TESTLOG,147,(unur_init(par)))==UNUR_SUCCESS)?0:1;
372 n_tests_failed += (check_errorcode(TESTLOG,147,UNUR_ERR_DISTR_REQUIRED)==UNUR_SUCCESS)?0:1;
373 
374 unur_reset_errno();
375 /* pmfsum */
376 unur_distr_discr_set_mode(distr,0);
377 par = unur_dsrou_new( distr );
378 n_tests_failed += (check_expected_NULL(TESTLOG,153,(unur_init(par)))==UNUR_SUCCESS)?0:1;
379 n_tests_failed += (check_errorcode(TESTLOG,153,UNUR_ERR_DISTR_REQUIRED)==UNUR_SUCCESS)?0:1;
380 unur_distr_free(distr);
381 }
382 
383 
384 	/* timing */
385 	stopwatch_print(TESTLOG,"\n<*>time = %.3f ms\n\n", stopwatch_lap(&watch));
386 
387 	/* test finished */
388 	test_ok &= (n_tests_failed) ? 0 : 1;
389 	(n_tests_failed) ? printf(" ==> failed] ") : printf(" ==> ok] ");
390 
391 } /* end of test_init() */
392 
393 /*---------------------------------------------------------------------------*/
394 /* [reinit] */
395 
test_reinit(void)396 void test_reinit (void)
397 {
398         int n_tests_failed;          /* number of failed tests */
399 
400 	/* start test */
401 	printf("[reinit "); fflush(stdout);
402 	fprintf(TESTLOG,"\n[reinit]\n");
403 
404 	/* reset counter */
405 	n_tests_failed = 0;
406 
407 	/* set stop watch */
408 	stopwatch_lap(&watch);
409 
410 { /* exist */
411 UNUR_DISTR *distr = NULL;
412 UNUR_PAR   *par = NULL;
413 UNUR_GEN   *gen = NULL;
414    double fpar[2] = {10.,0.63};
415    distr = unur_distr_binomial(fpar,2);
416    par = unur_dsrou_new(distr);
417    gen = unur_init( par );
418 abort_if_NULL(TESTLOG, 162,    gen );
419 
420 
421 unur_reset_errno();
422 n_tests_failed += (check_expected_reinit(TESTLOG,166,(unur_reinit( gen )))==UNUR_SUCCESS)?0:1;
423 unur_distr_free(distr);
424 unur_free(gen);
425 }
426 
427 
428 	/* timing */
429 	stopwatch_print(TESTLOG,"\n<*>time = %.3f ms\n\n", stopwatch_lap(&watch));
430 
431 	/* test finished */
432 	test_ok &= (n_tests_failed) ? 0 : 1;
433 	(n_tests_failed) ? printf(" ==> failed] ") : printf(" ==> ok] ");
434 
435 } /* end of test_reinit() */
436 
437 /*---------------------------------------------------------------------------*/
438 /* [sample] */
439 
test_sample(void)440 void test_sample (void)
441 {
442         int n_tests_failed;          /* number of failed tests */
443 
444 	/* start test */
445 	printf("[sample "); fflush(stdout);
446 	fprintf(TESTLOG,"\n[sample]\n");
447 
448 	/* reset counter */
449 	n_tests_failed = 0;
450 
451 	/* set stop watch */
452 	stopwatch_lap(&watch);
453 
454 { /* compare */
455 UNUR_DISTR *distr = NULL;
456 UNUR_PAR   *par = NULL;
457    double fpar[2] = {10.,0.63};
458    distr = unur_distr_binomial(fpar,2);
459    par = NULL;
460 
461 
462 unur_reset_errno();
463 /* default algorithm */
464 par = unur_dsrou_new(distr);
465 n_tests_failed += (compare_sequence_par_start(TESTLOG,179,par,COMPARE_SAMPLE_SIZE)==UNUR_SUCCESS)?0:1;
466 
467 unur_reset_errno();
468 /* default algorithm - verifying mode */
469 par = unur_dsrou_new(distr);
470 unur_dsrou_set_verify(par,1);
471 n_tests_failed += (compare_sequence_par(TESTLOG,184,par,COMPARE_SAMPLE_SIZE)==UNUR_SUCCESS)?0:1;
472 unur_distr_free(distr);
473 }
474 
475 { /* violate condition */
476 UNUR_DISTR *distr = NULL;
477 UNUR_PAR   *par = NULL;
478    double fpar[2] = {10.,0.63};
479    distr = unur_distr_binomial(fpar,2);
480    par = NULL;
481 
482 
483 unur_reset_errno();
484 /* use cdf at mode */
485 par = unur_dsrou_new(distr);
486 unur_dsrou_set_cdfatmode(par,0.1);
487  run_verify_generator (TESTLOG,196,par);
488 n_tests_failed += (check_errorcode(TESTLOG,196,UNUR_ERR_GEN_CONDITION)==UNUR_SUCCESS)?0:1;
489 unur_distr_free(distr);
490 }
491 
492 { /* compare clone */
493 UNUR_DISTR *distr = NULL;
494 UNUR_PAR   *par = NULL;
495 UNUR_GEN   *gen = NULL;
496    UNUR_GEN *clone;
497    double fpar[] = {10,0.3};
498    distr = unur_distr_binomial(fpar,2);
499    par = NULL;
500    gen = NULL;
501 
502 
503 unur_reset_errno();
504 /* original generator object */
505 par = unur_dsrou_new(distr);
506 gen = unur_init(par);
507 n_tests_failed += (compare_sequence_gen_start(TESTLOG,210,gen,COMPARE_SAMPLE_SIZE)==UNUR_SUCCESS)?0:1;
508 
509 unur_reset_errno();
510 /* clone */
511 clone = unur_gen_clone(gen);
512 unur_free(gen);
513 gen = clone;
514 n_tests_failed += (compare_sequence_gen(TESTLOG,216,gen,COMPARE_SAMPLE_SIZE)==UNUR_SUCCESS)?0:1;
515 unur_distr_free(distr);
516 unur_free(gen);
517 }
518 
519 { /* compare reinit */
520 UNUR_DISTR *distr = NULL;
521 UNUR_PAR   *par = NULL;
522 UNUR_GEN   *gen = NULL;
523    double fpar[] = {10,0.3};
524    distr = unur_distr_binomial(fpar,2);
525    par = NULL;
526    gen = NULL;
527 
528 
529 unur_reset_errno();
530 /* original generator object */
531 par = unur_dsrou_new(distr);
532 gen = unur_init(par);
533 n_tests_failed += (compare_sequence_gen_start(TESTLOG,229,gen,COMPARE_SAMPLE_SIZE)==UNUR_SUCCESS)?0:1;
534 
535 unur_reset_errno();
536 /* reinit */
537 unur_reinit(gen);
538 n_tests_failed += (compare_sequence_gen(TESTLOG,233,gen,COMPARE_SAMPLE_SIZE)==UNUR_SUCCESS)?0:1;
539 unur_distr_free(distr);
540 unur_free(gen);
541 }
542 
543 { /* compare stringparser */
544 UNUR_DISTR *distr = NULL;
545 UNUR_PAR   *par = NULL;
546 UNUR_GEN   *gen = NULL;
547    double fpar[] = {3.};
548    distr = NULL;
549    par = NULL;
550    gen = NULL;
551 
552 
553 unur_reset_errno();
554 distr = unur_distr_poisson(fpar,1);
555 par = unur_dsrou_new(distr);
556 gen = unur_init(par);
557 n_tests_failed += (compare_sequence_gen_start(TESTLOG,246,gen,COMPARE_SAMPLE_SIZE)==UNUR_SUCCESS)?0:1;
558 
559 unur_reset_errno();
560 unur_free(gen); gen = NULL;
561 unur_distr_free(distr); distr = NULL;
562 gen = unur_str2gen( "poisson(3.) & method = dsrou" );
563 n_tests_failed += (compare_sequence_gen(TESTLOG,251,gen,COMPARE_SAMPLE_SIZE)==UNUR_SUCCESS)?0:1;
564 
565 unur_reset_errno();
566 unur_free(gen); gen = NULL;
567 unur_distr_free(distr); distr = NULL;
568 distr = unur_distr_poisson(fpar,1);
569 par = unur_dsrou_new(distr);
570 unur_dsrou_set_cdfatmode(par,0.3);
571 unur_dsrou_set_verify(par,1);
572 gen = unur_init(par);
573 n_tests_failed += (compare_sequence_gen_start(TESTLOG,260,gen,COMPARE_SAMPLE_SIZE)==UNUR_SUCCESS)?0:1;
574 
575 unur_reset_errno();
576 unur_free(gen); gen = NULL;
577 unur_distr_free(distr); distr = NULL;
578 gen = unur_str2gen( "poisson(3.) & method = dsrou; cdfatmode=0.3; verify=on" );
579 n_tests_failed += (compare_sequence_gen(TESTLOG,265,gen,COMPARE_SAMPLE_SIZE)==UNUR_SUCCESS)?0:1;
580 unur_distr_free(distr);
581 unur_free(gen);
582 }
583 
584 
585 	/* timing */
586 	stopwatch_print(TESTLOG,"\n<*>time = %.3f ms\n\n", stopwatch_lap(&watch));
587 
588 	/* test finished */
589 	test_ok &= (n_tests_failed) ? 0 : 1;
590 	(n_tests_failed) ? printf(" ==> failed] ") : printf(" ==> ok] ");
591 
592 } /* end of test_sample() */
593 
594 /*---------------------------------------------------------------------------*/
595 /* [validate] */
596 
597 /*---------------------------------------------------------------------------*/
598 
599 /* [validate] */
600 
test_validate(void)601 void test_validate (void)
602 {
603 	UNUR_DISTR *distr[16];
604 	UNUR_PAR *par;
605 	UNUR_GEN *gen;
606 	int n_tests_failed;
607 	int rcode;
608 	double *darray;
609 	double fpm[10];
610 
611 	rcode = 0;
612 
613 	/* start test */
614 	printf("[validate "); fflush(stdout);
615 	fprintf(TESTLOG,"\n[validate]\n");
616 
617 	/* reset counter */
618 	n_tests_failed = 0;
619 
620 	/* set stop watch */
621 	stopwatch_lap(&watch);
622 
623 
624 /* distributions: 16 */
625 {
626 fpm[0] = 0.5;
627 distr[0] = unur_distr_geometric(fpm,1);
628 }
629 
630 {
631 fpm[0] = 0.1;
632 distr[1] = unur_distr_geometric(fpm,1);
633 }
634 
635 {
636 fpm[0] = 0.001;
637 distr[2] = unur_distr_geometric(fpm,1);
638 }
639 
640 {
641 fpm[0] = 0.1;
642 distr[3] = unur_distr_logarithmic(fpm,1);
643 }
644 
645 {
646 fpm[0] = 0.9;
647 distr[4] = unur_distr_logarithmic(fpm,1);
648 }
649 
650 {
651 fpm[0] = 0.5;
652 fpm[1] = 10.;
653 distr[5] = unur_distr_negativebinomial(fpm,2);
654 }
655 
656 {
657 fpm[0] = 0.7;
658 fpm[1] = 5.;
659 distr[6] = unur_distr_negativebinomial(fpm,2);
660 }
661 
662 {
663 fpm[0] = 0.1;
664 fpm[1] = 20.;
665 distr[7] = unur_distr_negativebinomial(fpm,2);
666 }
667 
668 {
669 fpm[0] = 3.;
670 distr[8] = unur_distr_poisson(fpm,1);
671 }
672 
673 {
674 fpm[0] = 50.;
675 distr[9] = unur_distr_poisson(fpm,1);
676 }
677 
678 {
679 fpm[0] = 2.;
680 fpm[1] = 1.;
681 distr[10] = unur_distr_zipf(fpm,2);
682 }
683 
684 {
685 fpm[0] = 20.;
686 fpm[1] = 0.8;
687 distr[11] = unur_distr_binomial(fpm,2);
688 }
689 
690 {
691 fpm[0] = 2000.;
692 fpm[1] = 0.0013;
693 distr[12] = unur_distr_binomial(fpm,2);
694 }
695 
696 {
697 fpm[0] = 2000.;
698 fpm[1] = 200.;
699 fpm[2] = 20;
700 distr[13] = unur_distr_hypergeometric(fpm,3);
701 }
702 
703 {
704 fpm[0] = 2000.;
705 fpm[1] = 200.;
706 fpm[2] = 220;
707 distr[14] = unur_distr_hypergeometric(fpm,3);
708 }
709 
710 {
711 distr[15] = unur_distr_discr_new();
712 unur_distr_discr_set_pmf(distr[15],pmf_geom05);
713 unur_distr_discr_set_cdf(distr[15],cdf_geom05);
714 unur_distr_set_name(distr[15],"test find_mode");
715 }
716 
717 	/* timing */
718 	stopwatch_print(TESTLOG,"\n<*>setup time = %.3f ms\n", stopwatch_lap(&watch));
719 
720 	printf("\n(chi^2) "); fflush(stdout);
721 
722 /* chi^2 tests: 64 */
723 
724 	unur_set_default_debug(~UNUR_DEBUG_SAMPLE);
725 	fprintf( TESTLOG,"\nChi^2 Test:\n");
726 
727 /* distribution [0] */
728 
729 	if(TRUE) {
730 	unur_reset_errno();
731 	do {
732 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[0]);
733 par = unur_dsrou_new(distr_localcopy);
734 	gen = unur_init(par);
735 	rcode = run_validate_chi2(TESTLOG,0,gen,distr[0],'+');
736 	n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
737 	n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
738 	unur_free(gen);
739 	unur_distr_free(distr_localcopy);
740 	} while (0);
741 	}
742 
743 	if(TRUE) {
744 	unur_reset_errno();
745 	do {
746 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[0]);
747 { double Fmode = unur_distr_discr_eval_cdf( unur_distr_discr_get_mode(distr_localcopy), distr_localcopy );
748 par = unur_dsrou_new(distr_localcopy);
749 unur_dsrou_set_cdfatmode(par,Fmode); }
750 	gen = unur_init(par);
751 	rcode = run_validate_chi2(TESTLOG,0,gen,distr[0],'+');
752 	n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
753 	n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
754 	unur_free(gen);
755 	unur_distr_free(distr_localcopy);
756 	} while (0);
757 	}
758 
759 	if(TRUE) {
760 	unur_reset_errno();
761 	do {
762 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[0]);
763 { UNUR_DISTR *dg =NULL;
764 par = unur_dsrou_new(distr_localcopy);
765 	gen = unur_init(par);
766 	if (gen) {
767 dg = unur_get_distr(gen);
768 unur_distr_discr_set_domain(dg,2,7);
769 unur_distr_discr_upd_pmfsum(dg);
770 unur_distr_discr_upd_mode(dg);
771 unur_reinit(gen); }
772 	}
773 	rcode = run_validate_chi2(TESTLOG,0,gen,distr[0],'+');
774 	n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
775 	n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
776 	unur_free(gen);
777 	unur_distr_free(distr_localcopy);
778 	} while (0);
779 	}
780 
781 	if(TRUE) {
782 	printf("."); fflush(stdout);
783 	}
784 
785 /* distribution [1] */
786 
787 	if(TRUE) {
788 	unur_reset_errno();
789 	do {
790 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[1]);
791 par = unur_dsrou_new(distr_localcopy);
792 	gen = unur_init(par);
793 	rcode = run_validate_chi2(TESTLOG,0,gen,distr[1],'+');
794 	n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
795 	n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
796 	unur_free(gen);
797 	unur_distr_free(distr_localcopy);
798 	} while (0);
799 	}
800 
801 	if(TRUE) {
802 	unur_reset_errno();
803 	do {
804 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[1]);
805 { double Fmode = unur_distr_discr_eval_cdf( unur_distr_discr_get_mode(distr_localcopy), distr_localcopy );
806 par = unur_dsrou_new(distr_localcopy);
807 unur_dsrou_set_cdfatmode(par,Fmode); }
808 	gen = unur_init(par);
809 	rcode = run_validate_chi2(TESTLOG,0,gen,distr[1],'+');
810 	n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
811 	n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
812 	unur_free(gen);
813 	unur_distr_free(distr_localcopy);
814 	} while (0);
815 	}
816 
817 	if(TRUE) {
818 	unur_reset_errno();
819 	do {
820 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[1]);
821 { UNUR_DISTR *dg =NULL;
822 par = unur_dsrou_new(distr_localcopy);
823 	gen = unur_init(par);
824 	if (gen) {
825 dg = unur_get_distr(gen);
826 unur_distr_discr_set_domain(dg,2,7);
827 unur_distr_discr_upd_pmfsum(dg);
828 unur_distr_discr_upd_mode(dg);
829 unur_reinit(gen); }
830 	}
831 	rcode = run_validate_chi2(TESTLOG,0,gen,distr[1],'+');
832 	n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
833 	n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
834 	unur_free(gen);
835 	unur_distr_free(distr_localcopy);
836 	} while (0);
837 	}
838 
839 	if(TRUE) {
840 	printf("."); fflush(stdout);
841 	}
842 
843 /* distribution [2] */
844 
845 	if(TRUE) {
846 	unur_reset_errno();
847 	do {
848 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[2]);
849 par = unur_dsrou_new(distr_localcopy);
850 	gen = unur_init(par);
851 	rcode = run_validate_chi2(TESTLOG,0,gen,distr[2],'+');
852 	n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
853 	n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
854 	unur_free(gen);
855 	unur_distr_free(distr_localcopy);
856 	} while (0);
857 	}
858 
859 	if(TRUE) {
860 	unur_reset_errno();
861 	do {
862 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[2]);
863 { double Fmode = unur_distr_discr_eval_cdf( unur_distr_discr_get_mode(distr_localcopy), distr_localcopy );
864 par = unur_dsrou_new(distr_localcopy);
865 unur_dsrou_set_cdfatmode(par,Fmode); }
866 	gen = unur_init(par);
867 	rcode = run_validate_chi2(TESTLOG,0,gen,distr[2],'+');
868 	n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
869 	n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
870 	unur_free(gen);
871 	unur_distr_free(distr_localcopy);
872 	} while (0);
873 	}
874 
875 	if(TRUE) {
876 	unur_reset_errno();
877 	do {
878 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[2]);
879 { UNUR_DISTR *dg =NULL;
880 par = unur_dsrou_new(distr_localcopy);
881 	gen = unur_init(par);
882 	if (gen) {
883 dg = unur_get_distr(gen);
884 unur_distr_discr_set_domain(dg,2,7);
885 unur_distr_discr_upd_pmfsum(dg);
886 unur_distr_discr_upd_mode(dg);
887 unur_reinit(gen); }
888 	}
889 	rcode = run_validate_chi2(TESTLOG,0,gen,distr[2],'+');
890 	n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
891 	n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
892 	unur_free(gen);
893 	unur_distr_free(distr_localcopy);
894 	} while (0);
895 	}
896 
897 	if(TRUE) {
898 	printf("."); fflush(stdout);
899 	}
900 
901 /* distribution [3] */
902 
903 	if(TRUE) {
904 	unur_reset_errno();
905 	do {
906 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[3]);
907 par = unur_dsrou_new(distr_localcopy);
908 	gen = unur_init(par);
909 	rcode = run_validate_chi2(TESTLOG,0,gen,distr[3],'+');
910 	n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
911 	n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
912 	unur_free(gen);
913 	unur_distr_free(distr_localcopy);
914 	} while (0);
915 	}
916 
917 	if(TRUE) {
918 	unur_reset_errno();
919 	do {
920 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[3]);
921 { double Fmode = unur_distr_discr_eval_cdf( unur_distr_discr_get_mode(distr_localcopy), distr_localcopy );
922 par = unur_dsrou_new(distr_localcopy);
923 unur_dsrou_set_cdfatmode(par,Fmode); }
924 	gen = unur_init(par);
925 	rcode = run_validate_chi2(TESTLOG,0,gen,distr[3],'+');
926 	n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
927 	n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
928 	unur_free(gen);
929 	unur_distr_free(distr_localcopy);
930 	} while (0);
931 	}
932 
933 	if(TRUE) {
934 	unur_reset_errno();
935 	do {
936 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[3]);
937 { UNUR_DISTR *dg =NULL;
938 par = unur_dsrou_new(distr_localcopy);
939 	gen = unur_init(par);
940 	if (gen) {
941 dg = unur_get_distr(gen);
942 unur_distr_discr_set_domain(dg,2,7);
943 unur_distr_discr_upd_pmfsum(dg);
944 unur_distr_discr_upd_mode(dg);
945 unur_reinit(gen); }
946 	}
947 	rcode = run_validate_chi2(TESTLOG,0,gen,distr[3],'+');
948 	n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
949 	n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
950 	unur_free(gen);
951 	unur_distr_free(distr_localcopy);
952 	} while (0);
953 	}
954 
955 	if(TRUE) {
956 	printf("."); fflush(stdout);
957 	}
958 
959 /* distribution [4] */
960 
961 	if(TRUE) {
962 	unur_reset_errno();
963 	do {
964 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[4]);
965 par = unur_dsrou_new(distr_localcopy);
966 	gen = unur_init(par);
967 	rcode = run_validate_chi2(TESTLOG,0,gen,distr[4],'+');
968 	n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
969 	n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
970 	unur_free(gen);
971 	unur_distr_free(distr_localcopy);
972 	} while (0);
973 	}
974 
975 	if(TRUE) {
976 	unur_reset_errno();
977 	do {
978 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[4]);
979 { double Fmode = unur_distr_discr_eval_cdf( unur_distr_discr_get_mode(distr_localcopy), distr_localcopy );
980 par = unur_dsrou_new(distr_localcopy);
981 unur_dsrou_set_cdfatmode(par,Fmode); }
982 	gen = unur_init(par);
983 	rcode = run_validate_chi2(TESTLOG,0,gen,distr[4],'+');
984 	n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
985 	n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
986 	unur_free(gen);
987 	unur_distr_free(distr_localcopy);
988 	} while (0);
989 	}
990 
991 	if(TRUE) {
992 	unur_reset_errno();
993 	do {
994 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[4]);
995 { UNUR_DISTR *dg =NULL;
996 par = unur_dsrou_new(distr_localcopy);
997 	gen = unur_init(par);
998 	if (gen) {
999 dg = unur_get_distr(gen);
1000 unur_distr_discr_set_domain(dg,2,7);
1001 unur_distr_discr_upd_pmfsum(dg);
1002 unur_distr_discr_upd_mode(dg);
1003 unur_reinit(gen); }
1004 	}
1005 	rcode = run_validate_chi2(TESTLOG,0,gen,distr[4],'+');
1006 	n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
1007 	n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
1008 	unur_free(gen);
1009 	unur_distr_free(distr_localcopy);
1010 	} while (0);
1011 	}
1012 
1013 	if(TRUE) {
1014 	printf("."); fflush(stdout);
1015 	}
1016 
1017 /* distribution [5] */
1018 
1019 	if(TRUE) {
1020 	unur_reset_errno();
1021 	do {
1022 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[5]);
1023 par = unur_dsrou_new(distr_localcopy);
1024 	gen = unur_init(par);
1025 	rcode = run_validate_chi2(TESTLOG,0,gen,distr[5],'+');
1026 	n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
1027 	n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
1028 	unur_free(gen);
1029 	unur_distr_free(distr_localcopy);
1030 	} while (0);
1031 	}
1032 
1033 	if(TRUE) {
1034 	unur_reset_errno();
1035 	do {
1036 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[5]);
1037 { double Fmode = unur_distr_discr_eval_cdf( unur_distr_discr_get_mode(distr_localcopy), distr_localcopy );
1038 par = unur_dsrou_new(distr_localcopy);
1039 unur_dsrou_set_cdfatmode(par,Fmode); }
1040 	gen = unur_init(par);
1041 	rcode = run_validate_chi2(TESTLOG,0,gen,distr[5],'+');
1042 	n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
1043 	n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
1044 	unur_free(gen);
1045 	unur_distr_free(distr_localcopy);
1046 	} while (0);
1047 	}
1048 
1049 	if(TRUE) {
1050 	unur_reset_errno();
1051 	do {
1052 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[5]);
1053 { UNUR_DISTR *dg =NULL;
1054 par = unur_dsrou_new(distr_localcopy);
1055 	gen = unur_init(par);
1056 	if (gen) {
1057 dg = unur_get_distr(gen);
1058 unur_distr_discr_set_domain(dg,2,7);
1059 unur_distr_discr_upd_pmfsum(dg);
1060 unur_distr_discr_upd_mode(dg);
1061 unur_reinit(gen); }
1062 	}
1063 	rcode = run_validate_chi2(TESTLOG,0,gen,distr[5],'+');
1064 	n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
1065 	n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
1066 	unur_free(gen);
1067 	unur_distr_free(distr_localcopy);
1068 	} while (0);
1069 	}
1070 
1071 	if(TRUE) {
1072 	printf("."); fflush(stdout);
1073 	}
1074 
1075 /* distribution [6] */
1076 
1077 	if(TRUE) {
1078 	unur_reset_errno();
1079 	do {
1080 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[6]);
1081 par = unur_dsrou_new(distr_localcopy);
1082 	gen = unur_init(par);
1083 	rcode = run_validate_chi2(TESTLOG,0,gen,distr[6],'+');
1084 	n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
1085 	n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
1086 	unur_free(gen);
1087 	unur_distr_free(distr_localcopy);
1088 	} while (0);
1089 	}
1090 
1091 	if(TRUE) {
1092 	unur_reset_errno();
1093 	do {
1094 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[6]);
1095 { double Fmode = unur_distr_discr_eval_cdf( unur_distr_discr_get_mode(distr_localcopy), distr_localcopy );
1096 par = unur_dsrou_new(distr_localcopy);
1097 unur_dsrou_set_cdfatmode(par,Fmode); }
1098 	gen = unur_init(par);
1099 	rcode = run_validate_chi2(TESTLOG,0,gen,distr[6],'+');
1100 	n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
1101 	n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
1102 	unur_free(gen);
1103 	unur_distr_free(distr_localcopy);
1104 	} while (0);
1105 	}
1106 
1107 	if(TRUE) {
1108 	unur_reset_errno();
1109 	do {
1110 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[6]);
1111 { UNUR_DISTR *dg =NULL;
1112 par = unur_dsrou_new(distr_localcopy);
1113 	gen = unur_init(par);
1114 	if (gen) {
1115 dg = unur_get_distr(gen);
1116 unur_distr_discr_set_domain(dg,2,7);
1117 unur_distr_discr_upd_pmfsum(dg);
1118 unur_distr_discr_upd_mode(dg);
1119 unur_reinit(gen); }
1120 	}
1121 	rcode = run_validate_chi2(TESTLOG,0,gen,distr[6],'+');
1122 	n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
1123 	n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
1124 	unur_free(gen);
1125 	unur_distr_free(distr_localcopy);
1126 	} while (0);
1127 	}
1128 
1129 	if(TRUE) {
1130 	printf("."); fflush(stdout);
1131 	}
1132 
1133 /* distribution [7] */
1134 
1135 	if(TRUE) {
1136 	unur_reset_errno();
1137 	do {
1138 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[7]);
1139 par = unur_dsrou_new(distr_localcopy);
1140 	gen = unur_init(par);
1141 	rcode = run_validate_chi2(TESTLOG,0,gen,distr[7],'+');
1142 	n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
1143 	n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
1144 	unur_free(gen);
1145 	unur_distr_free(distr_localcopy);
1146 	} while (0);
1147 	}
1148 
1149 	if(TRUE) {
1150 	unur_reset_errno();
1151 	do {
1152 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[7]);
1153 { double Fmode = unur_distr_discr_eval_cdf( unur_distr_discr_get_mode(distr_localcopy), distr_localcopy );
1154 par = unur_dsrou_new(distr_localcopy);
1155 unur_dsrou_set_cdfatmode(par,Fmode); }
1156 	gen = unur_init(par);
1157 	rcode = run_validate_chi2(TESTLOG,0,gen,distr[7],'+');
1158 	n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
1159 	n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
1160 	unur_free(gen);
1161 	unur_distr_free(distr_localcopy);
1162 	} while (0);
1163 	}
1164 
1165 	if(TRUE) {
1166 	unur_reset_errno();
1167 	do {
1168 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[7]);
1169 { UNUR_DISTR *dg =NULL;
1170 par = unur_dsrou_new(distr_localcopy);
1171 	gen = unur_init(par);
1172 	if (gen) {
1173 dg = unur_get_distr(gen);
1174 unur_distr_discr_set_domain(dg,2,7);
1175 unur_distr_discr_upd_pmfsum(dg);
1176 unur_distr_discr_upd_mode(dg);
1177 unur_reinit(gen); }
1178 	}
1179 	rcode = run_validate_chi2(TESTLOG,0,gen,distr[7],'+');
1180 	n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
1181 	n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
1182 	unur_free(gen);
1183 	unur_distr_free(distr_localcopy);
1184 	} while (0);
1185 	}
1186 
1187 	if(TRUE) {
1188 	printf("."); fflush(stdout);
1189 	}
1190 
1191 /* distribution [8] */
1192 
1193 	if(TRUE) {
1194 	unur_reset_errno();
1195 	do {
1196 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[8]);
1197 par = unur_dsrou_new(distr_localcopy);
1198 	gen = unur_init(par);
1199 	rcode = run_validate_chi2(TESTLOG,0,gen,distr[8],'+');
1200 	n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
1201 	n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
1202 	unur_free(gen);
1203 	unur_distr_free(distr_localcopy);
1204 	} while (0);
1205 	}
1206 
1207 	if(TRUE) {
1208 	unur_reset_errno();
1209 	do {
1210 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[8]);
1211 { double Fmode = unur_distr_discr_eval_cdf( unur_distr_discr_get_mode(distr_localcopy), distr_localcopy );
1212 par = unur_dsrou_new(distr_localcopy);
1213 unur_dsrou_set_cdfatmode(par,Fmode); }
1214 	gen = unur_init(par);
1215 	rcode = run_validate_chi2(TESTLOG,0,gen,distr[8],'+');
1216 	n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
1217 	n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
1218 	unur_free(gen);
1219 	unur_distr_free(distr_localcopy);
1220 	} while (0);
1221 	}
1222 
1223 	if(TRUE) {
1224 	unur_reset_errno();
1225 	do {
1226 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[8]);
1227 { UNUR_DISTR *dg =NULL;
1228 par = unur_dsrou_new(distr_localcopy);
1229 	gen = unur_init(par);
1230 	if (gen) {
1231 dg = unur_get_distr(gen);
1232 unur_distr_discr_set_domain(dg,2,7);
1233 unur_distr_discr_upd_pmfsum(dg);
1234 unur_distr_discr_upd_mode(dg);
1235 unur_reinit(gen); }
1236 	}
1237 	rcode = run_validate_chi2(TESTLOG,0,gen,distr[8],'+');
1238 	n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
1239 	n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
1240 	unur_free(gen);
1241 	unur_distr_free(distr_localcopy);
1242 	} while (0);
1243 	}
1244 
1245 	if(TRUE) {
1246 	printf("."); fflush(stdout);
1247 	}
1248 
1249 /* distribution [9] */
1250 
1251 	if(TRUE) {
1252 	unur_reset_errno();
1253 	do {
1254 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[9]);
1255 par = unur_dsrou_new(distr_localcopy);
1256 	gen = unur_init(par);
1257 	rcode = run_validate_chi2(TESTLOG,0,gen,distr[9],'+');
1258 	n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
1259 	n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
1260 	unur_free(gen);
1261 	unur_distr_free(distr_localcopy);
1262 	} while (0);
1263 	}
1264 
1265 	if(TRUE) {
1266 	unur_reset_errno();
1267 	do {
1268 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[9]);
1269 { double Fmode = unur_distr_discr_eval_cdf( unur_distr_discr_get_mode(distr_localcopy), distr_localcopy );
1270 par = unur_dsrou_new(distr_localcopy);
1271 unur_dsrou_set_cdfatmode(par,Fmode); }
1272 	gen = unur_init(par);
1273 	rcode = run_validate_chi2(TESTLOG,0,gen,distr[9],'+');
1274 	n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
1275 	n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
1276 	unur_free(gen);
1277 	unur_distr_free(distr_localcopy);
1278 	} while (0);
1279 	}
1280 
1281 	if(TRUE) {
1282 	unur_reset_errno();
1283 	do {
1284 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[9]);
1285 { UNUR_DISTR *dg =NULL;
1286 par = unur_dsrou_new(distr_localcopy);
1287 	gen = unur_init(par);
1288 	if (gen) {
1289 dg = unur_get_distr(gen);
1290 unur_distr_discr_set_domain(dg,2,7);
1291 unur_distr_discr_upd_pmfsum(dg);
1292 unur_distr_discr_upd_mode(dg);
1293 unur_reinit(gen); }
1294 	}
1295 	rcode = run_validate_chi2(TESTLOG,0,gen,distr[9],'+');
1296 	n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
1297 	n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
1298 	unur_free(gen);
1299 	unur_distr_free(distr_localcopy);
1300 	} while (0);
1301 	}
1302 
1303 	if(TRUE) {
1304 	printf("."); fflush(stdout);
1305 	}
1306 
1307 /* distribution [11] */
1308 
1309 	if(TRUE) {
1310 	unur_reset_errno();
1311 	do {
1312 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[11]);
1313 par = unur_dsrou_new(distr_localcopy);
1314 	gen = unur_init(par);
1315 	rcode = run_validate_chi2(TESTLOG,0,gen,distr[11],'+');
1316 	n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
1317 	n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
1318 	unur_free(gen);
1319 	unur_distr_free(distr_localcopy);
1320 	} while (0);
1321 	}
1322 
1323 	if(TRUE) {
1324 	unur_reset_errno();
1325 	do {
1326 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[11]);
1327 { double Fmode = unur_distr_discr_eval_cdf( unur_distr_discr_get_mode(distr_localcopy), distr_localcopy );
1328 par = unur_dsrou_new(distr_localcopy);
1329 unur_dsrou_set_cdfatmode(par,Fmode); }
1330 	gen = unur_init(par);
1331 	rcode = run_validate_chi2(TESTLOG,0,gen,distr[11],'+');
1332 	n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
1333 	n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
1334 	unur_free(gen);
1335 	unur_distr_free(distr_localcopy);
1336 	} while (0);
1337 	}
1338 
1339 	if(TRUE) {
1340 	unur_reset_errno();
1341 	do {
1342 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[11]);
1343 { UNUR_DISTR *dg =NULL;
1344 par = unur_dsrou_new(distr_localcopy);
1345 	gen = unur_init(par);
1346 	if (gen) {
1347 dg = unur_get_distr(gen);
1348 unur_distr_discr_set_domain(dg,2,7);
1349 unur_distr_discr_upd_pmfsum(dg);
1350 unur_distr_discr_upd_mode(dg);
1351 unur_reinit(gen); }
1352 	}
1353 	rcode = run_validate_chi2(TESTLOG,0,gen,distr[11],'+');
1354 	n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
1355 	n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
1356 	unur_free(gen);
1357 	unur_distr_free(distr_localcopy);
1358 	} while (0);
1359 	}
1360 
1361 	if(TRUE) {
1362 	unur_reset_errno();
1363 	do {
1364 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[11]);
1365 { UNUR_DISTR *dg =NULL;
1366 par = unur_dsrou_new(distr_localcopy);
1367 fpm[0] = 10.;
1368 fpm[1] = 0.63;
1369 	gen = unur_init(par);
1370 	if (gen) {
1371 dg = unur_get_distr(gen);
1372 unur_distr_discr_set_pmfparams(dg,fpm,2);
1373 unur_distr_discr_upd_pmfsum(dg);
1374 unur_distr_discr_upd_mode(dg);
1375 unur_reinit(gen); }
1376 	}
1377 	rcode = run_validate_chi2(TESTLOG,0,gen,distr[11],'+');
1378 	n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
1379 	n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
1380 	unur_free(gen);
1381 	unur_distr_free(distr_localcopy);
1382 	} while (0);
1383 	}
1384 
1385 /* distribution [12] */
1386 
1387 	if(TRUE) {
1388 	unur_reset_errno();
1389 	do {
1390 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[12]);
1391 par = unur_dsrou_new(distr_localcopy);
1392 	gen = unur_init(par);
1393 	rcode = run_validate_chi2(TESTLOG,0,gen,distr[12],'+');
1394 	n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
1395 	n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
1396 	unur_free(gen);
1397 	unur_distr_free(distr_localcopy);
1398 	} while (0);
1399 	}
1400 
1401 	if(TRUE) {
1402 	unur_reset_errno();
1403 	do {
1404 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[12]);
1405 { double Fmode = unur_distr_discr_eval_cdf( unur_distr_discr_get_mode(distr_localcopy), distr_localcopy );
1406 par = unur_dsrou_new(distr_localcopy);
1407 unur_dsrou_set_cdfatmode(par,Fmode); }
1408 	gen = unur_init(par);
1409 	rcode = run_validate_chi2(TESTLOG,0,gen,distr[12],'+');
1410 	n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
1411 	n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
1412 	unur_free(gen);
1413 	unur_distr_free(distr_localcopy);
1414 	} while (0);
1415 	}
1416 
1417 	if(TRUE) {
1418 	unur_reset_errno();
1419 	do {
1420 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[12]);
1421 { UNUR_DISTR *dg =NULL;
1422 par = unur_dsrou_new(distr_localcopy);
1423 	gen = unur_init(par);
1424 	if (gen) {
1425 dg = unur_get_distr(gen);
1426 unur_distr_discr_set_domain(dg,2,7);
1427 unur_distr_discr_upd_pmfsum(dg);
1428 unur_distr_discr_upd_mode(dg);
1429 unur_reinit(gen); }
1430 	}
1431 	rcode = run_validate_chi2(TESTLOG,0,gen,distr[12],'+');
1432 	n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
1433 	n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
1434 	unur_free(gen);
1435 	unur_distr_free(distr_localcopy);
1436 	} while (0);
1437 	}
1438 
1439 	if(TRUE) {
1440 	unur_reset_errno();
1441 	do {
1442 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[12]);
1443 { UNUR_DISTR *dg =NULL;
1444 par = unur_dsrou_new(distr_localcopy);
1445 fpm[0] = 10.;
1446 fpm[1] = 0.63;
1447 	gen = unur_init(par);
1448 	if (gen) {
1449 dg = unur_get_distr(gen);
1450 unur_distr_discr_set_pmfparams(dg,fpm,2);
1451 unur_distr_discr_upd_pmfsum(dg);
1452 unur_distr_discr_upd_mode(dg);
1453 unur_reinit(gen); }
1454 	}
1455 	rcode = run_validate_chi2(TESTLOG,0,gen,distr[12],'+');
1456 	n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
1457 	n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
1458 	unur_free(gen);
1459 	unur_distr_free(distr_localcopy);
1460 	} while (0);
1461 	}
1462 
1463 /* distribution [13] */
1464 
1465 	if(TRUE) {
1466 	unur_reset_errno();
1467 	do {
1468 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[13]);
1469 par = unur_dsrou_new(distr_localcopy);
1470 	gen = unur_init(par);
1471 	rcode = run_validate_chi2(TESTLOG,0,gen,distr[13],'+');
1472 	n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
1473 	n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
1474 	unur_free(gen);
1475 	unur_distr_free(distr_localcopy);
1476 	} while (0);
1477 	}
1478 
1479 	if(TRUE) {
1480 	unur_reset_errno();
1481 	do {
1482 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[13]);
1483 { double Fmode = unur_distr_discr_eval_cdf( unur_distr_discr_get_mode(distr_localcopy), distr_localcopy );
1484 par = unur_dsrou_new(distr_localcopy);
1485 unur_dsrou_set_cdfatmode(par,Fmode); }
1486 	gen = unur_init(par);
1487 	rcode = run_validate_chi2(TESTLOG,0,gen,distr[13],'+');
1488 	n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
1489 	n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
1490 	unur_free(gen);
1491 	unur_distr_free(distr_localcopy);
1492 	} while (0);
1493 	}
1494 
1495 	if(TRUE) {
1496 	unur_reset_errno();
1497 	do {
1498 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[13]);
1499 { UNUR_DISTR *dg =NULL;
1500 par = unur_dsrou_new(distr_localcopy);
1501 	gen = unur_init(par);
1502 	if (gen) {
1503 dg = unur_get_distr(gen);
1504 unur_distr_discr_set_domain(dg,2,7);
1505 unur_distr_discr_upd_pmfsum(dg);
1506 unur_distr_discr_upd_mode(dg);
1507 unur_reinit(gen); }
1508 	}
1509 	rcode = run_validate_chi2(TESTLOG,0,gen,distr[13],'+');
1510 	n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
1511 	n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
1512 	unur_free(gen);
1513 	unur_distr_free(distr_localcopy);
1514 	} while (0);
1515 	}
1516 
1517 	if(TRUE) {
1518 	printf("."); fflush(stdout);
1519 	}
1520 
1521 /* distribution [14] */
1522 
1523 	if(TRUE) {
1524 	unur_reset_errno();
1525 	do {
1526 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[14]);
1527 par = unur_dsrou_new(distr_localcopy);
1528 	gen = unur_init(par);
1529 	rcode = run_validate_chi2(TESTLOG,0,gen,distr[14],'+');
1530 	n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
1531 	n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
1532 	unur_free(gen);
1533 	unur_distr_free(distr_localcopy);
1534 	} while (0);
1535 	}
1536 
1537 	if(TRUE) {
1538 	unur_reset_errno();
1539 	do {
1540 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[14]);
1541 { double Fmode = unur_distr_discr_eval_cdf( unur_distr_discr_get_mode(distr_localcopy), distr_localcopy );
1542 par = unur_dsrou_new(distr_localcopy);
1543 unur_dsrou_set_cdfatmode(par,Fmode); }
1544 	gen = unur_init(par);
1545 	rcode = run_validate_chi2(TESTLOG,0,gen,distr[14],'+');
1546 	n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
1547 	n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
1548 	unur_free(gen);
1549 	unur_distr_free(distr_localcopy);
1550 	} while (0);
1551 	}
1552 
1553 	if(TRUE) {
1554 	unur_reset_errno();
1555 	do {
1556 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[14]);
1557 { UNUR_DISTR *dg =NULL;
1558 par = unur_dsrou_new(distr_localcopy);
1559 	gen = unur_init(par);
1560 	if (gen) {
1561 dg = unur_get_distr(gen);
1562 unur_distr_discr_set_domain(dg,2,7);
1563 unur_distr_discr_upd_pmfsum(dg);
1564 unur_distr_discr_upd_mode(dg);
1565 unur_reinit(gen); }
1566 	}
1567 	rcode = run_validate_chi2(TESTLOG,0,gen,distr[14],'+');
1568 	n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
1569 	n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
1570 	unur_free(gen);
1571 	unur_distr_free(distr_localcopy);
1572 	} while (0);
1573 	}
1574 
1575 	if(TRUE) {
1576 	printf("."); fflush(stdout);
1577 	}
1578 
1579 /* distribution [15] */
1580 
1581 	if(TRUE) {
1582 	unur_reset_errno();
1583 	do {
1584 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[15]);
1585 par = unur_dsrou_new(distr_localcopy);
1586 	gen = unur_init(par);
1587 	rcode = run_validate_chi2(TESTLOG,0,gen,distr[15],'+');
1588 	n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
1589 	n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
1590 	unur_free(gen);
1591 	unur_distr_free(distr_localcopy);
1592 	} while (0);
1593 	}
1594 
1595 	if(TRUE) {
1596 	printf("."); fflush(stdout);
1597 	}
1598 
1599 	if(TRUE) {
1600 	printf("."); fflush(stdout);
1601 	}
1602 
1603 	if(TRUE) {
1604 	printf("."); fflush(stdout);
1605 	}
1606 
1607 	/* timing */
1608 	stopwatch_print(TESTLOG,"\n<*>time = %.0f ms\n", stopwatch_lap(&watch));
1609 
1610 	printf("\n(verify hat) "); fflush(stdout);
1611 
1612 /* verify hat tests: 64 */
1613 
1614 	unur_set_default_debug(~UNUR_DEBUG_SAMPLE);
1615 	fprintf( TESTLOG,"\nVerify Hat Test (squeeze <= PDF <= hat):\n");
1616 
1617 /* distribution [0] */
1618 
1619 	if(TRUE) {
1620 	unur_reset_errno();
1621 	do {
1622 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[0]);
1623 par = unur_dsrou_new(distr_localcopy);
1624 	unur_dsrou_set_pedantic(par,0);
1625 	gen = unur_init(par);
1626 	if (gen) unur_dsrou_chg_verify(gen,1);
1627 	n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[0],'~')==UNUR_SUCCESS)?0:1000;
1628 	unur_free(gen);
1629 
1630 	unur_distr_free(distr_localcopy);
1631 	} while (0);
1632 	}
1633 
1634 	if(TRUE) {
1635 	unur_reset_errno();
1636 	do {
1637 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[0]);
1638 { double Fmode = unur_distr_discr_eval_cdf( unur_distr_discr_get_mode(distr_localcopy), distr_localcopy );
1639 par = unur_dsrou_new(distr_localcopy);
1640 	unur_dsrou_set_pedantic(par,0);
1641 unur_dsrou_set_cdfatmode(par,Fmode); }
1642 	gen = unur_init(par);
1643 	if (gen) unur_dsrou_chg_verify(gen,1);
1644 	n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[0],'~')==UNUR_SUCCESS)?0:1000;
1645 	unur_free(gen);
1646 
1647 	unur_distr_free(distr_localcopy);
1648 	} while (0);
1649 	}
1650 
1651 	if(TRUE) {
1652 	unur_reset_errno();
1653 	do {
1654 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[0]);
1655 { UNUR_DISTR *dg =NULL;
1656 par = unur_dsrou_new(distr_localcopy);
1657 	unur_dsrou_set_pedantic(par,0);
1658 	gen = unur_init(par);
1659 	if (gen) {
1660 dg = unur_get_distr(gen);
1661 unur_distr_discr_set_domain(dg,2,7);
1662 unur_distr_discr_upd_pmfsum(dg);
1663 unur_distr_discr_upd_mode(dg);
1664 unur_reinit(gen); }
1665 	}
1666 	if (gen) unur_dsrou_chg_verify(gen,1);
1667 	n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[0],'~')==UNUR_SUCCESS)?0:1000;
1668 	unur_free(gen);
1669 
1670 	unur_distr_free(distr_localcopy);
1671 	} while (0);
1672 	}
1673 
1674 	if(TRUE) {
1675 	printf("."); fflush(stdout);
1676 	}
1677 
1678 /* distribution [1] */
1679 
1680 	if(TRUE) {
1681 	unur_reset_errno();
1682 	do {
1683 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[1]);
1684 par = unur_dsrou_new(distr_localcopy);
1685 	unur_dsrou_set_pedantic(par,0);
1686 	gen = unur_init(par);
1687 	if (gen) unur_dsrou_chg_verify(gen,1);
1688 	n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[1],'~')==UNUR_SUCCESS)?0:1000;
1689 	unur_free(gen);
1690 
1691 	unur_distr_free(distr_localcopy);
1692 	} while (0);
1693 	}
1694 
1695 	if(TRUE) {
1696 	unur_reset_errno();
1697 	do {
1698 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[1]);
1699 { double Fmode = unur_distr_discr_eval_cdf( unur_distr_discr_get_mode(distr_localcopy), distr_localcopy );
1700 par = unur_dsrou_new(distr_localcopy);
1701 	unur_dsrou_set_pedantic(par,0);
1702 unur_dsrou_set_cdfatmode(par,Fmode); }
1703 	gen = unur_init(par);
1704 	if (gen) unur_dsrou_chg_verify(gen,1);
1705 	n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[1],'~')==UNUR_SUCCESS)?0:1000;
1706 	unur_free(gen);
1707 
1708 	unur_distr_free(distr_localcopy);
1709 	} while (0);
1710 	}
1711 
1712 	if(TRUE) {
1713 	unur_reset_errno();
1714 	do {
1715 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[1]);
1716 { UNUR_DISTR *dg =NULL;
1717 par = unur_dsrou_new(distr_localcopy);
1718 	unur_dsrou_set_pedantic(par,0);
1719 	gen = unur_init(par);
1720 	if (gen) {
1721 dg = unur_get_distr(gen);
1722 unur_distr_discr_set_domain(dg,2,7);
1723 unur_distr_discr_upd_pmfsum(dg);
1724 unur_distr_discr_upd_mode(dg);
1725 unur_reinit(gen); }
1726 	}
1727 	if (gen) unur_dsrou_chg_verify(gen,1);
1728 	n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[1],'~')==UNUR_SUCCESS)?0:1000;
1729 	unur_free(gen);
1730 
1731 	unur_distr_free(distr_localcopy);
1732 	} while (0);
1733 	}
1734 
1735 	if(TRUE) {
1736 	printf("."); fflush(stdout);
1737 	}
1738 
1739 /* distribution [2] */
1740 
1741 	if(TRUE) {
1742 	unur_reset_errno();
1743 	do {
1744 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[2]);
1745 par = unur_dsrou_new(distr_localcopy);
1746 	unur_dsrou_set_pedantic(par,0);
1747 	gen = unur_init(par);
1748 	if (gen) unur_dsrou_chg_verify(gen,1);
1749 	n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[2],'~')==UNUR_SUCCESS)?0:1000;
1750 	unur_free(gen);
1751 
1752 	unur_distr_free(distr_localcopy);
1753 	} while (0);
1754 	}
1755 
1756 	if(TRUE) {
1757 	unur_reset_errno();
1758 	do {
1759 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[2]);
1760 { double Fmode = unur_distr_discr_eval_cdf( unur_distr_discr_get_mode(distr_localcopy), distr_localcopy );
1761 par = unur_dsrou_new(distr_localcopy);
1762 	unur_dsrou_set_pedantic(par,0);
1763 unur_dsrou_set_cdfatmode(par,Fmode); }
1764 	gen = unur_init(par);
1765 	if (gen) unur_dsrou_chg_verify(gen,1);
1766 	n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[2],'~')==UNUR_SUCCESS)?0:1000;
1767 	unur_free(gen);
1768 
1769 	unur_distr_free(distr_localcopy);
1770 	} while (0);
1771 	}
1772 
1773 	if(TRUE) {
1774 	unur_reset_errno();
1775 	do {
1776 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[2]);
1777 { UNUR_DISTR *dg =NULL;
1778 par = unur_dsrou_new(distr_localcopy);
1779 	unur_dsrou_set_pedantic(par,0);
1780 	gen = unur_init(par);
1781 	if (gen) {
1782 dg = unur_get_distr(gen);
1783 unur_distr_discr_set_domain(dg,2,7);
1784 unur_distr_discr_upd_pmfsum(dg);
1785 unur_distr_discr_upd_mode(dg);
1786 unur_reinit(gen); }
1787 	}
1788 	if (gen) unur_dsrou_chg_verify(gen,1);
1789 	n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[2],'~')==UNUR_SUCCESS)?0:1000;
1790 	unur_free(gen);
1791 
1792 	unur_distr_free(distr_localcopy);
1793 	} while (0);
1794 	}
1795 
1796 	if(TRUE) {
1797 	printf("."); fflush(stdout);
1798 	}
1799 
1800 /* distribution [3] */
1801 
1802 	if(TRUE) {
1803 	unur_reset_errno();
1804 	do {
1805 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[3]);
1806 par = unur_dsrou_new(distr_localcopy);
1807 	unur_dsrou_set_pedantic(par,0);
1808 	gen = unur_init(par);
1809 	if (gen) unur_dsrou_chg_verify(gen,1);
1810 	n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[3],'~')==UNUR_SUCCESS)?0:1000;
1811 	unur_free(gen);
1812 
1813 	unur_distr_free(distr_localcopy);
1814 	} while (0);
1815 	}
1816 
1817 	if(TRUE) {
1818 	unur_reset_errno();
1819 	do {
1820 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[3]);
1821 { double Fmode = unur_distr_discr_eval_cdf( unur_distr_discr_get_mode(distr_localcopy), distr_localcopy );
1822 par = unur_dsrou_new(distr_localcopy);
1823 	unur_dsrou_set_pedantic(par,0);
1824 unur_dsrou_set_cdfatmode(par,Fmode); }
1825 	gen = unur_init(par);
1826 	if (gen) unur_dsrou_chg_verify(gen,1);
1827 	n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[3],'~')==UNUR_SUCCESS)?0:1000;
1828 	unur_free(gen);
1829 
1830 	unur_distr_free(distr_localcopy);
1831 	} while (0);
1832 	}
1833 
1834 	if(TRUE) {
1835 	unur_reset_errno();
1836 	do {
1837 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[3]);
1838 { UNUR_DISTR *dg =NULL;
1839 par = unur_dsrou_new(distr_localcopy);
1840 	unur_dsrou_set_pedantic(par,0);
1841 	gen = unur_init(par);
1842 	if (gen) {
1843 dg = unur_get_distr(gen);
1844 unur_distr_discr_set_domain(dg,2,7);
1845 unur_distr_discr_upd_pmfsum(dg);
1846 unur_distr_discr_upd_mode(dg);
1847 unur_reinit(gen); }
1848 	}
1849 	if (gen) unur_dsrou_chg_verify(gen,1);
1850 	n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[3],'~')==UNUR_SUCCESS)?0:1000;
1851 	unur_free(gen);
1852 
1853 	unur_distr_free(distr_localcopy);
1854 	} while (0);
1855 	}
1856 
1857 	if(TRUE) {
1858 	printf("."); fflush(stdout);
1859 	}
1860 
1861 /* distribution [4] */
1862 
1863 	if(TRUE) {
1864 	unur_reset_errno();
1865 	do {
1866 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[4]);
1867 par = unur_dsrou_new(distr_localcopy);
1868 	unur_dsrou_set_pedantic(par,0);
1869 	gen = unur_init(par);
1870 	if (gen) unur_dsrou_chg_verify(gen,1);
1871 	n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[4],'~')==UNUR_SUCCESS)?0:1000;
1872 	unur_free(gen);
1873 
1874 	unur_distr_free(distr_localcopy);
1875 	} while (0);
1876 	}
1877 
1878 	if(TRUE) {
1879 	unur_reset_errno();
1880 	do {
1881 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[4]);
1882 { double Fmode = unur_distr_discr_eval_cdf( unur_distr_discr_get_mode(distr_localcopy), distr_localcopy );
1883 par = unur_dsrou_new(distr_localcopy);
1884 	unur_dsrou_set_pedantic(par,0);
1885 unur_dsrou_set_cdfatmode(par,Fmode); }
1886 	gen = unur_init(par);
1887 	if (gen) unur_dsrou_chg_verify(gen,1);
1888 	n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[4],'~')==UNUR_SUCCESS)?0:1000;
1889 	unur_free(gen);
1890 
1891 	unur_distr_free(distr_localcopy);
1892 	} while (0);
1893 	}
1894 
1895 	if(TRUE) {
1896 	unur_reset_errno();
1897 	do {
1898 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[4]);
1899 { UNUR_DISTR *dg =NULL;
1900 par = unur_dsrou_new(distr_localcopy);
1901 	unur_dsrou_set_pedantic(par,0);
1902 	gen = unur_init(par);
1903 	if (gen) {
1904 dg = unur_get_distr(gen);
1905 unur_distr_discr_set_domain(dg,2,7);
1906 unur_distr_discr_upd_pmfsum(dg);
1907 unur_distr_discr_upd_mode(dg);
1908 unur_reinit(gen); }
1909 	}
1910 	if (gen) unur_dsrou_chg_verify(gen,1);
1911 	n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[4],'~')==UNUR_SUCCESS)?0:1000;
1912 	unur_free(gen);
1913 
1914 	unur_distr_free(distr_localcopy);
1915 	} while (0);
1916 	}
1917 
1918 	if(TRUE) {
1919 	printf("."); fflush(stdout);
1920 	}
1921 
1922 /* distribution [5] */
1923 
1924 	if(TRUE) {
1925 	unur_reset_errno();
1926 	do {
1927 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[5]);
1928 par = unur_dsrou_new(distr_localcopy);
1929 	unur_dsrou_set_pedantic(par,0);
1930 	gen = unur_init(par);
1931 	if (gen) unur_dsrou_chg_verify(gen,1);
1932 	n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[5],'~')==UNUR_SUCCESS)?0:1000;
1933 	unur_free(gen);
1934 
1935 	unur_distr_free(distr_localcopy);
1936 	} while (0);
1937 	}
1938 
1939 	if(TRUE) {
1940 	unur_reset_errno();
1941 	do {
1942 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[5]);
1943 { double Fmode = unur_distr_discr_eval_cdf( unur_distr_discr_get_mode(distr_localcopy), distr_localcopy );
1944 par = unur_dsrou_new(distr_localcopy);
1945 	unur_dsrou_set_pedantic(par,0);
1946 unur_dsrou_set_cdfatmode(par,Fmode); }
1947 	gen = unur_init(par);
1948 	if (gen) unur_dsrou_chg_verify(gen,1);
1949 	n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[5],'~')==UNUR_SUCCESS)?0:1000;
1950 	unur_free(gen);
1951 
1952 	unur_distr_free(distr_localcopy);
1953 	} while (0);
1954 	}
1955 
1956 	if(TRUE) {
1957 	unur_reset_errno();
1958 	do {
1959 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[5]);
1960 { UNUR_DISTR *dg =NULL;
1961 par = unur_dsrou_new(distr_localcopy);
1962 	unur_dsrou_set_pedantic(par,0);
1963 	gen = unur_init(par);
1964 	if (gen) {
1965 dg = unur_get_distr(gen);
1966 unur_distr_discr_set_domain(dg,2,7);
1967 unur_distr_discr_upd_pmfsum(dg);
1968 unur_distr_discr_upd_mode(dg);
1969 unur_reinit(gen); }
1970 	}
1971 	if (gen) unur_dsrou_chg_verify(gen,1);
1972 	n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[5],'~')==UNUR_SUCCESS)?0:1000;
1973 	unur_free(gen);
1974 
1975 	unur_distr_free(distr_localcopy);
1976 	} while (0);
1977 	}
1978 
1979 	if(TRUE) {
1980 	printf("."); fflush(stdout);
1981 	}
1982 
1983 /* distribution [6] */
1984 
1985 	if(TRUE) {
1986 	unur_reset_errno();
1987 	do {
1988 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[6]);
1989 par = unur_dsrou_new(distr_localcopy);
1990 	unur_dsrou_set_pedantic(par,0);
1991 	gen = unur_init(par);
1992 	if (gen) unur_dsrou_chg_verify(gen,1);
1993 	n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[6],'~')==UNUR_SUCCESS)?0:1000;
1994 	unur_free(gen);
1995 
1996 	unur_distr_free(distr_localcopy);
1997 	} while (0);
1998 	}
1999 
2000 	if(TRUE) {
2001 	unur_reset_errno();
2002 	do {
2003 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[6]);
2004 { double Fmode = unur_distr_discr_eval_cdf( unur_distr_discr_get_mode(distr_localcopy), distr_localcopy );
2005 par = unur_dsrou_new(distr_localcopy);
2006 	unur_dsrou_set_pedantic(par,0);
2007 unur_dsrou_set_cdfatmode(par,Fmode); }
2008 	gen = unur_init(par);
2009 	if (gen) unur_dsrou_chg_verify(gen,1);
2010 	n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[6],'~')==UNUR_SUCCESS)?0:1000;
2011 	unur_free(gen);
2012 
2013 	unur_distr_free(distr_localcopy);
2014 	} while (0);
2015 	}
2016 
2017 	if(TRUE) {
2018 	unur_reset_errno();
2019 	do {
2020 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[6]);
2021 { UNUR_DISTR *dg =NULL;
2022 par = unur_dsrou_new(distr_localcopy);
2023 	unur_dsrou_set_pedantic(par,0);
2024 	gen = unur_init(par);
2025 	if (gen) {
2026 dg = unur_get_distr(gen);
2027 unur_distr_discr_set_domain(dg,2,7);
2028 unur_distr_discr_upd_pmfsum(dg);
2029 unur_distr_discr_upd_mode(dg);
2030 unur_reinit(gen); }
2031 	}
2032 	if (gen) unur_dsrou_chg_verify(gen,1);
2033 	n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[6],'~')==UNUR_SUCCESS)?0:1000;
2034 	unur_free(gen);
2035 
2036 	unur_distr_free(distr_localcopy);
2037 	} while (0);
2038 	}
2039 
2040 	if(TRUE) {
2041 	printf("."); fflush(stdout);
2042 	}
2043 
2044 /* distribution [7] */
2045 
2046 	if(TRUE) {
2047 	unur_reset_errno();
2048 	do {
2049 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[7]);
2050 par = unur_dsrou_new(distr_localcopy);
2051 	unur_dsrou_set_pedantic(par,0);
2052 	gen = unur_init(par);
2053 	if (gen) unur_dsrou_chg_verify(gen,1);
2054 	n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[7],'~')==UNUR_SUCCESS)?0:1000;
2055 	unur_free(gen);
2056 
2057 	unur_distr_free(distr_localcopy);
2058 	} while (0);
2059 	}
2060 
2061 	if(TRUE) {
2062 	unur_reset_errno();
2063 	do {
2064 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[7]);
2065 { double Fmode = unur_distr_discr_eval_cdf( unur_distr_discr_get_mode(distr_localcopy), distr_localcopy );
2066 par = unur_dsrou_new(distr_localcopy);
2067 	unur_dsrou_set_pedantic(par,0);
2068 unur_dsrou_set_cdfatmode(par,Fmode); }
2069 	gen = unur_init(par);
2070 	if (gen) unur_dsrou_chg_verify(gen,1);
2071 	n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[7],'~')==UNUR_SUCCESS)?0:1000;
2072 	unur_free(gen);
2073 
2074 	unur_distr_free(distr_localcopy);
2075 	} while (0);
2076 	}
2077 
2078 	if(TRUE) {
2079 	printf("."); fflush(stdout);
2080 	}
2081 
2082 	if(TRUE) {
2083 	printf("."); fflush(stdout);
2084 	}
2085 
2086 /* distribution [8] */
2087 
2088 	if(TRUE) {
2089 	unur_reset_errno();
2090 	do {
2091 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[8]);
2092 par = unur_dsrou_new(distr_localcopy);
2093 	unur_dsrou_set_pedantic(par,0);
2094 	gen = unur_init(par);
2095 	if (gen) unur_dsrou_chg_verify(gen,1);
2096 	n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[8],'~')==UNUR_SUCCESS)?0:1000;
2097 	unur_free(gen);
2098 
2099 	unur_distr_free(distr_localcopy);
2100 	} while (0);
2101 	}
2102 
2103 	if(TRUE) {
2104 	unur_reset_errno();
2105 	do {
2106 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[8]);
2107 { double Fmode = unur_distr_discr_eval_cdf( unur_distr_discr_get_mode(distr_localcopy), distr_localcopy );
2108 par = unur_dsrou_new(distr_localcopy);
2109 	unur_dsrou_set_pedantic(par,0);
2110 unur_dsrou_set_cdfatmode(par,Fmode); }
2111 	gen = unur_init(par);
2112 	if (gen) unur_dsrou_chg_verify(gen,1);
2113 	n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[8],'~')==UNUR_SUCCESS)?0:1000;
2114 	unur_free(gen);
2115 
2116 	unur_distr_free(distr_localcopy);
2117 	} while (0);
2118 	}
2119 
2120 	if(TRUE) {
2121 	unur_reset_errno();
2122 	do {
2123 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[8]);
2124 { UNUR_DISTR *dg =NULL;
2125 par = unur_dsrou_new(distr_localcopy);
2126 	unur_dsrou_set_pedantic(par,0);
2127 	gen = unur_init(par);
2128 	if (gen) {
2129 dg = unur_get_distr(gen);
2130 unur_distr_discr_set_domain(dg,2,7);
2131 unur_distr_discr_upd_pmfsum(dg);
2132 unur_distr_discr_upd_mode(dg);
2133 unur_reinit(gen); }
2134 	}
2135 	if (gen) unur_dsrou_chg_verify(gen,1);
2136 	n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[8],'~')==UNUR_SUCCESS)?0:1000;
2137 	unur_free(gen);
2138 
2139 	unur_distr_free(distr_localcopy);
2140 	} while (0);
2141 	}
2142 
2143 	if(TRUE) {
2144 	printf("."); fflush(stdout);
2145 	}
2146 
2147 /* distribution [9] */
2148 
2149 	if(TRUE) {
2150 	unur_reset_errno();
2151 	do {
2152 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[9]);
2153 par = unur_dsrou_new(distr_localcopy);
2154 	unur_dsrou_set_pedantic(par,0);
2155 	gen = unur_init(par);
2156 	if (gen) unur_dsrou_chg_verify(gen,1);
2157 	n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[9],'~')==UNUR_SUCCESS)?0:1000;
2158 	unur_free(gen);
2159 
2160 	unur_distr_free(distr_localcopy);
2161 	} while (0);
2162 	}
2163 
2164 	if(TRUE) {
2165 	unur_reset_errno();
2166 	do {
2167 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[9]);
2168 { double Fmode = unur_distr_discr_eval_cdf( unur_distr_discr_get_mode(distr_localcopy), distr_localcopy );
2169 par = unur_dsrou_new(distr_localcopy);
2170 	unur_dsrou_set_pedantic(par,0);
2171 unur_dsrou_set_cdfatmode(par,Fmode); }
2172 	gen = unur_init(par);
2173 	if (gen) unur_dsrou_chg_verify(gen,1);
2174 	n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[9],'~')==UNUR_SUCCESS)?0:1000;
2175 	unur_free(gen);
2176 
2177 	unur_distr_free(distr_localcopy);
2178 	} while (0);
2179 	}
2180 
2181 	if(TRUE) {
2182 	unur_reset_errno();
2183 	do {
2184 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[9]);
2185 { UNUR_DISTR *dg =NULL;
2186 par = unur_dsrou_new(distr_localcopy);
2187 	unur_dsrou_set_pedantic(par,0);
2188 	gen = unur_init(par);
2189 	if (gen) {
2190 dg = unur_get_distr(gen);
2191 unur_distr_discr_set_domain(dg,2,7);
2192 unur_distr_discr_upd_pmfsum(dg);
2193 unur_distr_discr_upd_mode(dg);
2194 unur_reinit(gen); }
2195 	}
2196 	if (gen) unur_dsrou_chg_verify(gen,1);
2197 	n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[9],'~')==UNUR_SUCCESS)?0:1000;
2198 	unur_free(gen);
2199 
2200 	unur_distr_free(distr_localcopy);
2201 	} while (0);
2202 	}
2203 
2204 	if(TRUE) {
2205 	printf("."); fflush(stdout);
2206 	}
2207 
2208 /* distribution [11] */
2209 
2210 	if(TRUE) {
2211 	unur_reset_errno();
2212 	do {
2213 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[11]);
2214 par = unur_dsrou_new(distr_localcopy);
2215 	unur_dsrou_set_pedantic(par,0);
2216 	gen = unur_init(par);
2217 	if (gen) unur_dsrou_chg_verify(gen,1);
2218 	n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[11],'~')==UNUR_SUCCESS)?0:1000;
2219 	unur_free(gen);
2220 
2221 	unur_distr_free(distr_localcopy);
2222 	} while (0);
2223 	}
2224 
2225 	if(TRUE) {
2226 	unur_reset_errno();
2227 	do {
2228 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[11]);
2229 { double Fmode = unur_distr_discr_eval_cdf( unur_distr_discr_get_mode(distr_localcopy), distr_localcopy );
2230 par = unur_dsrou_new(distr_localcopy);
2231 	unur_dsrou_set_pedantic(par,0);
2232 unur_dsrou_set_cdfatmode(par,Fmode); }
2233 	gen = unur_init(par);
2234 	if (gen) unur_dsrou_chg_verify(gen,1);
2235 	n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[11],'~')==UNUR_SUCCESS)?0:1000;
2236 	unur_free(gen);
2237 
2238 	unur_distr_free(distr_localcopy);
2239 	} while (0);
2240 	}
2241 
2242 	if(TRUE) {
2243 	unur_reset_errno();
2244 	do {
2245 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[11]);
2246 { UNUR_DISTR *dg =NULL;
2247 par = unur_dsrou_new(distr_localcopy);
2248 	unur_dsrou_set_pedantic(par,0);
2249 	gen = unur_init(par);
2250 	if (gen) {
2251 dg = unur_get_distr(gen);
2252 unur_distr_discr_set_domain(dg,2,7);
2253 unur_distr_discr_upd_pmfsum(dg);
2254 unur_distr_discr_upd_mode(dg);
2255 unur_reinit(gen); }
2256 	}
2257 	if (gen) unur_dsrou_chg_verify(gen,1);
2258 	n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[11],'~')==UNUR_SUCCESS)?0:1000;
2259 	unur_free(gen);
2260 
2261 	unur_distr_free(distr_localcopy);
2262 	} while (0);
2263 	}
2264 
2265 	if(TRUE) {
2266 	unur_reset_errno();
2267 	do {
2268 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[11]);
2269 { UNUR_DISTR *dg =NULL;
2270 par = unur_dsrou_new(distr_localcopy);
2271 	unur_dsrou_set_pedantic(par,0);
2272 fpm[0] = 10.;
2273 fpm[1] = 0.63;
2274 	gen = unur_init(par);
2275 	if (gen) {
2276 dg = unur_get_distr(gen);
2277 unur_distr_discr_set_pmfparams(dg,fpm,2);
2278 unur_distr_discr_upd_pmfsum(dg);
2279 unur_distr_discr_upd_mode(dg);
2280 unur_reinit(gen); }
2281 	}
2282 	if (gen) unur_dsrou_chg_verify(gen,1);
2283 	n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[11],'~')==UNUR_SUCCESS)?0:1000;
2284 	unur_free(gen);
2285 
2286 	unur_distr_free(distr_localcopy);
2287 	} while (0);
2288 	}
2289 
2290 /* distribution [12] */
2291 
2292 	if(TRUE) {
2293 	unur_reset_errno();
2294 	do {
2295 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[12]);
2296 par = unur_dsrou_new(distr_localcopy);
2297 	unur_dsrou_set_pedantic(par,0);
2298 	gen = unur_init(par);
2299 	if (gen) unur_dsrou_chg_verify(gen,1);
2300 	n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[12],'~')==UNUR_SUCCESS)?0:1000;
2301 	unur_free(gen);
2302 
2303 	unur_distr_free(distr_localcopy);
2304 	} while (0);
2305 	}
2306 
2307 	if(TRUE) {
2308 	unur_reset_errno();
2309 	do {
2310 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[12]);
2311 { double Fmode = unur_distr_discr_eval_cdf( unur_distr_discr_get_mode(distr_localcopy), distr_localcopy );
2312 par = unur_dsrou_new(distr_localcopy);
2313 	unur_dsrou_set_pedantic(par,0);
2314 unur_dsrou_set_cdfatmode(par,Fmode); }
2315 	gen = unur_init(par);
2316 	if (gen) unur_dsrou_chg_verify(gen,1);
2317 	n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[12],'~')==UNUR_SUCCESS)?0:1000;
2318 	unur_free(gen);
2319 
2320 	unur_distr_free(distr_localcopy);
2321 	} while (0);
2322 	}
2323 
2324 	if(TRUE) {
2325 	unur_reset_errno();
2326 	do {
2327 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[12]);
2328 { UNUR_DISTR *dg =NULL;
2329 par = unur_dsrou_new(distr_localcopy);
2330 	unur_dsrou_set_pedantic(par,0);
2331 	gen = unur_init(par);
2332 	if (gen) {
2333 dg = unur_get_distr(gen);
2334 unur_distr_discr_set_domain(dg,2,7);
2335 unur_distr_discr_upd_pmfsum(dg);
2336 unur_distr_discr_upd_mode(dg);
2337 unur_reinit(gen); }
2338 	}
2339 	if (gen) unur_dsrou_chg_verify(gen,1);
2340 	n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[12],'~')==UNUR_SUCCESS)?0:1000;
2341 	unur_free(gen);
2342 
2343 	unur_distr_free(distr_localcopy);
2344 	} while (0);
2345 	}
2346 
2347 	if(TRUE) {
2348 	unur_reset_errno();
2349 	do {
2350 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[12]);
2351 { UNUR_DISTR *dg =NULL;
2352 par = unur_dsrou_new(distr_localcopy);
2353 	unur_dsrou_set_pedantic(par,0);
2354 fpm[0] = 10.;
2355 fpm[1] = 0.63;
2356 	gen = unur_init(par);
2357 	if (gen) {
2358 dg = unur_get_distr(gen);
2359 unur_distr_discr_set_pmfparams(dg,fpm,2);
2360 unur_distr_discr_upd_pmfsum(dg);
2361 unur_distr_discr_upd_mode(dg);
2362 unur_reinit(gen); }
2363 	}
2364 	if (gen) unur_dsrou_chg_verify(gen,1);
2365 	n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[12],'~')==UNUR_SUCCESS)?0:1000;
2366 	unur_free(gen);
2367 
2368 	unur_distr_free(distr_localcopy);
2369 	} while (0);
2370 	}
2371 
2372 /* distribution [13] */
2373 
2374 	if(TRUE) {
2375 	unur_reset_errno();
2376 	do {
2377 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[13]);
2378 par = unur_dsrou_new(distr_localcopy);
2379 	unur_dsrou_set_pedantic(par,0);
2380 	gen = unur_init(par);
2381 	if (gen) unur_dsrou_chg_verify(gen,1);
2382 	n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[13],'~')==UNUR_SUCCESS)?0:1000;
2383 	unur_free(gen);
2384 
2385 	unur_distr_free(distr_localcopy);
2386 	} while (0);
2387 	}
2388 
2389 	if(TRUE) {
2390 	unur_reset_errno();
2391 	do {
2392 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[13]);
2393 { double Fmode = unur_distr_discr_eval_cdf( unur_distr_discr_get_mode(distr_localcopy), distr_localcopy );
2394 par = unur_dsrou_new(distr_localcopy);
2395 	unur_dsrou_set_pedantic(par,0);
2396 unur_dsrou_set_cdfatmode(par,Fmode); }
2397 	gen = unur_init(par);
2398 	if (gen) unur_dsrou_chg_verify(gen,1);
2399 	n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[13],'~')==UNUR_SUCCESS)?0:1000;
2400 	unur_free(gen);
2401 
2402 	unur_distr_free(distr_localcopy);
2403 	} while (0);
2404 	}
2405 
2406 	if(TRUE) {
2407 	unur_reset_errno();
2408 	do {
2409 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[13]);
2410 { UNUR_DISTR *dg =NULL;
2411 par = unur_dsrou_new(distr_localcopy);
2412 	unur_dsrou_set_pedantic(par,0);
2413 	gen = unur_init(par);
2414 	if (gen) {
2415 dg = unur_get_distr(gen);
2416 unur_distr_discr_set_domain(dg,2,7);
2417 unur_distr_discr_upd_pmfsum(dg);
2418 unur_distr_discr_upd_mode(dg);
2419 unur_reinit(gen); }
2420 	}
2421 	if (gen) unur_dsrou_chg_verify(gen,1);
2422 	n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[13],'~')==UNUR_SUCCESS)?0:1000;
2423 	unur_free(gen);
2424 
2425 	unur_distr_free(distr_localcopy);
2426 	} while (0);
2427 	}
2428 
2429 	if(TRUE) {
2430 	printf("."); fflush(stdout);
2431 	}
2432 
2433 /* distribution [14] */
2434 
2435 	if(TRUE) {
2436 	unur_reset_errno();
2437 	do {
2438 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[14]);
2439 par = unur_dsrou_new(distr_localcopy);
2440 	unur_dsrou_set_pedantic(par,0);
2441 	gen = unur_init(par);
2442 	if (gen) unur_dsrou_chg_verify(gen,1);
2443 	n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[14],'~')==UNUR_SUCCESS)?0:1000;
2444 	unur_free(gen);
2445 
2446 	unur_distr_free(distr_localcopy);
2447 	} while (0);
2448 	}
2449 
2450 	if(TRUE) {
2451 	unur_reset_errno();
2452 	do {
2453 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[14]);
2454 { double Fmode = unur_distr_discr_eval_cdf( unur_distr_discr_get_mode(distr_localcopy), distr_localcopy );
2455 par = unur_dsrou_new(distr_localcopy);
2456 	unur_dsrou_set_pedantic(par,0);
2457 unur_dsrou_set_cdfatmode(par,Fmode); }
2458 	gen = unur_init(par);
2459 	if (gen) unur_dsrou_chg_verify(gen,1);
2460 	n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[14],'~')==UNUR_SUCCESS)?0:1000;
2461 	unur_free(gen);
2462 
2463 	unur_distr_free(distr_localcopy);
2464 	} while (0);
2465 	}
2466 
2467 	if(TRUE) {
2468 	unur_reset_errno();
2469 	do {
2470 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[14]);
2471 { UNUR_DISTR *dg =NULL;
2472 par = unur_dsrou_new(distr_localcopy);
2473 	unur_dsrou_set_pedantic(par,0);
2474 	gen = unur_init(par);
2475 	if (gen) {
2476 dg = unur_get_distr(gen);
2477 unur_distr_discr_set_domain(dg,2,7);
2478 unur_distr_discr_upd_pmfsum(dg);
2479 unur_distr_discr_upd_mode(dg);
2480 unur_reinit(gen); }
2481 	}
2482 	if (gen) unur_dsrou_chg_verify(gen,1);
2483 	n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[14],'~')==UNUR_SUCCESS)?0:1000;
2484 	unur_free(gen);
2485 
2486 	unur_distr_free(distr_localcopy);
2487 	} while (0);
2488 	}
2489 
2490 	if(TRUE) {
2491 	printf("."); fflush(stdout);
2492 	}
2493 
2494 /* distribution [15] */
2495 
2496 	if(TRUE) {
2497 	unur_reset_errno();
2498 	do {
2499 	UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[15]);
2500 par = unur_dsrou_new(distr_localcopy);
2501 	unur_dsrou_set_pedantic(par,0);
2502 	gen = unur_init(par);
2503 	if (gen) unur_dsrou_chg_verify(gen,1);
2504 	n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[15],'~')==UNUR_SUCCESS)?0:1000;
2505 	unur_free(gen);
2506 
2507 	unur_distr_free(distr_localcopy);
2508 	} while (0);
2509 	}
2510 
2511 	if(TRUE) {
2512 	printf("."); fflush(stdout);
2513 	}
2514 
2515 	if(TRUE) {
2516 	printf("."); fflush(stdout);
2517 	}
2518 
2519 	if(TRUE) {
2520 	printf("."); fflush(stdout);
2521 	}
2522 
2523 	/* timing */
2524 	stopwatch_print(TESTLOG,"\n<*>time = %.0f ms\n", stopwatch_lap(&watch));
2525 
2526 
2527 /* free distributions */
2528 	unur_distr_free(distr[0]);
2529 	unur_distr_free(distr[1]);
2530 	unur_distr_free(distr[2]);
2531 	unur_distr_free(distr[3]);
2532 	unur_distr_free(distr[4]);
2533 	unur_distr_free(distr[5]);
2534 	unur_distr_free(distr[6]);
2535 	unur_distr_free(distr[7]);
2536 	unur_distr_free(distr[8]);
2537 	unur_distr_free(distr[9]);
2538 	unur_distr_free(distr[10]);
2539 	unur_distr_free(distr[11]);
2540 	unur_distr_free(distr[12]);
2541 	unur_distr_free(distr[13]);
2542 	unur_distr_free(distr[14]);
2543 	unur_distr_free(distr[15]);
2544 
2545 	/* test finished */
2546 	test_ok &= (n_tests_failed>CHI2_FAILURES_TOLERATED) ? 0 : 1;
2547 	/* we accept CHI2_FAILURES_TOLERATED failures */
2548 	(n_tests_failed>CHI2_FAILURES_TOLERATED) ? printf(" ==> failed] ") : printf(" ==> ok] ");
2549 
2550 	/* prevent compiler from making useless annoying warnings */
2551 	distr[0] = NULL;
2552 	par = NULL;
2553 	gen = NULL;
2554 	darray = NULL;
2555 	fpm[0] = 0.;
2556 
2557 } /* end of test_validate */
2558 
2559 
2560 /*---------------------------------------------------------------------------*/
2561 /* run generator in verifying mode */
2562 
run_verify_generator(FILE * LOG,int line,UNUR_PAR * par)2563 void run_verify_generator( FILE *LOG, int line, UNUR_PAR *par )
2564 {
2565 	UNUR_GEN *gen;
2566 	int i;
2567 
2568 	/* switch to verifying mode */
2569 	unur_dsrou_set_verify(par,1);
2570 
2571 	/* initialize generator */
2572 	gen = unur_init( par ); abort_if_NULL(LOG, line, gen);
2573 
2574 	/* run generator */
2575 	for (i=0; i<VIOLATE_SAMPLE_SIZE; i++)
2576 		unur_sample_cont(gen);
2577 
2578 	/* destroy generator */
2579 	unur_free(gen);
2580 
2581 } /* end of run_verify_generator() */
2582 
2583 
2584 /*---------------------------------------------------------------------------*/
2585 
main(void)2586 int main(void)
2587 {
2588         unsigned long seed;
2589 	char *str_seed, *str_tail;
2590 
2591 	/* start stop watch */
2592 	stopwatch_init();
2593 	stopwatch_start(&watch);
2594 
2595         /* open log file for unuran and set output stream for unuran messages */
2596         UNURANLOG = fopen( "t_dsrou_unuran.log","w" );
2597         abort_if_NULL( stderr,-1, UNURANLOG );
2598         unur_set_stream( UNURANLOG );
2599 
2600         /* open log file for testing */
2601 	TESTLOG = fopen( "t_dsrou_test.log","w" );
2602 	abort_if_NULL( stderr,-1, TESTLOG );
2603 
2604         /* seed for uniform generators */
2605 
2606 	/* seed set by environment */
2607 	str_seed = getenv("SEED");
2608 
2609 	if (str_seed != NULL) {
2610 	    seed = strtol(str_seed, &str_tail, 10);
2611 	    if (seed == 0u)
2612 		seed = 542457;
2613 	}
2614 	else {
2615 #ifdef SEED
2616 	    seed = SEED;
2617 #else
2618 	    seed = 542457;
2619 #endif
2620 	}
2621 
2622         /* seed build-in uniform generators */
2623         unur_urng_MRG31k3p_seed(NULL,seed);
2624         unur_urng_fish_seed(NULL,seed);
2625 	unur_urng_mstd_seed(NULL,seed);
2626 
2627 	/* seed uniform random number generator */
2628 #ifdef UNUR_URNG_UNURAN
2629 #  ifdef UNUR_URNG_DEFAULT_RNGSTREAM
2630 	{
2631 	        unsigned long sa[6];
2632 	        int i;
2633 	        for (i=0; i<6; i++) sa[i] = seed;
2634                 RngStream_SetPackageSeed(sa);
2635         }
2636 #  else
2637 	if (unur_urng_seed(NULL,seed) != UNUR_SUCCESS) {
2638 	        fprintf(stderr,"WARNING: Seed could not be set at random\n");
2639                 seed = ~0u;
2640 	}
2641 #  endif  /* UNUR_URNG_DEFAULT_RNGSTREAM */
2642 #endif  /* UNUR_URNG_UNURAN */
2643 
2644 	/* set default debugging flag */
2645 	unur_set_default_debug(UNUR_DEBUG_ALL);
2646 
2647         /* detect required check mode */
2648         fullcheck = (getenv("UNURANFULLCHECK")==NULL) ? FALSE : TRUE;
2649 
2650 	/* write header into log file */
2651         print_test_log_header( TESTLOG, seed, fullcheck );
2652 
2653 	/* set timer for sending SIGALRM signal */
2654 	set_alarm(TESTLOG);
2655 
2656 	/* start test */
2657 	printf("dsrou: ");
2658 
2659 	/* run tests */
2660 test_new();
2661 test_set();
2662 test_chg();
2663 test_init();
2664 test_reinit();
2665 test_sample();
2666 test_validate();
2667 
2668 
2669 	/* test finished */
2670 	printf("\n");  fflush(stdout);
2671 
2672 	/* close log files */
2673 	fprintf(TESTLOG,"\n====================================================\n\n");
2674 	if (test_ok)
2675 		fprintf(TESTLOG,"All tests PASSED.\n");
2676 	else
2677 		fprintf(TESTLOG,"Test(s) FAILED.\n");
2678 
2679 	/* timing */
2680 	stopwatch_print(TESTLOG,"\n<*>total time = %.0f ms\n\n", stopwatch_stop(&watch));
2681 
2682 	fclose(UNURANLOG);
2683 	fclose(TESTLOG);
2684 
2685 	/* free memory */
2686 	compare_free_memory();
2687 	unur_urng_free(unur_get_default_urng());
2688 	unur_urng_free(unur_get_default_urng_aux());
2689 
2690 	/* exit */
2691 	exit( (test_ok) ? EXIT_SUCCESS : EXIT_FAILURE );
2692 
2693 } /* end of main */
2694 
2695