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

[main]

[main - data:]

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

[main - header:]

/* prototypes */

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

double mvpdf(const double *x, UNUR_DISTR *distr);
int mvdpdf(double *result, const double *x, UNUR_DISTR *distr);
double mvpdpdf(const double *x, int coord, UNUR_DISTR *distr);

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

[new]

[new - invalid data:
	distr = NULL; ]

unur_distr_cvec_new(0);
	 --> expected_NULL --> UNUR_ERR_DISTR_SET


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

[set]

[set - invalid NULL ptr:
   distr = NULL; ]

~_pdf( distr, mvpdf );
        --> expected_setfailed --> UNUR_ERR_NULL

~_dpdf( distr, mvdpdf );
        --> expected_setfailed --> UNUR_ERR_NULL

~_pdpdf( distr, mvpdpdf );
        --> expected_setfailed --> UNUR_ERR_NULL

~_logpdf( distr, mvpdf );
        --> expected_setfailed --> UNUR_ERR_NULL

~_dlogpdf( distr, mvdpdf );
        --> expected_setfailed --> UNUR_ERR_NULL

~_pdlogpdf( distr, mvpdpdf );
        --> expected_setfailed --> UNUR_ERR_NULL

~_mean( distr, NULL );
        --> expected_setfailed --> UNUR_ERR_NULL

~_covar( distr, NULL );
        --> expected_setfailed --> UNUR_ERR_NULL

~_covar_inv( distr, NULL );
        --> expected_setfailed --> UNUR_ERR_NULL

~_rankcorr( distr, NULL );
        --> expected_setfailed --> UNUR_ERR_NULL

~_mode( distr, NULL );
        --> expected_setfailed --> UNUR_ERR_NULL

~_center( distr, NULL );
        --> expected_setfailed --> UNUR_ERR_NULL

~_pdfparams( distr, NULL, 0 );
        --> expected_setfailed --> UNUR_ERR_NULL

~_pdfparams_vec( distr, 0, NULL, 0 );
        --> expected_setfailed --> UNUR_ERR_NULL

~_pdfvol( distr, 1. );
        --> expected_setfailed --> UNUR_ERR_NULL

~_marginals( distr, NULL );
        --> expected_setfailed --> UNUR_ERR_NULL

~_marginal_array( distr, NULL );
        --> expected_setfailed --> UNUR_ERR_NULL

~_domain_rect( distr, NULL, NULL );
        --> expected_setfailed --> UNUR_ERR_NULL


[set - invalid distribution type:
   double fpm[2] = {1.,2.};
   distr = unur_distr_discr_new(); ]

~_pdf( distr, mvpdf );
        --> expected_setfailed --> UNUR_ERR_DISTR_INVALID

~_dpdf( distr, mvdpdf );
        --> expected_setfailed --> UNUR_ERR_DISTR_INVALID

~_pdpdf( distr, mvpdpdf );
        --> expected_setfailed --> UNUR_ERR_DISTR_INVALID

~_logpdf( distr, mvpdf );
       --> expected_setfailed --> UNUR_ERR_DISTR_INVALID

~_dlogpdf( distr, mvdpdf );
        --> expected_setfailed --> UNUR_ERR_DISTR_INVALID

~_pdlogpdf( distr, mvpdpdf );
        --> expected_setfailed --> UNUR_ERR_DISTR_INVALID

~_mean( distr, NULL );
        --> expected_setfailed --> UNUR_ERR_DISTR_INVALID

~_covar( distr, NULL );
        --> expected_setfailed --> UNUR_ERR_DISTR_INVALID

~_covar_inv( distr, NULL );
        --> expected_setfailed --> UNUR_ERR_DISTR_INVALID

~_rankcorr( distr, NULL );
        --> expected_setfailed --> UNUR_ERR_DISTR_INVALID

~_mode( distr, NULL );
        --> expected_setfailed --> UNUR_ERR_DISTR_INVALID

~_center( distr, NULL );
        --> expected_setfailed --> UNUR_ERR_DISTR_INVALID

~_pdfparams( distr, fpm, 2 );
        --> expected_setfailed --> UNUR_ERR_DISTR_INVALID

~_pdfparams_vec( distr, 0, fpm, 2 );
        --> expected_setfailed --> UNUR_ERR_DISTR_INVALID

~_pdfvol( distr, 1. );
        --> expected_setfailed --> UNUR_ERR_DISTR_INVALID

~_marginals( distr, NULL );
        --> expected_setfailed --> UNUR_ERR_DISTR_INVALID

~_marginal_array( distr, NULL );
        --> expected_setfailed --> UNUR_ERR_DISTR_INVALID

~_domain_rect( distr, NULL, NULL );
        --> expected_setfailed --> UNUR_ERR_DISTR_INVALID


