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