Re: [Rcpp-devel] Strange behavior of NumericMatrix

2011-09-02 Thread Steve Lianoglou
Hi, On Sat, Sep 3, 2011 at 12:54 AM, Noah Silverman wrote: > Hi, > > Just starting to learn about Rcpp tonight (Using it through the inline > library) > > I'm attempting to construct a matrix and then fill it with values as I > iterate through my function.  The results are wrong.  Am I accessin

Re: [Rcpp-devel] Install RcppArmadillo against Intel MKL

2011-09-02 Thread Zarrar Shehzad
Great. This definitely seems like a better approach to rely on R. I have Revolution R setup on another machine so I just installed RcppArmadillo with that and indeed it appears to now be relying on Intel's MKL. Thanks! Zarrar On Sat, Sep 3, 2011 at 12:45 AM, Dirk Eddelbuettel wrote: > > Hi Zarr

[Rcpp-devel] Strange behavior of NumericMatrix

2011-09-02 Thread Noah Silverman
Hi, Just starting to learn about Rcpp tonight (Using it through the inline library) I'm attempting to construct a matrix and then fill it with values as I iterate through my function. The results are wrong. Am I accessing the cells of the matrix incorrectly? The idea was to have an integer i

Re: [Rcpp-devel] R.e. First foray into Rcpp and comparison of speed with R

2011-09-02 Thread Dirk Eddelbuettel
On 3 September 2011 at 10:54, Darren Cook wrote: | Anyway, I extended Christian Gunning's example with a noNA version | [1], then an STL version [2] that uses std::vector, then a C/C++ pointer | version [3]. [4] shows my compiler options (all defaults). | | test replications elapsed relat

Re: [Rcpp-devel] Return more than one value

2011-09-02 Thread Dirk Eddelbuettel
On 2 September 2011 at 14:30, Noah Silverman wrote: | Hi, | | I'm starting to use Rcpp (through rinside). | | I want to create several Rcpp::NumericMatrix in my C++ code and then return | them all. | | Is this possible? Please attempt to at least read one or two of the intro documents which C

Re: [Rcpp-devel] Install RcppArmadillo against Intel MKL

2011-09-02 Thread Dirk Eddelbuettel
Hi Zarrar, On 2 September 2011 at 17:19, Zarrar Shehzad wrote: | Is it possible to install RcppArmadillo with Intel's MKL library? In principle, yes. In practice, probably too as well :) When we started this we used Armadillo as library and via a configure step. Doug later convinced us that rel

Re: [Rcpp-devel] R.e. First foray into Rcpp and comparison of speed with R

