3 #include "constructionModelesLassoRank.h"
5 SEXP
constructionModelesLassoRank(
17 // Get matrices dimensions
18 SEXP dimX
= getAttrib(X_
, R_DimSymbol
);
19 int n
= INTEGER(dimX
)[0];
20 int p
= INTEGER(dimX
)[1];
21 SEXP dimRho
= getAttrib(Rho_
, R_DimSymbol
);
22 int m
= INTEGER(dimRho
)[0];
23 int k
= INTEGER(dimRho
)[2];
24 int L
= INTEGER(getAttrib(A1_
, R_DimSymbol
))[1];
30 // get scalar parameters
31 int mini
= INTEGER_VALUE(mini_
);
32 int maxi
= INTEGER_VALUE(maxi_
);
33 double tau
= NUMERIC_VALUE(tau_
);
34 double rangmin
= NUMERIC_VALUE(rangmin_
);
35 double rangmax
= NUMERIC_VALUE(rangmax_
);
37 // Get pointers from SEXP arrays ; WARNING: by columns !
38 double* Pi
= REAL(Pi_
);
39 double* Rho
= REAL(Rho_
);
42 int* A1
= INTEGER(A1_
);
48 int Size
= pow(rangmax
-rangmin
+1,k
);
49 SEXP phi
, lvraisemblance
, dimPhi
;
50 PROTECT(dimPhi
= allocVector(INTSXP
, 4));
51 int* pDimPhi
= INTEGER(dimPhi
);
52 pDimPhi
[0] = p
; pDimPhi
[1] = m
; pDimPhi
[2] = k
; pDimPhi
[3] = L
*Size
;
53 PROTECT(phi
= allocArray(REALSXP
, dimPhi
));
54 PROTECT(lvraisemblance
= allocMatrix(REALSXP
, L
*Size
, 2));
55 double *pPhi
=REAL(phi
), *pLvraisemblance
=REAL(lvraisemblance
);
57 //////////////////////////////////////////
58 // Call to constructionModelesLassoRank //
59 //////////////////////////////////////////
61 constructionModelesLassoRank_core(
62 Pi
,Rho
,mini
,maxi
,X
,Y
,tau
,A1
,rangmin
,rangmax
,
66 // Build list from OUT params and return it
67 SEXP listParams
, listNames
;
68 PROTECT(listParams
= allocVector(VECSXP
, 2));
69 char* lnames
[2] = {"phi", "lvraisemblance"}; //lists labels
70 PROTECT(listNames
= allocVector(STRSXP
,2));
71 for (int i
=0; i
<2; i
++)
72 SET_STRING_ELT(listNames
,i
,mkChar(lnames
[i
]));
73 setAttrib(listParams
, R_NamesSymbol
, listNames
);
74 SET_VECTOR_ELT(listParams
, 0, phi
);
75 SET_VECTOR_ELT(listParams
, 1, lvraisemblance
);