[Rcpp-commits] r2818 - in pkg/Rcpp: . inst/include/Rcpp/sugar/operators inst/unitTests
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu Dec 23 12:57:50 CET 2010
Author: romain
Date: 2010-12-23 12:57:49 +0100 (Thu, 23 Dec 2010)
New Revision: 2818
Modified:
pkg/Rcpp/ChangeLog
pkg/Rcpp/inst/include/Rcpp/sugar/operators/divides.h
pkg/Rcpp/inst/unitTests/runit.support.R
Log:
more efficient operator/
Modified: pkg/Rcpp/ChangeLog
===================================================================
--- pkg/Rcpp/ChangeLog 2010-12-23 11:13:16 UTC (rev 2817)
+++ pkg/Rcpp/ChangeLog 2010-12-23 11:57:49 UTC (rev 2818)
@@ -7,6 +7,9 @@
* inst/include/Rcpp/sugar/operators/times.h: More efficient operator* for
REALSXP sugar expressions, avoiding unnecessary NA tests.
+ * inst/include/Rcpp/sugar/operators/divides.h: More efficient operator/ for
+ REALSXP sugar expressions, avoiding unnecessary NA tests.
+
2010-12-22 Romain Francois <romain at r-enthusiasts.com>
* inst/include/Rcpp/sugar/operators/plus.h: More efficient operator+ for
Modified: pkg/Rcpp/inst/include/Rcpp/sugar/operators/divides.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/sugar/operators/divides.h 2010-12-23 11:13:16 UTC (rev 2817)
+++ pkg/Rcpp/inst/include/Rcpp/sugar/operators/divides.h 2010-12-23 11:57:49 UTC (rev 2818)
@@ -31,9 +31,11 @@
typedef typename Rcpp::VectorBase<RTYPE,LHS_NA,LHS_T> LHS_TYPE ;
typedef typename Rcpp::VectorBase<RTYPE,RHS_NA,RHS_T> RHS_TYPE ;
typedef typename traits::storage_type<RTYPE>::type STORAGE ;
+ typedef typename Rcpp::traits::Extractor< RTYPE, LHS_NA, LHS_T>::type LHS_EXT ;
+ typedef typename Rcpp::traits::Extractor< RTYPE, RHS_NA, RHS_T>::type RHS_EXT ;
Divides_Vector_Vector( const LHS_TYPE& lhs_, const RHS_TYPE& rhs_ ) :
- lhs(lhs_), rhs(rhs_) {}
+ lhs(lhs_.get_ref()), rhs(rhs_.get_ref()) {}
inline STORAGE operator[]( int i ) const {
STORAGE x = lhs[i] ;
@@ -45,9 +47,32 @@
inline int size() const { return lhs.size() ; }
private:
- const LHS_TYPE& lhs ;
- const RHS_TYPE& rhs ;
+ const LHS_EXT& lhs ;
+ const RHS_EXT& rhs ;
} ;
+ // RTYPE = REALSXP
+ template <bool LHS_NA, typename LHS_T, bool RHS_NA, typename RHS_T >
+ class Divides_Vector_Vector<REALSXP,LHS_NA,LHS_T,RHS_NA,RHS_T> :
+ public Rcpp::VectorBase<REALSXP,true, Divides_Vector_Vector<REALSXP,LHS_NA,LHS_T,RHS_NA,RHS_T> > {
+ public:
+ typedef typename Rcpp::VectorBase<REALSXP,LHS_NA,LHS_T> LHS_TYPE ;
+ typedef typename Rcpp::VectorBase<REALSXP,RHS_NA,RHS_T> RHS_TYPE ;
+ typedef typename Rcpp::traits::Extractor<REALSXP, LHS_NA, LHS_T>::type LHS_EXT ;
+ typedef typename Rcpp::traits::Extractor<REALSXP, RHS_NA, RHS_T>::type RHS_EXT ;
+
+ Divides_Vector_Vector( const LHS_TYPE& lhs_, const RHS_TYPE& rhs_ ) :
+ lhs(lhs_), rhs(rhs_) {}
+
+ inline double operator[]( int i ) const {
+ return lhs[i] / rhs[i] ;
+ }
+
+ inline int size() const { return lhs.size() ; }
+
+ private:
+ const LHS_EXT& lhs ;
+ const RHS_EXT& rhs ;
+ } ;
template <int RTYPE, typename LHS_T, bool RHS_NA, typename RHS_T >
@@ -56,9 +81,11 @@
typedef typename Rcpp::VectorBase<RTYPE,false,LHS_T> LHS_TYPE ;
typedef typename Rcpp::VectorBase<RTYPE,RHS_NA,RHS_T> RHS_TYPE ;
typedef typename traits::storage_type<RTYPE>::type STORAGE ;
+ typedef typename Rcpp::traits::Extractor< RTYPE, false, LHS_T>::type LHS_EXT ;
+ typedef typename Rcpp::traits::Extractor< RTYPE, RHS_NA, RHS_T>::type RHS_EXT ;
Divides_Vector_Vector( const LHS_TYPE& lhs_, const RHS_TYPE& rhs_ ) :
- lhs(lhs_), rhs(rhs_) {}
+ lhs(lhs_.get_ref()), rhs(rhs_.get_ref()) {}
inline STORAGE operator[]( int i ) const {
STORAGE y = rhs[i] ;
@@ -69,44 +96,94 @@
inline int size() const { return lhs.size() ; }
private:
- const LHS_TYPE& lhs ;
- const RHS_TYPE& rhs ;
+ const LHS_EXT& lhs ;
+ const RHS_EXT& rhs ;
} ;
+ // RTYPE = REALSXP
+ template <typename LHS_T, bool RHS_NA, typename RHS_T >
+ class Divides_Vector_Vector<REALSXP,false,LHS_T,RHS_NA,RHS_T> :
+ public Rcpp::VectorBase<REALSXP,true, Divides_Vector_Vector<REALSXP,false,LHS_T,RHS_NA,RHS_T> > {
+ public:
+ typedef typename Rcpp::VectorBase<REALSXP,false,LHS_T> LHS_TYPE ;
+ typedef typename Rcpp::VectorBase<REALSXP,RHS_NA,RHS_T> RHS_TYPE ;
+ typedef typename Rcpp::traits::Extractor<REALSXP, false, LHS_T>::type LHS_EXT ;
+ typedef typename Rcpp::traits::Extractor<REALSXP, RHS_NA, RHS_T>::type RHS_EXT ;
+
+ Divides_Vector_Vector( const LHS_TYPE& lhs_, const RHS_TYPE& rhs_ ) :
+ lhs(lhs_.get_ref()), rhs(rhs_.get_ref()) {}
+
+ inline double operator[]( int i ) const {
+ return lhs[i] / rhs[i] ;
+ }
+
+ inline int size() const { return lhs.size() ; }
+
+ private:
+ const LHS_EXT& lhs ;
+ const RHS_EXT& rhs ;
+ } ;
template <int RTYPE, bool LHS_NA, typename LHS_T, typename RHS_T >
- class Divides_Vector_Vector<RTYPE,LHS_NA,LHS_T,false,RHS_T> : public Rcpp::VectorBase<RTYPE,true, Divides_Vector_Vector<RTYPE,LHS_NA,LHS_T,false,RHS_T> > {
+ class Divides_Vector_Vector<RTYPE,LHS_NA,LHS_T,false,RHS_T> :
+ public Rcpp::VectorBase<RTYPE,true, Divides_Vector_Vector<RTYPE,LHS_NA,LHS_T,false,RHS_T> > {
public:
typedef typename Rcpp::VectorBase<RTYPE,LHS_NA,LHS_T> LHS_TYPE ;
typedef typename Rcpp::VectorBase<RTYPE,false,RHS_T> RHS_TYPE ;
typedef typename traits::storage_type<RTYPE>::type STORAGE ;
+ typedef typename Rcpp::traits::Extractor< RTYPE, LHS_NA, LHS_T>::type LHS_EXT ;
+ typedef typename Rcpp::traits::Extractor< RTYPE, false, RHS_T>::type RHS_EXT ;
Divides_Vector_Vector( const LHS_TYPE& lhs_, const RHS_TYPE& rhs_ ) :
- lhs(lhs_), rhs(rhs_) {}
+ lhs(lhs_.get_ref()), rhs(rhs_.get_ref()) {}
inline STORAGE operator[]( int i ) const {
STORAGE x = lhs[i] ;
if( Rcpp::traits::is_na<RTYPE>( x ) ) return x ;
return x / rhs[i] ;
}
+ inline int size() const { return lhs.size() ; }
+ private:
+ const LHS_EXT& lhs ;
+ const RHS_EXT& rhs ;
+ } ;
+ // RTYPE = REALSXP
+ template <bool LHS_NA, typename LHS_T, typename RHS_T >
+ class Divides_Vector_Vector<REALSXP,LHS_NA,LHS_T,false,RHS_T> :
+ public Rcpp::VectorBase<REALSXP,true, Divides_Vector_Vector<REALSXP,LHS_NA,LHS_T,false,RHS_T> > {
+ public:
+ typedef typename Rcpp::VectorBase<REALSXP,LHS_NA,LHS_T> LHS_TYPE ;
+ typedef typename Rcpp::VectorBase<REALSXP,false,RHS_T> RHS_TYPE ;
+ typedef typename Rcpp::traits::Extractor<REALSXP, LHS_NA, LHS_T>::type LHS_EXT ;
+ typedef typename Rcpp::traits::Extractor<REALSXP, false, RHS_T>::type RHS_EXT ;
+
+ Divides_Vector_Vector( const LHS_TYPE& lhs_, const RHS_TYPE& rhs_ ) :
+ lhs(lhs_.get_ref()), rhs(rhs_.get_ref()) {}
+
+ inline double operator[]( int i ) const {
+ return lhs[i] / rhs[i] ;
+ }
inline int size() const { return lhs.size() ; }
private:
- const LHS_TYPE& lhs ;
- const RHS_TYPE& rhs ;
+ const LHS_EXT& lhs ;
+ const RHS_EXT& rhs ;
} ;
template <int RTYPE, typename LHS_T, typename RHS_T >
- class Divides_Vector_Vector<RTYPE,false,LHS_T,false,RHS_T> : public Rcpp::VectorBase<RTYPE,false, Divides_Vector_Vector<RTYPE,false,LHS_T,false,RHS_T> > {
+ class Divides_Vector_Vector<RTYPE,false,LHS_T,false,RHS_T> :
+ public Rcpp::VectorBase<RTYPE,false, Divides_Vector_Vector<RTYPE,false,LHS_T,false,RHS_T> > {
public:
typedef typename Rcpp::VectorBase<RTYPE,false,LHS_T> LHS_TYPE ;
typedef typename Rcpp::VectorBase<RTYPE,false,RHS_T> RHS_TYPE ;
typedef typename traits::storage_type<RTYPE>::type STORAGE ;
+ typedef typename Rcpp::traits::Extractor<RTYPE, false, LHS_T>::type LHS_EXT ;
+ typedef typename Rcpp::traits::Extractor<RTYPE, false, RHS_T>::type RHS_EXT ;
Divides_Vector_Vector( const LHS_TYPE& lhs_, const RHS_TYPE& rhs_ ) :
- lhs(lhs_), rhs(rhs_) {}
+ lhs(lhs_.get_ref()), rhs(rhs_.get_ref()) {}
inline STORAGE operator[]( int i ) const {
return lhs[i] / rhs[i] ;
@@ -115,158 +192,217 @@
inline int size() const { return lhs.size() ; }
private:
- const LHS_TYPE& lhs ;
- const RHS_TYPE& rhs ;
+ const LHS_EXT& lhs ;
+ const RHS_EXT& rhs ;
} ;
-
+ // RTYPE : REALSXP
+ template <typename LHS_T, typename RHS_T >
+ class Divides_Vector_Vector<REALSXP,false,LHS_T,false,RHS_T> :
+ public Rcpp::VectorBase<REALSXP,false, Divides_Vector_Vector<REALSXP,false,LHS_T,false,RHS_T> > {
+ public:
+ typedef typename Rcpp::VectorBase<REALSXP,false,LHS_T> LHS_TYPE ;
+ typedef typename Rcpp::VectorBase<REALSXP,false,RHS_T> RHS_TYPE ;
+ typedef typename Rcpp::traits::Extractor<REALSXP, false, LHS_T>::type LHS_EXT ;
+ typedef typename Rcpp::traits::Extractor<REALSXP, false, RHS_T>::type RHS_EXT ;
+
+ Divides_Vector_Vector( const LHS_TYPE& lhs_, const RHS_TYPE& rhs_ ) :
+ lhs(lhs_.get_ref()), rhs(rhs_.get_ref()) {}
+
+ inline double operator[]( int i ) const {
+ return lhs[i] / rhs[i] ;
+ }
+
+ inline int size() const { return lhs.size() ; }
+
+ private:
+ const LHS_EXT& lhs ;
+ const RHS_EXT& rhs ;
+ } ;
+
template <int RTYPE, bool NA, typename T>
- class Divides_Vector_Primitive : public Rcpp::VectorBase<RTYPE,true, Divides_Vector_Primitive<RTYPE,NA,T> > {
+ class Divides_Vector_Primitive :
+ public Rcpp::VectorBase<RTYPE,true, Divides_Vector_Primitive<RTYPE,NA,T> > {
public:
typedef typename traits::storage_type<RTYPE>::type STORAGE ;
typedef typename Rcpp::VectorBase<RTYPE,NA,T> VEC_TYPE ;
- typedef STORAGE (Divides_Vector_Primitive::*METHOD)(int) const ;
+ typedef typename Rcpp::traits::Extractor<RTYPE,NA,T>::type VEC_EXT ;
Divides_Vector_Primitive( const VEC_TYPE& lhs_, STORAGE rhs_ ) :
- lhs(lhs_), rhs(rhs_){
-
- m = Rcpp::traits::is_na<RTYPE>(rhs) ?
- &Divides_Vector_Primitive::rhs_is_na :
- &Divides_Vector_Primitive::rhs_is_not_na ;
-
+ lhs(lhs_.get_ref()), rhs(rhs_), rhs_na( Rcpp::traits::is_na<RTYPE>(rhs_) ) {
}
inline STORAGE operator[]( int i ) const {
- return (this->*m)(i) ;
+ if(rhs_na) return rhs ;
+ STORAGE x = lhs[i] ;
+ return Rcpp::traits::is_na<RTYPE>(x) ? x : (x / rhs) ;
}
inline int size() const { return lhs.size() ; }
private:
- const VEC_TYPE& lhs ;
+ const VEC_EXT& lhs ;
STORAGE rhs ;
- METHOD m ;
+ bool rhs_na ;
+ } ;
+ // RTYPE : REALSXP
+ template <bool NA, typename T>
+ class Divides_Vector_Primitive<REALSXP,NA,T> :
+ public Rcpp::VectorBase<REALSXP,true, Divides_Vector_Primitive<REALSXP,NA,T> > {
+ public:
+ typedef typename Rcpp::VectorBase<REALSXP,NA,T> VEC_TYPE ;
+ typedef typename Rcpp::traits::Extractor<REALSXP,NA,T>::type VEC_EXT ;
- inline STORAGE rhs_is_na(int i) const { return rhs ; }
- inline STORAGE rhs_is_not_na(int i) const {
- STORAGE x = lhs[i] ;
- return Rcpp::traits::is_na<RTYPE>(x) ? x : (x / rhs) ;
+ Divides_Vector_Primitive( const VEC_TYPE& lhs_, double rhs_ ) :
+ lhs(lhs_.get_ref()), rhs(rhs_) {
}
+ inline double operator[]( int i ) const {
+ return lhs[i] / rhs ;
+ }
+
+ inline int size() const { return lhs.size() ; }
+
+ private:
+ const VEC_EXT& lhs ;
+ double rhs ;
} ;
+
template <int RTYPE, typename T>
- class Divides_Vector_Primitive<RTYPE,false,T> : public Rcpp::VectorBase<RTYPE,true, Divides_Vector_Primitive<RTYPE,false,T> > {
+ class Divides_Vector_Primitive<RTYPE,false,T> :
+ public Rcpp::VectorBase<RTYPE,true, Divides_Vector_Primitive<RTYPE,false,T> > {
public:
typedef typename traits::storage_type<RTYPE>::type STORAGE ;
typedef typename Rcpp::VectorBase<RTYPE,false,T> VEC_TYPE ;
- typedef STORAGE (Divides_Vector_Primitive::*METHOD)(int) const ;
+ typedef typename Rcpp::traits::Extractor<RTYPE,false,T>::type VEC_EXT ;
Divides_Vector_Primitive( const VEC_TYPE& lhs_, STORAGE rhs_ ) :
- lhs(lhs_), rhs(rhs_){
-
- m = Rcpp::traits::is_na<RTYPE>(rhs) ?
- &Divides_Vector_Primitive::rhs_is_na :
- &Divides_Vector_Primitive::rhs_is_not_na ;
-
- }
+ lhs(lhs_.get_ref()), rhs(rhs_), rhs_na( Rcpp::traits::is_na<RTYPE>(rhs_) ) {}
inline STORAGE operator[]( int i ) const {
- return (this->*m)(i) ;
+ if( rhs_na ) return rhs ;
+ STORAGE x = lhs[i] ;
+ return Rcpp::traits::is_na<RTYPE>(x) ? x : (x / rhs) ;
}
-
inline int size() const { return lhs.size() ; }
private:
- const VEC_TYPE& lhs ;
+ const VEC_EXT& lhs ;
STORAGE rhs ;
- METHOD m ;
+ bool rhs_na ;
+ } ;
+ // RTYPE = REALSXP
+ template <typename T>
+ class Divides_Vector_Primitive<REALSXP,false,T> :
+ public Rcpp::VectorBase<REALSXP,true, Divides_Vector_Primitive<REALSXP,false,T> > {
+ public:
+ typedef typename Rcpp::VectorBase<REALSXP,false,T> VEC_TYPE ;
+ typedef typename Rcpp::traits::Extractor<REALSXP,false,T>::type VEC_EXT ;
- inline STORAGE rhs_is_na(int i) const { return rhs ; }
- inline STORAGE rhs_is_not_na(int i) const {
- STORAGE x = rhs[i] ;
- return Rcpp::traits::is_na<RTYPE>(x) ? x : (lhs / x) ;
+ Divides_Vector_Primitive( const VEC_TYPE& lhs_, double rhs_ ) :
+ lhs(lhs_), rhs(rhs_){}
+
+ inline double operator[]( int i ) const {
+ return lhs[i] / rhs ;
}
+ inline int size() const { return lhs.size() ; }
+ private:
+ const VEC_EXT& lhs ;
+ double rhs ;
} ;
-
-
-
template <int RTYPE, bool NA, typename T>
- class Divides_Primitive_Vector : public Rcpp::VectorBase<RTYPE,true, Divides_Primitive_Vector<RTYPE,NA,T> > {
+ class Divides_Primitive_Vector :
+ public Rcpp::VectorBase<RTYPE,true, Divides_Primitive_Vector<RTYPE,NA,T> > {
public:
typedef typename Rcpp::VectorBase<RTYPE,NA,T> VEC_TYPE ;
+ typedef typename Rcpp::traits::Extractor<RTYPE,NA,T>::type VEC_EXT ;
typedef typename traits::storage_type<RTYPE>::type STORAGE ;
- typedef STORAGE (Divides_Primitive_Vector::*METHOD)(int) const ;
Divides_Primitive_Vector( STORAGE lhs_, const VEC_TYPE& rhs_ ) :
- lhs(lhs_), rhs(rhs_) {
-
- m = Rcpp::traits::is_na<RTYPE>(lhs) ?
- &Divides_Primitive_Vector::lhs_is_na :
- &Divides_Primitive_Vector::lhs_is_not_na ;
-
- }
+ lhs(lhs_), rhs(rhs_.get_ref()), lhs_na( Rcpp::traits::is_na<RTYPE>(lhs_) ) {}
inline STORAGE operator[]( int i ) const {
- return (this->*m)(i) ;
+ if( lhs_na ) return lhs ;
+ STORAGE x = rhs[i] ;
+ return Rcpp::traits::is_na<RTYPE>(x) ? x : (lhs / x) ;
}
-
inline int size() const { return rhs.size() ; }
-
-
private:
STORAGE lhs ;
- const VEC_TYPE& rhs ;
- METHOD m ;
+ const VEC_EXT& rhs ;
+ bool lhs_na ;
+ } ;
+ // RTYPE = REALSXP
+ template <bool NA, typename T>
+ class Divides_Primitive_Vector<REALSXP,NA,T> :
+ public Rcpp::VectorBase<REALSXP,true, Divides_Primitive_Vector<REALSXP,NA,T> > {
+ public:
+ typedef typename Rcpp::VectorBase<REALSXP,NA,T> VEC_TYPE ;
+ typedef typename Rcpp::traits::Extractor<REALSXP,NA,T>::type VEC_EXT ;
- inline STORAGE lhs_is_na(int i) const { return lhs ; }
- inline STORAGE lhs_is_not_na(int i) const {
- return lhs / rhs[i] ;
+ Divides_Primitive_Vector( double lhs_, const VEC_TYPE& rhs_ ) :
+ lhs(lhs_), rhs(rhs_.get_ref()) {}
+
+ inline double operator[]( int i ) const {
+ return lhs / rhs[i] ;
}
-
+ inline int size() const { return rhs.size() ; }
+ private:
+ double lhs ;
+ const VEC_EXT& rhs ;
} ;
+
template <int RTYPE, typename T>
- class Divides_Primitive_Vector<RTYPE,false,T> : public Rcpp::VectorBase<RTYPE,true, Divides_Primitive_Vector<RTYPE,false,T> > {
+ class Divides_Primitive_Vector<RTYPE,false,T> :
+ public Rcpp::VectorBase<RTYPE,true, Divides_Primitive_Vector<RTYPE,false,T> > {
public:
typedef typename Rcpp::VectorBase<RTYPE,false,T> VEC_TYPE ;
typedef typename traits::storage_type<RTYPE>::type STORAGE ;
- typedef STORAGE (Divides_Primitive_Vector::*METHOD)(int) const ;
+ typedef typename Rcpp::traits::Extractor<RTYPE,false,T>::type VEC_EXT ;
Divides_Primitive_Vector( STORAGE lhs_, const VEC_TYPE& rhs_ ) :
- lhs(lhs_), rhs(rhs_) {
-
- m = Rcpp::traits::is_na<RTYPE>(rhs) ?
- &Divides_Primitive_Vector::lhs_is_na :
- &Divides_Primitive_Vector::lhs_is_not_na ;
+ lhs(lhs_), rhs(rhs_.get_ref()), lhs_na( Rcpp::traits::is_na<RTYPE>(lhs_) ) {}
- }
-
inline STORAGE operator[]( int i ) const {
- return (this->*m)(i) ;
+ if( lhs_na ) return lhs ;
+ return lhs / rhs[i] ;
}
-
inline int size() const { return rhs.size() ; }
-
private:
STORAGE lhs ;
- const VEC_TYPE& rhs ;
- METHOD m ;
+ const VEC_EXT& rhs ;
+ bool lhs_na ;
+ } ;
+ // RTYPE = REALSXP
+ template <typename T>
+ class Divides_Primitive_Vector<REALSXP,false,T> :
+ public Rcpp::VectorBase<REALSXP,true, Divides_Primitive_Vector<REALSXP,false,T> > {
+ public:
+ typedef typename Rcpp::VectorBase<REALSXP,false,T> VEC_TYPE ;
+ typedef typename Rcpp::traits::Extractor<REALSXP,false,T>::type VEC_EXT ;
- inline STORAGE lhs_is_na(int i) const { return lhs ; }
- inline STORAGE lhs_is_not_na(int i) const {
+ Divides_Primitive_Vector( double lhs_, const VEC_TYPE& rhs_ ) :
+ lhs(lhs_), rhs(rhs_.get_ref()) {}
+
+ inline double operator[]( int i ) const {
return lhs / rhs[i] ;
}
+ inline int size() const { return rhs.size() ; }
+ private:
+ double lhs ;
+ const VEC_EXT& rhs ;
} ;
Modified: pkg/Rcpp/inst/unitTests/runit.support.R
===================================================================
--- pkg/Rcpp/inst/unitTests/runit.support.R 2010-12-23 11:13:16 UTC (rev 2817)
+++ pkg/Rcpp/inst/unitTests/runit.support.R 2010-12-23 11:57:49 UTC (rev 2818)
@@ -18,26 +18,37 @@
# along with Rcpp. If not, see <http://www.gnu.org/licenses/>.
definitions <- function() {
- list("plus_REALSXP"=list(
- signature(),
- '
- return List::create(
- NA_REAL + NA_REAL,
- NA_REAL + 1.0,
- 1.0 + NA_REAL
- );
- '),
- "times_REALSXP" = list(
- signature(),
- '
- return List::create(
- NA_REAL * NA_REAL,
- NA_REAL * 1.0,
- 1.0 * NA_REAL
- );
-
- '
- )
+ list(
+ "plus_REALSXP"=list(
+ signature(),
+ '
+ return List::create(
+ NA_REAL + NA_REAL,
+ NA_REAL + 1.0,
+ 1.0 + NA_REAL
+ );
+ '),
+ "times_REALSXP" = list(
+ signature(),
+ '
+ return List::create(
+ NA_REAL * NA_REAL,
+ NA_REAL * 1.0,
+ 1.0 * NA_REAL
+ );
+
+ '),
+ "divides_REALSXP" = list(
+ signature(),
+ '
+ return List::create(
+ NA_REAL / NA_REAL,
+ NA_REAL / 1.0,
+ 1.0 / NA_REAL
+ );
+
+ '
+ )
)
}
.setUp <- function() {
@@ -64,3 +75,11 @@
msg = " REALSXP * REALSXP" )
}
+test.divides.REALSXP <- function(){
+ fun <- .rcpp.support$divides_REALSXP
+ checkEquals(
+ fun(),
+ list(NA_real_,NA_real_,NA_real_) ,
+ msg = " REALSXP / REALSXP" )
+}
+
More information about the Rcpp-commits
mailing list