Re: [Rcpp-devel] NA_REAL in RcppParallel

2016-06-02 Thread Jason Foster
Thank you, Bill and Dirk, for the suggestions and insight. Much appreciated. On Thu, Jun 2, 2016 at 12:03 PM, Dirk Eddelbuettel wrote: > > For the particular case of 'not finite' on floats I also found that I could > resort to the standard NaN which IEEE arithmetic supports. Of course, this > w

Re: [Rcpp-devel] NA_REAL in RcppParallel

2016-06-02 Thread Dirk Eddelbuettel
For the particular case of 'not finite' on floats I also found that I could resort to the standard NaN which IEEE arithmetic supports. Of course, this will then be a NaN in R and not a NA where you might want the latter. But at least it stays cleanly away from R which may help in the multithread

Re: [Rcpp-devel] NA_REAL in RcppParallel

2016-06-02 Thread William Dunlap
> if (std::isnan(input[i])) { > output[i] = NA_REAL; // this is the desired output (instead of NAN) In this case I think you could replace the second line with output[i] = input[i]; to emulate the usual R mapping of NA to NA and NaN to NaN. (I have seen C compilers that messed up my pro

Re: [Rcpp-devel] NA_REAL in RcppParallel

2016-06-02 Thread Jason Foster
Great! Thank you, Hadley. On Jun 2, 2016 7:30 AM, "Hadley Wickham" wrote: > NA_REAL is just a NaN with a special value in the payload, so it's fine to > use. > Hadley > > On Thu, Jun 2, 2016 at 7:07 AM, Jason Foster > wrote: > > Hi, > > > > My question is how can I return a thread safe NA_REAL u

Re: [Rcpp-devel] NA_REAL in RcppParallel

2016-06-02 Thread Hadley Wickham
NA_REAL is just a NaN with a special value in the payload, so it's fine to use. Hadley On Thu, Jun 2, 2016 at 7:07 AM, Jason Foster wrote: > Hi, > > My question is how can I return a thread safe NA_REAL using RcppParallel? > I've read many posts about how it's not thread safe to call R or Rcpp AP

[Rcpp-devel] NA_REAL in RcppParallel

2016-06-02 Thread Jason Foster
Hi, My question is how can I return a thread safe NA_REAL using RcppParallel? I've read many posts about how it's not thread safe to call R or Rcpp APIs when using RcppParallel ( http://lists.r-forge.r-project.org/pipermail/rcpp-devel/2016-January/009061.html), so in the past I've played it safe b

Re: [Rcpp-devel] Setting armadillo preprocessor macros in R package

2016-06-02 Thread Scott Ritchie
Thanks JJ, That worked perfectly. On 2 June 2016 at 20:25, JJ Allaire wrote: > If you create a file called pkgname_types.hpp and put it in your src > directory it will be added to RcppExports.cpp ahead of RcppArmadillo.h. > e.g. if your package is named foo then create: > > src/foo_types.hpp >

Re: [Rcpp-devel] Setting armadillo preprocessor macros in R package

2016-06-02 Thread JJ Allaire
If you create a file called pkgname_types.hpp and put it in your src directory it will be added to RcppExports.cpp ahead of RcppArmadillo.h. e.g. if your package is named foo then create: src/foo_types.hpp And put your #define macros there. On Thu, Jun 2, 2016 at 3:32 AM, Scott Ritchie wrote:

[Rcpp-devel] Setting armadillo preprocessor macros in R package

2016-06-02 Thread Scott Ritchie
Hi all, I would like to set my own Armadillo #define macros (i.e. some of those listed http://arma.sourceforge.net/docs.html#config_hpp) in an R package I have developed. The instructions there are to put their definitions before the include statement to armadillo.h (or in this case RcppArmadillo