Re: [Rcpp-devel] Sparse matrices with RcppArmadillo

2012-12-08 Thread Romain Francois
That looks very similar, if not identical to what dgCMatrix uses. Can you direct me to a constructor where I could feed such information ? Romain Le 08/12/12 17:35, c s a écrit : Armadillo sparse matrices are stored in Compressed Sparse Column format: http://en.wikipedia.org/wiki

Re: [Rcpp-devel] Sparse matrices with RcppArmadillo

2012-12-08 Thread Romain Francois
Ah. One thing I could do is leverage this: #ifdef ARMA_EXTRA_SPMAT_PROTO #include ARMA_INCFILE_WRAP(ARMA_EXTRA_SPMAT_PROTO) #endif Not sure how yet. Le 08/12/12 19:17, Romain Francois a écrit : That looks very similar, if not identical to what dgCMatrix uses. Can you direct me to a

Re: [Rcpp-devel] Sparse matrices with RcppArmadillo

2012-12-08 Thread Romain Francois
ndices so it is likely that it would only be necessary to copy the contents of the arrays of column pointers (the "p" slot), row indices (the "i" slot) and values of the non-zeros (the "x" slot). It may even be possible to just map the pointers for a read-only spa

Re: [Rcpp-devel] Sparse matrices with RcppArmadillo

2012-12-09 Thread Romain Francois
Thanks for the valuable information. I will look into it more seriously at some point when I have some more time. Romain Le 09/12/12 14:40, c s a écrit : Hi Romain & Doug, Two points to note: (1) When poking around internal Armadillo pointers and arrays for sparse matrices, please

Re: [Rcpp-devel] RcppArmadillo: passing matrix columns by reference

2012-12-10 Thread Romain Francois
e, no data of its own, so cheap copy. double f3(arma::subview_col Z) { Z(1, 0) = 223; return 99.9; } Also, including RcppArmadillo.h after Rcpp.h is wrong. You should only include RcppArmadillo.h. I should do something so that the compiler tells you this. Romain Le 10/12/12 16:49,

Re: [Rcpp-devel] RcppArmadillo: passing matrix columns by reference

2012-12-10 Thread Romain Francois
Le 10/12/12 17:06, Romain Francois a écrit : the .col method gives you a subview_col : arma_inline subview_col col(const uword col_num); arma_inline const subview_col col(const uword col_num) const; not an umat. The name of the class implies that it is a "view" class, s

Re: [Rcpp-devel] For a Matrix A, is A(i, j) or A[i, j] preferred as an accessor for an element

2012-12-10 Thread Romain Francois
Le 10/12/12 17:45, Douglas Bates a écrit : On Mon, Dec 10, 2012 at 10:38 AM, Romain Francois mailto:rom...@r-enthusiasts.com>> wrote: Le 10/12/12 17:29, Douglas Bates a écrit : or does it matter? A[i,j] is wrong, not valid C or C++ code. so there is only one choice.

Re: [Rcpp-devel] Joining each row of CharacterMatrix to return a CharacterVector?

2012-12-10 Thread Romain Francois
r entries of a row of the CharacterMatrix X into a single string that will then comprise an element of the returned CharacterVector Y? Many thanks, Pete Peter Hickey, PhD Student/Research Assistant, Bioinformatics Division, Walter and Eliza Hall Institute of Medica

Re: [Rcpp-devel] Joining each row of CharacterMatrix to return a CharacterVector?

2012-12-11 Thread Romain Francois
ent of the returned CharacterVector Y? Many thanks, Pete Peter Hickey, PhD Student/Research Assistant, Bioinformatics Division, Walter and Eliza Hall Institute of Medical Research, 1G Royal Parade, Parkville, Vic 3052, Australia. Ph: +613 9345 2324 hic...@wehi

[Rcpp-devel] binding, combining vectors

2012-12-13 Thread Romain Francois
;u" "v" "w" "x" "y" "z" "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" [39] "m" "n" "o" &q

Re: [Rcpp-devel] iak problem -- dyn.load unable to load shared object

2012-12-13 Thread Romain Francois
be the case here. I suppose you have two versions of Rcpp installed; Romain Le 13/12/12 17:08, Glenn Lawyer a écrit : The problem seems to be file privileges. When I run R as superuser, it works. When I run as a normal user, I continue getting Error in dyn.load(libLFile) : unable to load

Re: [Rcpp-devel] binding, combining vectors

2012-12-13 Thread Romain Francois
Le 13/12/12 17:29, Dirk Eddelbuettel a écrit : On 13 December 2012 at 10:01, Romain Francois wrote: | Hello, | | I'd like to add a functionality to "bind" vectors of the same type (well | sugar expressions really, but let's say it is vectors for the sake of | this email). |

Re: [Rcpp-devel] How to free memory in Rcpp

2012-12-13 Thread Romain Francois
nction call then gets protected by the "result" object. If this does not work, then you can do some debugging as indicated by others. Romain Best wishes! Honglang Wang Office C402 Wells Hall Department of Statistics and Probability Michigan State University 1579 I Spartan Villag

