[Rcpp-commits] r4554 - in pkg/Rcpp: . inst inst/include/Rcpp/traits

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Oct 3 01:43:24 CEST 2013


Author: edd
Date: 2013-10-03 01:43:24 +0200 (Thu, 03 Oct 2013)
New Revision: 4554

Modified:
   pkg/Rcpp/ChangeLog
   pkg/Rcpp/inst/NEWS.Rd
   pkg/Rcpp/inst/THANKS
   pkg/Rcpp/inst/include/Rcpp/traits/is_na.h
Log:
some is.na() fixes also thanks to Thomas Tse


Modified: pkg/Rcpp/ChangeLog
===================================================================
--- pkg/Rcpp/ChangeLog	2013-10-02 03:04:36 UTC (rev 4553)
+++ pkg/Rcpp/ChangeLog	2013-10-02 23:43:24 UTC (rev 4554)
@@ -1,3 +1,7 @@
+2013-10-02  Dirk Eddelbuettel  <edd at debian.org>
+
+	* inst/include/Rcpp/traits/is_na.h: More fixes thanks to Thomas Tse
+
 2013-10-01  Dirk Eddelbuettel  <edd at debian.org>
 
 	* inst/include/Rcpp/api/meat/is.h: Applied patch by Thomas Tse to

Modified: pkg/Rcpp/inst/NEWS.Rd
===================================================================
--- pkg/Rcpp/inst/NEWS.Rd	2013-10-02 03:04:36 UTC (rev 4553)
+++ pkg/Rcpp/inst/NEWS.Rd	2013-10-02 23:43:24 UTC (rev 4554)
@@ -2,13 +2,13 @@
 \title{News for Package 'Rcpp'}
 \newcommand{\cpkg}{\href{http://CRAN.R-project.org/package=#1}{\pkg{#1}}}
 
-\section{Changes in Rcpp version 0.10.5.1 (2013-10-01)}{
+\section{Changes in Rcpp version 0.10.5.1 (2013-10-02)}{
   \itemize{
     \item Changes in Rcpp API:
     \itemize{
       \item Two missing \code{is<>()} templates for
-      \code{CharacterVector} and \code{CharacterMatrix} have been added
-      thanks to Thomas Tse.  
+      \code{CharacterVector} and \code{CharacterMatrix} have been added,
+      and tests for \code{is.na()} have been corrected thanks to Thomas Tse.  
     }
   }
 }

Modified: pkg/Rcpp/inst/THANKS
===================================================================
--- pkg/Rcpp/inst/THANKS	2013-10-02 03:04:36 UTC (rev 4553)
+++ pkg/Rcpp/inst/THANKS	2013-10-02 23:43:24 UTC (rev 4554)
@@ -25,7 +25,7 @@
 Oleg Sklyar             for the incredibly cool inline package
 Alexey Stukalov         for a support enabling Intel Compiler 12.0 support
 Luke Tierney            for helpful discussions on R internals
-Thomas Tse              for a patch filling in two missing is<T>() instances
+Thomas Tse              for several patches with small corrections
 Simon Urbanek           for help on OS X build issues and with R internals
 Ken Williams            for additional OS X testing
 Jelmer Ypma             for contributing the Rcout iostreams class patch

Modified: pkg/Rcpp/inst/include/Rcpp/traits/is_na.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/traits/is_na.h	2013-10-02 03:04:36 UTC (rev 4553)
+++ pkg/Rcpp/inst/include/Rcpp/traits/is_na.h	2013-10-02 23:43:24 UTC (rev 4554)
@@ -1,4 +1,4 @@
-// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
+// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*-
 //
 // is_na.h: Rcpp R/C++ interface class library -- vector operators
 //                                                                      
@@ -23,36 +23,41 @@
 #define Rcpp__traits_is_na_h
 
 namespace Rcpp{
-namespace traits{
-	
-	// default to always false, applies to VECSXP, EXPRSXP and RAWSXP
-	template <int RTYPE> 
-	bool is_na( typename storage_type<RTYPE>::type ){
-	    return false ;    
-	}
-	
-	template <> 
-	inline bool is_na<INTSXP>( int x ){
-		return x == NA_INTEGER ;
-	}
-	
-	template <> 
-	inline bool is_na<REALSXP>( double x ){
-		return R_IsNA(x) ;
-	}
-	
-	template <> 
-	inline bool is_na<CPLXSXP>( Rcomplex x ){
-		return R_IsNA(x.r) || R_IsNA(x.i) ;
-	}
-	
-	template <>
-	inline bool is_na<STRSXP>( SEXP x ){ return x == NA_STRING ; }
-	
-	template <>
-	inline bool is_na<LGLSXP>( int x ){ return x == NA_LOGICAL ; }
-	
+
+    namespace traits{
+        
+        // default to always false, applies to VECSXP, EXPRSXP and RAWSXP
+        template <int RTYPE> 
+        bool is_na(typename storage_type<RTYPE>::type) {
+            return false;    
+        }
+        
+        template <> 
+        inline bool is_na<INTSXP>(int x) {
+            return x == NA_INTEGER;
+        }
+        
+        template <> 
+        inline bool is_na<REALSXP>(double x) {
+            return R_IsNA(x) || R_IsNaN(x);
+        }
+        
+        template <> 
+        inline bool is_na<CPLXSXP>(Rcomplex x) {
+            return R_IsNA(x.r) || R_IsNA(x.i) || R_IsNaN(x.r) || R_IsNaN(x.i);
+        }
+        
+        template <>
+        inline bool is_na<STRSXP>(SEXP x) { 
+            return false; // see rcpp-devel on 2013-10-02; was:  x == NA_STRING; 
+        }
+        
+        template <>
+        inline bool is_na<LGLSXP>(int x) { 
+            return x == NA_LOGICAL; 
+        }
+        
+    }
 }
-}
 
 #endif



More information about the Rcpp-commits mailing list