Skip to content

Commit 9e62320

Browse files
committed
corrected where Thomas's small patch is applied
1 parent 79c1735 commit 9e62320

File tree

3 files changed

+36
-30
lines changed

3 files changed

+36
-30
lines changed

inst/NEWS.Rd

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
\itemize{
99
\item Two missing \code{is<>()} templates for
1010
\code{CharacterVector} and \code{CharacterMatrix} have been added,
11-
and tests for \code{is.na()} have been corrected thanks to Thomas Tse.
11+
and some tests for \code{is_na()} and \code{is_finite()} have been
12+
corrected thanks to Thomas Tse.
1213
}
1314
}
1415
}

inst/include/Rcpp/traits/is_finite.h

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
1+
// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*-
22
//
33
// is_finite.h: Rcpp R/C++ interface class library -- is finite
44
//
@@ -23,33 +23,38 @@
2323
#define Rcpp__traits_is_finite_h
2424

2525
namespace Rcpp{
26-
namespace traits{
27-
28-
// default for complex,
29-
template <int RTYPE>
30-
bool is_finite( typename storage_type<RTYPE>::type) ;
31-
32-
template <>
33-
inline bool is_finite<INTSXP>( int x ){
34-
return x != NA_INTEGER ;
35-
}
36-
37-
template <>
38-
inline bool is_finite<REALSXP>( double x ){
39-
return R_finite(x) ;
40-
}
41-
42-
template <>
43-
inline bool is_finite<CPLXSXP>( Rcomplex x ){
44-
return !( !R_finite(x.r) || !R_finite(x.i) );
45-
}
46-
47-
template <>
48-
inline bool is_finite<STRSXP>( SEXP x ){ return x != NA_STRING ; }
49-
50-
template <>
51-
inline bool is_finite<LGLSXP>( int x ){ return x != NA_LOGICAL ; }
52-
26+
27+
namespace traits{
28+
29+
// default for complex,
30+
template <int RTYPE>
31+
bool is_finite( typename storage_type<RTYPE>::type);
32+
33+
template <>
34+
inline bool is_finite<INTSXP>(int x){
35+
return x != NA_INTEGER;
36+
}
37+
38+
template <>
39+
inline bool is_finite<REALSXP>(double x) {
40+
return R_finite(x);
41+
}
42+
43+
template <>
44+
inline bool is_finite<CPLXSXP>(Rcomplex x) {
45+
return !( !R_finite(x.r) || !R_finite(x.i) );
46+
}
47+
48+
template <>
49+
inline bool is_finite<STRSXP>(SEXP x) {
50+
return false; // see rcpp-devel on 2013-10-02; was: x != NA_STRING;
51+
}
52+
53+
template <>
54+
inline bool is_finite<LGLSXP>(int x) {
55+
return x != NA_LOGICAL;
56+
}
57+
5358
}
5459
}
5560

inst/include/Rcpp/traits/is_na.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ namespace Rcpp{
4949

5050
template <>
5151
inline bool is_na<STRSXP>(SEXP x) {
52-
return false; // see rcpp-devel on 2013-10-02; was: x == NA_STRING;
52+
return x == NA_STRING;
5353
}
5454

5555
template <>

0 commit comments

Comments
 (0)