[set - invalid NULL ptr: 
   distr = unur_distr_cvec_new(2); ]

~_pdf( distr, NULL );
        --> expected_setfailed --> UNUR_ERR_NULL

~_dpdf( distr, NULL );
        --> expected_setfailed --> UNUR_ERR_NULL

~_pdpdf( distr, NULL );
        --> expected_setfailed --> UNUR_ERR_NULL

~_logpdf( distr, NULL );
        --> expected_setfailed --> UNUR_ERR_NULL

~_dlogpdf( distr, NULL );
        --> expected_setfailed --> UNUR_ERR_NULL

~_pdlogpdf( distr, NULL );
        --> expected_setfailed --> UNUR_ERR_NULL

~_pdfparams( distr, NULL, 0 );
        --> expected_setfailed --> UNUR_ERR_NULL

~_marginals( distr, NULL );
        --> expected_setfailed --> UNUR_ERR_NULL

~_marginal_array( distr, NULL );
        --> expected_setfailed --> UNUR_ERR_NULL

~_domain_rect( distr, NULL, NULL );
        --> expected_setfailed --> UNUR_ERR_NULL


[set - invalid parameters:
   double fpm[2] = {1.,2.};
   double dpm[2] = {4., 0.5};
   double covar_invalid_negative[4] = {-1.,0.,0.,1.};
   double covar_invalid_nonsym[4] = {1.,0.5,0.,1.};
   double covar_invalid_nonpositive[4] = {0.5,1.,1.,0.5};
   double ll[] = { 0., 0. };
   double ru[] = { 0., 0. };
   UNUR_DISTR *marginal = unur_distr_binomial(dpm,2);
   UNUR_DISTR *marginal_array[2];
   marginal_array[0] = marginal;
   marginal_array[1] = marginal;
   distr = unur_distr_cvec_new(2); ]

~_pdfvol( distr, -1. );
        --> expected_setfailed --> UNUR_ERR_DISTR_SET

~_covar( distr, covar_invalid_negative );
        --> expected_setfailed --> UNUR_ERR_DISTR_DOMAIN

~_covar_inv( distr, covar_invalid_negative );
        --> expected_setfailed --> UNUR_ERR_DISTR_DOMAIN

~_covar( distr, covar_invalid_nonsym );
        --> expected_setfailed --> UNUR_ERR_DISTR_DOMAIN

~_covar_inv( distr, covar_invalid_nonsym );
        --> expected_setfailed --> UNUR_ERR_DISTR_DOMAIN

~_covar( distr, covar_invalid_nonpositive );
        --> expected_setfailed --> UNUR_ERR_DISTR_DOMAIN

~_rankcorr( distr, covar_invalid_negative );
        --> expected_setfailed --> UNUR_ERR_DISTR_DOMAIN

~_rankcorr( distr, covar_invalid_nonsym );
        --> expected_setfailed --> UNUR_ERR_DISTR_DOMAIN

~_pdfparams( distr, fpm, -1 );
        --> expected_setfailed --> UNUR_ERR_DISTR_NPARAMS

~_pdfparams_vec( distr, -1, fpm, 2 );
        --> expected_setfailed --> UNUR_ERR_DISTR_NPARAMS

~_pdfparams_vec( distr, 100000, fpm, 2 );
        --> expected_setfailed --> UNUR_ERR_DISTR_NPARAMS

~_marginals( distr, marginal );
        --> expected_setfailed --> UNUR_ERR_DISTR_INVALID

~_marginal_array( distr, marginal_array );
        --> expected_setfailed --> UNUR_ERR_DISTR_INVALID

~_domain_rect( distr, ll, ru );
        --> expected_setfailed --> UNUR_ERR_DISTR_SET


unur_distr_free(marginal);

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

[get]

[get - invalid NULL ptr: 
   distr = NULL; ]

~_pdf( distr );
        --> expected_NULL --> UNUR_ERR_NULL

~_dpdf( distr );
        --> expected_NULL --> UNUR_ERR_NULL

~_pdpdf( distr );
        --> expected_NULL --> UNUR_ERR_NULL

~_logpdf( distr );
        --> expected_NULL --> UNUR_ERR_NULL

~_dlogpdf( distr );
        --> expected_NULL --> UNUR_ERR_NULL

~_pdlogpdf( distr );
        --> expected_NULL --> UNUR_ERR_NULL

~_pdfvol( distr );
        --> expected_INFINITY --> UNUR_ERR_NULL

~_mean( distr );
        --> expected_NULL --> UNUR_ERR_NULL

~_covar( distr );
        --> expected_NULL --> UNUR_ERR_NULL

~_covar_inv( distr );
        --> expected_NULL --> UNUR_ERR_NULL

