Re: [Rcpp-devel] Persistence of C++ changes in R.

2010-12-23 Thread Cedric Ginestet
Thanks Douglas and Dirk, Just to answer Douglas: No, I didn't get an error message when compiling the cxx.function that I posted yesterday. Regarding the use of clone, is it more time consuming to use this particular command? Cheers, Here are the corrected codes. It now works fine, or rather

Re: [Rcpp-devel] Persistence of C++ changes in R.

2010-12-23 Thread Douglas Bates
On Thu, Dec 23, 2010 at 2:38 AM, Cedric Ginestet wrote: > Thanks Douglas and Dirk, > > Just to answer Douglas: No, I didn't get an error message when compiling the > cxx.function that I posted yesterday. Regarding the use of clone, is it more > time consuming to use this particular command? Yes,

Re: [Rcpp-devel] Persistence of C++ changes in R.

2010-12-23 Thread Dirk Eddelbuettel
Cedric, On 23 December 2010 at 08:38, Cedric Ginestet wrote: | Thanks Douglas and Dirk, | | Just to answer Douglas: No, I didn't get an error message when compiling | the cxx.function that I posted yesterday. Regarding the use of clone, is You really want to revisit your compiler flags. Most

[Rcpp-devel] Cost of function pointer dereferencing

2010-12-23 Thread romain
Hello, Since I've been playing with efficiency of various operators for numeric vectors (+,-,/,*), I'm now looking at other functions such as exp, sqrt, etc ... The way we currently implement exp for vectors requires that we keep a function pointer for the atomic exp and that we dereference th

Re: [Rcpp-devel] Cost of function pointer dereferencing

2010-12-23 Thread Davor Cubranic
I tried using a functor, calling 'exp' in its operator(), and it was even faster than static (albeit very slightly): test replications elapsed relative user.self sys.self user.child 3 functor1 0.465 1.00 0.4640.000 0 1 static1 0.472 1.0

Re: [Rcpp-devel] Cost of function pointer dereferencing

2010-12-23 Thread romain
Le 23 déc. 2010 à 06:54 PM, Davor Cubranic a écrit : > I tried using a functor, calling 'exp' in its operator(), and it was even > faster than static (albeit very slightly): Intriguing. > test replications elapsed relative user.self sys.self user.child > 3 functor1 0.465

Re: [Rcpp-devel] Cost of function pointer dereferencing

2010-12-23 Thread Davor Cubranic
After a bit of googling, I figured out how to write the templated functor. It's very simple: incw <- ' template struct Ftor { inline double operator () (double x) const { return Func(x); } }; Ftor ftor; ' fw <- cxxfunction( , ' double x ; for( int j=0; j<1000; j++){ for( int i=0; i

Re: [Rcpp-devel] Cost of function pointer dereferencing

2010-12-23 Thread Davor Cubranic
On 2010-12-23, at 10:03 AM, rom...@r-enthusiasts.com wrote: >> Maybe you could create a functor for each basic function and use that in a >> common loop implementation. >> >> I also tried templatizing Ftor on the function it delegates to, so that you >> could do something like Ftor(), but I cou