Re: [Rcpp-devel] Starting R Interpreter from C++

2017-06-12 Thread Romain Francois
You might be looking for RInside. > Le 12 juin 2017 à 10:11, Wolf Vollprecht a écrit : > > I am trying to run C++ tests from C++ directly. > It looks like I need to start the R interpreter for memory management etc. > > So far I have achieved moderate success through: > > int Rf_initEmbedded

Re: [Rcpp-devel] Code review for xtensor R bindings

2017-06-07 Thread Romain Francois
Hi, Instead of doing that: const int vtype = traits::r_sexptype_traits::rtype; SEXP shape_sxp = Rf_allocVector(vtype, shape.size()); Perhaps your rxarray object could hold an IntegerVector. Also not quite sure why you use the first line at all, which does not depend on T, so vtype is always

Re: [Rcpp-devel] RcppParallel wrong after correct

2017-06-02 Thread Romain Francois
Can you prepare a reprex ? > Le 2 juin 2017 à 15:40, "f.k...@mailbox.org" a écrit : > > Hi all, > > I wrote a function foo using RcppParallel and I am observing a bug, which I > can’t figure out. > I first wrote the function in R, then in Rcpp, then RcppParallel. > > foo is doing exactly what

Re: [Rcpp-devel] starter

2017-05-31 Thread Romain Francois
of undeclared identifier 'output' > output.begin() + begin, > ^ > 2 errors generated. > make: *** [par_example.o] Error 1 > > > Hope this is as easily solved as the before error. > > Cheers, Franz > > > > >> On 31 May 2017, at 12:2

Re: [Rcpp-devel] starter

2017-05-31 Thread Romain Francois
You can add this somewhere on top of your cpp file // [[Rcpp::depends(RcppParallel)]] Romain > Le 31 mai 2017 à 12:22, f.k...@mailbox.org a écrit : > > Hi all, > > I am very new to Rcpp and I wrote a function which I now want to parallelize. > The function is working fine, and is much faster

Re: [Rcpp-devel] Rcpp sugar for double?

2017-02-22 Thread Romain Francois
Hello, Functions in sugar only apply to vectors. For a single value, you’d have to use the dnorm function in the R:: namespace: // [[Rcpp::export]] double test6(double x){ double y = R::dnorm(x,5.0,2.0,true); return y; } > test6(3) [1] -2.112086 > dnorm(3, mean = 5, sd = 2, log = TRUE)

Re: [Rcpp-devel] Rcpp Timer

2016-12-30 Thread Romain Francois
> | It is indeed cumulative. Previously (presumably when that gallery page was > | written) it was not cumulative, but Romain Francois changed the behavior of > the > | step() function several years ago, in this commit: > https://github.com/RcppCore/ > | Rcpp/commit/e295b2b178de552

Re: [Rcpp-devel] Rcpp ISNAN slower than C ISNAN?

2016-12-13 Thread Romain Francois
I’d be interesting to see what this more C++idomatic version would perform nanCount = std::count_if( x.begin(), x.end(), ISNAN ) ; Because despite all the inlining efforts that has been put in the implementation of NumericVector, its operator[] might not perform as well as using [] on a double

Re: [Rcpp-devel] NA in templates

