[Rcpp-devel] api/meat/is.h missing CharacterVector and CharacterMatrix

2013-10-01 Thread Thomas Tse
hi, seems like api/meat/is.h missed the implementation for CharacterVector and CharacterMatrix, i.e. we should add:     template <> inline bool is__simple( SEXP x ){         return TYPEOF(x) == STRSXP ;     }     template <> inline bool is__simple( SEXP x ){         return TYPEOF(x) == STRSXP &&

[Rcpp-devel] inconsistent is_na() vs. is.na()

2013-10-02 Thread Thomas Tse
Hi, is_na() does not handles R's NaN correctly, for the below test.cpp: #include using namespace Rcpp; using namespace std; // [[Rcpp::export]] void test (NumericVector x) {   LogicalVector y1 = is_na(x);   LogicalVector y2 = is_finite(x);   LogicalVector y3 = is_infinite(x);   LogicalVector y4

[Rcpp-devel] is_finite corrections

2013-10-02 Thread Thomas Tse
Hi, in R, is.finite() and is.infinite() always return FALSE for character(): > is.finite(c('abc', NA_character_, 'efg')) [1] FALSE FALSE FALSE > is.infinite(c('abc', NA_character_, 'efg')) [1] FALSE FALSE FALSE so, we may need to change the template is_finite from: template <> inline bool is_f

Re: [Rcpp-devel] inconsistent is_na() vs. is.na()

2013-10-02 Thread Thomas Tse
FALSE of coz, there're some subtle differences (priority) in doing calculations on them: > NaN + 1 [1] NaN > NA + 1 [1] NA > NA * Inf [1] NA > NaN * Inf [1] NaN > NaN * NA [1] NA Thomas, On 2 October 2013 at 19:31, Thomas Tse wrote: | is_na() does not handles R's NaN

Re: [Rcpp-devel] inconsistent is_na() vs. is.na()

2013-10-02 Thread Thomas Tse
Thanks. Just to note the it's traits::is_finite, rather than is_na(), that needs to (always) return false From: Dirk Eddelbuettel To: Dirk Eddelbuettel Cc: Thomas Tse ; "rcpp-devel@lists.r-forge.r-project.org" Sent: Thursday, October

[Rcpp-devel] calling R function triggers tryCatch() ???

2013-10-03 Thread Thomas Tse
Hi, I'm trying to implement a faster version of apply(x, 1L, FUN) in C++ but found some strange behaviors. // [[Rcpp::export]] NumericVector rowApply(NumericMatrix& x, const Function& FUN) {   int n = x.nrow();   NumericVector result = no_init(n);   for (int r = 0; r < n; r++) {     result[r] =

Re: [Rcpp-devel] calling R function triggers tryCatch() ???

2013-10-04 Thread Thomas Tse
The next test compares the speeds: // [[Rcpp::export]] NumericVector rowApply0(NumericMatrix& x, const Function& FUN) {   int n = x.nrow();   NumericVector result = no_init(n);   for (int r = 0; r < n; r++) {     result[r] = as(FUN(x(r, _) ) );   }   return result; } // [[Rcpp::export]] Nu

Re: [Rcpp-devel] calling R function triggers tryCatch() ???

2013-10-04 Thread Thomas Tse
Wow Romain!! Dirk and U are really "Professional R (and C++) Enthusiast" !!! The following tests verified your words. I just post them for the benefits of other readers in this list. With the following C++ functions exported: // [[Rcpp::export]] void testErr0(SEXP x, const Function & FUN)

[Rcpp-devel] How to use "ff" package in Rcpp?

2014-07-30 Thread Thomas Tse
Hello, bigmemory is not availabe in Windows, so I have to use ff (http://cran.r-project.org/web/packages/ff/index.html) for big data ... is there a way that I could reference ff object within Rcpp? Thanks, Thomas Tse ___ Rcpp-devel mailing list Rcpp