correction testEMGLLF.R
[valse.git] / src / test / TEST R / testEMGLLF.R
1 testEMGLLF = function(){
2 testFolder = 'data/'
3
4 #get dimensions
5 dimensions = read.table(strcat(testFolder,'dimensions'), header=FALSE)
6 n = dimensions[1]
7 p = dimensions[2]
8 m = dimensions[3]
9 k = dimensions[4]
10
11 #get all input arrays
12 phiInit = read.table(strcat(testFolder,'phiInit'), header=FALSE)
13 rhoInit = read.table(strcat(testFolder,'rhoInit'), header=FALSE)
14 piInit = t(read.table(strcat(testFolder,'piInit'), header=FALSE))
15 gamInit = read.table(strcat(testFolder,'gamInit'), header=FALSE)
16 mini = read.table(strcat(testFolder,'mini'), header=FALSE)
17 maxi = read.table(strcat(testFolder,'maxi'), header=FALSE)
18 gamma = read.table(strcat(testFolder,'gamma'), header=FALSE)
19 lambda = read.table(strcat(testFolder,'lambda'), header=FALSE)
20 X = rread.table(strcat(testFolder,'X'), header=FALSE)
21 Y = read.table(strcat(testFolder,'Y'), header=FALSE)
22 tau = read.table(strcat(testFolder,'tau'), header=FALSE)
23
24 #run EMGLLF.c
25 EMG = .Call("EMGLLF_core",phiInit,rhoInit,piInit1,gamInit,mini,maxi,gamma,lambda,X,Y,tau)
26 phi = EMG$phi
27 rho = EMG$rho
28 pi = EMG$pi
29 LLF = EMG$LLF
30 S = EMG$S
31
32 #get all stored outputs
33 ref_phi =read.table(strcat(testFolder,'phi'), header=FALSE)
34 ref_rho = read.table(strcat(testFolder,'rho'), header=FALSE)
35 ref_pi = read.table(strcat(testFolder,'pi'), header=FALSE)
36 ref_LLF = read.table(strcat(testFolder,'LLF'), header=FALSE)
37 ref_S = read.table(strcat(testFolder,'S'), header=FALSE)
38
39 #check that output correspond to stored output
40 tol = 1e-5;
41 checkOutput('phi',phi,ref_phi,tol);
42 checkOutput('rho',rho,ref_rho,tol);
43 checkOutput('pi',pi,ref_pi,tol);
44 checkOutput('LLF',LLF,ref_LLF,tol);
45 checkOutput('S',S,ref_S,tol);
46 }