Re: [Rcpp-devel] How to free memory in Rcpp

2012-12-14 Thread Romain Francois
I dont know. This looks like a deeply hidden problem. Maybe you can enable some rcpp debugging by adding #define RCPP_DEBUG_LEVEL 1 Before you include Rcpp.h, this will give you verbose output, maybe this will help locating the issue. Romain Envoyé de mon iPhone Le 14 déc. 2012 à 16:31

Re: [Rcpp-devel] Wrapping a C struct in C++ for constructor/destructor

2012-12-14 Thread Romain Francois
I would create a class that contains a pointer to the c struct. This obviously leaves the problem of freeing the memory, i.e does the c++ object own the pointer. Maybe a strategy using some reference counting smart pointer. In RcppEigen we have not resolved this, we simply exposed a free met

Re: [Rcpp-devel] Build of Rcpp from svn failure

2012-12-16 Thread Romain Francois
Thanks for the notice, will fix when i get a chance if nobody else does it first. I simplified this file yesterday to trim some old unused code, so i'll take the blame... The fix should just be to add #include On top of the file somewhere. Romain Le 16 déc. 2012 à 17:53, Thell F

Re: [Rcpp-devel] Build of Rcpp from svn failure

2012-12-16 Thread Romain Francois
Sure. Something like that, typeinfo is pretty orthogonal to features of the other includes, so no issue of header order. While you're there, does R CMD check Rcpp work fine ? Romain Le 16 déc. 2012 à 18:04, Thell Fowler a écrit : > diff --git a/pkg/Rcpp/src/exceptions.cpp b/pkg/

Re: [Rcpp-devel] Problems returning fload

2012-12-19 Thread Romain Francois
Put this in a file (foo.cpp) and then do: > sourceCpp( "foo.cpp" ) > test_func( my_matrix) [1] 1.000 0.667 0.000 0.400 0.500 0.2857143 0.333 [8] 0.300 This uses the Rcpp sugar sum function to sum a column: my_matrix(_,j) is a view on the j^th column.

Re: [Rcpp-devel] #include gretl libraries in Rcpp

2012-12-19 Thread Romain Francois
The extern "C" looks suspicious. What happens if you don't include it ? e.g. #include #include #include or perhaps: #include #include #include Romain Le 20/12/12 00:39, jea...@hushmail.com a écrit : Hi, I am having trouble getting Rcpp to compile c++ files including h

Re: [Rcpp-devel] #include gretl libraries in Rcpp

2012-12-19 Thread Romain Francois
Welcome in macro hell. Try this: #include #include #undef PARENT #include So one of these headers is defining a macro "PARENT" that conflicts with the name PARENT used in any.h. This should take care of it. Romain Le 20/12/12 00:56, jea...@hushmail.com a écrit : thanks for

Re: [Rcpp-devel] Using pointers with Numeric Vectors

2012-12-21 Thread Romain Francois
stem elapsed 0.198 0.000 0.198 That's more like it. And we are not paying the price of += // [[Rcpp::export]] double callRcppVar3(const NumericVector& v) { double x = 0.0 ; for (int i=0; i<100; i++) x += 2.0; return x ; } > system.time(callRcppVar3(a)) user system

Re: [Rcpp-devel] Rcpp and C++ mangling

2012-12-21 Thread Romain Francois
Are you linking against the gretl library ? Le 21 déc. 2012 à 12:12, jea...@hushmail.com a écrit : > hi, > > a quick question regarding a Rcpp function I wrote using an external library > (gretl) : > > with the help of a makefile (adapted from the convolution Rcpp example), the > code compi

Re: [Rcpp-devel] Most efficient way to apply function over rows of a matrix with Rcpp?

2013-01-30 Thread Romain Francois
0 Maybe there is something we can do at our end to improve this by making a more efficient iterator over a matrix row. Romain -- Romain Francois Professional R Enthusiast +33(0) 6 28 91 30 30 R Graph Gallery: http://gallery.r-enthusiasts.com blog:http://romainfrancois.bl

Re: [Rcpp-devel] package with module not compiling on Mac

2013-01-31 Thread Romain Francois
ir code, it looks like they only ever return *this. Why are you doing this ? I'd suggest you return void. Romain Le 29/01/13 16:04, Robin Girard a écrit : The Mac version of my package http://cran.r-project.org/web/packages/ConConPiWiFun/index.html (using Rcpp module) does not compi

Re: [Rcpp-devel] Performance question about DataFrame

2013-01-31 Thread Romain Francois
y 1 1 1 2 2 2 3 3 3 4 4 4 5 5 5 6 6 6 7 7 7 8 8 8 9 9 9 10 10 10 Romain -- Romain Francois Professional R Enthusiast +33(0) 6 28 91 30 30 R Graph Gallery: http://gallery.r-enthusiasts.com blog:http://romainfrancois.blog.free.fr |- http://bit.ly/RE6sYH :

Re: [Rcpp-devel] package with module not compiling on Mac

