1 /*****************************************************************************
2 * *
3 * UNURAN -- Universal Non-Uniform Random number generator *
4 * *
5 *****************************************************************************
6 * *
7 * FILE: m_correlation.c *
8 * *
9 * Random correlation matrix *
10 * *
11 *****************************************************************************
12 * *
13 * Copyright (c) 2000-2006 Wolfgang Hoermann and Josef Leydold *
14 * Department of Statistics and Mathematics, WU Wien, Austria *
15 * *
16 * This program is free software; you can redistribute it and/or modify *
17 * it under the terms of the GNU General Public License as published by *
18 * the Free Software Foundation; either version 2 of the License, or *
19 * (at your option) any later version. *
20 * *
21 * This program is distributed in the hope that it will be useful, *
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
24 * GNU General Public License for more details. *
25 * *
26 * You should have received a copy of the GNU General Public License *
27 * along with this program; if not, write to the *
28 * Free Software Foundation, Inc., *
29 * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA *
30 * *
31 *****************************************************************************/
32
33 /*---------------------------------------------------------------------------*/
34
35 #include <unur_source.h>
36 #include <distr/distr_source.h>
37 #include <distr/distr.h>
38 #include <distr/matr.h>
39 #include <specfunct/unur_specfunct_source.h>
40 #include "unur_distributions.h"
41 #include "unur_distributions_source.h"
42 #include "unur_stddistr.h"
43
44 /*---------------------------------------------------------------------------*/
45
46 static const char distr_name[] = "correlation";
47
48 /*---------------------------------------------------------------------------*/
49 /* parameters */
50
51 /*---------------------------------------------------------------------------*/
52
53 #define DISTR distr->data.matr
54
55 /*---------------------------------------------------------------------------*/
56 /* function prototypes */
57
58 /*---------------------------------------------------------------------------*/
59
60 /*****************************************************************************/
61 /** **/
62 /** Make distribution object **/
63 /** **/
64 /*****************************************************************************/
65
66 /*---------------------------------------------------------------------------*/
67
68 struct unur_distr *
unur_distr_correlation(int n)69 unur_distr_correlation( int n )
70 {
71 struct unur_distr *distr;
72
73 /* get new (empty) distribution object */
74 distr = unur_distr_matr_new(n,n);
75
76 /* check new parameter for generator */
77 if (distr == NULL) {
78 /* error: n < 2 */
79 return NULL;
80 }
81
82 /* set distribution id */
83 distr->id = UNUR_DISTR_MCORRELATION;
84
85 /* name of distribution */
86 distr->name = distr_name;
87
88 /* how to get special generators */
89 DISTR.init = NULL;
90
91 /* functions */
92
93 /* indicate which parameters are set (additional to mean and covariance) */
94 /* distr->set |= 0; */
95
96 /* return pointer to object */
97 return distr;
98
99 } /* end of unur_distr_correlation() */
100
101 /*---------------------------------------------------------------------------*/
102 #undef DISTR
103 /*---------------------------------------------------------------------------*/
104