fix memory leaks on EMGLLF, test OK for EMGrank
[valse.git] / src / test / test.constructionModelesLassoRank.c
1 #include "constructionModelesLassoRank.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* Pi = readArray_real("Pi");
18 Real* Rho = readArray_real("Rho");
19 int mini = read_int("mini");
20 int maxi = read_int("maxi");
21 Real* X = readArray_real("X");
22 Real* Y = readArray_real("Y");
23 Real tau = read_real("tau");
24 int* A1 = readArray_int("A1");
25 int rangmin = read_int("rangmin");
26 int rangmax = read_int("rangmax");
27 ////////////
28
29 /////////////
30 // OUTPUTS //
31 int Size = (int)pow(rangmax-rangmin+1, k);
32 Real* phi = (Real*)malloc(p*m*k*L*Size*sizeof(Real));
33 Real* llh = (Real*)malloc(L*Size*2*sizeof(Real));
34 /////////////
35
36 /////////////////////////////////////////
37 // Call to constructionModelesLassoMLE //
38 constructionModelesLassoRank_core(
39 Pi,Rho,mini,maxi,X,Y,tau,A1,rangmin,rangmax,
40 phi,llh,
41 n,p,m,k,L);
42 /////////////////////////////////////////
43
44 free(Rho);
45 free(Pi);
46 free(X);
47 free(Y);
48 free(A1);
49
50 // Compare to reference outputs
51 Real* ref_phi = readArray_real("phi");
52 compareArray_real("phi", phi, ref_phi, p*m*k*L*Size);
53 free(phi);
54 free(ref_phi);
55
56 Real* ref_llh = readArray_real("llh");
57 compareArray_real("llh", llh, ref_llh, L*Size*2);
58 free(llh);
59 free(ref_llh);
60
61 return 0;
62 }