[Rcpp-devel] Rcpp sugar preserving attributes

2015-01-04 Thread Søren Højsgaard
Dear all, I have noticed an issue with preserving attributes (or rather attributes that are not preserved). Consider this code where I take the log of an array: #include using namespace Rcpp; //[[Rcpp::export]] NumericVector fun1(NumericVector x){ return log( x ); } //[[Rcpp::export]] Numer

[Rcpp-devel] Call C++ Function into R function called in Rcpp

2015-01-04 Thread bbo...@tin.it
Dear list first of all happy new year. I have a question .. I would like to call rcpp function (so c++ function) into R function (optim for example) called into rcpp. I had prototype an example code and post below. (Using Rcpp::InternalFunction(&foo)) Is it correct the way I had used? There i

[Rcpp-devel] Call ++ funtion into R function called in rcpp

2015-01-04 Thread bbo...@tin.it
Dear list first of all happy new year. I have a question .. I would like to call rcpp function (so c++ function) into R function (optim for example) called into rcpp. I had prototype an example code and post below. (Using Rcpp::InternalFunction(&foo)) Is it correct the way I had used? There i

Re: [Rcpp-devel] Call C++ Function into R function called in Rcpp

2015-01-04 Thread Dirk Eddelbuettel
On 4 January 2015 at 10:56, bbo...@tin.it wrote: | Dear list first of all happy new year. | I have a question .. I would like to call rcpp function (so c++ function) into | R function (optim for example) called into rcpp. I had prototype an example | code and post | below. (Using Rcpp::Internal

Re: [Rcpp-devel] Rcpp sugar preserving attributes

2015-01-04 Thread Dirk Eddelbuettel
Søren, Happy New Year! On 4 January 2015 at 09:53, Søren Højsgaard wrote: | Dear all, | | I have noticed an issue with preserving attributes (or rather attributes that are not preserved). Consider this code where I take the log of an array: Quite possible. Attributes are just attached to ob

Re: [Rcpp-devel] Rcpp sugar preserving attributes

2015-01-04 Thread Søren Højsgaard
Thanks! Probably a stupid question, but where are these functions defined? In math.h I see VECTORIZED_MATH_1(log,::log) but - where to look for the implementation? Cheers Søren |-Original Message- |From: Dirk Eddelbuettel [mailto:e...@debian.org] |Sent: 4. januar 2015 16:32 |To: Søren

Re: [Rcpp-devel] Rcpp sugar preserving attributes

2015-01-04 Thread Dirk Eddelbuettel
On 4 January 2015 at 19:58, Søren Højsgaard wrote: | Thanks! Probably a stupid question, but where are these functions defined? In math.h I see | | VECTORIZED_MATH_1(log,::log) | | but - where to look for the implementation? You mean where VECTORIZED_MATH is defined? Let me introduce you to

Re: [Rcpp-devel] Rcpp sugar preserving attributes

2015-01-04 Thread Søren Højsgaard
Hi Dirk, Cunning piece of code you pointed me to ('ag' seems like a good friend): #define VECTORIZED_MATH_1(__NAME__,__SYMBOL__) \ namespace Rcpp{ \ template

Re: [Rcpp-devel] Best Practice for Optimize Functions in RCPP

2015-01-04 Thread Simon Riddell
Dear all, Thank you for your responses. I will look into the resources and code you have shared and hopefully I can figure something out! I appreciate your time and help. Simon On Fri, Jan 2, 2015 at 12:45 PM, Mark Clements wrote: > Alternatively, one could use the code for Brent_fmin() from t