Commit | Line | Data |
---|---|---|
7b272073 | 1 | #include "constructionModelesLassoRank.h" |
9ff729fb | 2 | #include "test_utils.h" |
7b272073 BA |
3 | |
4 | int main(int argc, char** argv) | |
5 | { | |
6 | // read dimensions | |
7ea8c1e5 BA |
7 | const int nbDims = 5; |
8 | int* dimensions = readArray_int("dimensions",&nbDims,1); | |
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); |
7ea8c1e5 | 15 | int lengthOne = 1; |
7b272073 BA |
16 | |
17 | //////////// | |
18 | // INPUTS // | |
19 | //////////// | |
20 | ||
21 | // piInit | |
7ea8c1e5 BA |
22 | const int dimPi[] = {k, L}; |
23 | float* Pi = readArray_real("Pi",dimPi,2); | |
7b272073 BA |
24 | |
25 | // rhoInit | |
7ea8c1e5 BA |
26 | const int dimRho[] = {m, m, k, L}; |
27 | float* Rho = readArray_real("Rho",dimRho,4); | |
7b272073 BA |
28 | |
29 | // min number of iterations | |
7ea8c1e5 BA |
30 | int* pmini = readArray_int("mini",&lengthOne,1); |
31 | int mini = *pmini; | |
7b272073 BA |
32 | free(pmini); |
33 | ||
34 | // max number of iterations | |
7ea8c1e5 BA |
35 | int* pmaxi = readArray_int("maxi",&lengthOne,1); |
36 | int maxi = *pmaxi; | |
7b272073 BA |
37 | free(pmaxi); |
38 | ||
39 | // X | |
7ea8c1e5 BA |
40 | const int dimX[] = {n, p}; |
41 | float* X = readArray_real("X",dimX,2); | |
7b272073 BA |
42 | |
43 | // Y | |
7ea8c1e5 BA |
44 | const int dimY[] = {n, m}; |
45 | float* Y = readArray_real("Y",dimY,2); | |
7b272073 BA |
46 | |
47 | // tau | |
7ea8c1e5 BA |
48 | float* ptau = readArray_real("tau",&lengthOne,1); |
49 | float tau = *ptau; | |
7b272073 BA |
50 | free(ptau); |
51 | ||
52 | // A1 | |
7ea8c1e5 BA |
53 | const int dimA[] = {p, L}; |
54 | int* A1 = readArray_int("A1",dimA,2); | |
7b272073 BA |
55 | |
56 | // rangmin | |
7ea8c1e5 BA |
57 | int* prangmin = readArray_int("rangmin",&lengthOne,1); |
58 | int rangmin = *prangmin; | |
7b272073 BA |
59 | free(prangmin); |
60 | ||
61 | // rangmax | |
7ea8c1e5 BA |
62 | int* prangmax = readArray_int("rangmax",&lengthOne,1); |
63 | int rangmax = *prangmax; | |
7b272073 BA |
64 | free(prangmax); |
65 | ||
66 | ///////////// | |
67 | // OUTPUTS // | |
68 | ///////////// | |
69 | ||
70 | // phi | |
7ea8c1e5 BA |
71 | int Size = (int)pow(rangmax-rangmin+1, k); |
72 | const int dimPhi[] = {p, m, k, L*Size}; | |
73 | float* phi = (float*)malloc(dimPhi[0]*dimPhi[1]*dimPhi[2]*dimPhi[3]*sizeof(float)); | |
7b272073 BA |
74 | |
75 | // lvraisemblance | |
7ea8c1e5 BA |
76 | const int dimLvraisemblance[] = {L*Size, 2}; |
77 | float* lvraisemblance = (float*)malloc(dimLvraisemblance[0]*dimLvraisemblance[1]*sizeof(float)); | |
7b272073 BA |
78 | |
79 | ////////////////////////////////////////////// | |
80 | // Main call to constructionModelesLassoMLE // | |
81 | ////////////////////////////////////////////// | |
82 | ||
83 | constructionModelesLassoRank( | |
84 | Pi,Rho,mini,maxi,X,Y,tau,A1,rangmin,rangmax, | |
85 | phi,lvraisemblance, | |
86 | n,p,m,k,L); | |
87 | ||
88 | free(Rho); | |
89 | free(Pi); | |
90 | free(X); | |
91 | free(Y); | |
92 | free(A1); | |
93 | ||
94 | // Compare to reference outputs | |
7ea8c1e5 | 95 | float* ref_phi = readArray_real("phi",dimPhi, 4); |
7b272073 BA |
96 | compareArray_real("phi", phi, ref_phi, dimPhi[0]*dimPhi[1]*dimPhi[2]*dimPhi[3]); |
97 | free(phi); | |
98 | free(ref_phi); | |
99 | ||
100 | // lvraisemblance | |
7ea8c1e5 | 101 | float* ref_lvraisemblance = readArray_real("lvraisemblance",dimLvraisemblance,2); |
7b272073 BA |
102 | compareArray_real("lvraisemblance", lvraisemblance, ref_lvraisemblance, dimLvraisemblance[0]*dimLvraisemblance[1]); |
103 | free(lvraisemblance); | |
104 | free(ref_lvraisemblance); | |
105 | ||
106 | return 0; | |
107 | } |