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