Commit | Line | Data |
---|---|---|
7b272073 | 1 | #include "EMGLLF.h" |
9ff729fb | 2 | #include "test_utils.h" |
7ea8c1e5 | 3 | #include <stdlib.h> |
7b272073 BA |
4 | |
5 | int main(int argc, char** argv) | |
6 | { | |
7ea8c1e5 BA |
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]; | |
7b272073 BA |
12 | free(dimensions); |
13 | ||
150fa42c BA |
14 | //////////// |
15 | // INPUTS // | |
c3bc4705 BA |
16 | Real* phiInit = readArray_real("phiInit"); |
17 | Real* rhoInit = readArray_real("rhoInit"); | |
18 | Real* piInit = readArray_real("piInit"); | |
19 | Real* gamInit = readArray_real("gamInit"); | |
7ea8c1e5 BA |
20 | int mini = read_int("mini"); |
21 | int maxi = read_int("maxi"); | |
c3bc4705 BA |
22 | Real gamma = read_real("gamma"); |
23 | Real lambda = read_real("lambda"); | |
24 | Real* X = readArray_real("X"); | |
25 | Real* Y = readArray_real("Y"); | |
26 | Real tau = read_real("tau"); | |
27 | //////////// | |
7b272073 BA |
28 | |
29 | ///////////// | |
30 | // OUTPUTS // | |
c3bc4705 BA |
31 | Real* phi = (Real*)malloc(p*m*k*sizeof(Real)); |
32 | Real* rho = (Real*)malloc(m*m*k*sizeof(Real)); | |
33 | Real* pi = (Real*)malloc(k*sizeof(Real)); | |
34 | Real* LLF = (Real*)malloc(maxi*sizeof(Real)); | |
35 | Real* S = (Real*)malloc(p*m*k*sizeof(Real)); | |
8be79c46 | 36 | int* affec = (int*)malloc(n*sizeof(int)); |
7b272073 BA |
37 | ///////////// |
38 | ||
7b272073 BA |
39 | //////////////////// |
40 | // Call to EMGLLF // | |
7b272073 | 41 | EMGLLF_core(phiInit,rhoInit,piInit,gamInit,mini,maxi,gamma,lambda,X,Y,tau, |
8be79c46 | 42 | phi,rho,pi,LLF,S,affec, |
7b272073 | 43 | n,p,m,k); |
c3bc4705 | 44 | //////////////////// |
7b272073 BA |
45 | |
46 | free(phiInit); | |
47 | free(rhoInit); | |
48 | free(piInit); | |
49 | free(gamInit); | |
50 | free(X); | |
51 | free(Y); | |
52 | ||
53 | // Compare to reference outputs | |
c3bc4705 | 54 | Real* ref_phi = readArray_real("phi"); |
7b272073 BA |
55 | compareArray_real("phi", phi, ref_phi, p*m*k); |
56 | free(phi); | |
57 | free(ref_phi); | |
58 | ||
c3bc4705 | 59 | Real* ref_rho = readArray_real("rho"); |
7b272073 BA |
60 | compareArray_real("rho", rho, ref_rho, m*m*k); |
61 | free(rho); | |
62 | free(ref_rho); | |
63 | ||
c3bc4705 | 64 | Real* ref_pi = readArray_real("pi"); |
7b272073 BA |
65 | compareArray_real("pi", pi, ref_pi, k); |
66 | free(pi); | |
67 | free(ref_pi); | |
68 | ||
c3bc4705 | 69 | Real* ref_LLF = readArray_real("LLF"); |
afa07d41 | 70 | compareArray_real("LLF", LLF, ref_LLF, maxi); |
7b272073 BA |
71 | free(LLF); |
72 | free(ref_LLF); | |
73 | ||
c3bc4705 | 74 | Real* ref_S = readArray_real("S"); |
7b272073 BA |
75 | compareArray_real("S", S, ref_S, p*m*k); |
76 | free(S); | |
77 | free(ref_S); | |
78 | ||
8be79c46 BA |
79 | int* ref_affec = readArray_int("affec"); |
80 | compareArray_int("affec", affec, ref_affec, n); | |
81 | free(affec); | |
82 | free(ref_affec); | |
83 | ||
7b272073 BA |
84 | return 0; |
85 | } |