[Rcpp-commits] r2203 - pkg/Rcpp/inst/include/Rcpp/sugar/operators
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sun Sep 26 21:45:20 CEST 2010
Author: romain
Date: 2010-09-26 21:45:20 +0200 (Sun, 26 Sep 2010)
New Revision: 2203
Modified:
pkg/Rcpp/inst/include/Rcpp/sugar/operators/minus.h
Log:
second pass at improving operator- (using the real type instead of the Base type) : better indexing
Modified: pkg/Rcpp/inst/include/Rcpp/sugar/operators/minus.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/sugar/operators/minus.h 2010-09-26 19:37:49 UTC (rev 2202)
+++ pkg/Rcpp/inst/include/Rcpp/sugar/operators/minus.h 2010-09-26 19:45:20 UTC (rev 2203)
@@ -33,7 +33,7 @@
typedef typename traits::storage_type<RTYPE>::type STORAGE ;
Minus_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,8 +45,8 @@
inline int size() const { return lhs.size() ; }
private:
- const LHS_TYPE& lhs ;
- const RHS_TYPE& rhs ;
+ const LHS_T& lhs ;
+ const RHS_T& rhs ;
} ;
@@ -58,7 +58,7 @@
typedef typename traits::storage_type<RTYPE>::type STORAGE ;
Minus_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,8 +69,8 @@
inline int size() const { return lhs.size() ; }
private:
- const LHS_TYPE& lhs ;
- const RHS_TYPE& rhs ;
+ const LHS_T& lhs ;
+ const RHS_T& rhs ;
} ;
@@ -82,7 +82,7 @@
typedef typename traits::storage_type<RTYPE>::type STORAGE ;
Minus_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] ;
@@ -93,8 +93,8 @@
inline int size() const { return lhs.size() ; }
private:
- const LHS_TYPE& lhs ;
- const RHS_TYPE& rhs ;
+ const LHS_T& lhs ;
+ const RHS_T& rhs ;
} ;
@@ -106,7 +106,7 @@
typedef typename traits::storage_type<RTYPE>::type STORAGE ;
Minus_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,13 +115,14 @@
inline int size() const { return lhs.size() ; }
private:
- const LHS_TYPE& lhs ;
- const RHS_TYPE& rhs ;
+ const LHS_T& lhs ;
+ const RHS_T& rhs ;
} ;
-
+
+
template <int RTYPE, bool NA, typename T>
class Minus_Vector_Primitive : public Rcpp::VectorBase<RTYPE,true, Minus_Vector_Primitive<RTYPE,NA,T> > {
public:
@@ -129,7 +130,7 @@
typedef typename Rcpp::VectorBase<RTYPE,NA,T> VEC_TYPE ;
Minus_Vector_Primitive( const VEC_TYPE& lhs_, STORAGE rhs_ ) :
- lhs(lhs_), rhs(rhs_), rhs_na( Rcpp::traits::is_na<RTYPE>(rhs_) ) {}
+ lhs(lhs_.get_ref()), rhs(rhs_), rhs_na( Rcpp::traits::is_na<RTYPE>(rhs_) ) {}
inline STORAGE operator[]( int i ) const {
if( rhs_na ) return rhs ;
@@ -140,7 +141,7 @@
inline int size() const { return lhs.size() ; }
private:
- const VEC_TYPE& lhs ;
+ const T& lhs ;
STORAGE rhs ;
bool rhs_na ;
@@ -154,7 +155,7 @@
typedef typename Rcpp::VectorBase<RTYPE,false,T> VEC_TYPE ;
Minus_Vector_Primitive( const VEC_TYPE& lhs_, STORAGE rhs_ ) :
- lhs(lhs_), rhs(rhs_), rhs_na( Rcpp::traits::is_na<RTYPE>(rhs_) ) {}
+ lhs(lhs_.get_ref()), rhs(rhs_), rhs_na( Rcpp::traits::is_na<RTYPE>(rhs_) ) {}
inline STORAGE operator[]( int i ) const {
if( rhs_na ) return rhs ;
@@ -165,7 +166,7 @@
inline int size() const { return lhs.size() ; }
private:
- const VEC_TYPE& lhs ;
+ const T& lhs ;
STORAGE rhs ;
bool rhs_na ;
@@ -181,10 +182,9 @@
public:
typedef typename Rcpp::VectorBase<RTYPE,NA,T> VEC_TYPE ;
typedef typename traits::storage_type<RTYPE>::type STORAGE ;
- typedef STORAGE (Minus_Primitive_Vector::*METHOD)(int) const ;
Minus_Primitive_Vector( STORAGE lhs_, const VEC_TYPE& rhs_ ) :
- lhs(lhs_), rhs(rhs_), lhs_na( Rcpp::traits::is_na<RTYPE>(lhs_) ) {}
+ lhs(lhs_), rhs(rhs_.get_ref()), lhs_na( Rcpp::traits::is_na<RTYPE>(lhs_) ) {}
inline STORAGE operator[]( int i ) const {
if( lhs_na ) return lhs ;
@@ -196,7 +196,7 @@
private:
STORAGE lhs ;
- const VEC_TYPE& rhs ;
+ const T& rhs ;
bool lhs_na ;
} ;
@@ -207,10 +207,9 @@
public:
typedef typename Rcpp::VectorBase<RTYPE,false,T> VEC_TYPE ;
typedef typename traits::storage_type<RTYPE>::type STORAGE ;
- typedef STORAGE (Minus_Primitive_Vector::*METHOD)(int) const ;
Minus_Primitive_Vector( STORAGE lhs_, const VEC_TYPE& rhs_ ) :
- lhs(lhs_), rhs(rhs_), lhs_na( Rcpp::traits::is_na<RTYPE>(lhs_) ) {}
+ lhs(lhs_), rhs(rhs_.get_ref()), lhs_na( Rcpp::traits::is_na<RTYPE>(lhs_) ) {}
inline STORAGE operator[]( int i ) const {
if( lhs_na ) return lhs ;
@@ -221,7 +220,7 @@
private:
STORAGE lhs ;
- const VEC_TYPE& rhs ;
+ const T& rhs ;
bool rhs_na ;
} ;
More information about the Rcpp-commits
mailing list