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