2013-01-31 Thread Romain Francois
Le 31/01/13 12:15, Robin Girard a écrit : Merci Romain ! I am doing this to make possible a direct use of the result such as in A=Sum(f1.Swap(0),f2.Etoile()) I see. I figured you were using some sort of chaining. I'm not a big fan of methods that return a reference to the object the

Re: [Rcpp-devel] Rcpp and boost on Windows 7

2013-02-03 Thread Romain Francois
n sourceCpp("testBoost.cpp") : Error 1 occurred building shared library. Regards, André Hello, You should have a look at the BH package, with which all you have to do (I think) is to have this in your DESCRIPTION: LinkingTo: BH, Rcpp And you're good to go. Romain -- Romain

Re: [Rcpp-devel] "expecting a string" and not finding it in a CharacterVector

2013-02-07 Thread Romain Francois
Thanks. I will fix it. Romain Le 8 févr. 2013 à 05:28, Davor Cubranic a écrit : > On 13-02-07 07:24 PM, Davor Cubranic wrote: >> The version assigning an element of a const CharacterVector to a const >> std::string (named "bar" below) compiles and works fine in Rcpp

Re: [Rcpp-devel] A though on Rcpp::wrap

2013-02-08 Thread Romain Francois
Thank you for this detailed email, i will study it carefully. Romain Le 8 févr. 2013 à 13:16, Yan Zhou a écrit : > This morning I was frustrated by a compilation error, below is a scratch of > the problem > > // MyClass1.h > template > class MyClass {/*...*/}; > &g

Re: [Rcpp-devel] "expecting a string" and not finding it in a CharacterVector

2013-02-10 Thread Romain Francois
Right. I see what you mean. If it does bot disturbe anything else, i should be able to bring it back. Romain Le 10 févr. 2013 à 04:54, Davor Cubranic a écrit : > On 13-02-09 05:06 AM, Dirk Eddelbuettel wrote: >> >> On 8 February 2013 at 20:58, Davor Cubranic wrote: >>

Re: [Rcpp-devel] Splitting a matrix by its rows into a list

2013-02-19 Thread Romain Francois
This was a bug, and is fixed in rev 4262. Romain Le 19/02/13 00:37, Søren Højsgaard a écrit : I want to split a matrix by its rows into a list as: a<- matrix(letters[1:6],ncol=2) split(a,row(a)) $`1` [1] "a" "d" $`2` [1] "b" "e" $`3` [1] "

Re: [Rcpp-devel] rcpp sugar elementary question

2013-02-19 Thread Romain Francois
_ is defined in the Rcpp namespace, so perhaps you want to add : using namespace Rcpp ; somewhere on top. Also, you could use mat.row(1) instead of mat(1,_) Romain Le 19/02/13 16:49, Bharath Govindarajan a écrit : Hi , I am trying a simple example to assign entire rows to a Rcpp

Re: [Rcpp-devel] Rcpp modules and parsing an object back and forth between R & C++

2013-02-19 Thread Romain Francois
r, and you would only need that before your class declaration: RCPP_EXPOSED_CLASS(Simple) So that as and wrap are taken care of. Romain -- Romain Francois Professional R Enthusiast +33(0) 6 28 91 30 30 R Graph Gallery: http://gallery.r-enthusiasts.com blog:http://romainfrancois.blo

Re: [Rcpp-devel] Rcpp modules and parsing an object back and forth between R & C++

2013-02-20 Thread Romain Francois
peid, pointer){ Class <- Rcpp:::.classes_map[[ typeid ]] new( Class, .object_pointer = pointer ) } Romain -- Romain Francois Professional R Enthusiast +33(0) 6 28 91 30 30 R Graph Gallery: http://gallery.r-enthusiasts.com blog:http://romainfrancois.blog.f

Re: [Rcpp-devel] Rcpp: Distinguishing between input types to function call

2013-02-20 Thread Romain Francois
throw std::range_error( "not a vector" ) ; \ } #define RCPP_RETURN_VECTOR( _FUN_, _SEXP_ ) ___RCPP_RETURN___( _FUN_, _SEXP_ , Vector ) #define RCPP_RETURN_MATRIX( _FUN_, _SEXP_ ) ___RCPP_RETURN___( _FUN_, _SEXP_

Re: [Rcpp-devel] Efficient DataFrame access by row & column

2013-02-20 Thread Romain Francois
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 R Graph Gallery: http://gallery.r-enthusiasts.com blog:http://romainfrancois.blog.free.fr |- http:/

Re: [Rcpp-devel] Rcpp: Distinguishing between input types to function call

2013-02-20 Thread Romain Francois
Well, as the funny name implies "Rf_inherits" comes from the R API. Romain Le 20/02/13 10:05, Søren Højsgaard a écrit : Thanks a lot! I thought that Rf_inherits was the Rcpp version of inherits (which gives what I expect). XX1 <- letters[1:4] # character XX2 <- 1:4

Re: [Rcpp-devel] Rcpp: Distinguishing between input types to function call

