[Rcpp-commits] r3200 - in pkg/Rcpp: . inst/include/Rcpp inst/include/Rcpp/sugar/block inst/include/Rcpp/sugar/functions

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Sep 24 19:35:28 CEST 2011


Author: edd
Date: 2011-09-24 19:35:28 +0200 (Sat, 24 Sep 2011)
New Revision: 3200

Modified:
   pkg/Rcpp/ChangeLog
   pkg/Rcpp/DESCRIPTION
   pkg/Rcpp/inst/include/Rcpp/Extractor.h
   pkg/Rcpp/inst/include/Rcpp/sugar/block/Vectorized_Math.h
   pkg/Rcpp/inst/include/Rcpp/sugar/functions/math.h
Log:
applied 2/3 of Martyn's patch for Solaris (excluded the reference vs full copy changes)
upped Version to 0.9.6.2


Modified: pkg/Rcpp/ChangeLog
===================================================================
--- pkg/Rcpp/ChangeLog	2011-09-16 18:55:32 UTC (rev 3199)
+++ pkg/Rcpp/ChangeLog	2011-09-24 17:35:28 UTC (rev 3200)
@@ -1,3 +1,10 @@
+2011-09-24  Dirk Eddelbuettel  <edd at debian.org>
+
+	* inst/include/Rcpp/Extractor.h: Apply patch by Martyn Plummer to
+	help with compilation on Solaris
+	* inst/include/Rcpp/sugar/block/Vectorized_Math.h: Idem 
+	* inst/include/Rcpp/sugar/functions/math.h: Idem
+
 2011-08-26  Douglas Bates  <bates at stat.wisc.edu>
 
 	* inst/examples/OpenMP/OpenMPandInline.r: Added another variant

Modified: pkg/Rcpp/DESCRIPTION
===================================================================
--- pkg/Rcpp/DESCRIPTION	2011-09-16 18:55:32 UTC (rev 3199)
+++ pkg/Rcpp/DESCRIPTION	2011-09-24 17:35:28 UTC (rev 3200)
@@ -1,6 +1,6 @@
 Package: Rcpp
 Title: Seamless R and C++ Integration
-Version: 0.9.6.1
+Version: 0.9.6.2
 Date: $Date$
 Author: Dirk Eddelbuettel and Romain Francois, 
  with contributions by Douglas Bates and John Chambers

Modified: pkg/Rcpp/inst/include/Rcpp/Extractor.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/Extractor.h	2011-09-16 18:55:32 UTC (rev 3199)
+++ pkg/Rcpp/inst/include/Rcpp/Extractor.h	2011-09-24 17:35:28 UTC (rev 3200)
@@ -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; -*-
 //
 // Extractor.h: Rcpp R/C++ interface class library -- faster vectors (less interface)
 //
@@ -35,6 +35,7 @@
     // update 30 Oct 2010: that may have been g++ 4.5 rather than Windows
     //                     so rephrasing text in terms of macro from RcppCommon.h
 //#ifndef WIN32
+#ifdef __GNUC__
 #ifndef IS_GCC_450_OR_LATER
     template <> 
     struct Extractor<INTSXP, true, Rcpp::Vector<INTSXP> >{
@@ -56,7 +57,8 @@
         typedef Rcpp::Fast< Rcpp::Vector<RAWSXP> > type ;
     } ;
 #endif    
-    
+#endif
+
 } // traits
 } // Rcpp 
 

Modified: pkg/Rcpp/inst/include/Rcpp/sugar/block/Vectorized_Math.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/sugar/block/Vectorized_Math.h	2011-09-16 18:55:32 UTC (rev 3199)
+++ pkg/Rcpp/inst/include/Rcpp/sugar/block/Vectorized_Math.h	2011-09-24 17:35:28 UTC (rev 3200)
@@ -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; -*-
 //
 // SugarBlock.h: Rcpp R/C++ interface class library -- sugar functions
 //
