#############################################################################

[main]

[main - data:]

# method (for information only: the program scans the file name)
method: STRINGPARSER

[main - header:]

/* prototypes */
int unur_ssr_set_pedantic( struct unur_par *par, int pedantic );

\#define COMPARE_SAMPLE_SIZE   (10000)
\#define VIOLATE_SAMPLE_SIZE   (20)

#############################################################################

[new]

#############################################################################

# [set]

#############################################################################

# [get]

#############################################################################

# [chg]

#############################################################################

[init]

# unur_str2gen ...

[init - invalid NULL ptr:
   distr = NULL;
   gen = NULL; ]

gen = unur_str2gen( NULL );
	--> expected_NULL --> UNUR_ERR_NULL

distr = unur_str2distr( NULL );
	--> expected_NULL --> UNUR_ERR_NULL

gen = unur_makegen_ssu(NULL,NULL,NULL);
	--> expected_NULL --> UNUR_ERR_NULL


[init - invalid distribution block:
   gen = NULL; ]

gen = unur_str2gen( "xxxx" );
	--> expected_NULL --> UNUR_ERR_STR_UNKNOWN

unur_free(gen); gen = NULL;
gen = unur_str2gen( "method = xxxx" );
	--> expected_NULL --> UNUR_ERR_STR_SYNTAX

unur_free(gen); gen = NULL;
gen = unur_str2gen( "normal; xxxx=1" );
	--> expected_NULL --> UNUR_ERR_STR_UNKNOWN

unur_free(gen); gen = NULL;
gen = unur_str2gen( "normal; pv=(1,2,3)" );
	--> expected_NULL --> UNUR_ERR_STR_UNKNOWN

unur_free(gen); gen = NULL;
gen = unur_str2gen( "normal,(1,2)" );
	--> expected_NULL --> UNUR_ERR_STR_UNKNOWN

unur_free(gen); gen = NULL;
gen = unur_str2gen( "beta" );
	--> expected_NULL --> UNUR_ERR_STR_INVALID

unur_free(gen); gen = NULL;
gen = unur_str2gen( "beta()" );
	--> expected_NULL --> UNUR_ERR_STR_INVALID

unur_free(gen); gen = NULL;
gen = unur_str2gen( "beta(1)" );
	--> expected_NULL --> UNUR_ERR_STR_INVALID

unur_free(gen); gen = NULL;
gen = unur_str2gen( "beta(1,2,3)" );
	--> none --> UNUR_ERR_DISTR_NPARAMS

unur_free(gen); gen = NULL;
gen = unur_str2gen( "beta(1,2,3,4,5)" );
	--> none --> UNUR_ERR_DISTR_NPARAMS

unur_free(gen); gen = NULL;
gen = unur_str2gen( "gamma(-0.5)" );
	--> expected_NULL --> UNUR_ERR_STR_INVALID

unur_free(gen); gen = NULL;
gen = unur_str2gen( "normal(); domain" );
	--> expected_NULL --> UNUR_ERR_STR_INVALID


[init - invalid other block:
   gen = NULL; ]

gen = unur_str2gen( "normal() & xxxx = arou" );
	--> expected_NULL --> UNUR_ERR_STR_UNKNOWN

unur_free(gen); gen = NULL;
gen = unur_str2gen( "normal() & distr=gamma(2)" );
	--> expected_NULL --> UNUR_ERR_STR_UNKNOWN


[init - invalid method block:
   gen = NULL; ]

gen = unur_str2gen( "normal() & method = arou; c = 0" );
	--> none --> UNUR_ERR_STR_UNKNOWN

unur_free(gen); gen = NULL;
gen = unur_str2gen( "normal() & method = xxx" );
	--> expected_NULL --> UNUR_ERR_NULL


[init - invalid urng block:
    gen = NULL; ]
 
gen = unur_str2gen( "normal & urng = xxx" );
	--> none --> UNUR_ERR_STR

unur_free(gen); gen = NULL;
\#ifdef UNURAN_SUPPORTS_PRNG
gen = unur_str2gen( "normal & urng = mt19937(123); xxx = 1" );
	--> none --> UNUR_ERR_STR_UNKNOWN

