Commit | Line | Data |
---|---|---|
7b272073 BA |
1 | #include "constructionModelesLassoMLE.h" |
2 | #include "ioutils.h" | |
3 | ||
4 | int main(int argc, char** argv) | |
5 | { | |
6 | // read dimensions | |
7ea8c1e5 BA |
7 | const int nbDims = 5; |
8 | int* dimensions = readArray_int("dimensions",&nbDims,1); | |
9 | int n = dimensions[0]; | |
10 | int p = dimensions[1]; | |
11 | int m = dimensions[2]; | |
12 | int k = dimensions[3]; | |
13 | int L = dimensions[4]; | |
7b272073 | 14 | free(dimensions); |
7ea8c1e5 | 15 | int lengthOne = 1; |
7b272073 BA |
16 | |
17 | //////////// | |
18 | // INPUTS // | |
19 | //////////// | |
20 | ||
21 | // phiInit | |
7ea8c1e5 BA |
22 | const int dimPhiInit[] = {p, m, k}; |
23 | float* phiInit = readArray_real("phiInit",dimPhiInit,3); | |
7b272073 BA |
24 | |
25 | // rhoInit | |
7ea8c1e5 BA |
26 | const int dimRhoInit[] = {m, m, k}; |
27 | float* rhoInit = readArray_real("rhoInit",dimRhoInit,3); | |
7b272073 BA |
28 | |
29 | // piInit | |
7ea8c1e5 | 30 | float* piInit = readArray_real("piInit",&k,1); |
7b272073 BA |
31 | |
32 | // gamInit | |
7ea8c1e5 BA |
33 | const int dimGamInit[] = {n, k}; |
34 | float* gamInit = readArray_real("gamInit",dimGamInit,2); | |
7b272073 BA |
35 | |
36 | // min number of iterations | |
7ea8c1e5 BA |
37 | int* pmini = readArray_int("mini",&lengthOne,1); |
38 | int mini = *pmini; | |
7b272073 BA |
39 | free(pmini); |
40 | ||
41 | // max number of iterations | |
7ea8c1e5 BA |
42 | int* pmaxi = readArray_int("maxi",&lengthOne,1); |
43 | int maxi = *pmaxi; | |
7b272073 BA |
44 | free(pmaxi); |
45 | ||
46 | // gamma | |
7ea8c1e5 BA |
47 | float* pgamma = readArray_real("gamma",&lengthOne,1); |
48 | float gamma = *pgamma; | |
7b272073 BA |
49 | free(pgamma); |
50 | ||
51 | // lambda | |
7ea8c1e5 | 52 | float* glambda = readArray_real("glambda",&L,1); |
7b272073 BA |
53 | |
54 | // X | |
7ea8c1e5 BA |
55 | const int dimX[] = {n, p}; |
56 | float* X = readArray_real("X",dimX,2); | |
7b272073 BA |
57 | |
58 | // Y | |
7ea8c1e5 BA |
59 | const int dimY[] = {n, m}; |
60 | float* Y = readArray_real("Y",dimY,2); | |
7b272073 BA |
61 | |
62 | // seuil | |
7ea8c1e5 BA |
63 | float* pseuil = readArray_real("seuil",&lengthOne,1); |
64 | float seuil = *pseuil; | |
7b272073 BA |
65 | free(pseuil); |
66 | ||
67 | // tau | |
7ea8c1e5 BA |
68 | float* ptau = readArray_real("tau",&lengthOne,1); |
69 | float tau = *ptau; | |
7b272073 BA |
70 | free(ptau); |
71 | ||
72 | // A1 | |
7ea8c1e5 BA |
73 | const int dimA[] = {p, m+1, L}; |
74 | int* A1 = readArray_int("A1",dimA,3); | |
7b272073 BA |
75 | |
76 | // A2 | |
7ea8c1e5 | 77 | int* A2 = readArray_int("A2",dimA,3); |
7b272073 BA |
78 | |
79 | ///////////// | |
80 | // OUTPUTS // | |
81 | ///////////// | |
82 | ||
83 | // phi | |
7ea8c1e5 BA |
84 | const int dimPhi[] = {dimPhiInit[0], dimPhiInit[1], dimPhiInit[2], L}; |
85 | float* phi = (float*)malloc(dimPhi[0]*dimPhi[1]*dimPhi[2]*dimPhi[3]*sizeof(float)); | |
7b272073 BA |
86 | |
87 | // rho | |
7ea8c1e5 BA |
88 | const int dimRho[] = {dimRhoInit[0], dimRhoInit[1], dimRhoInit[2], L}; |
89 | float* rho = (float*)malloc(dimRho[0]*dimRho[1]*dimRho[2]*dimRho[3]*sizeof(float)); | |
7b272073 BA |
90 | |
91 | // pi | |
7ea8c1e5 BA |
92 | const int dimPi[] = {k, L}; |
93 | float* pi = (float*)malloc(dimPi[0]*dimPi[1]*sizeof(float)); | |
7b272073 BA |
94 | |
95 | // lvraisemblance | |
7ea8c1e5 BA |
96 | const int dimLvraisemblance[] = {L, 2}; |
97 | float* lvraisemblance = (float*)malloc(dimLvraisemblance[0]*dimLvraisemblance[1]*sizeof(float)); | |
7b272073 BA |
98 | |
99 | ///////////////////////////////////////// | |
100 | // Call to constructionModelesLassoMLE // | |
101 | ///////////////////////////////////////// | |
102 | ||
103 | constructionModelesLassoMLE( | |
104 | phiInit,rhoInit,piInit,gamInit,mini,maxi,gamma,glambda,X,Y,seuil,tau,A1,A2, | |
105 | phi,rho,pi,lvraisemblance, | |
106 | n,p,m,k,L); | |
107 | ||
108 | free(phiInit); | |
109 | free(rhoInit); | |
110 | free(piInit); | |
111 | free(gamInit); | |
112 | free(X); | |
113 | free(Y); | |
114 | free(A1); | |
115 | free(A2); | |
116 | free(glambda); | |
117 | ||
118 | // Compare to reference outputs | |
7ea8c1e5 | 119 | float* ref_phi = readArray_real("phi",dimPhi,4); |
7b272073 BA |
120 | compareArray_real("phi", phi, ref_phi, dimPhi[0]*dimPhi[1]*dimPhi[2]*dimPhi[3]); |
121 | free(phi); | |
122 | free(ref_phi); | |
123 | ||
124 | // rho | |
7ea8c1e5 | 125 | float* ref_rho = readArray_real("rho",dimRho,4); |
7b272073 BA |
126 | compareArray_real("rho", rho, ref_rho, dimRho[0]*dimRho[1]*dimRho[2]*dimRho[3]); |
127 | free(rho); | |
128 | free(ref_rho); | |
129 | ||
130 | // pi | |
7ea8c1e5 | 131 | float* ref_pi = readArray_real("pi",dimPi,2); |
7b272073 BA |
132 | compareArray_real("pi", pi, ref_pi, dimPi[0]*dimPi[1]); |
133 | free(pi); | |
134 | free(ref_pi); | |
135 | ||
136 | // lvraisemblance | |
7ea8c1e5 | 137 | float* ref_lvraisemblance = readArray_real("lvraisemblance",dimLvraisemblance,2); |
7b272073 BA |
138 | compareArray_real("lvraisemblance", lvraisemblance, ref_lvraisemblance, dimLvraisemblance[0]*dimLvraisemblance[1]); |
139 | free(lvraisemblance); | |
140 | free(ref_lvraisemblance); | |
141 | ||
142 | return 0; | |
143 | } |