From: Benjamin Auder <benjamin.auder@somewhere> Date: Tue, 11 Apr 2017 13:10:52 +0000 (+0200) Subject: fix EMGLLF.c (there was one extra iteration) X-Git-Url: https://git.auder.net/variants/Chakart/pieces/current/css/DESCRIPTION?a=commitdiff_plain;h=9a73b9662b16a990370ac5142bf4cf1f782d801f;p=valse.git fix EMGLLF.c (there was one extra iteration) --- diff --git a/pkg/src/sources/EMGLLF.c b/pkg/src/sources/EMGLLF.c index a57a379..d2f5a8e 100644 --- a/pkg/src/sources/EMGLLF.c +++ b/pkg/src/sources/EMGLLF.c @@ -61,7 +61,7 @@ void EMGLLF_core( Real* Rho = (Real*)malloc(m*m*k*sizeof(Real)); Real* Pi = (Real*)malloc(k*sizeof(Real)); - for (int ite=0; ite<maxi; ite++) + for (int ite=1; ite<=maxi; ite++) { copyArray(phi, Phi, p*m*k); copyArray(rho, Rho, m*m*k); @@ -322,7 +322,7 @@ void EMGLLF_core( Real last_llh = *llh; //llh = -sumLogLLH/n + lambda*sumPen *llh = -invN * sumLogLLH + lambda * sumPen; - Real dist = ite==0 ? *llh : (*llh - last_llh) / (1. + fabs(*llh)); + Real dist = ite==1 ? *llh : (*llh - last_llh) / (1. + fabs(*llh)); //Dist1 = max( abs(phi-Phi) / (1+abs(phi)) ) Real Dist1 = 0.; @@ -399,6 +399,7 @@ void EMGLLF_core( free(Pi); free(Gram2); free(ps2); + free(detRho); gsl_matrix_free(matrix); gsl_permutation_free(permutation); free(XiPhiR); diff --git a/test/generateRunSaveTest_EMGLLF.R b/test/generateRunSaveTest_EMGLLF.R index bf37b5f..8b3f4c1 100644 --- a/test/generateRunSaveTest_EMGLLF.R +++ b/test/generateRunSaveTest_EMGLLF.R @@ -4,7 +4,7 @@ library(valse) generateRunSaveTest_EMGLLF = function(n=200, p=15, m=10, k=3, mini=5, maxi=10, gamma=1., lambda=0.5, tau=1e-6) { - testFolder = "../data/" + testFolder = "data/" dir.create(testFolder, showWarnings=FALSE, mode="0755") params = basicInitParameters(n, p, m, k)