22 #ifndef RCPP_SUGAR_BLOCK_2_H
23 #define RCPP_SUGAR_BLOCK_2_H
28 template <
bool NA,
typename RESULT_TYPE,
typename U1,
typename T1,
typename U2,
typename T2>
29 class SugarBlock_2 :
public Rcpp::VectorBase< Rcpp::traits::r_sexptype_traits<RESULT_TYPE>::rtype , NA, SugarBlock_2<NA,RESULT_TYPE,U1,T1,U2,T2> > {
31 typedef RESULT_TYPE (*
FunPtr)(U1,U2) ;
33 ptr(ptr_),
x(x_),
y(y_){
38 return ptr(
x[i],
y[i] ) ;
40 inline R_xlen_t
size()
const {
return x.size() ; }
49 template <
bool NA,
typename RESULT_TYPE,
typename U1,
typename T1,
typename U2>
52 typedef RESULT_TYPE (*
FunPtr)(U1,U2) ;
54 ptr(ptr_),
x(x_),
y(u2){}
57 return ptr(
x[i],
y ) ;
59 inline R_xlen_t
size()
const {
return x.size() ; }
67 template <
bool NA,
typename RESULT_TYPE,
typename U1,
typename U2,
typename T2>
70 typedef RESULT_TYPE (*
FunPtr)(U1,U2) ;
72 ptr(ptr_),
x(u1),
y(y_){}
75 return ptr(
x,
y[i] ) ;
77 inline R_xlen_t
size()
const {
return y.size() ; }
89 #define SB2_LHT VectorBase<REALSXP,LHS_NA,LHS_T>
90 #define SB2_RHT VectorBase<REALSXP,RHS_NA,RHS_T>
92 #define SUGAR_BLOCK_2(__NAME__,__SYMBOL__) \
94 template <bool LHS_NA, typename LHS_T, bool RHS_NA, typename RHS_T > \
95 inline sugar::SugarBlock_2< (LHS_NA||RHS_NA) ,double,double,SB2_LHT,double,SB2_RHT> \
100 return sugar::SugarBlock_2< (LHS_NA||RHS_NA) ,double,double,SB2_LHT,double,SB2_RHT >(\
101 __SYMBOL__ , lhs, rhs \
104 template <bool LHS_NA, typename LHS_T> \
105 inline sugar::SugarBlock_2__VP<LHS_NA,double,double,SB2_LHT,double> \
107 const SB2_LHT& lhs, \
110 return sugar::SugarBlock_2__VP<LHS_NA,double,double,SB2_LHT,double>( \
111 __SYMBOL__ , lhs, rhs \
114 template <bool RHS_NA, typename RHS_T> \
115 inline sugar::SugarBlock_2__PV<RHS_NA,double,double,double,SB2_RHT> \
120 return sugar::SugarBlock_2__PV<RHS_NA,double,double,double,SB2_RHT >( \
121 __SYMBOL__ , lhs, rhs \
127 #define SUGAR_BLOCK_2_NA(__NAME__,__SYMBOL__,__NA__) \
129 template <bool LHS_NA, typename LHS_T, bool RHS_NA, typename RHS_T > \
130 inline sugar::SugarBlock_2< __NA__ ,double,double,SB2_LHT,double,SB2_RHT> \
132 const SB2_LHT& lhs, \
135 return sugar::SugarBlock_2< __NA__ ,double,double,SB2_LHT,double,SB2_RHT \
137 __SYMBOL__ , lhs, rhs \
140 template <bool LHS_NA, typename LHS_T> \
141 inline sugar::SugarBlock_2__VP<__NA__,double,double,SB2_LHT,double> \
143 const SB2_LHT& lhs, \
146 return sugar::SugarBlock_2__VP<__NA__,double,double,SB2_LHT,double>( \
147 __SYMBOL__ , lhs, rhs \
150 template <bool RHS_NA, typename RHS_T> \
151 inline sugar::SugarBlock_2__PV<__NA__,double,double,double,SB2_RHT> \
156 return sugar::SugarBlock_2__PV<__NA__,double,double,double,SB2_RHT \
158 __SYMBOL__ , lhs, rhs \
RESULT_TYPE operator[](R_xlen_t i) const
RESULT_TYPE(* FunPtr)(U1, U2)
SugarBlock_2__PV(FunPtr ptr_, U1 u1, const T2 &y_)
RESULT_TYPE(* FunPtr)(U1, U2)
SugarBlock_2__VP(FunPtr ptr_, const T1 &x_, U2 u2)
RESULT_TYPE operator[](R_xlen_t i) const
SugarBlock_2(FunPtr ptr_, const T1 &x_, const T2 &y_)
RESULT_TYPE operator[](R_xlen_t i) const
RESULT_TYPE(* FunPtr)(U1, U2)