Re: [Rcpp-devel] Rcpp "version" of R's match function

2012-11-15 Thread Romain Francois
We need to fond the right compromise between bloating Rcpp (which is already quite huge: wc src/* inst/include/**/** inst/include/* 2> /dev/null | tail -n1 66180 784183 6425152 total and support generic enough things. I can see things like union and setdiff being generic enough (we already

[Rcpp-devel] Missing values

2012-11-15 Thread Hadley Wickham
Hi all, I'm working on a description of how missing values work in Rcpp (expanding on FAQ 3.4). I'd really appreciate any comments, corrections or suggestions on the text below. Thanks! Hadley # Missing values If you're working with missing values, you need to know two things: * what happen

Re: [Rcpp-devel] Rcpp 0.10

2012-11-15 Thread Ramon Diaz-Uriarte
> > I mean, the .h and *.R files generated with Rcpp.package.skeleton seem to > > have a simple structure that I find easy to replicate and modify as I keep > > adding stuff to my *.cpp file. (For instance, the placement of RccpExport > > before functions intended to be exported, the usage of S

Re: [Rcpp-devel] rcpp 0.10 on mac error with sourceCpp

2012-11-15 Thread Jiqiang Guo
I think it is just I did something wrong with installing Rcpp from source, which I cannot reproduce now. Thanks very much. -- Jiqiang On Thu, Nov 15, 2012 at 1:55 PM, Dirk Eddelbuettel wrote: > Possibly a non-standard Rcpp installation? ___ Rcpp-devel

Re: [Rcpp-devel] Rcpp 0.10

2012-11-15 Thread JJ Allaire
> 1. Suggestion: it might be appropriate to say (probably before 5.1) that > Makevars, etc, are still needed. And, thus, point the reader to > vignette("Rcpp-package"). > Very good suggestion -- will do! > I mean, the .h and *.R files generated with Rcpp.package.skeleton seem to > have a simple

Re: [Rcpp-devel] Rcpp "version" of R's match function

2012-11-15 Thread Søren Højsgaard
Dear list [>>] I am not sure if Hadleys remark below was an invitation to make a "wishlish", but I'll take the risk: 1) I have made several packages related to graphical models for multivariate data. Much of these packages deals with "book keeping": operations on sets of subsets of a finite s

[Rcpp-devel] Rcpp 0.10

2012-11-15 Thread Ramon Diaz-Uriarte
Dear Dirk, Romain, and JJ, Version 0.10 is really amazing. In particular, the Rcpp Attributes are awesome, as well as some of the additions to sugar!! If I may, I'd like to make a suggestion and a question about the documentation for Rcpp Attributes. 1. Suggestion: it might be appropriate to

Re: [Rcpp-devel] rcpp 0.10 on mac error with sourceCpp

2012-11-15 Thread Dirk Eddelbuettel
On 15 November 2012 at 13:42, JJ Allaire wrote: | The error appears to be occurring in the call to RcppLdPath (made by both | sourceCpp and RStan). Here's the source code for that function: | | RcppLdPath <- function() { |     if (nzchar(.Platform$r_arch)) { ## eg amd64, ia64, mips |         path

Re: [Rcpp-devel] rcpp 0.10 on mac error with sourceCpp

2012-11-15 Thread Dirk Eddelbuettel
On 15 November 2012 at 13:40, Jiqiang Guo wrote: | Thanks. | | The same error if I use cppFunction thought the example in sourceCpp | use a string of c++ code passed using code: Oh, sorry, my bad -- was short of time and couldn;t test, and don't even have a mac. I will let the mac squad get to

Re: [Rcpp-devel] rcpp 0.10 on mac error with sourceCpp

2012-11-15 Thread Jiqiang Guo
I see. For some reason, my installing Rcpp from source last time did not install the 64 bits lib, so Rcpp.system.file("lib", .Platform$r_arch) for me returns "". I reinstalled Rcpp 0.10.0 from source and made sure lib/x86_64 exists, then everything is fine. Thanks. -- Jiqiang On Thu, Nov 15, 2

Re: [Rcpp-devel] rcpp 0.10 on mac error with sourceCpp

2012-11-15 Thread JJ Allaire
The error appears to be occurring in the call to RcppLdPath (made by both sourceCpp and RStan). Here's the source code for that function: RcppLdPath <- function() { if (nzchar(.Platform$r_arch)) { ## eg amd64, ia64, mips path <- Rcpp.system.file("lib",.Platform$r_arch) } else {

Re: [Rcpp-devel] rcpp 0.10 on mac error with sourceCpp

2012-11-15 Thread Jiqiang Guo
Thanks. The same error if I use cppFunction thought the example in sourceCpp use a string of c++ code passed using code: > require(Rcpp) > > cppFunction(code=' +#include + +// [[Rcpp::export]] +int fibonacci(const int x) { + if (x == 0) return(0); +

Re: [Rcpp-devel] min, max, range

2012-11-15 Thread Hadley Wickham
You can make the differences more profound if you choose examples where range.default does really badly (assuming your implementation is similar to my attached implementation) expr min lq median uq max neval range(x, na.rm = TRUE) 1920 2488 2951 3349 23306 100 min

Re: [Rcpp-devel] rcpp 0.10 on mac error with sourceCpp

2012-11-15 Thread Dirk Eddelbuettel
On 15 November 2012 at 13:20, Jiqiang Guo wrote: | I tried the example of sourceCpp on Mac mountain lion with R 2.15.1 | with the following error (I hit the similar error in using RStan as | well). | | > library(Rcpp) | > require(Rcpp) | > | > sourceCpp(code=' Operator error: sourceCpp() t

Re: [Rcpp-devel] rcpp 0.10 on mac error with sourceCpp

2012-11-15 Thread Jiqiang Guo
Thanks. But I am using R from command line, and I think it is set correctly: > Sys.getenv("R_ARCH") [1] "/x86_64" -- Jiqiang On Thu, Nov 15, 2012 at 1:30 PM, JJ Allaire wrote: > > > On Thu, Nov 15, 2012 at 1:20 PM, Jiqiang Guo wrote: >> >> I tried the example of sourceCpp on Mac mountain lion

Re: [Rcpp-devel] rcpp 0.10 on mac error with sourceCpp

2012-11-15 Thread JJ Allaire
On Thu, Nov 15, 2012 at 1:20 PM, Jiqiang Guo wrote: > I tried the example of sourceCpp on Mac mountain lion with R 2.15.1 > with the following error (I hit the similar error in using RStan as > well). > I think the common problem here might be whether R_ARCH is set correctly. On the Mac R_ARCH n

[Rcpp-devel] rcpp 0.10 on mac error with sourceCpp

2012-11-15 Thread Jiqiang Guo
I tried the example of sourceCpp on Mac mountain lion with R 2.15.1 with the following error (I hit the similar error in using RStan as well). > library(Rcpp) > require(Rcpp) > > sourceCpp(code=' +#include + +// [[Rcpp::export]] +int fibonacci(const int x) { +

Re: [Rcpp-devel] Compilation error in Rcpp

2012-11-15 Thread Dirk Eddelbuettel
On 15 November 2012 at 08:40, Karl Millar wrote: | Yes.  I think only fairly recent versions of clang pick up on this though. Cool. Thanks for the feedback. At the top-secret "Rcpp R+D labs" someone is already plotting to get some of the clang goodness into Rcpp and its toolchain. Dirk -- Dir

Re: [Rcpp-devel] Rcpp version of %in%

2012-11-15 Thread Romain Francois
Le 15/11/12 17:52, Romain Francois a écrit : Hello, I've commited an Rcpp version of %in%. For example: require(Rcpp) require(microbenchmark) sourceCpp( code = ' #include using namespace Rcpp ; // [[Rcpp::export]] LogicalVector in_( CharacterVector x, CharacterVector table){ return in(

[Rcpp-devel] Rcpp version of %in%

2012-11-15 Thread Romain Francois
Hello, I've commited an Rcpp version of %in%. For example: require(Rcpp) require(microbenchmark) sourceCpp( code = ' #include using namespace Rcpp ; // [[Rcpp::export]] LogicalVector in_( CharacterVector x, CharacterVector table){ return in( x, table ) ; } ' ) `%in++%` <- in_ > c("a",

Re: [Rcpp-devel] Compilation error in Rcpp

2012-11-15 Thread Karl Millar
Yes. I think only fairly recent versions of clang pick up on this though. On Thu, Nov 15, 2012 at 4:34 AM, Dirk Eddelbuettel wrote: > > On 14 November 2012 at 21:57, Karl Millar wrote: > | In the Rcpp 0.10.0, > inst/include/Rcpp/sugar/logical/SingleLogicalResult.h there > | is the code: > | >

Re: [Rcpp-devel] Rcpp "version" of R's match function

2012-11-15 Thread Dirk Eddelbuettel
On 15 November 2012 at 16:45, Willem Ligtenberg wrote: | No need to jump on me. | I didn't know that Rcpp lived on R-Forge, but that is mostly because all of the | info is found on your site: | http://dirk.eddelbuettel.com/code/rcpp.html Well the problem is that a) we have too much document

Re: [Rcpp-devel] Rcpp "version" of R's match function

2012-11-15 Thread Willem Ligtenberg
No need to jump on me. I didn't know that Rcpp lived on R-Forge, but that is mostly because all of the info is found on your site: http://dirk.eddelbuettel.com/code/rcpp.html I will gladly use R-forge for this. (for the list etiquette I am blaiming gmail, it truncated the other messages...) On T

Re: [Rcpp-devel] Rcpp "version" of R's match function

2012-11-15 Thread Dirk Eddelbuettel
On 15 November 2012 at 16:02, Willem Ligtenberg wrote: | and now to the list... | | Nothing specific, but some way of sharing would be nice. :) Funny how we managed to do that "sharing thing" for almost 4000 commits without using github... Seriously, this has been on R-Forge for 4 1/2 years, an

Re: [Rcpp-devel] Rcpp "version" of R's match function

2012-11-15 Thread Willem Ligtenberg
and now to the list... Nothing specific, but some way of sharing would be nice. :) On Thu, Nov 15, 2012 at 3:58 PM, Romain Francois wrote: > Help is very welcome. Why github though ? > > Le 15/11/12 15:42, Willem Ligtenberg a écrit : > >> Would be nice to keep the list and the progress on githu

Re: [Rcpp-devel] Rcpp "version" of R's match function

2012-11-15 Thread Romain Francois
Help is very welcome. Why github though ? Le 15/11/12 15:42, Willem Ligtenberg a écrit : Would be nice to keep the list and the progress on github. Other might pitch in and help out, I am also interested, just don't know how much time I can spend on it. Kind regards, Willem On Thu, Nov 15, 2

Re: [Rcpp-devel] Rcpp "version" of R's match function

2012-11-15 Thread Willem Ligtenberg
Would be nice to keep the list and the progress on github. Other might pitch in and help out, I am also interested, just don't know how much time I can spend on it. Kind regards, Willem On Thu, Nov 15, 2012 at 3:24 PM, Romain Francois wrote: > Le 15/11/12 14:52, Hadley Wickham a écrit : > > R

Re: [Rcpp-devel] Loops, iterators and accumulate

2012-11-15 Thread Dirk Eddelbuettel
On 15 November 2012 at 07:49, Hadley Wickham wrote: | I didn't, but I'm looking at it now, thanks. The main problem is that | many of the examples use C++ idioms I don't understand - and as I That is *the whole point* -- C++, not unlike R, is a version of nethack: Enter the dungeon, and find the

Re: [Rcpp-devel] Rcpp "version" of R's match function

2012-11-15 Thread Hadley Wickham
>> PS. Would you be interested in a set of R functions that from a quick >> skim of the R sources that I think could be much much faster if >> implemented in Rcpp? > > Sure. Time I have available will decide what I do of the list ^^. Here's the list: rowsum.default (C)? findInterval (C)?

Re: [Rcpp-devel] Loops, iterators and accumulate

2012-11-15 Thread Smith, Dale
I'm not sure what compliers you are using out there, but gcc does have a way to enable warnings for this type of implicit conversion. -Wconversion Warn for implicit conversions that may alter a value. This includes conversions between real and integer... http://gcc.gnu.org/onlinedocs/gcc/Warnin

Re: [Rcpp-devel] Rcpp "version" of R's match function

2012-11-15 Thread Romain Francois
Le 15/11/12 14:52, Hadley Wickham a écrit : R utilisateur système écoulé 0.338 0.024 0.362 R (second time) utilisateur système écoulé 0.262 0.000 0.262 match_ manual Rcpp utilisateur système écoulé 0.144 0.000 0.1

Re: [Rcpp-devel] Loops, iterators and accumulate

2012-11-15 Thread Rainer M Krug
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Just to add one more test here: Unit: microseconds exprmin lq median uq max 1 sum1(x) 19.835 20.0445 20.184 20.3585 43.651 2 sum2a(x) 19.835 20.0095 20.184 20.3240 48.958 3 sum2(x) 93.797 94.0760 94.146 94.4250 204.355 4 s

Re: [Rcpp-devel] Loops, iterators and accumulate

2012-11-15 Thread Romain Francois
Le 15/11/12 15:14, Hadley Wickham a écrit : On Thu, Nov 15, 2012 at 8:11 AM, Romain Francois wrote: I'm not getting the same results, so I might not make the same conclusions: Unit: microseconds exprmin lq median uqmax 1 sum(x) 16.072 16.161 16.2090 16.3110 21.721 2

Re: [Rcpp-devel] Loops, iterators and accumulate

2012-11-15 Thread Hadley Wickham
On Thu, Nov 15, 2012 at 8:11 AM, Romain Francois wrote: > I'm not getting the same results, so I might not make the same conclusions: > > > Unit: microseconds > exprmin lq median uqmax > 1 sum(x) 16.072 16.161 16.2090 16.3110 21.721 > 2 sum1(x) 10.771 10.954 11.0445 11.1

Re: [Rcpp-devel] Loops, iterators and accumulate

2012-11-15 Thread Romain Francois
I'm not getting the same results, so I might not make the same conclusions: Unit: microseconds exprmin lq median uqmax 1 sum(x) 16.072 16.161 16.2090 16.3110 21.721 2 sum1(x) 10.771 10.954 11.0445 11.1910 16.163 3 sum2(x) 48.438 48.567 48.6650 48.8425 61.116 4 sum2a(x)

Re: [Rcpp-devel] Rcpp "version" of R's match function

2012-11-15 Thread Hadley Wickham
> R > utilisateur système écoulé > 0.338 0.024 0.362 > R (second time) > utilisateur système écoulé > 0.262 0.000 0.262 > match_ manual Rcpp > utilisateur système écoulé > 0.144 0.000 0.144 > match__ internal Rcpp > ut

Re: [Rcpp-devel] Loops, iterators and accumulate

2012-11-15 Thread Hadley Wickham
> | I'm trying to get a better handle on writing efficient numerical code > | with C++. I've attached five implementations of a simple sum function > | (mostly ignoring NAs) and timed them below: > > Did you see the (fairly extensive) comparison in > examples/ConvolveBenchmarks/ > which comp

Re: [Rcpp-devel] Loops, iterators and accumulate

2012-11-15 Thread Dirk Eddelbuettel
On 15 November 2012 at 07:24, Hadley Wickham wrote: | Hi all, | | I'm trying to get a better handle on writing efficient numerical code | with C++. I've attached five implementations of a simple sum function | (mostly ignoring NAs) and timed them below: Did you see the (fairly extensive) compar

Re: [Rcpp-devel] Rcpp "version" of R's match function

2012-11-15 Thread Romain Francois
Commited in revision 3973. I added a few abstraction that let me eventually write the code in terms of stl algorithms. See the implementation in match.h or the curious. With that: require(Rcpp) sourceCpp( code = ' #include using namespace Rcpp ; // [[Rcpp::export]] IntegerVector match__( Ch

[Rcpp-devel] Loops, iterators and accumulate

2012-11-15 Thread Hadley Wickham
Hi all, I'm trying to get a better handle on writing efficient numerical code with C++. I've attached five implementations of a simple sum function (mostly ignoring NAs) and timed them below: > source("sum.r") Unit: microseconds expr minlq medianuq max neval sum(x) 11.67 11.72

Re: [Rcpp-devel] Sample function(s) for inclusion in RcppArmadillo

2012-11-15 Thread Dirk Eddelbuettel
On 15 November 2012 at 04:00, Christian Gunning wrote: | |     Also, you may need to add RNGScope() if you use R's RNG. | | | | | | | | Yes, I should have mentioned that in my post.  Calling RNGScope() is left | to | | the user, since multiple calls to sample() can con

Re: [Rcpp-devel] Compilation error in Rcpp

2012-11-15 Thread Dirk Eddelbuettel
On 14 November 2012 at 21:57, Karl Millar wrote: | In the Rcpp 0.10.0, inst/include/Rcpp/sugar/logical/SingleLogicalResult.h there | is the code: | | template | class conversion_to_bool_is_forbidden :  | conversion_to_bool_is_forbidden{ | | Which obviously can't be instantiated. | | Presumabl

Re: [Rcpp-devel] Sample function(s) for inclusion in RcppArmadillo

2012-11-15 Thread Christian Gunning
> > | Also, you may need to add RNGScope() if you use R's RNG. > | > | > | > | Yes, I should have mentioned that in my post. Calling RNGScope() is > left to > | the user, since multiple calls to sample() can conceivably happen inside > a > | single RNGScope(). > > With that, maybe best to be i