@@ -25,54 +25,56 @@
 namespace Rcpp{
 namespace sugar{
 
-template <double Func(double), bool NA, typename VEC>
+extern "C" typedef double (*DDFun)(double);
+
+template <DDFun Func, bool NA, typename VEC>
 class Vectorized : public VectorBase<REALSXP, NA, Vectorized<Func,NA,VEC> >{
 public:
     typedef typename Rcpp::VectorBase<REALSXP,NA,VEC> VEC_TYPE ;
-	typedef typename Rcpp::traits::Extractor<REALSXP,NA,VEC>::type VEC_EXT ;
-	
-	Vectorized( const VEC_TYPE& object_) : object( object_.get_ref() ){}
-	inline double operator[]( int i) const {
-	    return Func( object[i] ) ;
-	}
-	inline int size() const { return object.size(); }
-	
+    typedef typename Rcpp::traits::Extractor<REALSXP,NA,VEC>::type VEC_EXT ;
+        
+    Vectorized( const VEC_TYPE& object_) : object( object_.get_ref() ){}
+    inline double operator[]( int i) const {
+        return Func( object[i] ) ;
+    }
+    inline int size() const { return object.size(); }
+        
 private:
-    const VEC_EXT& object ;	
+    const VEC_EXT& object ;     
 } ;
 
-template <double Func(double), bool NA, typename VEC>
+template <DDFun Func, bool NA, typename VEC>
 class Vectorized_INTSXP : public VectorBase<REALSXP, NA, Vectorized_INTSXP<Func,NA,VEC> >{
 public:
     typedef typename Rcpp::VectorBase<INTSXP,NA,VEC> VEC_TYPE ;
-	typedef typename Rcpp::traits::Extractor<INTSXP,NA,VEC>::type VEC_EXT ;
-	
-	Vectorized_INTSXP( const VEC_TYPE& object_) : object( object_.get_ref() ){}
-	inline double operator[]( int i) const {
-	    int x = object[i] ;
-	    if( x == NA_INTEGER ) return NA_REAL ;
-	    return Func( x ) ;
-	}
-	inline int size() const { return object.size(); }
-	
+    typedef typename Rcpp::traits::Extractor<INTSXP,NA,VEC>::type VEC_EXT ;
+        
+    Vectorized_INTSXP( const VEC_TYPE& object_) : object( object_.get_ref() ){}
+    inline double operator[]( int i) const {
+        int x = object[i] ;
+        if( x == NA_INTEGER ) return NA_REAL ;
+        return Func( x ) ;
+    }
+    inline int size() const { return object.size(); }
+        
 private:
-    const VEC_EXT& object ;	
+    const VEC_EXT& object ;     
 } ;
-template <double Func(double), typename VEC>
+template <DDFun Func, typename VEC>
 class Vectorized_INTSXP<Func,false,VEC> : 
     public VectorBase<REALSXP,false, Vectorized_INTSXP<Func,false,VEC> >{
 public:
     typedef typename Rcpp::VectorBase<INTSXP,false,VEC> VEC_TYPE ;
-	typedef typename Rcpp::traits::Extractor<INTSXP,false,VEC>::type VEC_EXT ;
-	
-	Vectorized_INTSXP( const VEC_TYPE& object_) : object( object_.get_ref() ){}
-	inline double operator[]( int i) const {
-	    return Func( object[i] ) ;
-	}
-	inline int size() const { return object.size(); }
-	
+    typedef typename Rcpp::traits::Extractor<INTSXP,false,VEC>::type VEC_EXT ;
+        
+    Vectorized_INTSXP( const VEC_TYPE& object_) : object( object_.get_ref() ){}
+    inline double operator[]( int i) const {
+        return Func( object[i] ) ;
+    }
+    inline int size() const { return object.size(); }
+        
 private:
-    const VEC_EXT& object ;	
+    const VEC_EXT& object ;     
 } ;
 
 } // sugar
@@ -80,18 +82,18 @@
 
 #define VECTORIZED_MATH_1(__NAME__,__SYMBOL__)                               \
 namespace Rcpp{                                                              \
-	template <bool NA, typename T>                                           \
-	inline sugar::Vectorized<__SYMBOL__,NA,T>                                \
-	__NAME__( const VectorBase<REALSXP,NA,T>& t ){                           \
-		return sugar::Vectorized<__SYMBOL__,NA,T>( t ) ;                     \
-	}                                                                        \
-	inline sugar::Vectorized<__SYMBOL__,true,NumericVector>                  \
-	__NAME__( SEXP x){ return __NAME__( NumericVector( x ) ) ; }             \
-	template <bool NA, typename T>                                           \
-	inline sugar::Vectorized_INTSXP<__SYMBOL__,NA,T>                         \
-	__NAME__( const VectorBase<INTSXP,NA,T>& t	){                           \
-		return sugar::Vectorized_INTSXP<__SYMBOL__,NA,T>( t ) ;              \
-	}                                                                        \
+        template <bool NA, typename T>                                           \
+        inline sugar::Vectorized<__SYMBOL__,NA,T>                                \
+        __NAME__( const VectorBase<REALSXP,NA,T>& t ){                           \
+                return sugar::Vectorized<__SYMBOL__,NA,T>( t ) ;                     \
+        }                                                                        \
+        inline sugar::Vectorized<__SYMBOL__,true,NumericVector>                  \
+        __NAME__( SEXP x){ return __NAME__( NumericVector( x ) ) ; }             \
+        template <bool NA, typename T>                                           \
+        inline sugar::Vectorized_INTSXP<__SYMBOL__,NA,T>                         \
+        __NAME__( const VectorBase<INTSXP,NA,T>& t      ){                           \
+                return sugar::Vectorized_INTSXP<__SYMBOL__,NA,T>( t ) ;              \
+        }                                                                        \
 }
 
 

Modified: pkg/Rcpp/inst/include/Rcpp/sugar/functions/math.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/sugar/functions/math.h	2011-09-16 18:55:32 UTC (rev 3199)
+++ pkg/Rcpp/inst/include/Rcpp/sugar/functions/math.h	2011-09-24 17:35:28 UTC (rev 3200)
@@ -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; -*-
 //
 // SugarBlock.h: Rcpp R/C++ interface class library -- sugar functions
 //
@@ -53,11 +53,11 @@
 namespace Rcpp{
 namespace internal{
 
-inline double factorial( double x ){
-	return ::Rf_gammafn( x + 1.0 ) ;
+extern "C" inline double factorial( double x ){
+    return ::Rf_gammafn( x + 1.0 ) ;
 }
-inline double lfactorial( double x ){
-	return ::Rf_lgammafn( x + 1.0 ) ;
+extern "C" inline double lfactorial( double x ){
+    return ::Rf_lgammafn( x + 1.0 ) ;
 }
 
 }



More information about the Rcpp-commits mailing list