It's one of my favourite Rcpp puzzles:
R> cppFunction('bool foo(NumericVector x) { x = 2 * x; return(true); }')
R> x <- 1:4 # note that x is now an int vector
R> foo(x) # so this casts to numeric --> copy
[1] TRUE
R> x
[1] 1 2 3 4 # s
On 08/07/2014 10:05 AM, Greg Minshall wrote:
hi. if i'm reading correctly, "Writing R Extensions" appears to be
inconsistent on the question of whether the arguments passed to a
routine called via .Call() or .External() should considered read-only.
section 5.2, "Interface functions .C and .Fortr
hi. if i'm reading correctly, "Writing R Extensions" appears to be
inconsistent on the question of whether the arguments passed to a
routine called via .Call() or .External() should considered read-only.
section 5.2, "Interface functions .C and .Fortran", says
However, when character vectors
(flagged thread as OT as this is now orthogonal to the OP's question)
On 8 July 2014 at 08:41, Prof J C Nash (U30A) wrote:
| Side comment: At UseR last week, Yihui Xie sat with me and we
| implemented a Fortran language engine for knitr. It looks like a Pascal
| one may also be possible, and mayb
As you dig deeper you will find vmmin.c, cgmin.c and (I think) nmmin.c
etc. Those were, as I understand, converted by p2c from my Pascal codes
that you can find in the pascal library on netlib.org. These can be run
with the Free Pascal compiler.
Given how long ago these were developed (>30 years i
Enrico,
I was in a similar position with a small likelihood function which was not
vectorizable (is that a word?) and in one morning I had a working function
using Rcpp which was 60 times faster than my reference function in R. I
*strongly* recommend that you use C++ through the Rcpp interface whic
I would like to write a fast version of a function which contains slow
loops that I cannot vectorize.
I would like to rewrite it in C, but in the loops I need to call a few
(two) R functions.
Which is the best way to do so? I have read that one can call a C library
which import all the R functions