search for: recusr

Displaying 2 results from an estimated 2 matches for "recusr".

Did you mean: recur
2006 Aug 24
4
extremely slow recursion in R?
I recently coded a recursion algorithm in R and ir ran a few days without returning any result. So I decided to try a simple case of computing binomial coefficient using recusrive relationship choose(n,k) = choose(n-1, k)+choose(n-1,k-1) I implemented in R and Fortran 90 the same algorithm (code follows). The R code finishes 31 minutes and the Fortran 90 program finishes in 6 seconds. So the Fortran program is 310 times faster. I thus wondered if there is room for speed...
2009 Aug 24
1
Basic Question regarding PROTECT
Hello, Suppose I have the function SEXP foo(){ SEXP s; PROTECT(s=allocVector(...)) .... UNPROTECT(1); return(s) } y=foo() // foo is a recusrive call Q: Am i correct in understanding that one does not need to write PROTECT(y=foo()) ?(and a corresponding unprotect later on) since it is the object that is protected , SEXP is an alias for SEXPREC* and allocVector probably does some memory allocation which does not get freed when foo retur...