\#endif


[init - invalid data:
   gen = NULL; ]

gen = unur_str2gen( "gamma(0.5) & method = tdr" );
	--> expected_NULL --> UNUR_ERR_GEN_DATA


# unur_str2par ...

[init - invalid data:
   struct unur_slist *mlist = NULL;
   distr = NULL;
   par = NULL;
   gen = NULL; ]

distr = unur_str2distr("normal()");
par = _unur_str2par(distr, "tdr", &mlist);
gen = unur_init(par); 
_unur_slist_free(mlist);

## Function parser

[init - invalid distribution block:
   distr = NULL; ]

## missing parenthesis for function
distr = unur_str2distr("cont; pdf='exp'");
	--> expected_NULL --> UNUR_ERR_STR_INVALID


## unknown function name
distr = unur_str2distr("cont; pdf='abc(x)'");
	--> expected_NULL --> UNUR_ERR_STR_INVALID

## the first symbol ('x') is interpreted as variable,
## the second one causes an error.
distr = unur_str2distr("cont; pdf='exp(x*y)'");
	--> expected_NULL --> UNUR_ERR_STR_INVALID

## invalid number of parentheses
distr = unur_str2distr("cont; pdf='exp(x'");
	--> expected_NULL --> UNUR_ERR_STR_INVALID

distr = unur_str2distr("cont; pdf='exp((x)'");
	--> expected_NULL --> UNUR_ERR_STR_INVALID

distr = unur_str2distr("cont; pdf='exp(x))'");
	--> expected_NULL --> UNUR_ERR_STR_INVALID

## variable name expected
distr = unur_str2distr("cont; pdf='x^'");
	--> expected_NULL --> UNUR_ERR_STR_INVALID

## 
distr = unur_str2distr("cont; pdf='exp(x)x'");
	--> expected_NULL --> UNUR_ERR_STR_INVALID

distr = unur_str2distr("cont; pdf='2x'");
	--> expected_NULL --> UNUR_ERR_STR_INVALID

distr = unur_str2distr("cont; pdf='x***2'");
	--> expected_NULL --> UNUR_ERR_STR_INVALID

distr = unur_str2distr("cont; pdf='x*exp(x^(x*y))'");
	--> expected_NULL --> UNUR_ERR_STR_INVALID



# unur_makegen_ssu ...


#############################################################################

# [reinit]

#############################################################################

[sample]

#----------------------------------------------------------------------------

[sample - compare function parser - cont:
   double fpm[10];
   distr = NULL;
   par = NULL;
   gen = NULL; ]

distr = unur_distr_normal(NULL,0); 
par = unur_srou_new(distr);
gen = unur_init(par);
	-->compare_sequence_gen_start

unur_free(gen); gen = NULL;
unur_distr_free(distr); distr = NULL;
gen = unur_str2gen( "cont; pdf = \"(1/sqrt(2*pi)*exp(-x^2/2))\"; mode = 0; pdfarea = 1 & \
	             method = srou" );
	-->compare_sequence_gen

unur_free(gen); gen = NULL;
unur_distr_free(distr); distr = NULL;
gen = unur_str2gen( "cont; logpdf = \"-x^2/2-0.5*log(2*pi)\"; mode = 0; pdfarea = 1 & \
	             method = srou" );
	-->compare_sequence_gen

unur_free(gen); gen = NULL;
unur_distr_free(distr); distr = NULL;
gen = unur_makegen_ssu( "cont; logpdf = \"-x^2/2-0.5*log(2*pi)\"; mode = 0; pdfarea = 1", \
	             "method = srou", NULL );
	-->compare_sequence_gen

unur_free(gen); gen = NULL;
unur_distr_free(distr); distr = NULL;
gen = unur_makegen_ssu( "cont; logpdf = \"-x^2/2-0.5*log(2*pi)\"; mode = 0; pdfarea = 1", \
	             "srou", NULL );
	-->compare_sequence_gen


