3 #include "selectiontotale.h"
19 // Get matrices dimensions
20 SEXP dimX
= getAttrib(X_
, R_DimSymbol
);
21 int n
= INTEGER(dimX
)[0];
22 int p
= INTEGER(dimX
)[1];
23 SEXP dimRhoInit
= getAttrib(rhoInit_
, R_DimSymbol
);
24 int m
= INTEGER(dimRhoInit
)[0];
25 int k
= INTEGER(dimRhoInit
)[2];
26 int L
= length(glambda_
);
32 // get scalar parameters
33 int mini
= INTEGER_VALUE(mini_
);
34 int maxi
= INTEGER_VALUE(maxi_
);
35 double gamma
= NUMERIC_VALUE(gamma_
);
36 double seuil
= NUMERIC_VALUE(seuil_
);
37 double tau
= NUMERIC_VALUE(tau_
);
39 // Get pointers from SEXP arrays ; WARNING: by columns !
40 double* phiInit
= REAL(phiInit_
);
41 double* rhoInit
= REAL(rhoInit_
);
42 double* piInit
= REAL(piInit_
);
43 double* gamInit
= REAL(gamInit_
);
44 double* glambda
= REAL(glambda_
);
52 SEXP A1
, A2
, rho
, pi
, dimA
, dimRho
;
53 PROTECT(dimA
= allocVector(INTSXP
, 3));
54 int* pDimA
= INTEGER(dimA
);
55 pDimA
[0] = p
; pDimA
[1] = m
+1; pDimA
[2] = L
;
56 PROTECT(A1
= allocArray(INTSXP
, dimA
));
57 PROTECT(A2
= allocArray(INTSXP
, dimA
));
58 PROTECT(dimRho
= allocVector(INTSXP
, 4));
59 int* pDimRho
= INTEGER(dimRho
);
60 pDimRho
[0] = m
; pDimRho
[1] = m
; pDimRho
[2] = k
; pDimRho
[3] = L
;
61 PROTECT(rho
= allocArray(REALSXP
, dimRho
));
62 PROTECT(pi
= allocMatrix(REALSXP
, k
, L
));
63 int *pA1
=INTEGER(A1
), *pA2
=INTEGER(A2
);
64 double *pRho
=REAL(rho
), *pPi
=REAL(pi
);
66 /////////////////////////////
67 // Call to selectiontotale //
68 /////////////////////////////
71 phiInit
,rhoInit
,piInit
,gamInit
,mini
,maxi
,gamma
,glambda
,X
,Y
,seuil
,tau
,
75 // Build list from OUT params and return it
76 SEXP listParams
, listNames
;
77 PROTECT(listParams
= allocVector(VECSXP
, 4));
78 char* lnames
[4] = { "A1", "A2", "rho", "pi" }; //lists labels
79 PROTECT(listNames
= allocVector(STRSXP
, 4));
80 for (int i
=0; i
<4; i
++)
81 SET_STRING_ELT(listNames
,i
,mkChar(lnames
[i
]));
82 setAttrib(listParams
, R_NamesSymbol
, listNames
);
83 SET_VECTOR_ELT(listParams
, 0, A1
);
84 SET_VECTOR_ELT(listParams
, 1, A2
);
85 SET_VECTOR_ELT(listParams
, 2, rho
);
86 SET_VECTOR_ELT(listParams
, 3, pi
);