Re: [Rcpp-devel] [R] Find number of elements less than some number: Elegant/fastsolution needed

2011-04-14 Thread Christian Gunning
On Thu, Apr 14, 2011 at 7:02 PM, wrote: > I was able to write a very short C++ function using the Rcpp package > that provided about a 1000-fold increase in speed relative to the best > I could do in R.  I don't have the script on this computer so I will > post it tomorrow when I am back on the c

Re: [Rcpp-devel] [R] Find number of elements less than some number: Elegant/fastsolution needed

2011-04-14 Thread Douglas Bates
On Thu, Apr 14, 2011 at 8:19 PM, Ravi Varadhan wrote: > Bill's code is insanely fast! > > f2 <- function(x, y) length(y) - findInterval(-x, rev(-sort(y))) > >  n1 <- 1e07 > n2 <- 10^c(1,2,3,4,5,6,7) > tt <- rep(NA, 7) > x <- rnorm(n1) > for (i in 1:length(n2)){ > y <- runif(n2[i]) > tt[i] <- syste

Re: [Rcpp-devel] [R] Find number of elements less than some number: Elegant/fastsolution needed

2011-04-14 Thread Douglas Bates
My colleague Sunduz Keles once mentioned a similar problem to me. She had a large sample from a reference distribution and a test sample (both real-valued in her case) and she wanted, for each element of the test sample, the proportion of the reference sample that was less than the element. It's

Re: [Rcpp-devel] Boolean vector from R to C++

2011-04-14 Thread romain
Yes. LogicalVector. Le 14 avr. 2011 à 05:00 PM, Cedric Ginestet a écrit : > Hi all, > > I am trying to pass on a boolean vector from R to C++. I have naively tried > the following: > > > src <- ' > using namespace Rcpp ; > using namespace std ; > in

Re: [Rcpp-devel] Boolean vector from R to C++

2011-04-14 Thread Dirk Eddelbuettel
On 14 April 2011 at 16:00, Cedric Ginestet wrote: | I am trying to pass on a boolean vector from R to C++. I have naively tried the | following: [...] | Is there an equivalent to IntegerVector or NumericVector for Boolean variables | or can I simply use the Rcpp::Vector template for this purpose?

Re: [Rcpp-devel] Boolean vector from R to C++

2011-04-14 Thread Douglas Bates
On Thu, Apr 14, 2011 at 10:00 AM, Cedric Ginestet wrote: > Hi all, > > I am trying to pass on a boolean vector from R to C++. I have naively tried > the following: > > > src <- ' >   using namespace Rcpp ; >   using namespace std ; >   int b = as(xb); > return wrap

[Rcpp-devel] Boolean vector from R to C++

2011-04-14 Thread Cedric Ginestet
Hi all, I am trying to pass on a boolean vector from R to C++. I have naively tried the following: src <- ' using namespace Rcpp ; using namespace std ; int b = as(xb); return wrap(b);' cxxfun <- cxxfunction(sig=signature(xb="logical"),

Re: [Rcpp-devel] Conflit with sys/vnode.h on Solaris (gcc 4.4.3)

2011-04-14 Thread Giuseppe Milicia
Dirk, >But about my polite request for help with Solaris cc compiler? Could you >help there? You are the living being from planet Solaris to set foot in >these corners and I mentioned, we do need some local help... Thing is, I don't even have R built with the sun compiler. I had a quick go to

Re: [Rcpp-devel] Segfaults when declaring Vector types

2011-04-14 Thread Dirk Eddelbuettel
Hi again, On 14 April 2011 at 23:20, Patrick Ye wrote: | Hi Dirk, | | Thanks so much for the reply, I really appreciate it. | | I thought that I was misusing Rcpp, as all the examples I found seemed | to be for writing C++ functions to be used in R -- not accessing R | functions in C++. | |

Re: [Rcpp-devel] Segfaults when declaring Vector types

2011-04-14 Thread Dirk Eddelbuettel
On 14 April 2011 at 08:03, Dirk Eddelbuettel wrote: | Or maybe you want to attach C++ functions to R after all. In which case you | may want to look at inside (also on CRAN) and the example posted here. You s/sinside/inline/ One day I start proofreading emails... Sorry, Dirk -- Dirk Eddelb

Re: [Rcpp-devel] R.e. loadRcppModules

2011-04-14 Thread Dirk Eddelbuettel
On 14 April 2011 at 07:49, Douglas Bates wrote: | On Thu, Apr 14, 2011 at 12:43 AM, Christian Gunning wrote: | > On Tue, Apr 12, 2011 at 11:07 PM, Romain Francois | > wrote: | >>> | >>> Just to clarify --  does your plan include storing user-modified | >>> fields and properties in objects?  E.g.

Re: [Rcpp-devel] Segfaults when declaring Vector types

2011-04-14 Thread Patrick Ye
Hi Dirk, Thanks so much for the reply, I really appreciate it. I thought that I was misusing Rcpp, as all the examples I found seemed to be for writing C++ functions to be used in R -- not accessing R functions in C++. Thanks so much for your suggestions on RInside, I just found out about i

Re: [Rcpp-devel] Segfaults when declaring Vector types

2011-04-14 Thread Dirk Eddelbuettel
Hi Patrick, Welcome! On 14 April 2011 at 18:27, Patrick Ye wrote: | Hi all, | | I'm completely new to R and Rcpp, and I thought I'd just make a simple program | to see how Rcpp works. Here is the code: You are a tad confused, which is excuseable given the amount of documentation. You wrote a

Re: [Rcpp-devel] R.e. loadRcppModules

2011-04-14 Thread Douglas Bates
On Thu, Apr 14, 2011 at 12:43 AM, Christian Gunning wrote: > On Tue, Apr 12, 2011 at 11:07 PM, Romain Francois > wrote: >>> >>> Just to clarify --  does your plan include storing user-modified >>> fields and properties in objects?  E.g. below, modtest with the msg >>> set? >> >> yes. Although the

[Rcpp-devel] Segfaults when declaring Vector types

2011-04-14 Thread Patrick Ye
Hi all, I'm completely new to R and Rcpp, and I thought I'd just make a simple program to see how Rcpp works. Here is the code: #include #include #include #include RcppExport void get_weights(int num_of_numbers, double* numbers); RcppExport void get_weights(int num_of_numbers, double* number