unur_free(gen); gen = NULL;
unur_distr_free(distr); distr = NULL;
distr = unur_str2distr("cont; logpdf = \"-x^2/2-0.5*log(2*pi)\"; mode = 0; pdfarea = 1");
gen = unur_makegen_dsu( distr, "srou", NULL );
	-->compare_sequence_gen

# ...........................................................................

unur_free(gen); gen = NULL;
unur_distr_free(distr); distr = NULL;
distr = unur_distr_normal(NULL,0); 
par = unur_ssr_new(distr);
gen = unur_init(par);
	-->compare_sequence_gen_start

#if(fullcheck) {
unur_free(gen); gen = NULL;
unur_distr_free(distr); distr = NULL;
gen = unur_str2gen( "cont; pdf = \"(1/sqrt(2*pi)*exp(-x^2/2))\"; mode = 0; pdfarea = 1 & \
	             method = ssr" );
	-->compare_sequence_gen

# ...........................................................................

unur_free(gen); gen = NULL;
unur_distr_free(distr); distr = NULL;
distr = unur_distr_normal(NULL,0); 
par = unur_utdr_new(distr);
gen = unur_init(par);
	-->compare_sequence_gen_start

unur_free(gen); gen = NULL;
unur_distr_free(distr); distr = NULL;
gen = unur_str2gen( "cont; pdf = \"(1/sqrt(2*pi)*exp(-x^2/2))\"; mode = 0; pdfarea = 1 & \
	             method = utdr" );
	-->compare_sequence_gen

unur_free(gen); gen = NULL;
unur_distr_free(distr); distr = NULL;
gen = unur_str2gen( "cont; logpdf = \"-x^2/2-0.5*log(2*pi)\"; mode = 0; pdfarea = 1 & \
	             method = utdr" );
	-->compare_sequence_gen

# ...........................................................................

unur_free(gen); gen = NULL;
unur_distr_free(distr); distr = NULL;
distr = unur_distr_normal(NULL,0); 
par = unur_tdr_new(distr);
unur_tdr_set_cpoints(par,8,NULL);
unur_tdr_set_max_sqhratio(par,0.);
gen = unur_init(par);
	-->compare_sequence_gen_start

unur_free(gen); gen = NULL;
unur_distr_free(distr); distr = NULL;
gen = unur_str2gen( "cont; pdf = \"(1/sqrt(2*pi)*exp(-x^2/2))\"; mode = 0; pdfarea = 1 & \
	             method = tdr; cpoints = 8; max_sqhratio = 0." );
	-->compare_sequence_gen

unur_free(gen); gen = NULL;
unur_distr_free(distr); distr = NULL;
gen = unur_str2gen( "cont; logpdf = \"-x^2/2-0.5*log(2*pi)\"; mode = 0; pdfarea = 1 & \
	             method = tdr; cpoints = 8; max_sqhratio = 0." );
	-->compare_sequence_gen

unur_free(gen); gen = NULL;
unur_distr_free(distr); distr = NULL;
gen = unur_makegen_ssu( "cont; logpdf = \"-x^2/2-0.5*log(2*pi)\"; mode = 0; pdfarea = 1", \
	             "method = tdr; cpoints = 8; max_sqhratio = 0.", NULL );
	-->compare_sequence_gen

unur_free(gen); gen = NULL;
unur_distr_free(distr); distr = NULL;
gen = unur_makegen_ssu( "cont; logpdf = \"-x^2/2-0.5*log(2*pi)\"; mode = 0; pdfarea = 1", \
	             "tdr; cpoints = 8; max_sqhratio = 0.", NULL );
	-->compare_sequence_gen

# ...........................................................................

unur_free(gen); gen = NULL;
unur_distr_free(distr); distr = NULL;
distr = unur_distr_normal(NULL,0); 
par = unur_arou_new(distr);
unur_arou_set_cpoints(par,8,NULL);
unur_arou_set_max_sqhratio(par,0.);
gen = unur_init(par);
	-->compare_sequence_gen_start

