> So your i_[0] - 1 is also nan. You are responsible for dealing with na. > > You can use traits::is_na: > > fx <- cxxfunction( signature( x_ = "numeric"), ' > > double x = as<double>(x_) ; > > if( traits::is_na<REALSXP>(x) ){ > // do something > } else { > // do something else > } > > ', plugin = "Rcpp" ) > > or perhaps if you don't like the whole traits::is_na<REALSXP> thing, you > could use e.g. somethin like this: > > template <typename T> > bool isna( T x ){ > return traits::is_na<traits::r_sexptype_traits<T>::rtype > (x) ; > } > > so that you coud just call > > if( isna(x) ){ ... }
What are the advantages/disadvantages of doing that over (say) x_[i] == NA_REAL ? Hadley -- Assistant Professor / Dobelman Family Junior Chair Department of Statistics / Rice University http://had.co.nz/ _______________________________________________ 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