2013-02-20 Thread Romain Francois
Hello, Soren and I had the same idea, so we'll jointly write it for the Rcpp gallery. Romain Le 20/02/13 17:55, Kevin Ushey a écrit : Hi Romain, Just wanted to give you a thanks for putting together this answer. It's a really great example of more generic programming wi

Re: [Rcpp-devel] Simple problem with modules

2013-02-20 Thread Romain Francois
Hello, I think this is about having const NumericVector& x_; In your class definition. It all works fine for me when I switch to NumericVector x_ ; and leave everything else unchanged. I'm not sure what the problem is though. Romain Le 20/02/13 22:14, Hadley Wickham a écri

Re: [Rcpp-devel] Initiate NumericMatrix in class constructor from S4 slot

2013-03-05 Thread Romain Francois
anyway, something like: > FirstClass::FirstClass(Rcpp::S4& classS4) : M( (SEXP)classS4.slot("M_R")) {} Hiwever, i will add the missing constructor if this does not break anything else. Romain Le 6 mars 2013 à 08:14, Simon Zehnder a écrit : > Dear Rcpp-Devels, > > I

Re: [Rcpp-devel] Filling a big.matrix in Rcpp

2013-03-14 Thread Romain Francois
+ Am[j][i-1]; > } > } > return Rcpp::wrap(true); > } Why do you use wrap here ? Wrap will create a SEXP, not a bool ! Actually why is this not void ? Romain > // R code for testing below > > /*** R > require(bigmemory) > > # set up big

Re: [Rcpp-devel] fill a NumericMatrix row by row

2013-03-27 Thread Romain Francois
I removed it in the revision 4294. Sorry for the inconvenience. Romain Le 27/03/13 09:23, Michael Love a écrit : Not a question here, but a note. Earlier there was an email about filling a NumericMatrix row by row. http://lists.r-forge.r-project.org/pipermail/rcpp-devel/2013-March/005390

Re: [Rcpp-devel] Rcpp can not return big DataFrame

2013-03-27 Thread Romain Francois
vices utils datasets methods base other attached packages: [1] Rcpp_0.10.3 data.table_1.8.8 loaded via a namespace (and not attached): [1] compiler_2.15.3 tools_2.15.3 _______ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org

Re: [Rcpp-devel] module with vector when Mytype has children with inheritence

2013-04-02 Thread Romain Francois
>*met)( ) ) ; } ... Romain Le 02/04/13 13:15, Robin Girard a écrit : Hello list, I'm having troubles using module on a class that redefines a vector of Mytype where Mytype is type that has several children types. Mytype has only methods while cihldren inherit methods and have fields that are doub

Re: [Rcpp-devel] Datetime substraction bug ?

2013-04-02 Thread Romain Francois
pas l'utiliser pour quelque | raison que ce soit, ne pas stocker ou copier l'information | qu'il contient sur un quelconque support. | | ___ | Rcpp-devel mailing list | Rcpp-devel@lists.r-forge.r-project.org | https://lists.r-forge.r-pro

Re: [Rcpp-devel] Bug with table sugar and NumericVector in Rcpp 0.10.3

2013-04-02 Thread Romain Francois
p(InputIterator, InputIterator)’ declared here, later in the translation unit make: *** [Module.o] Error 1 ERROR: compilation failed for package ‘Rcpp’ * removing ‘/tmp/RtmpfejSO9/Rinst312b332a9a19/Rcpp’ --- ERROR: package installation failed edd@max:~/svn/rcpp

Re: [Rcpp-devel] Rcpp can not return big DataFrame

2013-04-02 Thread Romain Francois
ta.table_1.8.8 loaded via a namespace (and not attached): [1] compiler_2.15.3 tools_2.15.3 ___ 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

Re: [Rcpp-devel] Bug with table sugar and NumericVector in Rcpp 0.10.3

2013-04-02 Thread Romain Francois
Le 02/04/13 17:01, Dirk Eddelbuettel a écrit : On 2 April 2013 at 16:36, Romain Francois wrote: | Le 29/03/13 16:37, Dirk Eddelbuettel a écrit : | > | > On 29 March 2013 at 16:20, rom...@r-enthusiasts.com wrote: | > | Cool. I'll have a look when I'm back from easter weekend.

Re: [Rcpp-devel] Datetime substraction bug ?

2013-04-02 Thread Romain Francois
g, then I agree that `-`(1, 3) should be negative. But we don't have a purely abstract setting. I agree with Dirk's New Year's/Easter example -- if the dates are in order, then the diff should be positive to my mind. Note also: > diff(c(1, 3)) [1] 2 Pat On 02/04/2013 15:33, Ro

Re: [Rcpp-devel] Datetime substraction bug ?

2013-04-02 Thread Romain Francois
example -- if the dates are in order, then the diff should be positive to my mind. Note also: > diff(c(1, 3)) [1] 2 Pat On 02/04/2013 15:33, Romain Francois wrote: Le 30/03/13 00:44, Dirk Eddelbuettel a écrit : On 29 March 2013 at 23:37, Robin Girard wrote: | Hi List | | why i

Re: [Rcpp-devel] Datetime substraction bug ?

