un peu de nettoyage, mais rien de fou
[valse.git] / src / test / test.selectiontotale.c
1 #include "selectiontotale.h"
2 #include "test_utils.h"
3 #include <stdlib.h>
4
5 int main(int argc, char** argv)
6 {
7 int* dimensions = readArray_int("dimensions");
8 int n = dimensions[0];
9 int p = dimensions[1];
10 int m = dimensions[2];
11 int k = dimensions[3];
12 int L = dimensions[4];
13 free(dimensions);
14
15 ////////////
16 // INPUTS //
17 Real* phiInit = readArray_real("phiInit");
18 Real* rhoInit = readArray_real("rhoInit");
19 Real* piInit = readArray_real("piInit");
20 Real* gamInit = readArray_real("gamInit");
21 int mini = read_int("mini");
22 int maxi = read_int("maxi");
23 Real gamma = read_real("gamma");
24 Real* glambda = readArray_real("glambda");
25 Real* X = readArray_real("X");
26 Real* Y = readArray_real("Y");
27 Real seuil = read_real("seuil");
28 Real tau = read_real("tau");
29 ////////////
30
31 /////////////
32 // OUTPUTS //
33 int* A1 = (int*)malloc(p*(m+1)*L*sizeof(int));
34 int* A2 = (int*)malloc(p*(m+1)*L*sizeof(int));
35 Real* Rho = (Real*)malloc(m*m*k*L*sizeof(Real));
36 Real* Pi = (Real*)malloc(k*L*sizeof(Real));
37 /////////////
38
39 /////////////////////////////////////////
40 // Call to constructionModelesLassoMLE //
41 selectiontotale_core(
42 phiInit,rhoInit,piInit,gamInit,mini,maxi,gamma,glambda,X,Y,seuil,tau,
43 A1,A2,Rho,Pi,
44 n,p,m,k,L);
45 /////////////////////////////////////////
46
47 free(phiInit);
48 free(rhoInit);
49 free(piInit);
50 free(gamInit);
51 free(glambda);
52 free(X);
53 free(Y);
54
55 // Compare to reference outputs
56 int* ref_A1 = readArray_int("A1");
57 compareArray_int("A1", A1, ref_A1, p*(m+1)*L);
58 free(A1);
59 free(ref_A1);
60
61 int* ref_A2 = readArray_int("A2");
62 compareArray_int("A2", A2, ref_A2, p*(m+1)*L);
63 free(A2);
64 free(ref_A2);
65
66 Real* ref_Rho = readArray_real("Rho");
67 compareArray_real("Rho", Rho, ref_Rho, m*m*k*L);
68 free(Rho);
69 free(ref_Rho);
70
71 Real* ref_Pi = readArray_real("Pi");
72 compareArray_real("Pi", Pi, ref_Pi, k*L);
73 free(Pi);
74 free(ref_Pi);
75
76 return 0;
77 }