[Rcpp-commits] r1708 - in pkg/Rcpp/inst/include/Rcpp/sugar: . functions operators
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu Jun 24 12:07:19 CEST 2010
Author: romain
Date: 2010-06-24 12:07:19 +0200 (Thu, 24 Jun 2010)
New Revision: 1708
Modified:
pkg/Rcpp/inst/include/Rcpp/sugar/functions/all.h
pkg/Rcpp/inst/include/Rcpp/sugar/functions/any.h
pkg/Rcpp/inst/include/Rcpp/sugar/operators/Comparator.h
pkg/Rcpp/inst/include/Rcpp/sugar/operators/Comparator_With_One_Value.h
pkg/Rcpp/inst/include/Rcpp/sugar/operators/logical_operators__Vector__Vector.h
pkg/Rcpp/inst/include/Rcpp/sugar/operators/logical_operators__Vector__primitive.h
pkg/Rcpp/inst/include/Rcpp/sugar/operators/r_binary_op.h
pkg/Rcpp/inst/include/Rcpp/sugar/sugar.h
Log:
many internal changes (logical operators did not implement CRTP correctly)
Modified: pkg/Rcpp/inst/include/Rcpp/sugar/functions/all.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/sugar/functions/all.h 2010-06-24 08:46:12 UTC (rev 1707)
+++ pkg/Rcpp/inst/include/Rcpp/sugar/functions/all.h 2010-06-24 10:07:19 UTC (rev 1708)
@@ -25,20 +25,14 @@
namespace Rcpp{
namespace sugar{
-template <typename T>
-class All : public SingleLogicalResult< true, All<T> >{
+template <bool NA, typename T>
+class All : public SingleLogicalResult< true, All<NA,T> >{
public:
- typedef SingleLogicalResult< true, All<T> > PARENT ;
- All( const T& t ) : PARENT() , object(t) {}
+ typedef typename Rcpp::VectorBase<LGLSXP,NA,T> VEC_TYPE ;
+ typedef SingleLogicalResult< true, All<NA,T> > PARENT ;
+ All( const VEC_TYPE& t ) : PARENT() , object(t) {}
void apply(){
- apply__impl( typename can_have_na<T>::type() ) ;
- }
-private:
- const T& object ;
-
- // version that takes NA into account
- void apply__impl( Rcpp::traits::true_type ){
int n = object.size() ;
int current = 0 ;
PARENT::reset() ;
@@ -55,10 +49,21 @@
if( PARENT::is_unresolved() ){
PARENT::set_true() ;
}
- }
+ }
+private:
+ const VEC_TYPE& object ;
+
+} ;
+
+
+template <typename T>
+class All<false,T> : public SingleLogicalResult< false, All<false,T> >{
+public:
+ typedef typename Rcpp::VectorBase<LGLSXP,false,T> VEC_TYPE ;
+ typedef SingleLogicalResult< false, All<false,T> > PARENT ;
+ All( const VEC_TYPE& t ) : PARENT() , object(t) {}
- // version to use when we know there is no NA
- void apply__impl( Rcpp::traits::false_type ){
+ void apply(){
int n = object.size() ;
PARENT::set_true() ;
for( int i=0 ; i<n ; i++){
@@ -67,15 +72,17 @@
return ;
}
}
- }
-
+ }
+private:
+ const VEC_TYPE& object ;
} ;
+
} // sugar
-template <typename T>
-inline sugar::All<T> all( const T& t){
- return sugar::All<T>( t ) ;
+template <bool NA, typename T>
+inline sugar::All<NA,T> all( const Rcpp::VectorBase<LGLSXP,NA,T>& t){
+ return sugar::All<NA,T>( t ) ;
}
} // Rcpp
Modified: pkg/Rcpp/inst/include/Rcpp/sugar/functions/any.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/sugar/functions/any.h 2010-06-24 08:46:12 UTC (rev 1707)
+++ pkg/Rcpp/inst/include/Rcpp/sugar/functions/any.h 2010-06-24 10:07:19 UTC (rev 1708)
@@ -25,20 +25,14 @@
namespace Rcpp{
namespace sugar{
-template <typename T>
-class Any : public SingleLogicalResult< true, Any<T> >{
+template <bool NA, typename T>
+class Any : public SingleLogicalResult< true, Any<NA,T> >{
public:
- typedef SingleLogicalResult< true , Any<T> > PARENT ;
- Any( const T& t ) : PARENT() , object(t) {}
+ typedef Rcpp::VectorBase<LGLSXP,NA,T> VEC_TYPE ;
+ typedef SingleLogicalResult< true , Any<NA,T> > PARENT ;
+ Any( const VEC_TYPE& t ) : PARENT() , object(t) {}
void apply(){
- apply__impl( typename can_have_na<T>::type() ) ;
- }
-private:
- const T& object ;
-
- // version that takes NA into account
- void apply__impl( Rcpp::traits::true_type ){
int n = object.size() ;
int current = 0 ;
PARENT::reset() ;
@@ -55,10 +49,19 @@
if( PARENT::is_unresolved() ){
PARENT::set_false() ;
}
- }
+ }
+private:
+ const VEC_TYPE& object ;
+} ;
+
+template <typename T>
+class Any<false,T> : public SingleLogicalResult< false, Any<false,T> >{
+public:
+ typedef Rcpp::VectorBase<LGLSXP,false,T> VEC_TYPE ;
+ typedef SingleLogicalResult< false , Any<false,T> > PARENT ;
+ Any( const VEC_TYPE& t ) : PARENT() , object(t) {}
- // version to use when we know there is no NA
- void apply__impl( Rcpp::traits::false_type ){
+ void apply(){
int n = object.size() ;
PARENT::set_false() ;
for( int i=0 ; i<n ; i++){
@@ -67,17 +70,16 @@
return ;
}
}
- }
-
-
-private:
+ }
+private:
+ const VEC_TYPE& object ;
} ;
} // sugar
-template <typename T>
-inline sugar::Any<T> any( const T& t){
- return sugar::Any<T>( t ) ;
+template <bool NA, typename T>
+inline sugar::Any<NA,T> any( const Rcpp::VectorBase<LGLSXP,NA,T>& t){
+ return sugar::Any<NA,T>( t ) ;
}
} // Rcpp
Modified: pkg/Rcpp/inst/include/Rcpp/sugar/operators/Comparator.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/sugar/operators/Comparator.h 2010-06-24 08:46:12 UTC (rev 1707)
+++ pkg/Rcpp/inst/include/Rcpp/sugar/operators/Comparator.h 2010-06-24 10:07:19 UTC (rev 1708)
@@ -25,28 +25,91 @@
namespace Rcpp{
namespace sugar{
-template <int RTYPE, typename Operator, typename LHS_TYPE, typename RHS_TYPE>
-class Comparator : public ::Rcpp::VectorBase< LGLSXP, true, Comparator<RTYPE,Operator,LHS_TYPE,RHS_TYPE> > {
+template <int RTYPE, typename Operator, bool LHS_NA, typename LHS_T, bool RHS_NA, typename RHS_T>
+class Comparator :
+ public ::Rcpp::VectorBase< LGLSXP, true, Comparator<RTYPE,Operator,LHS_NA,LHS_T,RHS_NA,RHS_T> > {
+
public:
+ 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 r_binary_op<RTYPE,Operator> R_OPERATOR ;
Comparator( const LHS_TYPE& lhs_, const RHS_TYPE& rhs_) :
- op(), lhs(lhs_), rhs(rhs_){}
+ lhs(lhs_), rhs(rhs_), op() {}
inline int operator[]( int i ) const {
- return op.compare( lhs[i], rhs[i] ) ;
+ STORAGE x = lhs[i] ;
+ if( Rcpp::traits::is_na<RTYPE>( x ) ) return NA_LOGICAL ;
+ STORAGE y = rhs[i] ;
+ if( Rcpp::traits::is_na<RTYPE>( y ) ) return NA_LOGICAL ;
+ return op( x, y ) ;
}
inline int size() const { return lhs.size() ; }
private:
- R_OPERATOR op ;
const LHS_TYPE& lhs ;
const RHS_TYPE& rhs ;
+ Operator op ;
} ;
+
+
+template <int RTYPE, typename Operator, typename LHS_T, bool RHS_NA, typename RHS_T>
+class Comparator<RTYPE,Operator,false,LHS_T,RHS_NA,RHS_T> :
+ public ::Rcpp::VectorBase< LGLSXP, true, Comparator<RTYPE,Operator,false,LHS_T,RHS_NA,RHS_T> > {
+
+public:
+ 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 ;
+
+ Comparator( const LHS_TYPE& lhs_, const RHS_TYPE& rhs_) :
+ lhs(lhs_), rhs(rhs_), op() {}
+
+ inline int operator[]( int i ) const {
+ STORAGE y = rhs[i] ;
+ if( Rcpp::traits::is_na<RTYPE>( y ) ) return NA_LOGICAL ;
+ return op( lhs[i], y ) ;
+ }
+
+ inline int size() const { return lhs.size() ; }
+
+private:
+ const LHS_TYPE& lhs ;
+ const RHS_TYPE& rhs ;
+ Operator op ;
+
+} ;
+
+
+template <int RTYPE, typename Operator, typename LHS_T, typename RHS_T>
+class Comparator<RTYPE,Operator,false,LHS_T,false,RHS_T> :
+ public ::Rcpp::VectorBase< LGLSXP, true, Comparator<RTYPE,Operator,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 ;
+
+ Comparator( const LHS_TYPE& lhs_, const RHS_TYPE& rhs_) :
+ lhs(lhs_), rhs(rhs_), op() {}
+
+ inline int operator[]( int i ) const {
+ return op( lhs[i], rhs[i] ) ;
+ }
+
+ inline int size() const { return lhs.size() ; }
+
+private:
+ const LHS_TYPE& lhs ;
+ const RHS_TYPE& rhs ;
+ Operator op ;
+
+} ;
+
+
}
}
Modified: pkg/Rcpp/inst/include/Rcpp/sugar/operators/Comparator_With_One_Value.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/sugar/operators/Comparator_With_One_Value.h 2010-06-24 08:46:12 UTC (rev 1707)
+++ pkg/Rcpp/inst/include/Rcpp/sugar/operators/Comparator_With_One_Value.h 2010-06-24 10:07:19 UTC (rev 1708)
@@ -25,27 +25,81 @@
namespace Rcpp{
namespace sugar{
-template <int RTYPE, typename Operator, bool na, typename VEC_TYPE>
-class Comparator_With_One_Value : public ::Rcpp::VectorBase< RTYPE, true, Comparator_With_One_Value<RTYPE,Operator,na,VEC_TYPE> > {
+template <int RTYPE, typename Operator, bool NA, typename T>
+class Comparator_With_One_Value : public ::Rcpp::VectorBase< LGLSXP, true, Comparator_With_One_Value<RTYPE,Operator,NA,T> > {
public:
+ typedef typename Rcpp::VectorBase<RTYPE,NA,T> VEC_TYPE ;
typedef typename traits::storage_type<RTYPE>::type STORAGE ;
- typedef r_binary_op<RTYPE,Operator> R_OPERATOR ;
+ typedef int (Comparator_With_One_Value::*METHOD)(int) const ;
Comparator_With_One_Value( const VEC_TYPE& lhs_, STORAGE rhs_ ) :
- op(), lhs(lhs_), rhs(rhs_){}
+ lhs(lhs_), rhs(rhs_), m(), op() {
+
+ m = Rcpp::traits::is_na<RTYPE>(rhs) ?
+ &Comparator_With_One_Value::rhs_is_na :
+ &Comparator_With_One_Value::rhs_is_not_na ;
+
+ }
inline int operator[]( int i ) const {
- return op.compare( lhs[i], rhs ) ;
+ return (this->*m)(i) ;
}
inline int size() const { return lhs.size() ; }
private:
- R_OPERATOR op ;
const VEC_TYPE& lhs ;
STORAGE rhs ;
+ METHOD m ;
+ Operator op ;
+
+ inline int rhs_is_na(int i) const { return rhs ; }
+ inline int rhs_is_not_na(int i) const {
+ STORAGE x = lhs[i] ;
+ return Rcpp::traits::is_na<RTYPE>(x) ? x : op( x, rhs ) ;
+ }
+
} ;
+
+template <int RTYPE, typename Operator, typename T>
+class Comparator_With_One_Value<RTYPE,Operator,false,T> :
+ public ::Rcpp::VectorBase< RTYPE, true, Comparator_With_One_Value<LGLSXP,Operator,false,T> > {
+
+public:
+ typedef typename Rcpp::VectorBase<RTYPE,false,T> VEC_TYPE ;
+ typedef typename traits::storage_type<RTYPE>::type STORAGE ;
+ typedef int (Comparator_With_One_Value::*METHOD)(int) const ;
+
+ Comparator_With_One_Value( const VEC_TYPE& lhs_, STORAGE rhs_ ) :
+ lhs(lhs_), rhs(rhs_), m(), op() {
+
+ m = Rcpp::traits::is_na<RTYPE>(rhs) ?
+ &Comparator_With_One_Value::rhs_is_na :
+ &Comparator_With_One_Value::rhs_is_not_na ;
+
+ }
+
+ inline int operator[]( int i ) const {
+ return (this->*m)(i) ;
+ }
+
+ inline int size() const { return lhs.size() ; }
+
+private:
+ const VEC_TYPE& lhs ;
+ STORAGE rhs ;
+ METHOD m ;
+ Operator op ;
+
+ inline int rhs_is_na(int i) const { return rhs ; }
+ inline int rhs_is_not_na(int i) const {
+ return op( lhs[i], rhs ) ;
+ }
+
+} ;
+
+
} // sugar
} // Rcpp
Modified: pkg/Rcpp/inst/include/Rcpp/sugar/operators/logical_operators__Vector__Vector.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/sugar/operators/logical_operators__Vector__Vector.h 2010-06-24 08:46:12 UTC (rev 1707)
+++ pkg/Rcpp/inst/include/Rcpp/sugar/operators/logical_operators__Vector__Vector.h 2010-06-24 10:07:19 UTC (rev 1708)
@@ -28,8 +28,8 @@
inline Rcpp::sugar::Comparator<
RTYPE ,
Rcpp::sugar::less<RTYPE>,
- Rcpp::VectorBase<RTYPE,LHS_NA,LHS_T>,
- Rcpp::VectorBase<RTYPE,RHS_NA,RHS_T>
+ LHS_NA, LHS_T,
+ RHS_NA, RHS_T
>
operator<(
const Rcpp::VectorBase<RTYPE,LHS_NA,LHS_T>& lhs ,
@@ -38,8 +38,8 @@
return Rcpp::sugar::Comparator<
RTYPE,
Rcpp::sugar::less<RTYPE>,
- Rcpp::VectorBase<RTYPE,LHS_NA,LHS_T>,
- Rcpp::VectorBase<RTYPE,RHS_NA,RHS_T>
+ LHS_NA, LHS_T,
+ RHS_NA, RHS_T
>(
lhs, rhs
) ;
@@ -49,8 +49,8 @@
inline Rcpp::sugar::Comparator<
RTYPE ,
Rcpp::sugar::greater<RTYPE>,
- Rcpp::VectorBase<RTYPE,LHS_NA,LHS_T>,
- Rcpp::VectorBase<RTYPE,RHS_NA,RHS_T>
+ LHS_NA, LHS_T,
+ RHS_NA, RHS_T
>
operator>(
const Rcpp::VectorBase<RTYPE,LHS_NA,LHS_T>& lhs ,
@@ -59,8 +59,8 @@
return Rcpp::sugar::Comparator<
RTYPE,
Rcpp::sugar::greater<RTYPE>,
- Rcpp::VectorBase<RTYPE,LHS_NA,LHS_T>,
- Rcpp::VectorBase<RTYPE,RHS_NA,RHS_T>
+ LHS_NA, LHS_T,
+ RHS_NA, RHS_T
>(
lhs, rhs
) ;
@@ -70,8 +70,8 @@
inline Rcpp::sugar::Comparator<
RTYPE ,
Rcpp::sugar::less_or_equal<RTYPE>,
- Rcpp::VectorBase<RTYPE,LHS_NA,LHS_T>,
- Rcpp::VectorBase<RTYPE,RHS_NA,RHS_T>
+ LHS_NA, LHS_T,
+ RHS_NA, RHS_T
>
operator<=(
const Rcpp::VectorBase<RTYPE,LHS_NA,LHS_T>& lhs ,
@@ -80,8 +80,8 @@
return Rcpp::sugar::Comparator<
RTYPE,
Rcpp::sugar::less_or_equal<RTYPE>,
- Rcpp::VectorBase<RTYPE,LHS_NA,LHS_T>,
- Rcpp::VectorBase<RTYPE,RHS_NA,RHS_T>
+ LHS_NA, LHS_T,
+ RHS_NA, RHS_T
>(
lhs, rhs
) ;
@@ -91,8 +91,8 @@
inline Rcpp::sugar::Comparator<
RTYPE ,
Rcpp::sugar::greater_or_equal<RTYPE>,
- Rcpp::VectorBase<RTYPE,LHS_NA,LHS_T>,
- Rcpp::VectorBase<RTYPE,RHS_NA,RHS_T>
+ LHS_NA, LHS_T,
+ RHS_NA, RHS_T
>
operator>=(
const Rcpp::VectorBase<RTYPE,LHS_NA,LHS_T>& lhs ,
@@ -101,8 +101,8 @@
return Rcpp::sugar::Comparator<
RTYPE,
Rcpp::sugar::greater_or_equal<RTYPE>,
- Rcpp::VectorBase<RTYPE,LHS_NA,LHS_T>,
- Rcpp::VectorBase<RTYPE,RHS_NA,RHS_T>
+ LHS_NA, LHS_T,
+ RHS_NA, RHS_T
>(
lhs, rhs
) ;
@@ -112,8 +112,8 @@
inline Rcpp::sugar::Comparator<
RTYPE ,
Rcpp::sugar::equal<RTYPE>,
- Rcpp::VectorBase<RTYPE,LHS_NA,LHS_T>,
- Rcpp::VectorBase<RTYPE,RHS_NA,RHS_T>
+ LHS_NA, LHS_T,
+ RHS_NA, RHS_T
>
operator==(
const Rcpp::VectorBase<RTYPE,LHS_NA,LHS_T>& lhs ,
@@ -122,8 +122,8 @@
return Rcpp::sugar::Comparator<
RTYPE,
Rcpp::sugar::equal<RTYPE>,
- Rcpp::VectorBase<RTYPE,LHS_NA,LHS_T>,
- Rcpp::VectorBase<RTYPE,RHS_NA,RHS_T>
+ LHS_NA, LHS_T,
+ RHS_NA, RHS_T
>(
lhs, rhs
) ;
@@ -133,8 +133,8 @@
inline Rcpp::sugar::Comparator<
RTYPE ,
Rcpp::sugar::not_equal<RTYPE>,
- Rcpp::VectorBase<RTYPE,LHS_NA,LHS_T>,
- Rcpp::VectorBase<RTYPE,RHS_NA,RHS_T>
+ LHS_NA, LHS_T,
+ RHS_NA, RHS_T
>
operator!=(
const Rcpp::VectorBase<RTYPE,LHS_NA,LHS_T>& lhs ,
@@ -143,8 +143,8 @@
return Rcpp::sugar::Comparator<
RTYPE,
Rcpp::sugar::not_equal<RTYPE>,
- Rcpp::VectorBase<RTYPE,LHS_NA,LHS_T>,
- Rcpp::VectorBase<RTYPE,RHS_NA,RHS_T>
+ LHS_NA, LHS_T,
+ RHS_NA, RHS_T
>(
lhs, rhs
) ;
Modified: pkg/Rcpp/inst/include/Rcpp/sugar/operators/logical_operators__Vector__primitive.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/sugar/operators/logical_operators__Vector__primitive.h 2010-06-24 08:46:12 UTC (rev 1707)
+++ pkg/Rcpp/inst/include/Rcpp/sugar/operators/logical_operators__Vector__primitive.h 2010-06-24 10:07:19 UTC (rev 1708)
@@ -24,42 +24,42 @@
#define Rcpp__sugar__logical_operators__Vector__primitive_h
/* Vector < primitive */
-template <int RTYPE, bool na, typename VEC_TYPE>
+template <int RTYPE, bool NA, typename T>
inline Rcpp::sugar::Comparator_With_One_Value<
RTYPE ,
Rcpp::sugar::less<RTYPE>,
- na,
- Rcpp::VectorBase<RTYPE,na,VEC_TYPE>
+ NA,
+ T
>
operator<(
- const Rcpp::VectorBase<RTYPE,na,VEC_TYPE>& lhs ,
+ const Rcpp::VectorBase<RTYPE,NA,T>& lhs ,
typename Rcpp::traits::storage_type<RTYPE>::type rhs
){
return Rcpp::sugar::Comparator_With_One_Value<
RTYPE,
Rcpp::sugar::less<RTYPE>,
- na,
- Rcpp::VectorBase<RTYPE,na,VEC_TYPE>
+ NA,
+ T
>(
lhs, rhs
) ;
}
-template <int RTYPE, bool na, typename VEC_TYPE>
+template <int RTYPE, bool NA, typename T>
inline Rcpp::sugar::Comparator_With_One_Value<
RTYPE ,
Rcpp::sugar::less<RTYPE>,
- na,
- Rcpp::VectorBase<RTYPE,na,VEC_TYPE>
+ NA,
+ T
>
operator>(
typename Rcpp::traits::storage_type<RTYPE>::type rhs,
- const Rcpp::VectorBase<RTYPE,na,VEC_TYPE>& lhs
+ const Rcpp::VectorBase<RTYPE,NA,T>& lhs
){
return Rcpp::sugar::Comparator_With_One_Value<
RTYPE,
Rcpp::sugar::less<RTYPE>,
- na,
- Rcpp::VectorBase<RTYPE,na,VEC_TYPE>
+ NA,
+ T
>(
lhs, rhs
) ;
@@ -68,42 +68,42 @@
/* Vector > primitive */
-template <int RTYPE, bool na, typename VEC_TYPE>
+template <int RTYPE, bool NA, typename T>
inline Rcpp::sugar::Comparator_With_One_Value<
RTYPE ,
Rcpp::sugar::greater<RTYPE>,
- na,
- Rcpp::VectorBase<RTYPE,na,VEC_TYPE>
+ NA,
+ T
>
operator>(
- const Rcpp::VectorBase<RTYPE,na,VEC_TYPE>& lhs ,
+ const Rcpp::VectorBase<RTYPE,NA,T>& lhs ,
typename Rcpp::traits::storage_type<RTYPE>::type rhs
){
return Rcpp::sugar::Comparator_With_One_Value<
RTYPE,
Rcpp::sugar::greater<RTYPE>,
- na,
- Rcpp::VectorBase<RTYPE,na,VEC_TYPE>
+ NA,
+ T
>(
lhs, rhs
) ;
}
-template <int RTYPE, bool na, typename VEC_TYPE>
+template <int RTYPE, bool NA, typename T>
inline Rcpp::sugar::Comparator_With_One_Value<
RTYPE ,
Rcpp::sugar::greater<RTYPE>,
- na,
- Rcpp::VectorBase<RTYPE,na,VEC_TYPE>
+ NA,
+ T
>
operator<(
typename Rcpp::traits::storage_type<RTYPE>::type rhs,
- const Rcpp::VectorBase<RTYPE,na,VEC_TYPE>& lhs
+ const Rcpp::VectorBase<RTYPE,NA,T>& lhs
){
return Rcpp::sugar::Comparator_With_One_Value<
RTYPE,
Rcpp::sugar::greater<RTYPE>,
- na,
- Rcpp::VectorBase<RTYPE,na,VEC_TYPE>
+ NA,
+ T
>(
lhs, rhs
) ;
@@ -112,42 +112,42 @@
/* Vector <= primitive */
-template <int RTYPE, bool na, typename VEC_TYPE>
+template <int RTYPE, bool NA, typename T>
inline Rcpp::sugar::Comparator_With_One_Value<
RTYPE ,
Rcpp::sugar::less_or_equal<RTYPE>,
- na,
- Rcpp::VectorBase<RTYPE,na,VEC_TYPE>
+ NA,
+ T
>
operator<=(
- const Rcpp::VectorBase<RTYPE,na,VEC_TYPE>& lhs ,
+ const Rcpp::VectorBase<RTYPE,NA,T>& lhs ,
typename Rcpp::traits::storage_type<RTYPE>::type rhs
){
return Rcpp::sugar::Comparator_With_One_Value<
RTYPE,
Rcpp::sugar::less_or_equal<RTYPE>,
- na,
- Rcpp::VectorBase<RTYPE,na,VEC_TYPE>
+ NA,
+ T
>(
lhs, rhs
) ;
}
-template <int RTYPE, bool na, typename VEC_TYPE>
+template <int RTYPE, bool NA, typename T>
inline Rcpp::sugar::Comparator_With_One_Value<
RTYPE ,
Rcpp::sugar::less_or_equal<RTYPE>,
- na,
- Rcpp::VectorBase<RTYPE,na,VEC_TYPE>
+ NA,
+ T
>
operator>=(
typename Rcpp::traits::storage_type<RTYPE>::type rhs,
- const Rcpp::VectorBase<RTYPE,na,VEC_TYPE>& lhs
+ const Rcpp::VectorBase<RTYPE,NA,T>& lhs
){
return Rcpp::sugar::Comparator_With_One_Value<
RTYPE,
Rcpp::sugar::less_or_equal<RTYPE>,
- na,
- Rcpp::VectorBase<RTYPE,na,VEC_TYPE>
+ NA,
+ T
>(
lhs, rhs
) ;
@@ -157,42 +157,42 @@
/* Vector >= primitive */
-template <int RTYPE, bool na, typename VEC_TYPE>
+template <int RTYPE, bool NA, typename T>
inline Rcpp::sugar::Comparator_With_One_Value<
RTYPE ,
Rcpp::sugar::greater_or_equal<RTYPE>,
- na,
- Rcpp::VectorBase<RTYPE,na,VEC_TYPE>
+ NA,
+ T
>
operator>=(
- const Rcpp::VectorBase<RTYPE,na,VEC_TYPE>& lhs ,
+ const Rcpp::VectorBase<RTYPE,NA,T>& lhs ,
typename Rcpp::traits::storage_type<RTYPE>::type rhs
){
return Rcpp::sugar::Comparator_With_One_Value<
RTYPE,
Rcpp::sugar::greater_or_equal<RTYPE>,
- na,
- Rcpp::VectorBase<RTYPE,na,VEC_TYPE>
+ NA,
+ T
>(
lhs, rhs
) ;
}
-template <int RTYPE, bool na, typename VEC_TYPE>
+template <int RTYPE, bool NA, typename T>
inline Rcpp::sugar::Comparator_With_One_Value<
RTYPE ,
Rcpp::sugar::greater_or_equal<RTYPE>,
- na,
- Rcpp::VectorBase<RTYPE,na,VEC_TYPE>
+ NA,
+ T
>
operator<=(
typename Rcpp::traits::storage_type<RTYPE>::type rhs,
- const Rcpp::VectorBase<RTYPE,na,VEC_TYPE>& lhs
+ const Rcpp::VectorBase<RTYPE,NA,T>& lhs
){
return Rcpp::sugar::Comparator_With_One_Value<
RTYPE,
Rcpp::sugar::greater_or_equal<RTYPE>,
- na,
- Rcpp::VectorBase<RTYPE,na,VEC_TYPE>
+ NA,
+ T
>(
lhs, rhs
) ;
@@ -201,42 +201,42 @@
/* Vector == primitive */
-template <int RTYPE, bool na, typename VEC_TYPE>
+template <int RTYPE, bool NA, typename T>
inline Rcpp::sugar::Comparator_With_One_Value<
RTYPE ,
Rcpp::sugar::equal<RTYPE>,
- na,
- Rcpp::VectorBase<RTYPE,na,VEC_TYPE>
+ NA,
+ T
>
operator==(
- const Rcpp::VectorBase<RTYPE,na,VEC_TYPE>& lhs ,
+ const Rcpp::VectorBase<RTYPE,NA,T>& lhs ,
typename Rcpp::traits::storage_type<RTYPE>::type rhs
){
return Rcpp::sugar::Comparator_With_One_Value<
RTYPE,
Rcpp::sugar::equal<RTYPE>,
- na,
- Rcpp::VectorBase<RTYPE,na,VEC_TYPE>
+ NA,
+ T
>(
lhs, rhs
) ;
}
-template <int RTYPE, bool na, typename VEC_TYPE>
+template <int RTYPE, bool NA, typename T>
inline Rcpp::sugar::Comparator_With_One_Value<
RTYPE ,
Rcpp::sugar::equal<RTYPE>,
- na,
- Rcpp::VectorBase<RTYPE,na,VEC_TYPE>
+ NA,
+ T
>
operator==(
typename Rcpp::traits::storage_type<RTYPE>::type rhs,
- const Rcpp::VectorBase<RTYPE,na,VEC_TYPE>& lhs
+ const Rcpp::VectorBase<RTYPE,NA,T>& lhs
){
return Rcpp::sugar::Comparator_With_One_Value<
RTYPE,
Rcpp::sugar::equal<RTYPE>,
- na,
- Rcpp::VectorBase<RTYPE,na,VEC_TYPE>
+ NA,
+ T
>(
lhs, rhs
) ;
@@ -245,42 +245,42 @@
/* Vector != primitive */
-template <int RTYPE, bool na, typename VEC_TYPE>
+template <int RTYPE, bool NA, typename T>
inline Rcpp::sugar::Comparator_With_One_Value<
RTYPE ,
Rcpp::sugar::not_equal<RTYPE>,
- na,
- Rcpp::VectorBase<RTYPE,na,VEC_TYPE>
+ NA,
+ T
>
operator!=(
- const Rcpp::VectorBase<RTYPE,na,VEC_TYPE>& lhs ,
+ const Rcpp::VectorBase<RTYPE,NA,T>& lhs ,
typename Rcpp::traits::storage_type<RTYPE>::type rhs
){
return Rcpp::sugar::Comparator_With_One_Value<
RTYPE,
Rcpp::sugar::not_equal<RTYPE>,
- na,
- Rcpp::VectorBase<RTYPE,na,VEC_TYPE>
+ NA,
+ T
>(
lhs, rhs
) ;
}
-template <int RTYPE, bool na, typename VEC_TYPE>
+template <int RTYPE, bool NA, typename T>
inline Rcpp::sugar::Comparator_With_One_Value<
RTYPE ,
Rcpp::sugar::not_equal<RTYPE>,
- na,
- Rcpp::VectorBase<RTYPE,na,VEC_TYPE>
+ NA,
+ T
>
operator!=(
typename Rcpp::traits::storage_type<RTYPE>::type rhs,
- const Rcpp::VectorBase<RTYPE,na,VEC_TYPE>& lhs
+ const Rcpp::VectorBase<RTYPE,NA,T>& lhs
){
return Rcpp::sugar::Comparator_With_One_Value<
RTYPE,
Rcpp::sugar::not_equal<RTYPE>,
- na,
- Rcpp::VectorBase<RTYPE,na,VEC_TYPE>
+ NA,
+ T
>(
lhs, rhs
) ;
Modified: pkg/Rcpp/inst/include/Rcpp/sugar/operators/r_binary_op.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/sugar/operators/r_binary_op.h 2010-06-24 08:46:12 UTC (rev 1707)
+++ pkg/Rcpp/inst/include/Rcpp/sugar/operators/r_binary_op.h 2010-06-24 10:07:19 UTC (rev 1708)
@@ -31,7 +31,7 @@
class NAME { \
public: \
typedef typename traits::storage_type<RTYPE>::type STORAGE ; \
- inline bool compare_one( STORAGE lhs, STORAGE rhs) const { \
+ inline int operator()( STORAGE lhs, STORAGE rhs) const { \
return lhs OP rhs ; \
} \
} ;
@@ -43,20 +43,6 @@
RCPP_OP(not_equal,!=)
#undef RCPP_OP
-
-template <int RTYPE, typename T>
-class r_binary_op : public T {
-public:
- typedef typename traits::storage_type<RTYPE>::type STORAGE ;
-
- r_binary_op(){}
-
- inline int compare( STORAGE lhs, STORAGE rhs) const {
- return ( traits::is_na<RTYPE>(lhs) || traits::is_na<RTYPE>(rhs) ) ?
- NA_LOGICAL : static_cast<int>( compare_one( lhs, rhs ) ) ;
- }
-
-} ;
} // sugar
} // Rcpp
Modified: pkg/Rcpp/inst/include/Rcpp/sugar/sugar.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/sugar/sugar.h 2010-06-24 08:46:12 UTC (rev 1707)
+++ pkg/Rcpp/inst/include/Rcpp/sugar/sugar.h 2010-06-24 10:07:19 UTC (rev 1708)
@@ -22,7 +22,7 @@
#ifndef RCPP_SUGAR_H
#define RCPP_SUGAR_H
+#include <Rcpp/sugar/operators/operators.h>
#include <Rcpp/sugar/functions/functions.h>
-#include <Rcpp/sugar/operators/operators.h>
#endif
More information about the Rcpp-commits
mailing list