unur_free(gen); gen = NULL;
unur_distr_free(distr); distr = NULL;
gen = unur_str2gen( "cont; pdf = \"(1/sqrt(2*pi)*exp(-x^2/2))\"; mode = 0; pdfarea = 1 & \
	             method = arou; cpoints = 8; max_sqhratio = 0." );
	-->compare_sequence_gen

# ...........................................................................

unur_free(gen); gen = NULL;
unur_distr_free(distr); distr = NULL;
distr = unur_distr_cont_new();
unur_distr_cont_set_cdfstr(distr,"1-exp(-x)");
par = unur_ninv_new(distr);
unur_ninv_set_usenewton(par);
gen = unur_init(par);
	-->compare_sequence_gen_start

unur_free(gen); gen = NULL;
unur_distr_free(distr); distr = NULL;
gen = unur_str2gen( "cont; cdf = \"1-exp(-x)\"; domain = (0,inf)& \
	             method = ninv; usenewton" );
	-->compare_sequence_gen

# ...........................................................................

unur_free(gen); gen = NULL;
unur_distr_free(distr); distr = NULL;
distr = unur_distr_cont_new();
unur_distr_cont_set_hrstr(distr,"1/(1+x)");
par = unur_hrb_new(distr);
gen = unur_init(par);
	-->compare_sequence_gen_start

unur_free(gen); gen = NULL;
unur_distr_free(distr); distr = NULL;
gen = unur_str2gen( "cont; hr = \"1/(1+x)\"; domain = (0,inf)& \
	             method = hrb" );
	-->compare_sequence_gen

# ...........................................................................

unur_free(gen); gen = NULL;
unur_distr_free(distr); distr = NULL;
distr = unur_distr_normal(NULL,0);
par = unur_auto_new(distr);
gen = unur_init(par);
	-->compare_sequence_gen_start

unur_free(gen); gen = NULL;
unur_distr_free(distr); distr = NULL;
gen = unur_str2gen( "normal() & method=auto" );
	-->compare_sequence_gen

unur_free(gen); gen = NULL;
unur_distr_free(distr); distr = NULL;
gen = unur_makegen_ssu( "normal()", "method=auto", NULL );
	-->compare_sequence_gen

unur_free(gen); gen = NULL;
unur_distr_free(distr); distr = NULL;
gen = unur_makegen_ssu( "normal()", "auto", NULL );
	-->compare_sequence_gen

unur_free(gen); gen = NULL;
unur_distr_free(distr); distr = NULL;
gen = unur_makegen_ssu( "normal()", "", NULL );
	-->compare_sequence_gen

unur_free(gen); gen = NULL;
unur_distr_free(distr); distr = NULL;
gen = unur_makegen_ssu( "normal()", NULL, NULL );
	-->compare_sequence_gen

unur_free(gen); gen = NULL;
unur_distr_free(distr); distr = NULL;
gen = unur_makegen_ssu( "normal", NULL, NULL );
	-->compare_sequence_gen

# ...........................................................................

unur_free(gen); gen = NULL;
unur_distr_free(distr); distr = NULL;
fpm[0] = 1.;
fpm[1] = 2.;
distr = unur_distr_normal(fpm,2);
par = unur_auto_new(distr);
gen = unur_init(par);
	-->compare_sequence_gen_start

unur_free(gen); gen = NULL;
unur_distr_free(distr); distr = NULL;
gen = unur_str2gen( "normal(1.,2.) & method=auto" );
	-->compare_sequence_gen

unur_free(gen); gen = NULL;
unur_distr_free(distr); distr = NULL;
gen = unur_makegen_ssu( "normal(1,2)", "method=auto", NULL );
	-->compare_sequence_gen

unur_free(gen); gen = NULL;
unur_distr_free(distr); distr = NULL;
gen = unur_makegen_ssu( "normal(1,2.)", "auto", NULL );
	-->compare_sequence_gen

unur_free(gen); gen = NULL;
unur_distr_free(distr); distr = NULL;
gen = unur_makegen_ssu( "normal(1.,2)", "", NULL );
	-->compare_sequence_gen

