search for: integervector

Displaying 12 results from an estimated 12 matches for "integervector".

2015 Mar 02
1
R-devel does not update the C++ returned variables
...ith compiled code. | | When testing that, I've went a step further: As you may know, int can be 'casted up' to double which is what happens here. So in what follows you _always_ create a copy from an int vector to a numeric vector. For pure int, use eg Rcpp::cppFunction("IntegerVector doubleThis(IntegeerVector x) { return(2*x); }") and rename the function names as needed to have two defined concurrently. Dirk | | ##---- now "test": | require(microbenchmark) | i <- 1:10 | (mb <- microbenchmark(doubleThis(i), i*2, 2*i, i*2L, 2L*i, i+i, times=2^12)) | ## Ly...
2015 Mar 02
3
R-devel does not update the C++ returned variables
...ms also depends on the size of the input vector. i + i becomes the winner for longer vectors (e.g. i <- 1:1e6), but a proper Rcpp version is still approximately twice as fast. Rcpp::cppFunction("NumericVector doubleThisNum(NumericVector x) { return(2*x); }") Rcpp::cppFunction("IntegerVector doubleThisInt(IntegerVector x) { return(2*x); }") i <- 1:1e6 mb <- microbenchmark::microbenchmark(doubleThisNum(i), doubleThisInt(i), i*2, 2*i, i*2L, 2L*i, i+i, times=100) plot(mb, log="y", notch=TRUE) > (mb <- microbenchmark(doubleThis(i), i*2, 2*i, i*2L, 2L*i, i+i,...
2018 Sep 21
1
Bias in R's random integers?
On 9/20/18 5:15 PM, Duncan Murdoch wrote: > On 20/09/2018 6:59 AM, Ralf Stubner wrote: >> It is difficult to do this in a package, since R does not provide access >> to the random bits generated by the RNG. Only a float in (0,1) is >> available via unif_rand(). > > I believe it is safe to multiply the unif_rand() value by 2^32, and take > the whole number part as an
2015 Mar 02
0
R-devel does not update the C++ returned variables
...> 2L * i [1] 2147483642 2147483644 2147483646 NA NA NA Warning message: In 2L * i : NAs produced by integer overflow H. > > Rcpp::cppFunction("NumericVector doubleThisNum(NumericVector x) { > return(2*x); }") > Rcpp::cppFunction("IntegerVector doubleThisInt(IntegerVector x) { > return(2*x); }") > i <- 1:1e6 > mb <- microbenchmark::microbenchmark(doubleThisNum(i), doubleThisInt(i), > i*2, 2*i, i*2L, 2L*i, i+i, times=100) > plot(mb, log="y", notch=TRUE) > > >> (mb <- microbenchmark(doubleT...
2015 Mar 02
3
R-devel does not update the C++ returned variables
On 2 March 2015 at 09:09, Duncan Murdoch wrote: | I generally recommend that people use Rcpp, which hides a lot of the | details. It will generate your .Call calls for you, and generate the | C++ code that receives them; you just need to think about the real | problem, not the interface. It has its own learning curve, but I think | it is easier than using the low-level code that you need to
2011 Jan 26
2
Dealing with R list objects in C/C++
Hi, I'd like to construct an R list object in C++, fill it with relevant data, and pass it to an R function which will return a different list object back. I have browsed through all the R manuals, and examples under tests/Embedding, but can't figure out the correct way. Below is my code snippet: #include <Rinternals.h> // Rf_initEmbeddedR and other setups already performed
2010 Oct 27
2
must .Call C functions return SEXP?
For using R's .Call interface to C functions, all the examples I've seen have the C function return type SEXP. Why? What does R actually do with this return type? What happens if I *don't* return a SEXP? Reason I ask, is I've written some R code which allocates two long lists, and then calls a C function with .Call. My C code writes to those two pre-allocated lists, thus, I
2010 May 17
0
Rcpp 0.8.0 on CRAN
...as released to CRAN today. This release marks another milestone in the ongoing redesign of the package, and underlying C++ library. ===== Overview ===== Rcpp is an R package and C++ library that facilitates integration of C++ code in R packages. The package features a set of C++ classes (Rcpp::IntegerVector, Rcpp::Function, Rcpp::Environment, ...) that makes it easier to manipulate R objects of matching types (integer vectors, functions, environments, etc ...). Rcpp takes advantage of C++ language features such as the explicit constructor/destructor lifecycle of objects to manage garbage collection a...
2010 May 17
0
Rcpp 0.8.0 on CRAN
...as released to CRAN today. This release marks another milestone in the ongoing redesign of the package, and underlying C++ library. ===== Overview ===== Rcpp is an R package and C++ library that facilitates integration of C++ code in R packages. The package features a set of C++ classes (Rcpp::IntegerVector, Rcpp::Function, Rcpp::Environment, ...) that makes it easier to manipulate R objects of matching types (integer vectors, functions, environments, etc ...). Rcpp takes advantage of C++ language features such as the explicit constructor/destructor lifecycle of objects to manage garbage collection a...
2010 Apr 13
3
Inline Package: void vs return type functions
Dear all, After having a look at the "inline" package and also going through the "Rcpp" package which is tighty related to it, it came to me this question: 1) my C/ C++ code has a return type (let say a double[][] or a user define class) 2) I am working with an extensive library built by someone else and I don't have the time/knowledge to change it by means of working
2010 Dec 22
0
Rcpp 0.9.0 and RcppClassic 0.9.0
...few key points are highlighted below. More details are in the NEWS and ChangeLog files included in the package. ===== Overview ===== Rcpp is an R package and associated C++ library that facilitates integration of C++ code in R packages. The package features a complete set of C++ classes (Rcpp::IntegerVector, Rcpp:NumericVector, Rcpp::Function, Rcpp::Environment, ...) that makes it easier to manipulate R objects of matching types (integer vectors, functions, environments, etc ...). Rcpp takes advantage of C++ language features such as the explicit constructor / destructor lifecycle of objects to manag...
2010 Dec 22
0
Rcpp 0.9.0 and RcppClassic 0.9.0
...few key points are highlighted below. More details are in the NEWS and ChangeLog files included in the package. ===== Overview ===== Rcpp is an R package and associated C++ library that facilitates integration of C++ code in R packages. The package features a complete set of C++ classes (Rcpp::IntegerVector, Rcpp:NumericVector, Rcpp::Function, Rcpp::Environment, ...) that makes it easier to manipulate R objects of matching types (integer vectors, functions, environments, etc ...). Rcpp takes advantage of C++ language features such as the explicit constructor / destructor lifecycle of objects to manag...