[Rcpp-commits] r1994 - pkg/Rcpp/inst/include/Rcpp/sugar/functions

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Aug 12 17:42:52 CEST 2010


Author: romain
Date: 2010-08-12 17:42:52 +0200 (Thu, 12 Aug 2010)
New Revision: 1994

Modified:
   pkg/Rcpp/inst/include/Rcpp/sugar/functions/SugarMath.h
Log:
SugarMath was broken

Modified: pkg/Rcpp/inst/include/Rcpp/sugar/functions/SugarMath.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/sugar/functions/SugarMath.h	2010-08-12 14:57:56 UTC (rev 1993)
+++ pkg/Rcpp/inst/include/Rcpp/sugar/functions/SugarMath.h	2010-08-12 15:42:52 UTC (rev 1994)
@@ -26,10 +26,17 @@
 namespace sugar{
 	
 template <bool NA, typename OUT, typename U1, typename T1, typename FunPtr>
-class SugarMath_1 : public Rcpp::VectorBase< Rcpp::traits::r_sexptype_traits<OUT>::rtype , NA, SugarMath_1<NA,OUT,U1,T1,FunPtr> > {
+class SugarMath_1 : public Rcpp::VectorBase< 
+	Rcpp::traits::r_sexptype_traits<OUT>::rtype , 
+	NA, 
+	SugarMath_1<NA,OUT,U1,T1,FunPtr>
+	> {
 public:
-	SugarMath_1( FunPtr ptr_, const T1 & vec_) : ptr(ptr_), vec(vec_){}
 	
+	typedef Rcpp::VectorBase< Rcpp::traits::r_sexptype_traits<OUT>::rtype ,NA,T1> VEC_TYPE ;
+	
+	SugarMath_1( FunPtr ptr_, const VEC_TYPE & vec_) : ptr(ptr_), vec(vec_){}
+	
 	inline OUT operator[]( int i) const { 
 		U1 x = vec[i] ;
 		if( ISNAN(x) ) return x;
@@ -39,14 +46,20 @@
 	
 private:
 	FunPtr ptr ;
-	const T1& vec ;
+	const VEC_TYPE& vec ;
 };
 
 template <bool NA, typename OUT, typename T1, typename FunPtr>
-class SugarMath_1<NA,OUT,int,T1,FunPtr> : public Rcpp::VectorBase< Rcpp::traits::r_sexptype_traits<OUT>::rtype , NA, SugarMath_1<NA,OUT,int,T1,FunPtr> > {
+class SugarMath_1<NA,OUT,int,T1,FunPtr> : public Rcpp::VectorBase< 
+	Rcpp::traits::r_sexptype_traits<OUT>::rtype , 
+	NA, 
+	SugarMath_1<NA,OUT,int,T1,FunPtr>
+	> {
 public:
-	SugarMath_1( FunPtr ptr_, const T1 & vec_) : ptr(ptr_), vec(vec_){}
+	typedef Rcpp::VectorBase< INTSXP ,NA,T1> VEC_TYPE ;
 	
+	SugarMath_1( FunPtr ptr_, const VEC_TYPE & vec_) : ptr(ptr_), vec(vec_){}
+	
 	inline OUT operator[]( int i) const { 
 		int x = vec[i] ;
 		if( Rcpp::traits::is_na<INTSXP>(x) ) return Rcpp::traits::get_na<REALSXP>( ) ;
@@ -56,13 +69,19 @@
 	
 private:
 	FunPtr ptr ;
-	const T1& vec ;
+	const VEC_TYPE& vec ;
 };
 
 template <typename OUT, typename T1, typename FunPtr>
-class SugarMath_1<false,OUT,int,T1,FunPtr> : public Rcpp::VectorBase< Rcpp::traits::r_sexptype_traits<OUT>::rtype , false, SugarMath_1<false,OUT,int,T1,FunPtr> > {
+class SugarMath_1<false,OUT,int,T1,FunPtr> : public 
+Rcpp::VectorBase< 
+	Rcpp::traits::r_sexptype_traits<OUT>::rtype , 
+	false, 
+	SugarMath_1<false,OUT,int,T1,FunPtr>
+> {
 public:
-	SugarMath_1( FunPtr ptr_, const T1 & vec_) : ptr(ptr_), vec(vec_){}
+	typedef Rcpp::VectorBase< INTSXP ,false,T1> VEC_TYPE ;
+	SugarMath_1( FunPtr ptr_, const VEC_TYPE & vec_) : ptr(ptr_), vec(vec_){}
 	
 	inline OUT operator[]( int i) const { 
 		return ptr( vec[i] ) ;
@@ -71,7 +90,7 @@
 	
 private:
 	FunPtr ptr ;
-	const T1& vec ;
+	const VEC_TYPE& vec ;
 };
 
 
@@ -86,7 +105,7 @@
 		const VectorBase<REALSXP,NA,T>& t                                    \
 	){                                                                       \
 		return sugar::SugarMath_1<NA,double,double,T, double (*)(double)>(   \
-			__SYMBOL__ , t                                                   \
+			&__SYMBOL__ , t                                                   \
 		) ;                                                                  \
 	}                                                                        \
 	template <bool NA, typename T>                                           \
@@ -95,7 +114,7 @@
 		const VectorBase<INTSXP,NA,T>& t                                     \
 	){                                                                       \
 		return sugar::SugarMath_1<NA,double,int,T, double (*)(double)>(      \
-			__SYMBOL__ , t                                                   \
+			&__SYMBOL__ , t                                                   \
 		) ;                                                                  \
 	}                                                                        \
 	}



More information about the Rcpp-commits mailing list