unur_free(gen); gen = NULL;
unur_distr_free(distr); distr = NULL;
gen = unur_makegen_ssu( "normal(1,2)", NULL, NULL );
	-->compare_sequence_gen

unur_free(gen); gen = NULL;
unur_distr_free(distr); distr = NULL;
fpm[0] = 1.;
fpm[1] = 2.;
distr = unur_distr_normal(fpm,2);
gen = unur_makegen_dsu( distr, "method=auto", NULL );
	-->compare_sequence_gen

unur_free(gen); gen = NULL;
unur_distr_free(distr); distr = NULL;
fpm[0] = 1.;
fpm[1] = 2.;
distr = unur_distr_normal(fpm,2);
gen = unur_makegen_dsu( distr, "auto", NULL );
	-->compare_sequence_gen

unur_free(gen); gen = NULL;
unur_distr_free(distr); distr = NULL;
fpm[0] = 1.;
fpm[1] = 2.;
distr = unur_distr_normal(fpm,2);
gen = unur_makegen_dsu( distr, "", NULL );
	-->compare_sequence_gen

unur_free(gen); gen = NULL;
unur_distr_free(distr); distr = NULL;
fpm[0] = 1.;
fpm[1] = 2.;
distr = unur_distr_normal(fpm,2);
gen = unur_makegen_dsu( distr, NULL, NULL );
	-->compare_sequence_gen

# ...........................................................................

## Not tested:
## 
## unur_distr_cont_set_pdfparams();

#---------------------------------------------------------------------

[sample - compare function parser - discr:
   double fpar[] = {0.4};
   distr = NULL;
   par = NULL;
   gen = NULL; ]

distr = unur_distr_geometric(fpar,1); 
par = unur_dsrou_new(distr);
gen = unur_init(par);
	-->compare_sequence_gen_start

unur_free(gen); gen = NULL;
unur_distr_free(distr); distr = NULL;
gen = unur_str2gen( "discr; pmf = \"0.4 * (1-0.4)^k\"; domain = (0,inf); mode = 0; pmfsum = 1 & \
	             method = dsrou" );
	-->compare_sequence_gen


unur_free(gen); gen = NULL;
unur_distr_free(distr); distr = NULL;
distr = unur_distr_geometric(fpar,1); 
par = unur_dau_new(distr);
gen = unur_init(par);
	-->compare_sequence_gen_start

unur_free(gen); gen = NULL;
unur_distr_free(distr); distr = NULL;
gen = unur_str2gen( "discr; pmf = \"0.4 * (1-0.4)^k\"; domain = (0,inf); mode = 0; pmfsum = 1 & \
	             method = dau" );
	-->compare_sequence_gen


unur_free(gen); gen = NULL;
unur_distr_free(distr); distr = NULL;
distr = unur_distr_geometric(fpar,1); 
par = unur_dgt_new(distr);
gen = unur_init(par);
	-->compare_sequence_gen_start

unur_free(gen); gen = NULL;
unur_distr_free(distr); distr = NULL;
gen = unur_str2gen( "discr; pmf = \"0.4 * (1-0.4)^k\"; domain = (0,inf); mode = 0; pmfsum = 1 & \
	             method = dgt" );
	-->compare_sequence_gen


unur_free(gen); gen = NULL;
unur_distr_free(distr); distr = NULL;
distr = unur_distr_geometric(fpar,1); 
par = unur_dari_new(distr);
gen = unur_init(par);
	-->compare_sequence_gen_start


unur_free(gen); gen = NULL;
unur_distr_free(distr); distr = NULL;
gen = unur_str2gen( "discr; pmf = \"0.4 * (1-0.4)^k\"; domain = (0,inf); mode = 0; pmfsum = 1 & \
	             method = dari" );
	-->compare_sequence_gen

## Not tested:
## 
## unur_distr_discr_set_mode();
## unur_distr_discr_set_pmfparams();

#############################################################################

# [validate]

#############################################################################
#############################################################################

[verbatim]

#############################################################################

