Re: [Rcpp-devel] Inline, templates, and easy debugging

2012-11-21 Thread John Merrill
I agree. As I said in the original note, I use inline as a development tool. The point is to be able to develop Rcpp components for packages in a structured fashion which makes the test and develop cycle faster. On Wed, Nov 21, 2012 at 8:00 PM, Dirk Eddelbuettel wrote: > > On 21 November 2012 a

Re: [Rcpp-devel] Inline, templates, and easy debugging

2012-11-21 Thread Dirk Eddelbuettel
On 21 November 2012 at 18:59, John Merrill wrote: | Is there a way to do this using inline? Maybe. I tend to write packages. That is the way we documented, and still recommend. Dirk -- Dirk Eddelbuettel | e...@debian.org | http://dirk.eddelbuettel.com __

Re: [Rcpp-devel] Rcpp 0.10

2012-11-21 Thread JJ Allaire
> All to say, it is unclear to me whether the intended use of > compileAttributes() is solely to help package writers allow package users > to more easily access the c++ functions at the R layer or additionally to > also streamline how package developers source c++ files within their own > package

[Rcpp-devel] Inline, templates, and easy debugging

2012-11-21 Thread John Merrill
tl;dr summary -- is there a way to incorporate multiple functions into an inline call? Specifically, is there a way to include a templated function in an inline compilation? Consider the following outline: template void InsertTypedVector } RcppExport SEXP ExposedFunction(SEXP r_foobar) { Dat

Re: [Rcpp-devel] Rcpp 0.10

2012-11-21 Thread Dirk Eddelbuettel
On 21 November 2012 at 18:36, terrance savitsky wrote: | Hi,  I've read this note a few times and still find myself similarly confused. Maybe you could take a look at the seven page vignette 'Rcpp-attribute' which came with your copy of Rcpp 0.10.0. It should answers these questions of yours.

Re: [Rcpp-devel] Rcpp 0.10

2012-11-21 Thread terrance savitsky
Hi, I've read this note a few times and still find myself similarly confused. Does the new compileAttributes() for //[[Rcpp::export]] tagged functions intend to provide a more streamlined alternative to employment of RcppExport inclusions in declarations in the header file and subsequent use of

Re: [Rcpp-devel] R vectorisation vs. C++ vectorisation

2012-11-21 Thread Darren Cook
> | > I believe that such a function is normally called "clamp". > | > | I'd not heard that before; is that the mathematical word for it? (clip > | is terminology from graphics programming, where a clipping rectangle is > | another word for a window or viewport) > > http://en.wikipedia.org/wiki/C

Re: [Rcpp-devel] R vectorisation vs. C++ vectorisation

2012-11-21 Thread Dirk Eddelbuettel
On 22 November 2012 at 09:23, Darren Cook wrote: | > I believe that such a function is normally called "clamp". | | I'd not heard that before; is that the mathematical word for it? (clip | is terminology from graphics programming, where a clipping rectangle is | another word for a window or viewp

Re: [Rcpp-devel] R vectorisation vs. C++ vectorisation

2012-11-21 Thread Darren Cook
> I believe that such a function is normally called "clamp". I'd not heard that before; is that the mathematical word for it? (clip is terminology from graphics programming, where a clipping rectangle is another word for a window or viewport) Darren __

Re: [Rcpp-devel] R vectorisation vs. C++ vectorisation

2012-11-21 Thread Dirk Eddelbuettel
On 21 November 2012 at 22:24, Martyn Plummer wrote: | I believe that such a function is normally called "clamp". I like that too. Shall we change it? Dirk -- Dirk Eddelbuettel | e...@debian.org | http://dirk.eddelbuettel.com ___ Rcpp-devel mailing

Re: [Rcpp-devel] R vectorisation vs. C++ vectorisation

2012-11-21 Thread Darren Cook
>> By "sugar versions" I meant vacc4() vs. vacc3() >> (https://gist.github.com/4111256) not pmin() and friends. The vacc4() >> code looks like: >> >>NumericVector p(age.size()); >>p = 0.25 + 0.3 * 1 / (1 - exp(0.04 * age)) + 0.1 * ily; >>p = p * ifelse(female, 1.25, 0.75); >>p = pma

Re: [Rcpp-devel] Dispatching based on SEXPTYPE

2012-11-21 Thread Hadley Wickham
> Something like this yes. I was thinking of something that still kept the > logical split between the dispatcher "unique3" and the workers unique1, so > essentially have all the unique1 overloads returning SEXP instead of stl > containers. Ah, got it. That would make the variable initialisation

Re: [Rcpp-devel] Dispatching based on SEXPTYPE

2012-11-21 Thread Romain Francois
Le 21/11/12 22:35, Hadley Wickham a écrit : I would perhaps advise you to have the unique1 overloads not to return the stl object, as you are generating copies (although some may argue about compiler optimizations). Ah, ok. I don't have much intuition for when copies occur in C++. I would ad

Re: [Rcpp-devel] Dispatching based on SEXPTYPE

2012-11-21 Thread Hadley Wickham
>> I would perhaps advise you to have the unique1 overloads not to return the >> stl object, as you are generating copies (although some may argue about >> compiler optimizations). > > Ah, ok. I don't have much intuition for when copies occur in C++. > >> I would advise to return include the call

Re: [Rcpp-devel] R vectorisation vs. C++ vectorisation

2012-11-21 Thread Martyn Plummer
I believe that such a function is normally called "clamp". Martyn Quoting Romain Francois : > clip it is, with this order: > > p = clip( 0.0, p, 1.0 ) ; > > which I found more natural. > > For now, I implemented only a version with primitives for the first and > last argument and sugar expression

Re: [Rcpp-devel] Dispatching based on SEXPTYPE

2012-11-21 Thread Hadley Wickham
> I would perhaps advise you to have the unique1 overloads not to return the > stl object, as you are generating copies (although some may argue about > compiler optimizations). Ah, ok. I don't have much intuition for when copies occur in C++. > I would advise to return include the call to wrap

Re: [Rcpp-devel] R vectorisation vs. C++ vectorisation

2012-11-21 Thread Romain Francois
Le 19/11/12 16:31, Hadley Wickham a écrit : Hi all, Inspired by "Rcpp is smoking fast for agent-based models in data frames" (http://www.babelgraph.org/wp/?p=358), I've been doing some exploration of vectorisation in R vs C++ at https://gist.github.com/4111256 I have five versions of the basic

Re: [Rcpp-devel] R vectorisation vs. C++ vectorisation

2012-11-21 Thread Romain Francois
clip it is, with this order: p = clip( 0.0, p, 1.0 ) ; which I found more natural. For now, I implemented only a version with primitives for the first and last argument and sugar expression for the one in the middle, but we can imagine writing vector versions everywhere. Romain Le 21/11/12

Re: [Rcpp-devel] R vectorisation vs. C++ vectorisation

2012-11-21 Thread Alexandre Bujard
How about clip(): p = clip(p, 0.0, 1.0); Great idea!!! On Wed, Nov 21, 2012 at 2:00 PM, Romain Francois wrote: > Le 21/11/12 13:22, Darren Cook a écrit : > > I wrote: >> >>> P.S. I don't think the sugar versions can be made any quicker, because > they have to allocate intermediate vect

Re: [Rcpp-devel] R vectorisation vs. C++ vectorisation

2012-11-21 Thread Romain Francois
Le 21/11/12 13:22, Darren Cook a écrit : I wrote: P.S. I don't think the sugar versions can be made any quicker, because they have to allocate intermediate vectors, and do more memory copies. By "sugar versions" I meant vacc4() vs. vacc3() (https://gist.github.com/4111256) not pmin() and frien

Re: [Rcpp-devel] R vectorisation vs. C++ vectorisation

2012-11-21 Thread Darren Cook
I wrote: >>> P.S. I don't think the sugar versions can be made any quicker, because >>> they have to allocate intermediate vectors, and do more memory copies. By "sugar versions" I meant vacc4() vs. vacc3() (https://gist.github.com/4111256) not pmin() and friends. The vacc4() code looks like: N

Re: [Rcpp-devel] R vectorisation vs. C++ vectorisation

2012-11-21 Thread Romain Francois
Le 19/11/12 17:47, Douglas Bates a écrit : On Mon, Nov 19, 2012 at 9:56 AM, Dirk Eddelbuettel mailto:e...@debian.org>> wrote: On 19 November 2012 at 09:31, Hadley Wickham wrote: | Hi all, | | Inspired by "Rcpp is smoking fast for agent-based models in data | frames" (http://

Re: [Rcpp-devel] R vectorisation vs. C++ vectorisation

2012-11-21 Thread Romain Francois
I'll make a more general reply later (this triggered a few findings on the code). Le 20/11/12 16:54, Hadley Wickham a écrit : P.S. I don't think the sugar versions can be made any quicker, because they have to allocate intermediate vectors, and do more memory copies. I don't think they _hav

Re: [Rcpp-devel] Dispatching based on SEXPTYPE

2012-11-21 Thread Romain Francois
Pretty much. I would perhaps advise you to have the unique1 overloads not to return the stl object, as you are generating copies (although some may argue about compiler optimizations). I would advise to return include the call to wrap in your unique1. Things will be different some day when w