~_rankcorr( distr );
        --> expected_NULL --> UNUR_ERR_NULL

~_cholesky( distr );
        --> expected_NULL --> UNUR_ERR_NULL

~_mode( distr );
        --> expected_NULL --> UNUR_ERR_NULL

~_center( distr );
        --> expected_NULL --> UNUR_ERR_NULL

~_pdfparams( distr, NULL );
        --> expected_zero --> UNUR_ERR_NULL

~_pdfparams_vec( distr, 0, NULL );
        --> expected_zero --> UNUR_ERR_NULL

~_marginal( distr, 1 );
        --> expected_NULL --> UNUR_ERR_NULL


[get - invalid distribution type:
   const double *fpm;
   distr = unur_distr_discr_new(); ]

unur_distr_cvec_get_pdf( distr );
        --> expected_NULL --> UNUR_ERR_DISTR_INVALID

unur_distr_cvec_get_dpdf( distr );
        --> expected_NULL --> UNUR_ERR_DISTR_INVALID

unur_distr_cvec_get_pdpdf( distr );
        --> expected_NULL --> UNUR_ERR_DISTR_INVALID

unur_distr_cvec_get_logpdf( distr );
        --> expected_NULL --> UNUR_ERR_DISTR_INVALID

unur_distr_cvec_get_dlogpdf( distr );
        --> expected_NULL --> UNUR_ERR_DISTR_INVALID

unur_distr_cvec_get_pdlogpdf( distr );
        --> expected_NULL --> UNUR_ERR_DISTR_INVALID

~_pdfvol( distr );
        --> expected_INFINITY --> UNUR_ERR_DISTR_INVALID

~_mean( distr );
        --> expected_NULL --> UNUR_ERR_DISTR_INVALID

~_covar( distr );
        --> expected_NULL --> UNUR_ERR_DISTR_INVALID

~_covar_inv( distr );
        --> expected_NULL --> UNUR_ERR_DISTR_INVALID

~_rankcorr( distr );
        --> expected_NULL --> UNUR_ERR_DISTR_INVALID

~_cholesky( distr );
        --> expected_NULL --> UNUR_ERR_DISTR_INVALID

~_mode( distr );
        --> expected_NULL --> UNUR_ERR_DISTR_INVALID

~_center( distr );
        --> expected_NULL --> UNUR_ERR_DISTR_INVALID

~_pdfparams( distr, &fpm );
        --> expected_zero --> UNUR_ERR_DISTR_INVALID

~_pdfparams_vec( distr, 0, &fpm );
        --> expected_zero --> UNUR_ERR_DISTR_INVALID

~_marginal( distr, 1 );
        --> expected_NULL --> UNUR_ERR_DISTR_INVALID


[get - parameters not unknown:
   const double *fpm;
   distr = unur_distr_cvec_new(2); ]

~_pdfvol( distr );
        --> expected_INFINITY --> UNUR_ERR_DISTR_GET

~_mean( distr );
        --> expected_NULL --> UNUR_ERR_DISTR_GET

~_covar( distr );
        --> expected_NULL --> UNUR_ERR_DISTR_GET

~_covar_inv( distr );
        --> expected_NULL --> UNUR_ERR_DISTR_GET

~_rankcorr( distr );
        --> expected_NULL --> UNUR_ERR_DISTR_GET

~_cholesky( distr );
        --> expected_NULL --> UNUR_ERR_DISTR_GET

~_mode( distr );
        --> expected_NULL --> UNUR_ERR_DISTR_GET

~_pdfparams_vec( distr, -1, &fpm );
        --> expected_zero --> UNUR_ERR_DISTR_NPARAMS

~_pdfparams_vec( distr, 1000, &fpm );
        --> expected_zero --> UNUR_ERR_DISTR_NPARAMS

~_marginal( distr, 1 );
        --> expected_NULL --> UNUR_ERR_DISTR_GET


[get - invalid parameters:
   double covar_invalid_noninv[4] = {1.,1.,1.,1.};
   UNUR_DISTR *marginal = unur_distr_normal(NULL,0);
   distr = unur_distr_cvec_new(2); 
   unur_distr_cvec_set_marginals( distr, marginal );
   unur_distr_cvec_set_covar( distr, covar_invalid_noninv ); ]

~_covar( distr );
        --> expected_NULL --> UNUR_ERR_DISTR_GET

~_rankcorr( distr );
        --> expected_NULL --> UNUR_ERR_DISTR_GET

~_marginal( distr, 0 );
        --> expected_NULL --> UNUR_ERR_DISTR_GET

~_marginal( distr, 3 );
        --> expected_NULL --> UNUR_ERR_DISTR_GET

unur_distr_free(marginal);

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

[chg]

[chg - invalid NULL ptr: 
   distr = NULL; ]