2013-04-02 Thread Romain Francois
R> ddiff2(NewYear, Easter) [1] -89 ## closer to R's difftime and 'odd' to me R> If it isn't used here, where is it actually used? Dirk -- Romain Francois Professional R Enthusiast +33(0) 6 28 91 30 30 R Gra

Re: [Rcpp-devel] Bug with table sugar and NumericVector in Rcpp 0.10.3

2013-04-02 Thread Romain Francois
`as.factor`. stringsAsFactor is an important feature at R side, but does RCpp have to match the exact interface of R? For now, RCpp doesn't really support factor. Returning a data.frame with factor element would make it useless for RCpp. Hi Romain, I'm curious about the difference betwee

Re: [Rcpp-devel] Module with vector of a class with inheritance, how to avoid slicing

2013-04-03 Thread Romain Francois
ss_( "children2_t" ) .derives("father" ) .constructor() ; class_( "vector_Of_father") .constructor() .method( "size", &vector_Of_father::size) .method( "WhoAmI",&vector_Of_father::WhoAmI ) .method( "push_back&

Re: [Rcpp-devel] Module with vector of a class with inheritance, how to avoid slicing

2013-04-03 Thread Romain Francois
Please note that this is the "in progress" section of modules, so things can change. There are probably open questions. e.g. at the moment you have to deal with who is responsible for the pointers. Le 03/04/13 22:12, Romain Francois a écrit : Hi, Fasten your seatbelts. First, t

Re: [Rcpp-devel] Module with vector of a class with inheritance, how to avoid slicing

2013-04-04 Thread Romain Francois
Le 04/04/13 17:34, Robin Girard a écrit : Thanks a lot Romain ! you're amazingly fast and furious (got my seatbelt). I'll definitely buy the book. That works on my example, I confirm (I had a side problem with using _t which I removed but don't see where this comes from, m

Re: [Rcpp-devel] Module with vector of a class with inheritance, how to avoid slicing

2013-04-04 Thread Romain Francois
have something like res$whoAmI(1) Good luck - Mail original - De: "Robin Girard" À: "Romain Francois" Cc: rcpp-devel@lists.r-forge.r-project.org Envoyé: Jeudi 4 Avril 2013 18:08:50 Objet: Re: [Rcpp-devel] Module with vector of a class with inheritance, how to a

Re: [Rcpp-devel] Rcpp::List::create(...) with more than 20 elements ?

2013-04-17 Thread Romain Francois
t;] = bar2 ; wrap( map ) ; Or perhaps: std::map map ; map["foo"] = wrap( bar1 ) ; map["foo2"] = wrap( bar2 ) ; wrap( map ) ; Or perhaps even : std::map map ; map["foo"] = wrap( bar1 ) ; map["foo2"] = wrap( bar2 ) ; wrap( map ) ; Romain -- Romain F

Re: [Rcpp-devel] Fwd: How can I avoid calls to coerceToReal

2013-05-02 Thread Romain Francois
What is the type of df[i] ? i.e. what does it says: SEXP tmp = df[i] ; Rprintf( "TYPEOF(tmp)=%d", TYPEOF(tmp) ) ; If this is anything but REALSXP (i.e. 14), then you have to coerce the data to bne able to use it as a NumericVector. Romain Le 30/04/13 17:19, Pratibha Rana a é

Re: [Rcpp-devel] [Rcpp Modules] Static functions

2013-05-09 Thread Romain Francois
(){ return Foo::myFunction() ; } We might support direct syntactic sugar for exposing static functions later, but i'm not sure the concept of staric functions is supported by reference classes which is the texhnology we use to expose module classes. Romain Le 9 mai 2013 à 16:47, Julien Duvan

Re: [Rcpp-devel] [RCPP Sugar] sapply function

2013-05-10 Thread Romain Francois
Iirc we have mapply2 and mapply3. Otherwise you can make Foo a helper class instead of a function. And you embed the 3 variables in your class. Le 10 mai 2013 à 17:40, Julien Duvanel a écrit : > Hello again, > > I hope I don't disturb you too much. I have again a small question. I haven't

Re: [Rcpp-devel] How to access fields and methods of a RefClass from C++?

2013-05-30 Thread Romain Francois
More easily, you can use Rcpp::Reference: // [[Rcpp::export]] std::string getId(Reference obj) { std::string txt = obj.field("id"); return txt; } Here, you are isolated from the implementation of reference classes using environments and the .xData slot name. Romain Le 29/0

Re: [Rcpp-devel] How to access fields and methods of a RefClass from C++?

2013-05-30 Thread Romain Francois
Le 30/05/13 16:02, Dirk Eddelbuettel a écrit : On 30 May 2013 at 15:15, Romain Francois wrote: | More easily, you can use Rcpp::Reference: | | // [[Rcpp::export]] | std::string getId(Reference obj) { | std::string txt = obj.field("id"); | return txt; | } Thanks -- had forgo

Re: [Rcpp-devel] [RCPP Sugar] sapply function

2013-05-30 Thread Romain Francois
} // [[Rcpp::export]] NumericVector mapply_fun(NumericVector x, NumericVector y, NumericVector z){ return mapply(x, y, z, fun ) ; } So mapply'ing fun over x, y and z. works for 2 or 3 objects for now. Romain -- Romain Francois Professional R Enthusiast +33(0) 6 28 91 30 30 R Graph

