NA_REAL is just a NaN with a special value in the payload, so it's fine to use.
Hadley
On Thu, Jun 2, 2016 at 7:07 AM, Jason Foster wrote:
> Hi,
>
> My question is how can I return a thread safe NA_REAL using RcppParallel?
> I've read many posts about how it's not thread safe to call R or Rcpp AP
How are you installing Rcpp? You sometimes see problems like that on
Windows if you try and install a package that is currently loaded.
Hadley
On Wed, Oct 14, 2015 at 11:41 AM, David Gerbing wrote:
> Hi All
>
> Have a Mac and Windows 7 and all has been fine. I have learned, however,
> that on W
On Wed, Jun 24, 2015 at 11:08 AM, Charles Determan
wrote:
> Many thanks Krzysztof, your suggestion works. I can explicitly create a
> 'new' arma::mat object and pass the resulting XPtr between functions. I
> will work on making everything prettier and document for a submission to
> Rcpp Gallery
>> Almost always an issue related to binary mismatch from components.
>> Have them recompile.
>
> the application is distributed as a compiled binary (which is known to
> work on other machines, including fresh OS installs), so i don't think
> it can be that; they don't compile anything.
This may
> What Romain says makes sense to me, despite my lack of expertise in this
> area.. the really intermittent nature of the problem and the fact that I
> can't recreate it in a small / fast running example suggests that perhaps
> this manifests when R happens to garbage collect at an unfortunate time
I'd recommend:
a) using cppFunction instead of the older cxxfunction
b) creating an example that anyone can copy and paste out of their
email client and into R.
You are more likely to get helpful responses if you reduce the burden
on the potential helpers as much as possible
Hadley
On Fri, Mar
Another solution is to rely on Rcpp's auto-wrapping smarts:
// [[Rcpp::export]]
std::vector test(){
std::vector a;
a.push_back(1);
a.push_back(2);
a.push_back(3);
return a;
}
Hadley
On Fri, Jan 3, 2014 at 11:19 AM, Dirk Eddelbuettel wrote:
>
> Ale,
>
> Try this:
>
> R> sourceCpp("/t
> I believe you are mistaken. sorting is an expensive O( N log(N) ) operation.
>
> I’d use something like std::find (or std::any_of if you use C++11). Those
> are O(N)
> Otherwise, you might like Rcpp::any or Rcpp::any_of
It depends on the scenario - if you want to look up M values in a
vector of
> I am reluctant to follow Romains suggestion because the package has a lot of
> c-code in it, so using load_all() takes quite some time because all c and c++
> code is being compiled. (Maybe that is just slow on windows? I tried on linux
> (ubuntu) too but I can't get devtools installed (becaus
BTW since you have `using namespace Rcpp;` you don't need `Rcpp::` in
front of every function from the Rcpp namespace
Hadley
On Fri, Dec 27, 2013 at 3:21 PM, Scott Monroe wrote:
> Thanks so much. Sorry for the silly error in the example. The following
> works, and has the basic functionality I
> Maintaining an Rcpp-based package on CRAN these days is a case of "no good
> deed shall go unpunished" and "the flogging will continue until morale
> improves". I am the maintainer of the RcppEigen package which apparently
> also makes me the maintainer of an Eigen port to Solaris. When compile
It's worth noting that simply using Rstudio (which will automatically
set up the paths for you), makes this process much simpler:
1. Install R
2. Install Rstudio
3. Install Rtools
4. install.packages("Rcpp")
Hadley
On Sat, Nov 23, 2013 at 11:38 PM, Brian Templeton wrote:
> I ended up spending a
> After every call, the memory from gc() is stable, while rsession process
> memory keeps growing of around 100Mb at each call and doesn't decrease after
> the garbage collection.
You don't mention how you're determining the size of the rsession
process, but you shouldn't necessarily expect it to
Did you install Rcpp from source? That's what I had to do to solve a
similar problem.
Hadley
On Friday, November 1, 2013, Simon Zehnder wrote:
> Same thing actually on my side: I had a hardware crash lately with 10.8
> and made fresh install after formatting my harddrive NSA-style :)
>
> Afterwa
a NumericVector so the compiler looks for a conversion, the one that
> is found is the ctor for NumericVector that takes an int.
>
> Romain
>
> Le 28 oct. 2013 à 17:05, Hadley Wickham a écrit :
>
>> FYI, that's equivalent to the somewhat cleaner
>>
>> li
FYI, that's equivalent to the somewhat cleaner
library(Rcpp)
cppFunction("NumericVector x(NumericVector start) {
return 1;
}")
Hadley
On Mon, Oct 28, 2013 at 8:58 AM, Simon Zehnder wrote:
> Dear Rcpp::Users and Rcpp::Devels,
>
> I get a weird error when using inline and I want to know, where
delbuettel wrote:
>
> On 11 October 2013 at 09:24, Hadley Wickham wrote:
> | FYI, I recommend using microbenchmark which uses a much higher
> | precision timer so you can see the variability as well as the mean
> | times.
>
> Someone really needs to mod it to give the 'single
Interestingly, that shows that rowApply2 is actually slightly _slower_
than rowApply1.
Hadley
On Fri, Oct 11, 2013 at 9:24 AM, Hadley Wickham wrote:
> FYI, I recommend using microbenchmark which uses a much higher
> precision timer so you can see the variability as well as the mean
&
FYI, I recommend using microbenchmark which uses a much higher
precision timer so you can see the variability as well as the mean
times. Also note that you can use /*** R */ to include R code that's
automatically run when benchmarking:
https://gist.github.com/hadley/6935459
That gives:
> microben
t code from
> this gist https://gist.github.com/romainfrancois/6672944 on a .c file and go
> old school about it:
>
> $ R CMD SHLIB size.c
> $ Rscript -e "dyn.load('size.so'); siz <- function(.) .Call( 'siz', .) ;
> siz(1:10); siz(siz); siz(letters) "
> And for these:
>
> extern void UNIMPLEMENTED_TYPE(const char *s, SEXP x) ;
> extern SEXP csduplicated(SEXP) ;
Fortunately for my version, I don't actually need those, but I'll see
if I can find a friendly member of R-core who might be willing to
review a patch.
Hadley
--
Chief Scientist, RStu
Hi all,
Is it possible to access the R internals api through Rcpp? For
example, I want to right my own version of object.size() that's aimed
at detecting memory leaks, so it needs to recursively include the size
of environments. The objectsize C function needs to access R internals
to get the siz
> In most cases your package is going to be distributed as binary anyway, so
> CRAN compiled it, and CRAN compiled Rcpp, so there should be nothing to
> worry.
And even if you're not distributing from source, telling (windows)
users to install rtools and then use install_github is not a big
barrie
> I understand your point, and am not sure how to proceed without it.
Just make sure you clone the initial list once, or use another C++
data structure (e.g. std::vector) that can grow efficiently.
Alternatively, you could create your own alternative to as.dendrogram
that doesn't create a hierarc
> // note: The FUN will change the object x itself
> // hence - it must be clear to use an object we wish to change
> (it will NOT be copied!)
Why do you want to do that? It's a generally a bad idea to modify R
objects in place.
Here's a simple example showing why C level
> I've just commited some code that will help us identify if a given R object
> (a SEXP) can be seen as a given c++ type (e.g. IntegerVector, etc ...)
>
> Works like this:
>
> SEXP x ; // a SEXP from somewhere, or an RObject
> is( x ) ;
> is( x ) ;
> is( x ) ;
Nice!
Combining this with attribute
On Wed, Jun 19, 2013 at 8:41 AM, Dirk Eddelbuettel wrote:
>
> On 19 June 2013 at 15:12, Romain Francois wrote:
> | So:
> | - when we release Rcpp 0.10.4 nothing changes. people can still enjoy
> | using this feature, if anyone is.
> | - when we release Rcpp 0.10.5 the feature is still there, but w
>> I'm sure we could just write a wrapper factory function that generates
>> all that code, it's just boilerplate until you get to the calls for
>> calling methods for whatever the XPtr points to
>>
>> Krzysztof
>
> Maintaining the idea that this external pointer acts as a numeric vector
> wit
> I generated a new Rccp package and changed the hello_world function.
> The attached Rcpp Code stops working if I rename the method
> "rcpp_hello_world" to
> "conditionalProbabilityTables". The error I get is:
> "conditionalProbabilityTables" not available for .Call() for package
> "PhyloFun"
>
>
> | So maybe sourceCpp could provide a warning if the extension is not in that
> list?
>
> Hmpd. I am not exactly sure why you advocate supporting .c or .f, .f90, .f95,
> .m and .mm none of which are likely to work _in any way_ with the parsing
> done and scaffolding added by sourceCpp. When you
>> R governs the behaviour of R CMD based on the extension.
>>
>> The .cxx form was /never/ supported by R as far as I know.
>
> Indeed. According to "Package subdirectories" in Writing R Extensions
> (http://cran.r-project.org/doc/manuals/R-exts.html#Package-subdirectories)
> the only supported e
> Dear Hadley, Dirk removed 3/4 of my original message :) I just added it now
> after your email so that our discussion inherit from the past.
That was me - I don't think it's relevant to your problem.
> - When I run make from MinGW terminal in the src folder of the git web site
> this fails (t
> I know this has to do with my library path (and actually when I launch the
> function "knit(input,output)" in R for a given Rcpp example this works and
> generate the markdown file) but don't find where this comes from.
Could you be more explicit? How are you running make? And how are you
runn
On Thu, Mar 21, 2013 at 10:44 AM, Smith, Dale wrote:
> I have a question about the fastLm example in the Gallery
> http://gallery.rcpp.org/articles/fast-linear-model-with-armadillo/. I put
> the code directly into my package (after renaming it fastLmProto so I don’t
> mask the RcppArmadillo functi
> | I searched BH for regex and found nothing so I don't think BH includes
> | Boost.Regex.
>
> Could you register an issue ticket at the r-forge page for BH, please? There
> are other things missing too, of course, as we started pretty with the needs
> of "just" bigmemory and RcppBDT.
But Boost.
t;
> and leave everything else unchanged.
>
>
> I'm not sure what the problem is though.
>
> Romain
>
> Le 20/02/13 22:14, Hadley Wickham a écrit :
>
>> I've attached a somewhat tweaked example which I think might indicate
>> that modules don't know ab
The answers should be 8, 100 and 0.08075014 respectively.
Hadley
On Wed, Feb 20, 2013 at 11:39 AM, Hadley Wickham wrote:
> Hi all,
>
> I'm having a simple problem with modules - when I instantiating the
> object and call the methods in C++, I get a different answer from
> instant
> as the funny name implies "Rf_inherits" comes from the R API.
You may want to read about InternalGenerics, which I suspect is what
Rf_inherits is used for. S3 dispatch has differences depending on
whether it's initiated in R or in C.
Hadley
--
Chief Scientist, RStudio
http://had.co.nz/
_
>> Until that happens, is it possible to write my own as and wrap methods?
>>
>
> Sure.
>
> For as, You can get a Simple* using this:
>
> Simple* obj = as_module_object(x) ;
>
> For the details, see as.h, this will call this:
>
> template object as_module_object(SEXP x){
> retu
Hi all,
I'm having a simple problem with modules - when I instantiating the
object and call the methods in C++, I get a different answer from
instantiating and calling the methods in R via a module. I've
attached a simple test case that you can run with sourceCpp() - when I
run it (using svn rev
> Dirk has an example in the Rcpp gallery --
> http://gallery.rcpp.org/articles/custom-as-and-wrap-example/. Not sure if
> you've seen it already, but it might help.
Yeah, I've seen it - the problem in my case is understand the
structure of the generate ref class so I can automatically generate
fr
> Unfortunately, at the moment modules and attributes don't play together. The
> attributes feature used to be built on top of modules, but this caused
> issues on windows.
>
> One thing we could perhaps negociate with JJ is recognition of the export
> attribute on module. Something like :
>
> // [
Hi all,
I'd like to have a simple C++ object that I can work with in either
C++ or R. I can create the class, and expose it to R with modules
(https://gist.github.com/hadley/4987110), but I don't know how to
write the SEXP constructor or SEXP() operator to make it easy to move
it back and worth b
> The reason we used a callback to data.frame is close to lazyness on our
> part. With the R function, for example we know that columns of different
> sizes will be handled properly, with recylcling, etc ...
And S3 methods (as.data.frame) will be dispatched upon correctly etc.
Hadley
--
Chief
On Fri, Jan 18, 2013 at 6:25 PM, John Merrill wrote:
> Sure. I'll write something up for the gallery, but here's the crude
> outline.
>
> Here's the C++ code:
Is C++ really necessary here? I have the following R function in plyr:
quickdf <- function(list) {
rows <- unique(unlist(lapply(list,
> On 9 December 2012 at 10:32, Gabor Grothendieck wrote:
> | Rgui.bat, R.bat and Rcmd.bat in the batchfiles distribution
> | automatically locate R, Rtools and temporarily set all environment
> | variables and modify your path appropriately each time you call R so
> | the whole process is just inst
> Nice document but it would be good to distinguish between the C
> interfaces -- the .C interface may not be fully general; however, it
> is adequate for a lot of numerical work such as writing the objective
> function and gradient in optimization routines and is not painful at
> all.
I guess my
> I'm not sure I'd go quite this far in ragging on the C API. For someone who
> wants to write plain-vanilla C code (without C++) working on vectors and
> matrices, it really seems acceptable to me. If someone doesn't have at
> least some basic technical ability, they shouldn't be writing C or C+
> I've printed this out and will sit down with it sometime in the next week.
> One (personal opinion) edit -- the following:
>
> " It is possible to write high performance code in C or Fortran. This
> might produce faster code than C++ (but probably not), but it will
> take you much much longer to
Hi all,
I've been working on a beginners guide to Rcpp at
https://github.com/hadley/devtools/wiki/Rcpp. The aim is to help R
programmers get the basics of C++ so that they can start to write
efficiently code as quickly and easily as possible.
I'd love your feedback - what have I missed? what is
> I have been attempting to collect enough material together to create a wiki
> book of sorts for the Windows user that is likely new to C++ as well. I
> would be pleased to receive progress notes/problems off-list as you venture
> here.
>
> Rtools is pretty good, but there are things happening th
> #define DISPATCH_METHOD(method, x) \
> switch( TYPEOF(x) ){ \
> case REALSXP: \
> return method(x);\
> case INTSXP:\
> return method(x); \
> case STRSXP:\
> return method(x); \
> ca
> 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
>> 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
> 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
> switch(x.sexp_type()) {
> case REALSXP:
> return wrap(unique1(as(x)));
> break;
> case INTSXP:
> return wrap(unique1(as(x)));
> break;
> case CHARSXP:
That should be STRSXP, of course.
Hadley
--
RStudio / Rice University
http://had.co.nz/
Hi all,
I've attached a simple implementation of unique for numeric, integer,
logical, and character vectors. To do that I have four C++ function,
along the lines of :
std::tr1::unordered_set unique1(NumericVector x) {
return std::tr1::unordered_set(x.begin(), x.end());
}
and then one exporte
>> I don't think they _have_to - my understanding is that the expression
>> template approach is general enough that you could compile away those
>> intermediates. It may be extremely difficult to do though!
>
> That's the issue in delayed evaluation. You do a lot of template magic to
> discover
> In my case, informed by interesting benchmarks such as yours, I now tend
> to write my R functions with optimizing to C++ in mind. In other words,
> I've stopped being ashamed of having loops in my R code.
>
> If my R script completes Quick Enough I don't care. But when it takes
> Too Long, I kno
>> I think you could do it a bit more elegantly with
>>
>> gender <- 0.75 + female * 0.5
>>
>> but pmin and pmax are "real" primitives, so I think it's fine to use them.
>
>
> In the folklore ifelse, pmin and pmax are know to be slow. I know that
> there was some work on pmin and pmax but I think
> 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 _have_to - my understanding is that the expression
template approach is general enough that you could compile away those
intermediate
> But still, I don't understand why you consider pmin and pmax as primitives?
>
> Even if they are part of the base package it's not right to consider them as
> primitive of the R language!
>
> You can check:
> .Primitive('pmax')
Well, they're implemented in C code. I don't think R has a good
defi
> To be fair with the R language, I would have compare with the use of real
> primitives :
>
> vaccBubu <- function(age, female, ily) {
> gender <- female * 1.25
> gender[!female] <- 0.75
> p <- (0.25 + 0.3 * 1 / (1 - exp(0.04 * age)) + 0.1 * ily) * gender
> p[p < 0] <- 0
> p[p
> Unsurprisingly the R loop (vacc1) is very slow, and proper
> vectorisation speeds it up immensely. Interestingly, however, the C++
> loop still does considerably better (about 10x faster) - I'm not sure
> exactly why this is the case, but I suspect it may be because it
> avoids the many intermed
> | 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
>
> [ I liked that post, but we got flak afterwards as his example was not well
> chosen. The illustration of the language speed difference do
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 vaccinate function:
* vacc1: vectorisation in
>> recycle(x, y, z);
>>
>> Hadley
>
>
> In a way, we can already use sugar rep_len.
>
> rep_len( x, 30 )
>
> will recycle x into a vector of length 30, lazily.
Agreed, but a helper function would automate this process:
int length = max(x.length(), y.length(), z.length())
# check integer multiples
>> microbenchmark(
>>pdist1(0.5, ys),
>>pdist2(0.5, ys),
>>pdist3(0.5, ys)
>> )
>> # 10-fold slower?? Maybe it's because I'm using a double instead of
>> # a numeric vector?
>
> That's weird. Not sure where the ineffiency is. Some hunting.
> My guess is that sugar pow needs a refresh.
On Sat, Nov 17, 2012 at 9:23 AM, Romain Francois
wrote:
> Le 17/11/12 15:22, Hadley Wickham a écrit :
>>
>> Hi all,
>>
>> Am I doing something wrong with the functions below, or has this
>> behaviour not yet been implemented in Rcpp?
>>
>>
Hi all,
Am I doing something wrong with the functions below, or has this
behaviour not yet been implemented in Rcpp?
cppFunction('std::string first_char(CharacterVector x) {
return x[0];
}')
cppFunction('CharacterVector miss_c() {
return CharacterVector::create(NA_STRING)
Hi all,
I've included what seems to be a simple application of Rcpp sugar
below, but I'm getting some very strange results. Any help would be
much appreciate!
Thanks,
Hadley
library(Rcpp)
library(microbenchmark)
# Compute distance between single point and vector of points
pdist1 <- function(x
> Ouch. Simon wins:
>
> expr minlqmedianuq max
> 1 fmatch(xx, letters) 59.4727 60.29989 74.18049 77.94288 112.2938
> 2 match__(xx, letters) 137.3878 137.77486 138.33766 152.14018 193.3748
> 3 match_(xx, letters) 147.7115 148.36442 149.20221 162.
> | I've been using (e.g.) http://www.cplusplus.com/reference/stl/map/ a
> | lot - it has plenty of examples, which is really helpful for getting
> | started.
>
> It seems that site has a bit of an uncool reputation among the cognoscenti on
> SO.
So you're saying it's good? ;)
> I usually go bac
> You might like to di something like:
>
> std::vector< std::vector > groups( max(i) ) ;
>
> you'll pay for the traversal of the max, but then you don't need to resize.
I ended up going with:
NumericVector tapply3(NumericVector x, IntegerVector i, Function fun) {
std::map > groups;
NumericVe
> | Cool - thanks! It might be useful in general to expose some of the
> | STL sorted range commands - I'm not sure if that's general enough for
> | base Rcpp or not.
>
> Even having really good documentation on all the STL goodness would be good.
> There is an entire chapter in (free, pdf and oth
ley
On Fri, Nov 16, 2012 at 8:36 AM, Hadley Wickham wrote:
> Hi all,
>
> I'm attempting to write a simple version of tapply in C++ (see
> attached). However, when I run tapply2(1, 1, sum) (which should
> return 1), R segfaults. If I run R with gdb, I get the followin
Hi all,
I'm attempting to write a simple version of tapply in C++ (see
attached). However, when I run tapply2(1, 1, sum) (which should
return 1), R segfaults. If I run R with gdb, I get the following
stack trace:
#0 0x03942120 in tapply2 (x=@0xbfffda68, i=@0xbfffda58,
fun=@0xbfffda50) at tappl
>> I guess we could come up with a nicer syntax for these, maybe static
>> functions in Vector<> so that we could do :
>>
>> IntegerVector::is_na( )
>> NumericVector::get_na( )
>> ...
>
>
> commmited in rev 3979.
I don't want to flog a dead horse, but one of the things I like about
github is how e
On Fri, Nov 16, 2012 at 2:25 AM, Romain Francois
wrote:
> Thanks for exploring these issue. This looks very useful.
>
> I get:
>
>> str( first_log(NA) )
> logi TRUE
>> str( first_int(NA_integer_) )
> int NA
>> str( first_num(NA_real_) )
> num NA
>> str( first_char(NA_character_) )
> chr "NA"
>
> I've commited an initial version of setdiff.
Cool - thanks! It might be useful in general to expose some of the
STL sorted range commands - I'm not sure if that's general enough for
base Rcpp or not.
> There is room for improvement given the R version:
>
>> setdiff
> function (x, y)
> {
>
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
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
>> 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)?
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
> 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
> | 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
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
> devtools on github is still of version 0.7.1. Are you talking about a
> branch different from master? In the newer version, when I call
> load(), it will automatically compile the C++ code?
The version number hasn't been bumped yet, but you'll notice there
have been many changes. load_all will
> Thanks! I did briefly consider testthat, based on reading [1], and
> dismissed it because it seemed to be different without being better.
> (I'm not saying it was worse, just it didn't appear to have any killer
> reason to make it worth turning my back on the 10-15 years worth of
> experience the
> BTW, the test code in RcppArmadillo_0.3.2.4/inst/unitTests can be run
> only after RcppArmadillo is installed. For a developer, he/she does
> not always want to install the package before he/she can run the test
> case. "devtools" solves this problem for pure R package. I'm wondering
> if there i
>
> | > And you can tell R CMD INSTALL to skip steps like vignettes, tests,
> cleanup,
> | > ... to just load the R and C++ code.
> |
> | Do you have a standard set of flags you use: --no-docs --no-html
> | --no-multiarch? I'll probably make a quick_install function for
> | devtools. (Or maybe I
> Plus I call 'g++' et al as 'ccache g++' so it's all cached in case of no
> changes, thanks to the amazing compiler caching package ccache (which is
> pretty standard on Linux).
Never heard of that before - thanks!
> And you can tell R CMD INSTALL to skip steps like vignettes, tests, cleanup,
>
> Sure, very valid question. I tend to do two things:
>
> a) at times experiment/try/play with the inline package and cxxfunction
>
> b) much more often, work with a package where, for force of habit, my
> typical workflow often is
>
> $ R CMD INSTALL mypkg && r -lmypkg -e 'someFunctio
> For usage beyond what we document and test, you're on your own. If you want
> to explore usage with devtools and other means, go for it.
>
> But I will be unlikely to have time to work this out for you, unfortunately.
Let me flip this around on you - when you're developing a package that
uses R
> I get quite a speed up on hadley's example:
>
> utilisateur système écoulé
> 1.555 0.003 1.558
> utilisateur système écoulé
> 0.547 0.004 0.550
> [1] TRUE
Thanks Romain! I get a similar improvement:
system.time(convolve_2d(x, k))
# user syst
> What are you doing the timing on? On a modest desktop (2.6 GHz Athlon
> X4) I get less than a second for this
...
>> k <- matrix(runif(20* 20), ncol = 20)
>> system.time(convolve_2d(x, k))
> user system elapsed
> 0.864 0.000 0.862
Ooops, I must have been using a old k - I now get
> sys
> Fancy indexing tricks aside, another avenue you might want to look
> into is doing the convolution in fourier space ...
I have looked into that, and I'm pretty sure for my case (k much
smaller than x), that it's less efficient (and less numerically
stable). In my experience, it also make the co
> As I said earlier, this construction guarantees that the storage is
> not copied. An Rcpp::NumericVector also uses the storage from R but
> it can be difficult to determine exactly when a copy constructor,
> which actually allocates new storage for an SEXPREC, is invoked.
But that's half the fu
Hi all,
The rcpp-devel list has been very helpful to me so far, so I hope you
don't mind another question! I'm trying to speed up my 2d convolution
function:
library(inline)
# 2d convolution -
convolve_2d <- cxxfunction(signature(sam
> I'm coming late to the party but ... I was able to squeeze a couple
> of milliseconds from the computation by expressing the counts as
> integers and ensuring that I did not copy x by using an Eigen::Map.
> It may well be that an Rcpp::NumericVector will not be a copy in this
> case but I have f
1 - 100 of 115 matches
Mail list logo