Re: [Rcpp-devel] Initialize a matrix with a vector and the dimensions

2012-08-28 Thread Davor Cubranic
On 12-08-28 02:23 PM, Peng Yu wrote: > Just to clarify my original question, I want to convert from native R > vector to matrix directly (not through NumericVector). The following > code involves NumericVector. Does it result in extra copying of a > NumericVector? > >> suppressPackageStartupMessag

[Rcpp-devel] Exporting size() for NumericMatrix?

2012-08-28 Thread Peng Yu
Hi, For a matrix, the size intuitively should be just nrow * ncol. Hence, it is reasonable to call size(). But the following code gives errors, because two parent class all have the size() member function. Should something be done to make one of them available to NumericMatrix? suppressPackageSta

Re: [Rcpp-devel] Initialize a matrix with a vector and the dimensions

2012-08-28 Thread Peng Yu
On Tue, Aug 28, 2012 at 4:17 PM, Peng Yu wrote: > Hi, > > The closest thing that I can find to initialize a NumericMatrix with a > NumericVector is the following constructor from Rcpp/vector/Matrix.h. > But I need to see an example on how to use it. Does anybody have any > example to share with me

Re: [Rcpp-devel] Using Rcpp with C++11 and clang

2012-08-28 Thread Dirk Eddelbuettel
Michael, On 28 August 2012 at 20:54, Michael Braun wrote: | Dirk: | | Thanks for the kind words, although I'm not sure that 2 packages constitutes a flood. | | The only reason I was using c++11 was to access some mathematical functions in TR1. I can work around that, so I do not have to send

[Rcpp-devel] Initialize a matrix with a vector and the dimensions

2012-08-28 Thread Peng Yu
Hi, The closest thing that I can find to initialize a NumericMatrix with a NumericVector is the following constructor from Rcpp/vector/Matrix.h. But I need to see an example on how to use it. Does anybody have any example to share with me? Thanks! template Matrix( const int& nrows_, cons

Re: [Rcpp-devel] Using Rcpp with C++11 and clang

2012-08-28 Thread Michael Braun
Dirk: Thanks for the kind words, although I'm not sure that 2 packages constitutes a flood. The only reason I was using c++11 was to access some mathematical functions in TR1. I can work around that, so I do not have to send any C++11 code to CRAN. But still, playing around with some more, th

Re: [Rcpp-devel] Using Rcpp with C++11 and clang

2012-08-28 Thread Dirk Eddelbuettel
Hi Michael, Congrats on your recent flooding of CRAN with packages :) On 28 August 2012 at 18:46, Michael Braun wrote: | Is it possible that there is some kind of incompatibility among clang, libc++ and Rcpp? Consider this super-simple example (filename is tr1.cpp): | | #include | RcppExport

[Rcpp-devel] Using Rcpp with C++11 and clang

2012-08-28 Thread Michael Braun
Is it possible that there is some kind of incompatibility among clang, libc++ and Rcpp? Consider this super-simple example (filename is tr1.cpp): #include RcppExport SEXP testtr1() { return(Rcpp::wrap(0)); } If I compile it as a dynamic library with clang, I get: clang -O3 -m64 -msse4.2 -s

Re: [Rcpp-devel] Why inline function is much faster than .Call?

2012-08-28 Thread Dirk Eddelbuettel
For completeness, on Linux I get (with thanks to Davor providing his package; and omitting compiler warnings over signed/unsigned comparisons in Peng's code) the following: edd@max:/tmp$ r pengyu3.r test replications elapsed relative user.self 2

Re: [Rcpp-devel] Why inline function is much faster than .Call?

2012-08-28 Thread Davor Cubranic
I tried to reproduce your results, but I cannot : > xx<-matrix(1:6, 2) > benchmark(test(xx), test_inline(xx), .Call('test', xx)) test replications elapsed relative user.self sys.self user.child 3 .Call("test", xx) 100 0.996 1.00 0.9910.006 0 1

Re: [Rcpp-devel] RInside missing R.dll

2012-08-28 Thread Dan Murphy
Sorry to mislead. My RInside attempts were with Windows binaries and package freshly downloaded from CRAN (into a directory without spaces in the names, as RInside's make had problems with the space in Windows' "Program Files" -- even after I had forced the name to Progra~1 it still could not find

Re: [Rcpp-devel] RInside missing R.dll

2012-08-28 Thread Smith, Dale
I'm working with Rcpp now. I would say use pre-built binaries, including R, whenever possible. I've found the most success by avoiding local builds. Now if I could just get corporate to approve the 64 bit builds for the GSL... There are pre-built GSL libraries for 64 bit Windows available, if you

Re: [Rcpp-devel] RInside missing R.dll

2012-08-28 Thread Dirk Eddelbuettel
On 28 August 2012 at 06:14, Dan Murphy wrote: | Hmm, that's a possibility. When I built R from source, I ended up with | the 64bit version only. Perhaps there's something wrong with my | Rtools. I will look into that. Or maybe it is your R-built-from-source which may make your setup non-standard.

Re: [Rcpp-devel] RInside missing R.dll

2012-08-28 Thread Dan Murphy
Hmm, that's a possibility. When I built R from source, I ended up with the 64bit version only. Perhaps there's something wrong with my Rtools. I will look into that. Thanks, Dan On Tue, Aug 28, 2012 at 4:08 AM, Dirk Eddelbuettel wrote: > > On 27 August 2012 at 21:23, Dan Murphy wrote: > | Dirk, >

Re: [Rcpp-devel] RInside missing R.dll

2012-08-28 Thread Dirk Eddelbuettel
On 27 August 2012 at 21:23, Dan Murphy wrote: | Dirk, | | I made some progress. I noticed that the only folder in ...\library\RInside\lib | is i386, which explains why, when I set the architecture to x64 in WINFILE.WIN, | I get the error "g++.exe: error: /libRInside.a: No such file or directory

Re: [Rcpp-devel] How to export a .Call function in a closure?

2012-08-28 Thread Dirk Eddelbuettel
On 27 August 2012 at 22:36, Peng Yu wrote: | I have the following two functions which wrap a C++ function differently. | | rcpp_hello_world=local({ | sym=getNativeSymbolInfo('rcpp_hello_world', PACKAGE='mypkg') | function() .Call(sym, PACKAGE='mypkg') | }) | | rcpp_hello_world1=function(){ |