Re: [Rcpp-devel] Turning a vector into a matrix

2013-05-31 Thread Romain Francois
Hello Søren, This is easy templating: template Matrix vec2matrix(Vector x, int nrow, int ncol) { return Matrix(nrow, ncol, x.begin()); } will work for NumericVector, IntegerVector, CharacterVector, ... Romain Le 31/05/13 11:08, Søren Højsgaard a écrit : Dear all, Dirk: Thanks for

Re: [Rcpp-devel] Turning a vector into a matrix

2013-05-31 Thread Romain Francois
want to handle default: return R_NilValue ; // .. or do whatever } } /*** R vec2matrix( 1:10, 2, 5 ) vec2matrix( rnorm(10), 2, 5 ) ***/ Romain Le 31/05/13 11:30, Søren Højsgaard a écrit : Romain, I actually already tried this in my file util.cpp but can't g

Re: [Rcpp-devel] Turning a vector into a matrix

2013-05-31 Thread Romain Francois
) ; } /*** R vec2matrix( 1:10, 2, 5 ) vec2matrix( rnorm(10), 2, 5 ) ***/ Romain Le 31/05/13 11:37, Romain Francois a écrit : Ah ok, so you want to use this from R, I would suggest to Rcpp::export a dispatcher, something like this: #include using namespace Rcpp ; // the template

Re: [Rcpp-devel] Rcpp.package.skeleton testmod

2013-06-03 Thread Romain Francois
and src directories for more detail. Romain Le 03/06/13 19:31, Andreas Prescher a écrit : Hello, Any help would be greatly appreciated I am trying to use the example testmod package by using: Rcpp.package.skeleton( "testmod", module = TRUE ) and: R CMD INSTALL testmod s

Re: [Rcpp-devel] How to include "Rcpp.h" in code

2013-06-04 Thread Romain Francois
I don't use eclipse or windows, but as I understand it from the link, you are looking for something like this: > system.file( "include", package = "Rcpp") Romain Le 04/06/13 18:02, Yanping Liu a écrit : Hey, I'm a newcomer to use Rcpp in ec

Re: [Rcpp-devel] Possible inconsistency in Rcpp vs stl in erase(iterator, iterator)

2013-06-05 Thread Romain Francois
<< l.size() << endl; END_RCPP } /*** R # library(Rcpp) # sourceCpp("truncateTest.cpp") # truncateTest() # #prints 6 and 5 */ -- Romain Francois Professional R Enthusiast +33(0) 6 28 91 30 30 R Graph Gallery: http://gallery.r-enthusiasts.com blog:http://blo

Re: [Rcpp-devel] Warnings in build of RcppArmadillo project

2013-06-05 Thread Romain Francois
ard.h, fn_as_scalar.hpp and class.h it seems that there is something about typedefs, but I am not sure. It seems to me just not right, that all these warnings occur in my build output. Best Simon -- Romain Francois Professional R Enthusiast +33(0) 6 28 91 30 30 R Graph Gallery: http://gall

Re: [Rcpp-devel] Possible inconsistency in Rcpp vs stl in erase(iterator, iterator)

2013-06-05 Thread Romain Francois
This is now fixed in rev 4330. I'm looking at the other issue you reported. Le 05/06/13 14:50, Romain Francois a écrit : Thanks. I'll have a look. Le 05/06/13 14:09, Toni Giorgino a écrit : Dears, I am a newbie to Rcpp. I may have found an off-by-one inconsistency in the handlin

Re: [Rcpp-devel] Warnings in build of RcppArmadillo project

2013-06-05 Thread Romain Francois
The change affects Rcpp, not RcppArmadillo. Le 05/06/13 16:45, Simon Zehnder a écrit : Hi Romain, is revision 4331 already in RcppArmadillo 3.9.0? Best Simon On Jun 5, 2013, at 4:30 PM, Romain Francois wrote: Most of these are in fact happening in armadillo's code base. Le 05/06/

Re: [Rcpp-devel] Fwd: Possible inconsistency in Rcpp vs stl in erase(iterator, iterator)

2013-06-05 Thread Romain Francois
size() << endl; Rcpp::List::iterator li=l.begin()+1; while(li!=l.end()) li=l.erase(li);// This doesn't cout << "Rcpp::List left with " << l.size() << endl; return(R_NilValue); } On Wed, Jun 5, 2013 at 2:50 PM, Romain Francois m

Re: [Rcpp-devel] Integer matrices in Rcpp and Armadillo

2013-06-06 Thread Romain Francois
ot;armaS:"); return Rcpp::wrap(1);', plugin = "RcppArmadillo") 3. Run the function: cfunction(mclass) -- What I need is an arma::umat in C++ and if possible in addition an integer array in R. Is this possible? Best

