move selectiontotale to appropriate folder (untranslated)
[valse.git] / src / test / test.constructionModelesLassoRank.c
1 #include "constructionModelesLassoRank.h"
2 #include "test_utils.h"
3 #include <stdlib.h>
4 #include <math.h>
5
6 int main(int argc, char** argv)
7 {
8 int* dimensions = readArray_int("dimensions");
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];
14 free(dimensions);
15
16 ////////////
17 // INPUTS //
18 Real* pi = readArray_real("pi");
19 Real* rho = readArray_real("rho");
20 int mini = read_int("mini");
21 int maxi = read_int("maxi");
22 Real* X = readArray_real("X");
23 Real* Y = readArray_real("Y");
24 Real tau = read_real("tau");
25 int* A1 = readArray_int("A1");
26 int rangmin = read_int("rangmin");
27 int rangmax = read_int("rangmax");
28 ////////////
29
30 /////////////
31 // OUTPUTS //
32 int Size = (int)pow(rangmax-rangmin+1, k);
33 Real* phi = (Real*)malloc(p*m*k*L*Size*sizeof(Real));
34 Real* llh = (Real*)malloc(L*Size*2*sizeof(Real));
35 /////////////
36
37 /////////////////////////////////////////
38 // Call to constructionModelesLassoMLE //
39 constructionModelesLassoRank_core(
40 pi,rho,mini,maxi,X,Y,tau,A1,rangmin,rangmax,
41 phi,llh,
42 n,p,m,k,L);
43 /////////////////////////////////////////
44
45 free(rho);
46 free(pi);
47 free(X);
48 free(Y);
49 free(A1);
50
51 // Compare to reference outputs
52 Real* ref_phi = readArray_real("phi");
53 compareArray_real("phi", phi, ref_phi, p*m*k*L*Size);
54 free(phi);
55 free(ref_phi);
56
57 Real* ref_llh = readArray_real("llh");
58 compareArray_real("llh", llh, ref_llh, L*Size*2);
59 free(llh);
60 free(ref_llh);
61
62 return 0;
63 }