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