I just found Rcpp can recognize is_infinite() function only for vector input..
The example is below
#include <Rcpp.h>
using namespace Rcpp;
// [[Rcpp::export]]
double testInfinite() {
NumericVector v =
NumericVector::create( 1, NA_REAL, R_NaN, R_PosInf, R_NegInf);
NumericVector x= NumericVector :: create(log(0.0),1/0.0);
LogicalVector l1 = is_na(v);
LogicalVector l2 = is_nan(v);
LogicalVector l3 = is_infinite(v);
LogicalVector l4 = is_infinite(x);
Rcout << l1 << "\n"; // 0 1 1 0 0
Rcout << l2 << "\n"; // 0 0 1 0 0
Rcout << l3 << "\n"; // 0 0 0 1 1
Rcout << l4 << "\n"; // 1 1
return 0.0;
}
The following page has a good explanation on NaN and Inf in Rcpp