Displaying 1 result from an estimated 1 matches for "change_veca".
2011 Nov 17
3
.Call in R
...g;
vecR<-runif(10000);
if (sum(vecR)>=5000)){
vecA<-vecR;
}
Now my question is, if I am going to do the same thing in R using .Call.
How can I achieve it in a more efficient way (i.e. less computation time
compared with pure R code above.). My c code (called "change_vecA.c") using
.Call is like this:
SEXP change_vecA(SEXP vecA){
int i,vecA_len;
double sum,*res_ptr,*vecR_ptr,*vecA_ptr;
vecA_ptr=REAL(vecA);
vecA_len=length(vecA);
SEXP res_vec,vecR;
PROTECT(res_vec=allocVector(REALSXP, vec_len));...