2015-09-08 Thread Romain Francois
You can use T::get_na() Romain > Le 9 sept. 2015 à 08:24, Rguy a écrit : > > What is correct way to represent NA in a template? I have been successfully > using NA_REAL (see example below) but I am not sure if this is the proper > method. > Thanks. > > /* template_NA.cpp: > Experiment with

Re: [Rcpp-devel] Specify Rcpp header location in Makevars

2015-07-29 Thread Romain Francois
You need LinkingTo: Rcpp And the information goes into the CLINK_CPPFLAGS variable if you really need to make a custom rule for .cpp files Romain > Le 29 juil. 2015 à 17:19, "jsmith5...@yahoo.com" a > écrit : > > Hi, > > Is there a way to automatically specify the location of the Rcpp inclu

Re: [Rcpp-devel] Specify Rcpp header location in Makevars

2015-07-29 Thread Romain Francois
You need LinkingTo: Rcpp As per the current documentation. Romain Envoyé de mon iPhone > Le 29 juil. 2015 à 17:19, "jsmith5...@yahoo.com" a > écrit : > > Hi, > > Is there a way to automatically specify the location of the Rcpp include > directory (for Rcpp.h) in Makevars? > > In my Make

Re: [Rcpp-devel] When calling same Rcpp function several times different results are returned

2015-07-14 Thread Romain Francois
Or just use a std::vector for sg. That should do it. Romain Envoyé de mon iPhone > Le 14 juil. 2015 à 13:21, JJ Allaire a écrit : > > The examples in the RcppParallel documentation assume that access to > vectors and matrixes are *aligned* (i.e. fall into neat buckets > whereby reading and wr

Re: [Rcpp-devel] On Developing Header Packages

2015-04-07 Thread Romain Francois
I would definitely second that. This eliminates a whole class of hard to deal with issues. Even Rcpp IMO should really just be header only. Romain Envoyé de mon iPhone > Le 7 avr. 2015 à 20:51, JJ Allaire a écrit : > > I think that header-only packages (where possible) are definitely > pre

Re: [Rcpp-devel] RcppParallel on Solaris

2015-04-02 Thread Romain Francois
Would be useful to have a solaris machine on aws or whatever with R all these toils installed. I once had a virtual machine set up thanks to martyn but the user experience of virtualbox + keyboard conflicts with my french mac book keyboard was not that good. Does someone have the skills to s

Re: [Rcpp-devel] assert() for Rcpp?

2015-02-20 Thread Romain Francois
Envoyé de mon iPhone > Le 18 févr. 2015 à 17:31, JJ Allaire a écrit : > > We *can* call Rf_error from C++ code, but when we do it bypasses all > C++ destructors on the stack, so we don't do it so as not leak memory > and otherwise have deterministic behavior around > construction/destruction.

Re: [Rcpp-devel] Does uncaught c++ exception cause memory leak?

2014-12-29 Thread Romain Francois
Uncaught exception gives you UB. It is however difficult not to catch exceptions if you use Rcpp::export attributes which includes a "catch all and deal with it" part. Romain Envoyé de mon iPhone > Le 29 déc. 2014 à 18:28, Wush Wu a écrit : > > Dear all, > > I have a question which is desc

Re: [Rcpp-devel] String encoding (UTF-8 conversion)

2014-12-15 Thread Romain Francois
That is similar to a path i've followed in Rcpp11/Rcpp14. What's really missing in R is api access to strings, e.g testing for equality of two CHARSXP, comparing them, ... This causes all sorts of problems with dplyr. Romain > Le 16 déc. 2014 à 06:00, Jeroen Ooms a écrit : > >> On Thu, Dec

Re: [Rcpp-devel] Returning an arma vec

2014-12-03 Thread Romain Francois
Envoyé de mon iPhone > Le 3 déc. 2014 à 17:59, Gabor Grothendieck a écrit : > > 1. This returns a matrix rather than a vector: > > -- start of file teste.cpp --- > #include > // [[Rcpp::depends(RcppArmadillo)]] > > using namespace arma; > using namespace Rcpp; > > // [[Rcpp::export]] > Nume

Re: [Rcpp-devel] Indexing vector with x(i) and x[i] gives remarkable difference in computing time

2014-11-27 Thread Romain Francois
> Le 27 nov. 2014 à 13:22, Søren Højsgaard a écrit : > > Dear all, > By "accident" I noticed that indexing with x(i) and x[i] gives remarkable > difference in computing time. For example: > > library(Rcpp) > cppFunction(' > IntegerVector insert1 (int n){ > IntegerVector z(n); > for (int i=0;

Re: [Rcpp-devel] Const correctness of NumericVector iterators

2014-11-27 Thread Romain Francois
This is probably related to this: template struct r_vector_const_iterator { typedef typename storage_type::type* type ; }; There should be a const there somewhere. FWIW, more modern implementations of R/C++ are more safe on that issue: $ Rcpp11Script

Re: [Rcpp-devel] sugar: x+y and y+x gives different results when there are NA's in y

2014-11-22 Thread Romain Francois
You get UB if the first is bigger than the second. Envoyé de mon iPhone > Le 22 nov. 2014 à 14:30, Søren Højsgaard a écrit : > > OK; thanks! Shall I read this such as "the behaviour is undefined"? > Søren > > |-Original Message----- > |From: R

Re: [Rcpp-devel] sugar: x+y and y+x gives different results when there are NA's in y

2014-11-22 Thread Romain Francois
This has nothing to do with NA. It's just about the size difference. sugar does not make attempt at recycling. Your responsibility. Romain > Le 22 nov. 2014 à 11:48, Søren Højsgaard a écrit : > > Dear all, > Came across this: > > #include > using namespace Rcpp; > > //[[Rcpp::export]] > Li

Re: [Rcpp-devel] inplace modification more affect other varibles

2014-10-22 Thread Romain Francois
g Xu a écrit : > > Thanks a lot! > > Does that mean we should never modify an argument passed from R to cpp? > > On Wed, Oct 22, 2014 at 8:24 AM, Romain Francois <mailto:rom...@r-enthusiasts.com>> wrote: > a and b are the same object: > > > a <- s

Re: [Rcpp-devel] inplace modification more affect other varibles

2014-10-22 Thread Romain Francois
a and b are the same object: > a <- seq(1, 0.1, -0.1) > b <- a > pryr::address( a ) [1] "0x7f9504534948" > pryr::address( b ) [1] "0x7f9504534948" So clone is what you need here. Implementing copy on write for that kind of example is possible, but would require a lot of additional code, i.e.

Re: [Rcpp-devel] convert to unsigned char* variable

2014-10-20 Thread Romain Francois
Hi, that's not going to fly. A CharacterVector holds strings of arbitrary lengths, well technically it holds other R objects (SEXP) that hold pointers to strings. A RawVector holds unsigned char. Can you add some meat to your example, e.g. what you'd expect to go in, etc ... Romain > Le

Re: [Rcpp-devel] convert to unsigned char* variable

2014-10-20 Thread Romain Francois
> Le 20 oct. 2014 à 21:54, Dirk Eddelbuettel a écrit : > > > Hi Gustaf, > > On 20 October 2014 at 15:17, Gustaf Granath wrote: > | Im trying to use some C++ functions in R. However, these functions are > | build around unsigned char* variables (1D array). I have for example a > | large matri

Re: [Rcpp-devel] Grid Search in RcppParallel

2014-10-04 Thread Romain Francois
Envoyé de mon iPhone > Le 5 oct. 2014 à 07:51, Jeffrey Wong a écrit : > > I am trying to use RcppParallel to do a fast grid search. The idea is to > construct a matrix using R's expand.grid, then for each row of that matrix, > x, call f(x). For simplicity the function f will always return a

Re: [Rcpp-devel] statement about rcpp11 ?

2014-09-29 Thread Romain Francois
If you want to have a private conversation with Dirk, just email him directly: e...@debian.org Now since this is all in the open, let me participate to this. Le 29 sept. 2014 à 22:42, Jonathon Love a écrit : > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA512 > > hey dirk, > > i was wonderi

Re: [Rcpp-devel] Pass an Rcpp module object to a method belonging to another module from R?

2014-09-10 Thread Romain Francois
Le 10 sept. 2014 à 14:22, Gregory Jefferis a écrit : > > > Gregory Jefferis > > On 10 Sep 2014, at 10:39, Romain Francois wrote: > >> RCPP_EXPOSED_CLASS(A) >> >> before you declare class A and simply use this signature for the method. >>

Re: [Rcpp-devel] Pass an Rcpp module object to a method belonging to another module from R?

2014-09-10 Thread Romain Francois
This is once again something with which the RCPP_EXPOSED_CLASS macro can help with. Try adding RCPP_EXPOSED_CLASS(A) before you declare class A and simply use this signature for the method. void DoSomethingWithInstanceOfA(const A& ) Also, you can have both of these classes in the same modul

Re: [Rcpp-devel] RcppModules with templated class

2014-09-01 Thread Romain Francois
Le 1 sept. 2014 à 11:48, Dr Gregory Jefferis a écrit : > Hello, > > I have a more or less complete Rcpp(Eigen) dependent package that exposes a > pair of C++ classes to R using RcppModules;the C++ classes (which implement k > nearest neighbour search trees) differ only in their scalar storag

Re: [Rcpp-devel] (Very) rare segfault

2014-08-21 Thread Romain Francois
g attributes then this isn't a concern, if you are not > then you need the return value SEXP on the stack prior to RNGScope. > > On Thursday, August 21, 2014, Romain Francois > wrote: > Ah interesting. PutRNGstate does indeed allocate so might trigger GC. > h

Re: [Rcpp-devel] (Very) rare segfault

2014-08-21 Thread Romain Francois
in and Gregor, > > maybe I am misunderstanding everything, but hasn't this problem been > explained and solved here: > > http://lists.r-forge.r-project.org/pipermail/rcpp-devel/2013-May/005838.html > > Best, > > Matteo > > > > > On Thu, Aug 21,

Re: [Rcpp-devel] (Very) rare segfault

2014-08-21 Thread Romain Francois
Le 21 août 2014 à 11:47, Gregor Kastner a écrit : > On Thu, 21 Aug 2014 11:34:23 +0200 > Romain Francois wrote: > > GK> Yep, sorry for the misuse of language. And I do understand going back to > GK> GetRNGstate() and PutRNGstate() is a bit old school; but I can definite

Re: [Rcpp-devel] (Very) rare segfault

2014-08-21 Thread Romain Francois
Le 20 août 2014 à 20:57, Gregor Kastner a écrit : > JJ> Yes, RNGScope isn't safe by itself. You can use it via attributes (and we > JJ> make sure to use it correctly) or you could use this pattern e.g. if you > JJ> are planning to return a NumericVector: > JJ> > JJ> NumericVector vec(20); //

Re: [Rcpp-devel] [Rcpp] How can i call a R function in Cpp source code?

2014-08-05 Thread Romain Francois
Not sure what you mean by hide the R function. You can extract a function by its name on the C++ side : Function bazinga("mean") ; or extract it from a particular environment, e.g. Environment("package:base")["mean"] or Environment base("package:base") ; Function foo = base["mean"] Romain

Re: [Rcpp-devel] Typecasting bug in Rcpp::List (generic_name_proxy) when using clang

2014-07-29 Thread Romain Francois
EST PROTOCOL -- Tue Jul 29 13:20:29 2014 > *** > Number of test functions: 439 > Number of errors: 0 > Number of failures: 0 > > > Sorry, due to a restrictive firewall on my dev computer, I cannot access > github from it. A mail will have to suffice for now. > >

Re: [Rcpp-devel] Typecasting bug in Rcpp::List (generic_name_proxy) when using clang

2014-07-29 Thread Romain Francois
This is likely to be a bug in Rcpp, don't go bother clang about it:) Perhaps you can try to remove the bool cast and run the test suite. If everything works, then it either means that there are no tests for the particular case or that the overload is useless. You probably have to consider what

Re: [Rcpp-devel] Faster lookup: Named Rcpp::List or std::map?

2014-07-23 Thread Romain Francois
Lookup in Rcpp::List is linear on something that is quite cheap (comparing pointers, because strings in R are cached). Lookup in std::map is logarithmic on whatever it means to compare the keys (so in your case comparing strings). on top of that, copying the data across is linear in the best c

Re: [Rcpp-devel] RCPP_MODULE for inheritance class

2014-06-19 Thread Romain Francois
Hi, Please find an answer here. http://stackoverflow.com/questions/24317910/rcpp-module-for-inheritance-class/24320207#24320207 Romain Le 20 juin 2014 à 01:13, Jianyang Zhao a écrit : > Hello All, > > I got a problem when I try module with inheritance class. Basiclly, I can't > compile thi

Re: [Rcpp-devel] Raise a condition

2014-06-18 Thread Romain Francois
Le 19 juin 2014 à 03:05, Dirk Eddelbuettel a écrit : > > On 18 June 2014 at 19:40, Tim Keitt wrote: > | > | > | > | On Wed, Jun 18, 2014 at 6:26 PM, Dirk Eddelbuettel wrote: > | > | > | Tim, > | > | Step back for a second and recognise that everything happens via > | > |

Re: [Rcpp-devel] Raise a condition

2014-06-18 Thread Romain Francois
Le 19 juin 2014 à 01:02, Tim Keitt a écrit : > > > > On Wed, Jun 18, 2014 at 5:37 PM, Romain Francois > wrote: > Le 19 juin 2014 à 00:30, Tim Keitt a écrit : > >> On Wed, Jun 18, 2014 at 5:22 PM, Romain Francois >> wrote: >> Le 1

Re: [Rcpp-devel] Raise a condition

2014-06-18 Thread Romain Francois
Le 19 juin 2014 à 00:30, Tim Keitt a écrit : > On Wed, Jun 18, 2014 at 5:22 PM, Romain Francois > wrote: > Le 19 juin 2014 à 00:15, Tim Keitt a écrit : > > >> >> On Wed, Jun 18, 2014 at 5:07 PM, Romain Francois >> wrote: >> Le 18 juin 2014 à 23:5

Re: [Rcpp-devel] Raise a condition

2014-06-18 Thread Romain Francois
Le 19 juin 2014 à 00:15, Tim Keitt a écrit : > > On Wed, Jun 18, 2014 at 5:07 PM, Romain Francois > wrote: > Le 18 juin 2014 à 23:54, Tim Keitt a écrit : > > >> I'd like to raise a condition other than error or warning. Is that possible >> using the Rcpp

Re: [Rcpp-devel] Raise a condition

2014-06-18 Thread Romain Francois
Le 18 juin 2014 à 23:54, Tim Keitt a écrit : > I'd like to raise a condition other than error or warning. Is that possible > using the Rcpp api? I assume this can be done via R internals, but I'd prefer > not to call error() directly (or is that the recommendation?). > > THK Definitely not. R

Re: [Rcpp-devel] "Error during wrapup"

2014-05-28 Thread Romain Francois
is the problem. Romain > > On Wed, May 28, 2014 at 3:44 PM, Romain Francois > wrote: > (now with some links): > > Le 28 mai 2014 à 16:31, John Mous a écrit : > >> The object really is just built as part of the return statement. i.e. the >> lines from my prio

Re: [Rcpp-devel] "Error during wrapup"

2014-05-28 Thread Romain Francois
(now with some links): Le 28 mai 2014 à 16:31, John Mous a écrit : > The object really is just built as part of the return statement. i.e. the > lines from my prior e-mail exist as-is in the full code, Sure. What happens is that Rcpp::export generates something that calls wrap( std::map ).

Re: [Rcpp-devel] "Error during wrapup"

2014-05-28 Thread Romain Francois
This looks like a protection issue. For whomever this makes sense to: From the code that wraps such object, i would investigate the call to setAttrib. Perhaps we are supposed to get the result of it and protect it. So i would tend to use an Armor instead of a Shield. Romain Le 28 mai 2014

Re: [Rcpp-devel] How to create list of list without known structure

2014-05-06 Thread Romain Francois
Le 6 mai 2014 à 09:35, Florian Burkart a écrit : > Hi, > > I have been creating lists of lists with > > return Rcpp::List::create(Rcpp::Named("vec") = someVector, > Rcpp::Named("lst") = someList, > Rcpp::Named("vec2") = someOtherVector); >

Re: [Rcpp-devel] Questions on extending Rcpp wrap and as with templates

2014-05-06 Thread Romain Francois
Le 6 mai 2014 à 08:45, Florian Burkart a écrit : > Hi everyone (and Dirk), > > Second attempt on corrected email list. > > I have been trying to extend Rcpp with my own wrap and as templates. > > Two issues: > > 1) I need to explicitly call wrap. Is that expected? > > So for example I wrote

Re: [Rcpp-devel] g++ flags

2014-04-30 Thread Romain Francois
gt; > I've tested and it seems to work as intended. Is this fix you were conceiving > of or is there something more we should be doing? > > J.J. > > > On Wed, Apr 30, 2014 at 9:19 AM, Romain Francois > wrote: >> The plugin as implemented now is not portable

Re: [Rcpp-devel] g++ flags

2014-04-30 Thread Romain Francois
The plugin as implemented now is not portable. The easiest way to make it portable would be to define the USE_CXX1X environment variable, which R knows how to interpret. This way R would do what makes sense, i.e. use -std=c++0x on windows (for which rtools is limited to gcc 4.6.3 now) and -std

Re: [Rcpp-devel] Parallel random numbers using Rcpp and OpenMP

2014-04-28 Thread Romain Francois
Hi, If you can assume c++11, you might bot need openmp, as you can just use standard support for threads, etc ... Although the compiler suite used on windows (if you care about that) does not support c++11 threads. This might be available later. Romain Le 28 avr. 2014 à 12:51, Matteo Fasi

[Rcpp-devel] Rcpp11 3.1.0 is on CRAN

2014-04-11 Thread Romain Francois
Hello, I’ll keep it short here. Rcpp11 3.1.0 was released on CRAN today. An announcement email has been sent to both r-packages and the new R and C++ mailing list. https://groups.google.com/forum/#!forum/r-and-cpp Best Regards, Romain ___ Rcpp-deve

Re: [Rcpp-devel] Generic R and C++ discussion

2014-04-08 Thread Romain Francois
Le 8 avr. 2014 à 13:28, stat quant a écrit : > Hi, > Will that be ok to ask Rcpp questions to on this list too? > Definitely. Anything R and C++ related. > On 8 Apr 2014 09:56, "Romain François" wrote: > Hello, > > I have created a new mailing list (as a google group) for general discussio

Re: [Rcpp-devel] Rcpp syntactic sugar equivalent for R's optimize() function

2014-02-28 Thread Romain Francois
Le 28 févr. 2014 à 11:52, Gregor Kastner a écrit : > Hi Hideyoshi, > >> Is there a way I can just call that function in Rcpp rather than having to >> install new libraries or create my own? (I presume that there is probably a >> “C_do_fmin.c” file somewhere that I can use?) > > This questions

Re: [Rcpp-devel] Default empty values for vector and matrices

2014-02-17 Thread Romain Francois
Le 17 févr. 2014 à 12:17, Alessandro Mammana a écrit : > Dear all, > I am trying to write an Rcpp function that accepts optionally a > vector, but I cannot figure out what default value I should give to > it. > > First I tried the following: > > // [[Rcpp::export]] > int nilVec(NumericVector v

Re: [Rcpp-devel] Array into C++ with cppFunction

2014-02-12 Thread Romain Francois
FYI, there is a Array template in Rcpp11. https://github.com/romainfrancois/Rcpp11/blob/master/inst/include/Rcpp/Array.h With which you could use code like this: #include using namespace Rcpp ; // [[Rcpp::export]] double NewFunc( NumericArray<3> x){ return x(1,2,3) + x(2,3,4) ; } Romain L

Re: [Rcpp-devel] Segfault, is it because of iterators/pointers?

2014-02-12 Thread Romain Francois
Le 12 févr. 2014 à 13:36, Alessandro Mammana a écrit : > Ah wait, my bad (as always T.T), I found a much simpler explanation: > > colset <- sample(3e7-nr, 1e7) > storage.mode(colset) > [1] "integer" > storage.mode(colset-1) > [1] "double" > > So when I was unwrapping colset I allocated new mem

Re: [Rcpp-devel] calling and R function from rcpp and evaluation

2014-02-06 Thread Romain Francois
Hi Antonio, This is about how R evaluation works. Might not just be what you think it is. When you use Rcpp and therefore .Call things are evaluated fairly early, at least earlier than what would happen with R, etc … you can reproduce what R does by using promises. For example this work in Rc

Re: [Rcpp-devel] Package built with Rcpp fails to install

2014-02-03 Thread Romain Francois
com | > Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | > www.r-statistics.com (English) > ------ > > > > On Mon, Feb 3, 2014 at 9:12 PM, Romain Francois > wrote: >> The problem is likely t

Re: [Rcpp-devel] Package built with Rcpp fails to install

2014-02-03 Thread Romain Francois
The problem is likely to be that it was assumed that List derives from RObject. It used to, it does not anymore. Classes from the api now use a policy based design. See andrei alexandrescu's modern c++ book for the why and the how of policy based design. . Envoyé de mon iPhone Le 3 févr.

Re: [Rcpp-devel] RcppMLPACK ?

2014-01-20 Thread Romain Francois
Hello, Do you have a budget fo that work ? Romain Le 20 janv. 2014 à 11:12, Damian Lyons a écrit : > Dear Rcpp developers, > > Firstly, many thanks for your work on Rcpp. It has saved me countless hours > (or is that months?) of simulation time. > > I'm a big fan of RcppArmadillo and Arma

Re: [Rcpp-devel] A strange question while using Rcpp

2014-01-19 Thread Romain Francois
Hello, This stands out double U; for(int i=0; i(X); NumericVector y = as(Y); … } by things like this: //[[Rcpp::export]] double mydcov(NumericVector x, NumericVector y){ … } Romain Le 19 janv. 2014 à 14:09, 晔张 a écrit : > Hello, everyone. > I guess the probrem maybe occur be

Re: [Rcpp-devel] Bug: compileAttributes incorrectly handles Rcpp::export-ed functions with multiple arguments

2014-01-18 Thread Romain Francois
Le 18 janv. 2014 à 06:10, Davor Cubranic a écrit : > Running compileAttributes with “verbose = TRUE” was very informative: > > $ Rscript -e 'Rcpp::compileAttributes(".", TRUE)' > Exports from /Users/davor/projects/Davor/myPackage/src/rcpp_hello_world.cpp: >List rcpp_hello_world(NumericVecto

Re: [Rcpp-devel] vector < RawVector > to RawMatrix [like do.call(rbind, mylist)]

2014-01-10 Thread Romain Francois
Hi, If you wrap your std::vector you get a list of raw vectors, and this does not do deep copies of the RawVector. If you want a RawMatrix, you have to make copies as all the matrix data is contiguous in memory. Perhaps you can change things around, first create the matrix and then fill it

Re: [Rcpp-devel] Question about modules

2014-01-09 Thread Romain Francois
; On Thu, Jan 9, 2014 at 11:31 AM, Romain Francois > wrote: > Hi, > > The module docs is probably the one in the worst shape. I think the current > recommendation is to have this in one of your .R files: > > loadModule( "yourmodule", TRUE ) > > which trigge

Re: [Rcpp-devel] Question about modules

2014-01-09 Thread Romain Francois
the factory function pointer.) > > However I am not seeing any of my functions exported to the package. How > would the factory be called from R? I sort of understood that exporting in > packages was automatic. Do I have to manually create the module in R? > > THK > >

Re: [Rcpp-devel] Question about modules

2014-01-09 Thread Romain Francois
Hello, You can use .factory instead of .constructor in that case. Romain Le 9 janv. 2014 à 03:16, Tim Keitt a écrit : > I did a little experiment with RCPP_MODULE trying to wrap a class from > another library. The class in question has a protected default constructor > and uses a non-membe

Re: [Rcpp-devel] Problems wrapping stl::vector

2014-01-03 Thread Romain Francois
Hello, wrap is for converting an object of arbitrary class to an R object. It deduces what to do based on the class of what you pass it. So you usually don’t specify the template parameter. So you’d usually just write : return wrap(a); If you wanted to be explicit, then you would use: re

Re: [Rcpp-devel] What is the most efficient method to check if a Rcpp vector contains an element?

2013-12-31 Thread Romain Francois
Thanks. In any case, for things like this the best thing to do is to not trust what anyone says and actually benchmark with realistic data. Romain Le 31 déc. 2013 à 16:29, Hadley Wickham a écrit : >> I believe you are mistaken. sorting is an expensive O( N log(N) ) operation. >> >> I’d use

Re: [Rcpp-devel] exporting void test(void) function

2013-12-31 Thread Romain Francois
Hello, This is fixed in Rcpp implementations I maintain: Rcpp11 and Rcpp98 and tested for in Rcpp-test. https://github.com/romainfrancois/Rcpp11/blob/master/src/attributes.cpp#L1195 https://github.com/romainfrancois/Rcpp98/blob/master/src/attributes.cpp#L1228 Trivial to port the fix to Rcpp.

Re: [Rcpp-devel] How to speed up selection of unique unordered pairs

2013-12-30 Thread Romain Francois
Hello, This is a perfect example for using hash sets (std::unordered_set in C++11) with custom implementations of hashing and comparison operators. See this gist: https://gist.github.com/romainfrancois/8187193 I have only tested it with Rcpp11 (and therefore using C++11), but I get down to 2

Re: [Rcpp-devel] calling a homegrown cpp function from my own package when using sourceCpp

2013-12-30 Thread Romain Francois
Hi, If both these functions will end up in the same package, then I’d suggest to put both files in the src directory and use devtools::load_all on your package root directory. Dirk’s recommendation is relevant bar is in its own package and calls foo from another package. Might not be what yo

Re: [Rcpp-devel] What is the most efficient method to check if a Rcpp vector contains an element?

2013-12-29 Thread Romain Francois
Le 29 déc. 2013 à 12:50, Asis Hallab a écrit : > Dear Rcpp experst, > > I hope everyone has had a pleasant Xmas. > > I am just wondering what would be the recommended and most efficient way to > check, if a Rcpp Vector contains a given element? > > If I am not mistaken the C++ standard appro

Re: [Rcpp-devel] RcppEigen needs 1GB memory to compile

2013-12-03 Thread Romain Francois
in a | JSS paper? We could add a 'Suggests: RcppEigenFastLm' (or whichever name we end up with). It would help with a thing or too -- didn't you even discover a slight NAMESPACE issue on the R side recently? On 3 December 2013 at 08:47, Romain Francois wrote: | without them, w

Re: [Rcpp-devel] RcppEigen needs 1GB memory to compile

2013-12-02 Thread Romain Francois
utside of the package, kind of like "look how I can do fastLm with this one". This has been useful in training sessions for example. But now presumably, I'll get replies in the "this has been there for years" department. Romain -- R

Re: [Rcpp-devel] linking error when using matrices?

2013-11-25 Thread Romain Francois
.R. C==filt says the I'm currently on OS X 10.9 with R 3.0.2 and Rcpp 0.10.6. Does anyone know how to fix this? Best, -- Hao Ye h...@ucsd.edu -- Romain Francois Professional R Enthusiast +33(0) 6 28 91 30 30 ___ Rcpp-devel mailing list Rcpp

Re: [Rcpp-devel] Header-only version of Rcpp provides a couple of gotcha's in RcppEigen

2013-11-14 Thread Romain Francois
es/R/x86_64-unknown-linux-gnu-library/3.1/Rcpp/include/Rcpp/exceptions.h:172:17: note: 'Rcpp::forward_exception_to_r' declared here inline void forward_exception_to_r( const std::exception& ex){ ^ Do these all look like issues that I should address in RcppEigen? -- R

Re: [Rcpp-devel] Header-only version of Rcpp provides a couple of gotcha's in RcppEigen

2013-11-14 Thread Romain Francois
are usually called through the BEGIN_RCPP / END_RCPP or nowadays by compileAttributes. Do these all look like issues that I should address in RcppEigen? This seems more like Rcpp issues. However I'll propose a few changes to RcppEigen so that it uses at

Re: [Rcpp-devel] RcppArmadillo and the version of Rcpp

2013-11-07 Thread Romain Francois
removing 'C:/Program Files/R/R-2.15.1/library/RcppArmadillo' Any advice would be much appreciated. Thanks Greg -- Romain Francois Professional R Enthusiast +33(0) 6 28 91 30 30 ___ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Re: [Rcpp-devel] How much speedup for matrix operations?

2013-11-06 Thread Romain Francois
This very much depends on the code but there is a good chance that RcppArmadillo will generate code making less data copies, etc ... Hard to say without seeing the code. Romain -- Romain Francois Professional R Enthusiast +33(0) 6 28 91 30 30 ___ Rcp

Re: [Rcpp-devel] Rcpp and RcppArmadillo errors on OSX Mavericks

2013-11-04 Thread Romain Francois
ne _______ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel -- Romain Francois Professional R Enthusiast +33(0) 6 28 91 30 30 ___ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Re: [Rcpp-devel] Attribute does not compile with 'compileAttributes' but with 'sourceCpp'

2013-11-02 Thread Romain Francois
when I call > compileAttributes. Is there anywhere a linking involved with Rcpp.so or > Rcpp.dylib? > > > Best > > Simon > > > On 02 Nov 2013, at 09:57, Romain Francois wrote: > >> Le 02/11/2013 09:35, Simon Zehnder a écrit : >>> First,

Re: [Rcpp-devel] Attribute does not compile with 'compileAttributes' but with 'sourceCpp'

2013-11-02 Thread Romain Francois
th -- Chief Scientist, RStudio http://had.co.nz/ ___ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel -- Romain Francois Professional R Enthusiast +33(0) 6 28 91 30 30 __

Re: [Rcpp-devel] Fwd: CRAN packages with C++ compilation errors on OS X 10.9

2013-10-31 Thread Romain Francois
Le 31/10/2013 17:36, Dirk Eddelbuettel a écrit : On 31 October 2013 at 17:15, Romain Francois wrote: | Le 31/10/2013 15:59, baptiste auguie a écrit : | > "OS X 10.9 (aka Mavericks) has a new C++ compiler, clang++ with libcxx | > headers/runtime. Your package fails to compile with th

Re: [Rcpp-devel] Fwd: CRAN packages with C++ compilation errors on OS X 10.9

2013-10-31 Thread Romain Francois
ch trivial uses of modules (i.e. no classes), maybe it is worth considering using // [[Rcpp::export]] and code generation given by compileAttributes instead of modules. Romain -- Romain Francois Professional R Enthusiast +33(0) 6 28 91 30 30 ___

Re: [Rcpp-devel] Fwd: CRAN packages with C++ compilation errors on OS X 10.9

2013-10-31 Thread Romain Francois
I'll have a look. It is likely to be a bug in some part of Rcpp's code bloat. I will try to find a solution that does not involve releasing a new Rcpp as 0.10.6 was just released. Romain -- Romain Francois Professional R Enthusiast +33(0) 6 28 91 30 30 _

Re: [Rcpp-devel] Rcpp/C++ serialization of R objects?

2013-10-29 Thread Romain Francois
re details if needed... I am doing some long-running MCMC calculations. And, I would like the C++ code to store the results every, say, 1 iterations. Of course, I could do this in a loop from R. But, I want to be sure that is really necessary before I re-write my R code ;o) -- Romain Fra

Re: [Rcpp-devel] ListOf -- update

2013-10-29 Thread Romain Francois
lapply(x, add_1); Thanks! -Kevin -- Romain Francois Professional R Enthusiast +33(0) 6 28 91 30 30 ___ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Re: [Rcpp-devel] inline error

2013-10-28 Thread Romain Francois
Just a warning that this code creates a NumericVector of length 1 initialised with 0. 1 is not 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

Re: [Rcpp-devel] feature proposal: ListOf

2013-10-25 Thread Romain Francois
ey a écrit : Hi Romain, Dirk, I'd be willing to contribute an Rcpp Gallery post and some tests if this were added to Rcpp; I think it would be quite useful. -Kevin On Wed, Oct 23, 2013 at 6:31 AM, Dirk Eddelbuettel wrote: On 23 October 2013 at 14:31, Romain Francois wrote: | Le 23/10/2

Re: [Rcpp-devel] Exporter.h cannot convert 'SEXP' to 'const std::vector*' in initialization

2013-10-23 Thread Romain Francois
ter to a function that is Rcpp::export'ed, what happens is that the data gets copied. Could you instead pass down an NumericVector ? The reason is that given Rcpp's design, copy semantics of NumericVector are cheap (no data copy). Which leads back

Re: [Rcpp-devel] feature proposal: ListOf

2013-10-23 Thread Romain Francois
Le 23/10/2013 13:47, Dirk Eddelbuettel a écrit : On 21 October 2013 at 14:32, Romain Francois wrote: | Hello, | | Another thing I have developped in dplyr but might be generally useful | is the ListOf class. See | https://github.com/hadley/dplyr/blob/master/inst/include/tools/ListOf.h | | The

Re: [Rcpp-devel] max length of Rcpp::List is 20 elements?

2013-10-23 Thread Romain Francois
nserter["x29"] = 32 ; You can probably encapsulate more so that you don't have to create the 3 objects (out, names and inserter), but I leave this as an exercize. This is not as nice as using create, but it gets the job done in a way that does not compro

Re: [Rcpp-devel] Redirecting cout/cerr streams to Rprintf

2013-10-23 Thread Romain Francois
(){ Sinker bar ; // call whatever that uses cout } Romain -- Romain Francois Professional R Enthusiast +33(0) 6 28 91 30 30 ___ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp

[Rcpp-devel] feature proposal: ListOf

2013-10-23 Thread Romain Francois
list and SO, but could be generally useufl for Rcpp users. Do people want to see this in Rcpp. This is orthogonal to everything else, so the risk is minimum. This is a template class, so the cost is null if the class is not used. Romain -- Romain Francois Professional R Enthusiast +33(0) 6

Re: [Rcpp-devel] Local .h files and Rcpp attributes

2013-10-23 Thread Romain Francois
Dirk Eddelbuettel | e...@debian.org <mailto:e...@debian.org> | http://dirk.eddelbuettel.com -- Romain Francois Professional R Enthusiast +33(0) 6 28 91 30 30 ___ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Re: [Rcpp-devel] Local .h files and Rcpp attributes

2013-10-23 Thread Romain Francois
enough, so maybe the next someone struggles with this they may find. If someone is itching to fix this, we will gladly take patches. Dirk -- Dirk Eddelbuettel | e...@debian.org | http://dirk.eddelbuettel.com -- Romain Francois Professional R Enthusiast

Re: [Rcpp-devel] Local .h files and Rcpp attributes

2013-10-19 Thread Romain Francois
Le 19/10/13 20:09, Dirk Eddelbuettel a écrit : On 19 October 2013 at 17:55, Romain Francois wrote: | Try putting your declarations into a RItools.h file in inst/include/ or | src/ in your package, i.e. have this in RItools.h | | typedef double (*testStat)(NumericVector, NumericVector); | | and

  1   2   3   4   5   6   7   8   >