write test.EMGrank.c
[valse.git] / src / test / test.EMGrank.c
1 #include "EMGrank.h"
2 #include "utils.h"
3
4 int main(int argc, char** argv)
5 {
6 int* dimensions = readArray_int("dimensions");
7 int n = dimensions[0];
8 int p = dimensions[1];
9 int m = dimensions[2];
10 int k = dimensions[3];
11 free(dimensions);
12
13 ////////////
14 // INPUTS //
15 ////////////
16
17 float* Rho = readArray_real("Rho");
18 float* Pi = readArray_real("Pi");
19 int mini = read_int("mini");
20 int maxi = read_int("maxi");
21 float* X = readArray_real("X");
22 float* Y = readArray_real("Y");
23 float tau = read_real("tau");
24 int* rank = readArray_int("rank");
25
26 /////////////
27 // OUTPUTS //
28 /////////////
29
30 float* phi = (float*)malloc(p*m*k*sizeof(float));
31 float* LLF = (float*)malloc(1*sizeof(float));
32
33 //////////////////////////
34 // Main call to EMGrank //
35 //////////////////////////
36
37 EMGrank(Pi,Rho,mini,maxi,X,Y,tau,rank,
38 phi,LLF,
39 n,p,m,k);
40
41 free(Rho);
42 free(Pi);
43 free(X);
44 free(Y);
45 free(rank);
46
47 // Compare to reference outputs
48 float* ref_phi = readArray_real("phi");
49 compareArray_real("phi", phi, ref_phi, p*m*k);
50 free(phi);
51 free(ref_phi);
52
53 // LLF
54 float* ref_LLF = readArray_real("LLF");
55 compareArray_real("LLF", LLF, ref_LLF, 1);
56 free(LLF);
57 free(ref_LLF);
58
59 return 0;
60 }