Fix test/ folder: tests of C code run fine now
[valse.git] / test / test.EMGrank.c
CommitLineData
3453829e
BA
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 eps = read_real("eps");
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,eps,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}