Commit | Line | Data |
---|---|---|
7b272073 BA |
1 | #include "EMGrank.h" |
2 | #include "ioutils.h" | |
3 | ||
4 | int main(int argc, char** argv) | |
5 | { | |
6 | // read dimensions | |
7 | const Int nbDims = 4; | |
8 | Int* dimensions = readArray_int("dimensions",&nbDims,1); | |
9 | mwSize n = dimensions[0]; | |
10 | mwSize p = dimensions[1]; | |
11 | mwSize m = dimensions[2]; | |
12 | mwSize k = dimensions[3]; | |
13 | free(dimensions); | |
14 | mwSize lengthOne = 1; | |
15 | ||
16 | //////////// | |
17 | // INPUTS // | |
18 | //////////// | |
19 | ||
20 | // Rho | |
21 | const mwSize dimRho[] = {m, m, k}; | |
22 | Real* Rho = readArray_real("Rho",dimRho,3); | |
23 | ||
24 | // Pi | |
25 | Real* Pi = readArray_real("Pi",&k,1); | |
26 | ||
27 | // min number of iterations | |
28 | Int* pmini = readArray_int("mini",&lengthOne,1); | |
29 | Int mini = *pmini; | |
30 | free(pmini); | |
31 | ||
32 | // max number of iterations | |
33 | Int* pmaxi = readArray_int("maxi",&lengthOne,1); | |
34 | Int maxi = *pmaxi; | |
35 | free(pmaxi); | |
36 | ||
37 | // X | |
38 | const mwSize dimX[] = {n, p}; | |
39 | Real* X = readArray_real("X",dimX, 2); | |
40 | ||
41 | // Y | |
42 | const mwSize dimY[] = {n, m}; | |
43 | Real* Y = readArray_real("Y",dimY, 2); | |
44 | ||
45 | // tau | |
46 | Real* ptau = readArray_real("tau",&lengthOne,1); | |
47 | Real tau = *ptau; | |
48 | free(ptau); | |
49 | ||
50 | // tau | |
51 | Int* rank = readArray_int("rank",&k,1); | |
52 | ||
53 | ///////////// | |
54 | // OUTPUTS // | |
55 | ///////////// | |
56 | ||
57 | // phi | |
58 | const mwSize dimPhi[] = {p, m, k}; | |
59 | Real* phi = (Real*)malloc(dimPhi[0]*dimPhi[1]*dimPhi[2]*sizeof(Real)); | |
60 | ||
61 | // LLF | |
62 | Real* LLF = (Real*)malloc(1*sizeof(Real)); | |
63 | ||
64 | ////////////////////////// | |
65 | // Main call to EMGrank // | |
66 | ////////////////////////// | |
67 | ||
68 | EMGrank(Pi,Rho,mini,maxi,X,Y,tau,rank, | |
69 | phi,LLF, | |
70 | n,p,m,k); | |
71 | ||
72 | // free input pointers | |
73 | free(Rho); | |
74 | free(Pi); | |
75 | free(X); | |
76 | free(Y); | |
77 | free(rank); | |
78 | ||
79 | // Compare to reference outputs | |
80 | Real* ref_phi = readArray_real("phi",dimPhi, 3); | |
81 | compareArray_real("phi", phi, ref_phi, dimPhi[0]*dimPhi[1]*dimPhi[2]); | |
82 | free(phi); | |
83 | free(ref_phi); | |
84 | ||
85 | // LLF | |
86 | Real* ref_LLF = readArray_real("LLF",&lengthOne,1); | |
87 | compareArray_real("LLF", LLF, ref_LLF, 1); | |
88 | free(LLF); | |
89 | free(ref_LLF); | |
90 | ||
91 | return 0; | |
92 | } |