projects
/
valse.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix EMGLLF.c (there was one extra iteration)
[valse.git]
/
pkg
/
src
/
sources
/
EMGLLF.c
diff --git
a/pkg/src/sources/EMGLLF.c
b/pkg/src/sources/EMGLLF.c
index
4ceb3e3
..
d2f5a8e
100644
(file)
--- a/
pkg/src/sources/EMGLLF.c
+++ b/
pkg/src/sources/EMGLLF.c
@@
-4,7
+4,7
@@
#include <gsl/gsl_linalg.h>
// TODO: don't recompute indexes ai(...) and mi(...) when possible
#include <gsl/gsl_linalg.h>
// TODO: don't recompute indexes ai(...) and mi(...) when possible
-void EMGLL
H
_core(
+void EMGLL
F
_core(
// IN parameters
const Real* phiInit, // parametre initial de moyenne renormalisé
const Real* rhoInit, // parametre initial de variance renormalisé
// IN parameters
const Real* phiInit, // parametre initial de moyenne renormalisé
const Real* rhoInit, // parametre initial de variance renormalisé
@@
-61,7
+61,7
@@
void EMGLLH_core(
Real* Rho = (Real*)malloc(m*m*k*sizeof(Real));
Real* Pi = (Real*)malloc(k*sizeof(Real));
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);
{
copyArray(phi, Phi, p*m*k);
copyArray(rho, Rho, m*m*k);
@@
-261,6
+261,7
@@
void EMGLLH_core(
/////////////
// Precompute det(rho[,,r]) for r in 1...k
/////////////
// Precompute det(rho[,,r]) for r in 1...k
+ int signum;
for (int r=0; r<k; r++)
{
for (int u=0; u<m; u++)
for (int r=0; r<k; r++)
{
for (int u=0; u<m; u++)
@@
-272,7
+273,6
@@
void EMGLLH_core(
detRho[r] = gsl_linalg_LU_det(matrix, signum);
}
detRho[r] = gsl_linalg_LU_det(matrix, signum);
}
- int signum;
Real sumLogLLH = 0.;
for (int i=0; i<n; i++)
{
Real sumLogLLH = 0.;
for (int i=0; i<n; i++)
{
@@
-322,7
+322,7
@@
void EMGLLH_core(
Real last_llh = *llh;
//llh = -sumLogLLH/n + lambda*sumPen
*llh = -invN * sumLogLLH + lambda * sumPen;
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.;
//Dist1 = max( abs(phi-Phi) / (1+abs(phi)) )
Real Dist1 = 0.;
@@
-399,6
+399,7
@@
void EMGLLH_core(
free(Pi);
free(Gram2);
free(ps2);
free(Pi);
free(Gram2);
free(ps2);
+ free(detRho);
gsl_matrix_free(matrix);
gsl_permutation_free(permutation);
free(XiPhiR);
gsl_matrix_free(matrix);
gsl_permutation_free(permutation);
free(XiPhiR);