1 # ifndef MACROS_H
2 # define MACROS_H
3 
4 
5 /****************/
6 /** structrues **/
7 /****************/
8 
9 /* ENUMS
10  * sufficient statistic to calculate: 0->W1*, 1->W2*, 2->(W1*)^2, 3->(W1*)(W2*), 4->(W2*)^2, 5->W1,6->W2 7->Log Lik,8->test
11  * data point type: 0=general, 1= homogenous with (X==1), 2= homogenous with (X==0), 3=survey (W1 and W2 are known)
12  */
13  enum e_sufficient_stats {SS_W1star, SS_W2star, SS_W1star2, SS_W1W2star, SS_W2star2, SS_W1, SS_W2, SS_Loglik, SS_Test};
14  typedef enum e_sufficient_stats sufficient_stat;
15  enum e_datapoint_types {DPT_General,DPT_Homog_X1, DPT_Homog_X0, DPT_Survey};
16  typedef enum e_datapoint_types datapoint_type;
17 
18 /* parameters and observed data  -- no longer used*/
19 struct Param_old{
20   double mu[2];
21   double Sigma[2][2];
22   double InvSigma[2][2];
23   double Sigma3[3][3];
24   double InvSigma3[3][3];
25   int NCAR;
26   double data[2]; //collect the data
27   double X; //X,Y here for ease of use
28   double Y;
29   double normcT; //normalized const on tomog line (integrating with parameterization)
30   double W[2]; //if W is known, also handy place to store E[W1] when we calculate it each step
31   double Wstar[2]; //place to store E[W1*] when we calculate it each step
32   double W1_lb; //lower and upper bounds for W1 and W2 (not starred)
33   double W1_ub;
34   double W2_lb;
35   double W2_ub;
36   sufficient_stat suff; //the sufficient stat we're calculating: 0->W1, 1->W2,2->W1^2,3->W1W2,4->W2^2,7->Log Lik, 5/6,-1 ->test case
37 };
38 
39 typedef struct Param_old Param_old;
40 
41 /**
42  * The structure that holds per-record infromation
43  */
44 struct caseParam {
45   double mu[2];
46   double data[2]; //collect the data
47   double X; //X,Y here for ease of use
48   double Y;
49   double normcT; //normalized const on tomog line (integrating with parameterization)
50   double W[2]; //if W is known, also handy place to store E[W1] when we calculate it each step
51   double Wstar[2]; //place to store E[W1*] when we calculate it each step
52   double Wbounds[2][2];  //[i][j] is {j:lower,upper}-bound of W{i+1}
53   int suff; //the sufficient stat we're calculating: 0->W1, 1->W2,2->W1^2,3->W1W2,4->W2^2,7->Log Lik, 5/6,-1 ->test case
54   datapoint_type dataType;
55   double** Z_i; //CCAR: k x 2
56 };
57 
58 typedef struct caseParam caseParam;
59 
60 /**
61  * The structure that holds dataset infromation
62  */
63 struct setParam {
64   int n_samp, t_samp, s_samp,x1_samp,x0_samp,param_len,suffstat_len; //types of data sizes
65   int iter, ncar, ccar, ccar_nvar, fixedRho, sem, hypTest, verbose, calcLoglik; //options
66   int semDone[7]; //whether that row of the R matrix is done
67   int varParam[9]; //whether the parameter is included in the R matrix
68   double convergence;
69   double Sigma[2][2];
70   double InvSigma[2][2];
71   double Sigma3[3][3];
72   double InvSigma3[3][3];
73   double** SigmaK; //for CCAR
74   double** InvSigmaK;
75   double** hypTestCoeff;
76   double hypTestResult;
77   double* pdTheta;
78 };
79 
80 typedef struct setParam setParam;
81 
82 struct Param {
83   setParam* setP; //pointer to the singleton structure
84   caseParam caseP;
85 };
86 
87 typedef struct Param Param;
88 
89 /***************************/
90 /** typedef functions     **/
91 /***************************/
92 
93 //typedef void integr_fn(double *x, int n, void *ex); //is already defined in Applic.h
94 typedef double gsl_fn(double x, void *ex);
95 
96 # endif
97