From: Benjamin Goehry Date: Fri, 13 Jan 2017 15:52:16 +0000 (+0100) Subject: ajout tests X-Git-Url: https://git.auder.net/variants/Chakart/css/assets/doc/html/%7B%7B%20pkg.url%20%7D%7D?a=commitdiff_plain;h=f8a1fd7cde94f8bbc9bf85d1d20525568ba92525;p=valse.git ajout tests --- diff --git a/src/test/TEST R/checkOutput.R b/src/test/TEST R/checkOutput.R new file mode 100644 index 0000000..1faddaa --- /dev/null +++ b/src/test/TEST R/checkOutput.R @@ -0,0 +1,10 @@ +checkOutput = function(varName, matrix, refMatrix, tol){ + print('Checking %s\n',varName); + maxError = max(max(max(max(abs(matrix - refMatrix))))); + if(maxError >= tol){ + print('Inaccuracy: max(abs(error)) = %g >= %g\n',maxError,tol) + } + else{ + print('OK\n') + } +} \ No newline at end of file diff --git a/src/test/TEST R/covariance.R b/src/test/TEST R/covariance.R new file mode 100644 index 0000000..2dea7f2 --- /dev/null +++ b/src/test/TEST R/covariance.R @@ -0,0 +1,9 @@ +covariance= function(p,a){ + A = matrix(a, p,p) + for{i in 1:p}{ + for{k in 1:p}{ + A[i,]= A[i,]^abs(i-k) + } + } + return(A=A) +} \ No newline at end of file diff --git a/src/test/TEST R/testEMGLLF.R b/src/test/TEST R/testEMGLLF.R new file mode 100644 index 0000000..c2f109f --- /dev/null +++ b/src/test/TEST R/testEMGLLF.R @@ -0,0 +1,19 @@ +testEMGLLF = function(n,p,m,k, phiInit, rhoInit, gamInit, mini, maxi, gamma, lambda, X, Y, tau, ref_phi, ref_rho, ref_pi, ref_LLf, ref_S){ + testFolder = 'data/' + delimiter = '\n' + + EMG = .Call("EMGLLF_core",phiInit,rhoInit,piInit1,gamInit,mini,maxi,gamma,lambda,X,Y,tau) + phi = EMG$phi + rho = EMG$rho + pi = EMG$pi + LLF = EMG$LLF + S = EMG$S + + + tol = 1e-5; + checkOutput('phi',phi,ref_phi,tol); + checkOutput('rho',rho,ref_rho,tol); + checkOutput('pi',pi,ref_pi,tol); + checkOutput('LLF',LLF,ref_LLF,tol); + checkOutput('S',S,ref_S,tol); +}