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