Re: [Rcpp-devel] Integer matrices in Rcpp and Armadillo

2013-06-06 Thread Romain Francois
sible? R itself has no unsigned integers (just as it has no [signed or unsigned] short or long integeger). You should be able to write wrappers though, but this MUST entail copies for that very reason. So maybe stick to ints? Dirk -- Romain Francois Professional R Enthusiast +33(0) 6 28 91 30

Re: [Rcpp-devel] Integer matrices in Rcpp and Armadillo

2013-06-06 Thread Romain Francois
Le 06/06/13 19:05, Simon Zehnder a écrit : Hi Romain, sorry I had overseen this message from you. Okay, so the explicit cast to SEXP together with the assignment operator makes the deal. But it still includes the reuse of memory right, i.e. the '=' does not call the copy construc

Re: [Rcpp-devel] Integer matrices in Rcpp and Armadillo

2013-06-07 Thread Romain Francois
Le 07/06/13 13:09, Simon Zehnder a écrit : HI Dirk, hi Romain, allright, this is now clear to me, if I want to reuse memory, the allocated memory from R (so implicitly in C) must of course have the same type - otherwise the memory has a different size. so far, this is obvious. On the

Re: [Rcpp-devel] Integer matrices in Rcpp and Armadillo

2013-06-07 Thread Romain Francois
Le 07/06/13 15:14, Simon Zehnder a écrit : Hi Romain, hi Dirk, sorry for posting here again, but I found something in some way connected to this discussion - and pretty interesting concerning the Rcpp::as<>() function: 1. I create a class containing a list: setClass("myclass"

Re: [Rcpp-devel] Setting the R random seed from Rcpp

2013-06-07 Thread Romain Francois
And then when you want to set the variable: you just do : RandomSeed = someVariable ; The Environment::Binding class acts a a proxy class. Romain Le 7 juin 2013 à 16:22, Matteo Fasiolo a écrit : > Dear Rcpp experts, > > I would like to be able to store the R random seed from a

Re: [Rcpp-devel] Integer matrices in Rcpp and Armadillo

2013-06-07 Thread Romain Francois
Le 07/06/13 16:07, Simon Zehnder a écrit : Hi Romain, thanks for this precise answer. So the suggested methods below will work without making a copy of the object. yes What is about the implicit call of Rcpp::as<>() inside arma::mat()? It is a very convenient way to create an arma

Re: [Rcpp-devel] returning array from C

2013-06-11 Thread Romain Francois
Envoyé de mon iPhone Le 11 juin 2013 à 18:33, Steve Jaffe a écrit : >> On 11 June 2013, Dirk Eddelbuettel wrote: >> | On 11 June 2013, Steve Jaffe wrote: >> | Is there a way to 'wrap', say, an array of double allocated on the heap in >> C/C++ and return it to R without copying, ie as the data

Re: [Rcpp-devel] returning array from C

2013-06-11 Thread Romain Francois
Le 11 juin 2013 à 20:40, Steve Jaffe a écrit : > On Tuesday, June 11, 2013 2:37 PM, Krzysztof Sakrejda wrote: >>> Would you know of a simple example of writing a "reference class" that looks >>> to R like a numeric vector? >> >> I think all the examples I've written are too complicated to be us

Re: [Rcpp-devel] returning array from C

2013-06-11 Thread Romain Francois
Le 11 juin 2013 à 20:54, Krzysztof Sakrejda a écrit : > On Tue, Jun 11, 2013 at 2:49 PM, Romain Francois > wrote: >> >> Le 11 juin 2013 à 20:40, Steve Jaffe a écrit : >> >>> On Tuesday, June 11, 2013 2:37 PM, Krzysztof Sakrejda wrote: >>>>>

Re: [Rcpp-devel] returning array from C

2013-06-11 Thread Romain Francois
Le 11 juin 2013 à 22:10, Steve Jaffe a écrit : > On Tuesday, June 11, 2013 3:02 PM, Romain Francois wrote: >> Maintaining the idea that this external pointer acts as a numeric vector >> without being one. >> >> What happens then you want its mean, its quantile or wh

Re: [Rcpp-devel] Problem with exceptions from standalone functions (Windows only)

2013-06-13 Thread Romain Francois
Great. I'll let you know when i need your help for testing. Might be in a few days as i'm travelling now. Romain Le 13 juin 2013 à 11:47, QRD a écrit : > Hi Romain, > > Thanks for looking at this. > >>> [...] do you think adding BEGIN_RCPP / END_RCPP pair

Re: [Rcpp-devel] Compilation without libR.so ?

2013-06-14 Thread Romain Francois
Le 14 juin 2013 à 10:40, Martin Jakt a écrit : > Hi Romain (?), > > thanks for your quick reply, > >> >> Why do you want that. R CMD essentially takes care all of the details, >> cooks a Makefile, runs it ... transparently. It never needs to be a >> conc

[Rcpp-devel] macros RCPP_FUNCTION_...,

2013-06-18 Thread Romain Francois
about 10% of the lines of the .h files in Rcpp. I don't think many people are using it, and I don't blame them. This was an interesting idea when we introduced it, but we have something better now. Romain -- Romain Francois Professional R Enthusiast +33(0) 6 28 91 30 30 R G

Re: [Rcpp-devel] Problem with exceptions from standalone functions (Windows only)

2013-06-18 Thread Romain Francois
Hi, I have commited adding BEGIN_RCPP and END_RCPP. Could you have a go at testing it on Windows. Romain Le 13/06/13 10:17, QRD a écrit : Hi, I've just had some trouble, on Windows with Rtools-3.0, throwing exceptions from within a standalone function belonging to a module: - -

Re: [Rcpp-devel] macros RCPP_FUNCTION_...,

2013-06-18 Thread Romain Francois
Le 18/06/13 19:50, Dirk Eddelbuettel a écrit : On 18 June 2013 at 16:26, Romain Francois wrote: | Hello, | | Who is using the macros RCPP_FUNCTION_0, ..., RCPP_FUNCTION_65, ... | (i.e. all the macros that live in the preprocessor_generated.h file). | | Their functionality is superseded by a

Re: [Rcpp-devel] macros RCPP_FUNCTION_...,

2013-06-18 Thread Romain Francois
Le 18/06/13 21:12, Dirk Eddelbuettel a écrit : On 18 June 2013 at 21:05, Romain Francois wrote: | For what it is worth. I just downloaded and unpacked source code for 113 | packages using Rcpp, using a modified version of your runRcppDepends. Our users comprise a much larger set than those

Re: [Rcpp-devel] macros RCPP_FUNCTION_...,

2013-06-18 Thread Romain Francois
mention there either.) Dirk wrote: APIs are contracts we have with users. I would prefer to see strong reasons for change, rather than a style preference. Romain wrote: If we keep it we surely need to document it as part of this contract I think this is the most compelling reason. It seems almost

