-#include <stdio.h>
-
-// nlhs, nrhs: resp. numbers of out and in parameters.
-// plhs: array of out parameters, each being a mxArray
-// plhs: array of in parameters (immutable), each being a mxArray
-//
-// MATLAB translates a call [A,B] = fun(C,D) into mexFunction(2,{A,B},2,{C,D}).
-// Then mxArrayS are adapted to be passed to a regular C function,
-// and the results are translated back to mxArrayS into plhs.
-void mexFunction(int nlhs, mxArray* plhs[],
- int nrhs, const mxArray* prhs[])
-{
- // Basic sanity checks
- if (nrhs!=10)
- mexErrMsgIdAndTxt("select:constructionModelesLassoRank:nrhs","10 inputs required.");
- if (nlhs!=2)
- mexErrMsgIdAndTxt("select:constructionModelesLassoRank:nlhs","3 outputs required.");
-
- // Get matrices dimensions, to be given to main routine above
- const mwSize n = mxGetDimensions(prhs[4])[0];
- const mwSize p = mxGetDimensions(prhs[4])[1];
- const mwSize m = mxGetDimensions(prhs[1])[0];
- const mwSize k = mxGetDimensions(prhs[1])[2];
- const mwSize L = mxGetDimensions(prhs[7])[1];
+SEXP EMGLLF(
+ SEXP Pi_,
+ SEXP Rho_,
+ SEXP mini_,
+ SEXP maxi_,
+ SEXP X_,
+ SEXP Y_,
+ SEXP tau_,
+ SEXP A1_,
+ SEXP rangmin_,
+ SEXP rangmax
+) {
+ // Get matrices dimensions
+ SEXP dimX = getAttrib(X_, R_DimSymbol);
+ int n = INTEGER(dimX)[0];
+ int p = INTEGER(dimX)[1];
+ SEXP dimRho = getAttrib(Rho_, R_DimSymbol)
+ int m = INTEGER(dimRho)[0];
+ int k = INTEGER(dimRho)[2];
+ int L = INTEGER(getAttrib(A1_, R_DimSymbol))[1];