'update'
[valse.git] / test / test.EMGrank.c
... / ...
CommitLineData
1#include "EMGrank.h"
2#include "test_utils.h"
3#include <stdlib.h>
4
5int 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 free(dimensions);
13
14 ////////////
15 // INPUTS //
16 Real* rho = readArray_real("rho");
17 Real* pi = readArray_real("pi");
18 int mini = read_int("mini");
19 int maxi = read_int("maxi");
20 Real* X = readArray_real("X");
21 Real* Y = readArray_real("Y");
22 Real tau = read_real("tau");
23 int* rank = readArray_int("rank");
24 ////////////
25
26 /////////////
27 // OUTPUTS //
28 Real* phi = (Real*)malloc(p*m*k*sizeof(Real));
29 Real* LLF = (Real*)malloc(1*sizeof(Real));
30 /////////////
31
32 //////////////////////////
33 // Main call to EMGrank //
34 EMGrank_core(pi,rho,mini,maxi,X,Y,tau,rank,
35 phi,LLF,
36 n,p,m,k);
37 //////////////////////////
38
39 free(rho);
40 free(pi);
41 free(X);
42 free(Y);
43 free(rank);
44
45 // Compare to reference outputs
46 Real* ref_phi = readArray_real("phi");
47 compareArray_real("phi", phi, ref_phi, p*m*k);
48 free(phi);
49 free(ref_phi);
50
51 // LLF
52 Real* ref_LLF = readArray_real("LLF");
53 compareArray_real("LLF", LLF, ref_LLF, 1);
54 free(LLF);
55 free(ref_LLF);
56
57 return 0;
58}