Re: [Rcpp-devel] Linux or OS X on Macbook Pro Retina?

2013-06-19 Thread Romain Francois
to be wary about? Thanks, Rainer -- Romain Francois Professional R Enthusiast +33(0) 6 28 91 30 30 R Graph Gallery: http://gallery.r-enthusiasts.com blog:http://blog.r-enthusiasts.com |- http://bit.ly/Zs97qg : highlight 0.4.1 `- http://bit.ly/10X94UM : Mobile version of the graph ga

Re: [Rcpp-devel] macros RCPP_FUNCTION_...,

2013-06-19 Thread Romain Francois
6 the feature is gone. Considering we release now approximately quarterly, this leaves a period between 6 and 9 months before the feature is gone. I hope everybody will be ok with that. This is more work, and I actually need to remember to do it, but that is a good compromise. Romain Le 19/06/13

Re: [Rcpp-devel] macros RCPP_FUNCTION_...,

2013-06-19 Thread Romain Francois
Le 19/06/13 15:41, Dirk Eddelbuettel a écrit : 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 with extra | annoying

Re: [Rcpp-devel] macros RCPP_FUNCTION_...,

2013-06-19 Thread Romain Francois
Le 19/06/13 15:49, Romain Francois a écrit : Le 19/06/13 15:41, Dirk Eddelbuettel a écrit : 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

Re: [Rcpp-devel] macros RCPP_FUNCTION_...,

2013-06-19 Thread Romain Francois
Le 19/06/13 15:50, Hadley Wickham a écrit : 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

Re: [Rcpp-devel] macros RCPP_FUNCTION_...,

2013-06-19 Thread Romain Francois
ith Open Source. Breaking an API is extremely poor style and annoying as hell to everybody. We all agree on that -- and what Romain proposed (ie removing unused cruft) is generally a good rather than thing. But one has to be extra careful to not accidentally create the former too. The burden only

Re: [Rcpp-devel] macros RCPP_FUNCTION_...,

2013-06-19 Thread Romain Francois
Le 19/06/13 16:17, Dirk Eddelbuettel a écrit : On 19 June 2013 at 16:07, Romain Francois wrote: | We were waiting for the book release to bump up to 1.0.0 right ? Not really. Ah ok. I don't really care anyway. That would look nice though. | Rcpp is mature enough now to deserve a

Re: [Rcpp-devel] two minor bugs with Rcpp's sugar table

2013-06-26 Thread Romain Francois
Thanks for this. We'll have a look. Romain Le 25/06/13 22:06, Kevin Ushey a écrit : Hi guys, Sorry to be bringing this up so close after the CRAN release, but I just stumbled upon them today. - 1) The table function occasionally produces names as '-0', rather than &

Re: [Rcpp-devel] Seamless Rcpp gives errors with RcppArmadillo

2013-06-26 Thread Romain Francois
Hello, I don't have a copy of the book at hand. Below are some insights on what you are doing wrong. Hope this helps. Romain Le 26/06/13 11:11, John Swan a écrit : Hi, I just purchased Dirk's book on Seamless Rcpp and I'm finding it very useful. However, I'm ha

<    1   2   3   4   5   6   7   8   9   10   >