2011-09-02 Thread Darren Cook
> There is a noNA() wrapper for Rcpp sugar to push performance -- NA checking > is implemented on access 'because that is how R does' (and our first task to > reproduce numbers you'd get at the R prompt) but if you know what you are > doing and are aware of possible pitfalls you can skip this. See

Re: [Rcpp-devel] Best way to return raw array

2011-09-02 Thread Darren Cook
>> | double *p=third_party_function(nn); >> | NumericVector ret(p,p+nn); >> | delete p; >> | return ret; > What puzzles me is why Darren's original version doesn't work. Due to an embarrassing bug in my test code: delete should be delete[]. So, I think we can say these two idioms are equivalent:

Re: [Rcpp-devel] Best way to return raw array

2011-09-02 Thread Darren Cook
>> > Maybe this would do >> > >> > double *p=third_party_function(nn); >> > NumericVector ret(nn); // new memory >> > copy(ret.begin(), ret.end(), p); // untested >> > delete p; >> > return ret; >> > >>> | where third_party_function() is C legacy code that is >>> documented as | re

Re: [Rcpp-devel] Return more than one value

2011-09-02 Thread Noah Silverman
Genius. Thank You!! -- Noah Silverman UCLA Department of Statistics 8117 Math Sciences Building #8208 Los Angeles, CA 90095 On Sep 2, 2011, at 2:33 PM, Hadley Wickham wrote: > Return a list of matrices? > > Hadley > > On Fri, Sep 2, 2011 at 4:30 PM, Noah Silverman wrote: >> Hi, >> I'm start

[Rcpp-devel] Return more than one value

2011-09-02 Thread Noah Silverman
Hi, I'm starting to use Rcpp (through rinside). I want to create several Rcpp::NumericMatrix in my C++ code and then return them all. Is this possible? -- Noah Silverman UCLA Department of Statistics 8117 Math Sciences Building #8208 Los Angeles, CA 90095

Re: [Rcpp-devel] Return more than one value

2011-09-02 Thread Zarrar Shehzad
Here are 2 links that contain examples of lists being used: http://dirk.eddelbuettel.com/code/rcpp.armadillo.html http://cran.r-project.org/web/packages/Rcpp/vignettes/Rcpp-quickref.pdf Z On Fri, Sep 2, 2011 at 5:35 PM, Noah Silverman wrote: > Sorry to ask something so simple, but could you poi

Re: [Rcpp-devel] Return more than one value

2011-09-02 Thread Noah Silverman
Sorry to ask something so simple, but could you point me to an example? Thanks! -- Noah Silverman UCLA Department of Statistics 8117 Math Sciences Building #8208 Los Angeles, CA 90095 On Sep 2, 2011, at 2:33 PM, Hadley Wickham wrote: > Return a list of matrices? > > Hadley > > On Fri, Sep 2,

Re: [Rcpp-devel] Return more than one value

2011-09-02 Thread Hadley Wickham
Return a list of matrices? Hadley On Fri, Sep 2, 2011 at 4:30 PM, Noah Silverman wrote: > Hi, > I'm starting to use Rcpp (through rinside). > I want to create several Rcpp::NumericMatrix in my C++ code and then return > them all. > Is this possible? > -- > Noah Silverman > UCLA Department of Sta

[Rcpp-devel] Install RcppArmadillo against Intel MKL

2011-09-02 Thread Zarrar Shehzad
Is it possible to install RcppArmadillo with Intel's MKL library? I tried to replace the "$(LAPACK_LIBS) $(BLAS_LIBS)" in the Makevars with links to Intel's MKL: "-L/opt/intel/composerxe/mkl/lib/intel64/ -lmkl_gf_ilp64 -lmkl_core -lmkl_def -lmkl_gnu_thread - lgomp -L/opt/intel/composerxe/mkl/lib/i

Re: [Rcpp-devel] Best way to return raw array

2011-09-02 Thread Davor Cubranic
On 2011-09-02, at 5:19 AM, Dirk Eddelbuettel wrote: > Maybe this would do > > double *p=third_party_function(nn); > NumericVector ret(nn); // new memory > copy(ret.begin(), ret.end(), p); // untested > delete p; > return ret; > > | where third_party_function() is C legacy code tha

Re: [Rcpp-devel] Best way to return raw array

2011-09-02 Thread Dirk Eddelbuettel
On 2 September 2011 at 10:42, Douglas Bates wrote: | On Fri, Sep 2, 2011 at 7:19 AM, Dirk Eddelbuettel wrote: | > | > On 2 September 2011 at 11:10, Darren Cook wrote: | > | > | I've extended Christian Gunning's speed test with an STL and C/C++ | > | > | version; I was about to post but then I got

Re: [Rcpp-devel] Best way to return raw array

2011-09-02 Thread Douglas Bates
On Fri, Sep 2, 2011 at 7:19 AM, Dirk Eddelbuettel wrote: > > On 2 September 2011 at 11:10, Darren Cook wrote: > | > | I've extended Christian Gunning's speed test with an STL and C/C++ > | > | version; I was about to post but then I got a bit stuck with using > | > | Rcpp::wrap() for a raw block o

[Rcpp-devel] RcppArmadillo: Propagating .print() from C++ layer to R

2011-09-02 Thread Savitsky, Terrance
Hi, I find it convenient to use inline for debugging Rcpp script. Armadillo possesses print member functions, such as .print() that would be very helpful to me to see object values under failure. Is it possible within RcppArmadillo to propagate these .print() commands to the R layer? On a r

Re: [Rcpp-devel] Best way to return raw array

2011-09-02 Thread Dirk Eddelbuettel
On 2 September 2011 at 11:10, Darren Cook wrote: | > | I've extended Christian Gunning's speed test with an STL and C/C++ | > | version; I was about to post but then I got a bit stuck with using | > | Rcpp::wrap() for a raw block of memory. I'm using this: | | | > src1cpp<-' | int nn=as(n); | do