unur_distr_cvec_upd_mode( distr );
        --> expected_setfailed --> UNUR_ERR_NULL

unur_distr_cvec_upd_pdfvol( distr );
        --> expected_setfailed --> UNUR_ERR_NULL

[chg - invalid distribution type:
   distr = unur_distr_cont_new(); ]

unur_distr_cvec_upd_mode( distr );
        --> expected_setfailed --> UNUR_ERR_DISTR_INVALID

unur_distr_cvec_upd_pdfvol( distr );
        --> expected_setfailed --> UNUR_ERR_DISTR_INVALID

[chg - missing data:
   distr = unur_distr_cvec_new(3); ]

unur_distr_cvec_upd_mode( distr );
        --> expected_setfailed --> UNUR_ERR_DISTR_DATA

unur_distr_cvec_upd_pdfvol( distr );
        --> expected_setfailed --> UNUR_ERR_DISTR_DATA


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

# [init]

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

# [reinit]

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

[sample]

[sample - invalid NULL ptr: 
   distr = NULL; ]

unur_distr_cvec_eval_pdf( NULL, distr );
        --> expected_INFINITY --> UNUR_ERR_NULL

unur_distr_cvec_eval_dpdf( NULL, NULL, distr );
        --> expected_setfailed --> UNUR_ERR_NULL

unur_distr_cvec_eval_pdpdf( NULL, 1, distr );
        --> expected_INFINITY --> UNUR_ERR_NULL

unur_distr_cvec_eval_logpdf( NULL, distr );
        --> expected_INFINITY --> UNUR_ERR_NULL

unur_distr_cvec_eval_dlogpdf( NULL, NULL, distr );
        --> expected_setfailed --> UNUR_ERR_NULL

unur_distr_cvec_eval_pdlogpdf( NULL, 1, distr );
        --> expected_INFINITY --> UNUR_ERR_NULL


[sample - invalid distribution object:
   distr = unur_distr_discr_new(); ]

unur_distr_cvec_eval_pdf( NULL, distr );
        --> expected_INFINITY --> UNUR_ERR_DISTR_INVALID

unur_distr_cvec_eval_dpdf( NULL, NULL, distr );
        --> expected_setfailed --> UNUR_ERR_DISTR_INVALID

unur_distr_cvec_eval_pdpdf( NULL, 1, distr );
        --> expected_INFINITY --> UNUR_ERR_DISTR_INVALID

unur_distr_cvec_eval_logpdf( NULL, distr );
        --> expected_INFINITY --> UNUR_ERR_DISTR_INVALID

unur_distr_cvec_eval_dlogpdf( NULL, NULL, distr );
        --> expected_setfailed --> UNUR_ERR_DISTR_INVALID

unur_distr_cvec_eval_pdlogpdf( NULL, 1, distr );
        --> expected_INFINITY --> UNUR_ERR_DISTR_INVALID


[sample - missing data:
   double x[2], result[2];
   distr = unur_distr_cvec_new(2); ]

unur_distr_cvec_eval_pdf( x, distr );
        --> expected_INFINITY --> UNUR_ERR_DISTR_DATA

unur_distr_cvec_eval_dpdf( result, x, distr );
        --> expected_setfailed --> UNUR_ERR_DISTR_DATA

unur_distr_cvec_eval_pdpdf( x, 1, distr );
        --> expected_INFINITY --> UNUR_ERR_DISTR_DATA

unur_distr_cvec_eval_logpdf( x, distr );
        --> expected_INFINITY --> UNUR_ERR_DISTR_DATA

unur_distr_cvec_eval_dlogpdf( result, x, distr );
        --> expected_setfailed --> UNUR_ERR_DISTR_DATA

unur_distr_cvec_eval_pdlogpdf( x, 1, distr );
        --> expected_INFINITY --> UNUR_ERR_DISTR_DATA


[sample - check for memory leaks:
   double x[] = { 1., 2., 3. };
   distr = unur_distr_cvec_new(3); ]

unur_distr_cvec_set_pdfparams_vec( distr, 0, x, 3 );
        --> none --> UNUR_SUCCESS


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

# [validate]

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

[verbatim]

double mvpdf(const double *x ATTRIBUTE__UNUSED, UNUR_DISTR *distr ATTRIBUTE__UNUSED) { return 1.; }
int mvdpdf(double *result ATTRIBUTE__UNUSED, const double *x ATTRIBUTE__UNUSED, UNUR_DISTR *distr ATTRIBUTE__UNUSED) { return 1; }
double mvpdpdf(const double *x ATTRIBUTE__UNUSED, int coord ATTRIBUTE__UNUSED, UNUR_DISTR *distr ATTRIBUTE__UNUSED) { return 1.; }

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