On 22 January 2014 at 23:07, Søren Højsgaard wrote:
| I am struggeling with checking for NA and Inf in a loop over a numeric 
vector. I have created these two helpers:

"If in doubt, check unit tests". 

See e.g. inst/unitTests/cpp/sugar.cpp 

// [[Rcpp::export]]
LogicalVector runit_isna( NumericVector xx){
    return wrap( is_na( xx ) ) ;
}

// [[Rcpp::export]]
LogicalVector runit_isfinite( NumericVector xx){
    return is_finite(xx) ;
}

// [[Rcpp::export]]
LogicalVector runit_isinfinite( NumericVector xx){
    return is_infinite(xx) ;
}

// [[Rcpp::export]]
LogicalVector runit_isnan( NumericVector xx){
    return is_nan(xx) ;
}

These save you the loop. But if you want to you do of course the plain C
functions from the R interface.

Dirk


-- 
Dirk Eddelbuettel | e...@debian.org | http://dirk.eddelbuettel.com
_______________________________________________
Rcpp-devel mailing list
Rcpp-devel@lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Reply via email to