| 1 | #include "EMGLLF.h" |
| 2 | #include "utils.h" |
| 3 | #include <stdlib.h> |
| 4 | |
| 5 | int 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 | //////////// |
| 17 | |
| 18 | float* phiInit = readArray_real("phiInit"); |
| 19 | float* rhoInit = readArray_real("rhoInit"); |
| 20 | float* piInit = readArray_real("piInit"); |
| 21 | float* gamInit = readArray_real("gamInit"); |
| 22 | int mini = read_int("mini"); |
| 23 | int maxi = read_int("maxi"); |
| 24 | float gamma = read_real("gamma"); |
| 25 | float lambda = read_real("lambda"); |
| 26 | float* X = readArray_real("X"); |
| 27 | float* Y = readArray_real("Y"); |
| 28 | float tau = read_real("tau"); |
| 29 | |
| 30 | ///////////// |
| 31 | // OUTPUTS // |
| 32 | ///////////// |
| 33 | |
| 34 | float* phi = (float*)malloc(p*m*k*sizeof(float)); |
| 35 | float* rho = (float*)malloc(m*m*k*sizeof(float)); |
| 36 | float* pi = (float*)malloc(k*sizeof(float)); |
| 37 | float* LLF = (float*)malloc(maxi*sizeof(float)); |
| 38 | float* S = (float*)malloc(p*m*k*sizeof(float)); |
| 39 | |
| 40 | //////////////////// |
| 41 | // Call to EMGLLF // |
| 42 | //////////////////// |
| 43 | |
| 44 | EMGLLF_core(phiInit,rhoInit,piInit,gamInit,mini,maxi,gamma,lambda,X,Y,tau, |
| 45 | phi,rho,pi,LLF,S, |
| 46 | n,p,m,k); |
| 47 | |
| 48 | free(phiInit); |
| 49 | free(rhoInit); |
| 50 | free(piInit); |
| 51 | free(gamInit); |
| 52 | free(X); |
| 53 | free(Y); |
| 54 | |
| 55 | // Compare to reference outputs |
| 56 | float* ref_phi = readArray_real("phi"); |
| 57 | compareArray_real("phi", phi, ref_phi, p*m*k); |
| 58 | free(phi); |
| 59 | free(ref_phi); |
| 60 | |
| 61 | float* ref_rho = readArray_real("rho"); |
| 62 | compareArray_real("rho", rho, ref_rho, m*m*k); |
| 63 | free(rho); |
| 64 | free(ref_rho); |
| 65 | |
| 66 | float* ref_pi = readArray_real("pi"); |
| 67 | compareArray_real("pi", pi, ref_pi, k); |
| 68 | free(pi); |
| 69 | free(ref_pi); |
| 70 | |
| 71 | float* ref_LLF = readArray_real("LLF"); |
| 72 | compareArray_real("LLF", LLF, ref_LLF, maxi); |
| 73 | free(LLF); |
| 74 | free(ref_LLF); |
| 75 | |
| 76 | float* ref_S = readArray_real("S"); |
| 77 | compareArray_real("S", S, ref_S, p*m*k); |
| 78 | free(S); |
| 79 | free(ref_S); |
| 80 | |
| 81 | return 0; |
| 82 | } |