[R] Problem with C extension
schmidb at ibe.med.uni-muenchen.de
Mon Jan 22 18:00:29 CET 2007
thanks for help and code.
We did a lot of work to speedup our function in R. We have a nested
loop, vectorizing is the fastest way. But there we got a very big matrix
and problems with memory. So we want to stay by loops an speedup with C.
My code is similar to this. (my_c is code from Brian D. Ripley)
SEXP test(SEXP a, SEXP b, SEXP in)
SEXP ans, new;
PROTECT(ans = allocVector(REALSXP, 1));
/* for(j = 0; i < m; j++)*/
for(i = 0; i < n; i++)
/* b= ... ^i ....*j*/
PROTECT(new = allocVector(REALSXP, i+2));
new = my_c(ans,b);
PROTECT(ans = allocVector(REALSXP, i+2));
ans = new;
We get an error by in=1300
Fehler: type mismatch
Is there a possibility to free allocated memory? free(...) does not work.
Is there a possibility to reallocate a vector?
Thanks a lot
More information about the R-help