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