# regression data (size n*p, where n is the number of observations,
                # and p is the number of regressors)
-               X = "numeric",
+               X = "matrix",
                # response data (size n*m, where n is the number of observations,
                # and m is the number of responses)
-               Y = "numeric",
+               Y = "matrix",
 
                # Optionally user defined (some default values)
 
 
                                {
                                        YiRhoR[u] = 0.0;
                                        for (int v=0; v<m; v++)
-                                               YiRhoR[u] += Y[imi(i,v,n,m)] * rho[ai(v,u,r,m,m,k)];
+                                               YiRhoR[u] += Y[mi(i,v,n,m)] * rho[ai(v,u,r,m,m,k)];
                                }
 
                                //compute X(i,:)*phi(:,:,r)
 
 #include <stdlib.h>
 #include <omp.h>
+#include <math.h>
 #include "EMGLLF.h"
 #include "utils.h"
 
                double* pi = (double*)malloc(k*sizeof(double));
                double* LLF = (double*)malloc(maxi*sizeof(double));
                double* S = (double*)malloc(p*m*k*sizeof(double));
-               EMGLLF(phiInit,rhoInit,piInit,gamInit,mini,maxi,gamma,glambda[lambdaIndex],X,Y,tau,
+               EMGLLF_core(phiInit,rhoInit,piInit,gamInit,mini,maxi,gamma,glambda[lambdaIndex],X,Y,tau,
                        phi,rho,pi,LLF,S,
                        n,p,m,k);
                free(LLF);