|
Rcpp Version 0.9.10
|
00001 // -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*- 00002 // 00003 // logical_operators__Vector__primitive.h: Rcpp R/C++ interface class library -- 00004 // logical operators for Vector to primitive comparisons 00005 // 00006 // Copyright (C) 2010 - 2011 Dirk Eddelbuettel and Romain Francois 00007 // 00008 // This file is part of Rcpp. 00009 // 00010 // Rcpp is free software: you can redistribute it and/or modify it 00011 // under the terms of the GNU General Public License as published by 00012 // the Free Software Foundation, either version 2 of the License, or 00013 // (at your option) any later version. 00014 // 00015 // Rcpp is distributed in the hope that it will be useful, but 00016 // WITHOUT ANY WARRANTY; without even the implied warranty of 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 // GNU General Public License for more details. 00019 // 00020 // You should have received a copy of the GNU General Public License 00021 // along with Rcpp. If not, see <http://www.gnu.org/licenses/>. 00022 00023 #ifndef Rcpp__sugar__logical_operators__Vector__primitive_h 00024 #define Rcpp__sugar__logical_operators__Vector__primitive_h 00025 00026 /* Vector < primitive */ 00027 template <int RTYPE, bool NA, typename T> 00028 inline Rcpp::sugar::Comparator_With_One_Value< 00029 RTYPE , 00030 Rcpp::sugar::less<RTYPE>, 00031 NA, 00032 T 00033 > 00034 operator<( 00035 const Rcpp::VectorBase<RTYPE,NA,T>& lhs , 00036 typename Rcpp::traits::storage_type<RTYPE>::type rhs 00037 ){ 00038 return Rcpp::sugar::Comparator_With_One_Value< 00039 RTYPE, 00040 Rcpp::sugar::less<RTYPE>, 00041 NA, 00042 T 00043 >( 00044 lhs, rhs 00045 ) ; 00046 } 00047 template <int RTYPE, bool NA, typename T> 00048 inline Rcpp::sugar::Comparator_With_One_Value< 00049 RTYPE , 00050 Rcpp::sugar::less<RTYPE>, 00051 NA, 00052 T 00053 > 00054 operator>( 00055 typename Rcpp::traits::storage_type<RTYPE>::type rhs, 00056 const Rcpp::VectorBase<RTYPE,NA,T>& lhs 00057 ){ 00058 return Rcpp::sugar::Comparator_With_One_Value< 00059 RTYPE, 00060 Rcpp::sugar::less<RTYPE>, 00061 NA, 00062 T 00063 >( 00064 lhs, rhs 00065 ) ; 00066 } 00067 00068 00069 00070 /* Vector > primitive */ 00071 template <int RTYPE, bool NA, typename T> 00072 inline Rcpp::sugar::Comparator_With_One_Value< 00073 RTYPE , 00074 Rcpp::sugar::greater<RTYPE>, 00075 NA, 00076 T 00077 > 00078 operator>( 00079 const Rcpp::VectorBase<RTYPE,NA,T>& lhs , 00080 typename Rcpp::traits::storage_type<RTYPE>::type rhs 00081 ){ 00082 return Rcpp::sugar::Comparator_With_One_Value< 00083 RTYPE, 00084 Rcpp::sugar::greater<RTYPE>, 00085 NA, 00086 T 00087 >( 00088 lhs, rhs 00089 ) ; 00090 } 00091 template <int RTYPE, bool NA, typename T> 00092 inline Rcpp::sugar::Comparator_With_One_Value< 00093 RTYPE , 00094 Rcpp::sugar::greater<RTYPE>, 00095 NA, 00096 T 00097 > 00098 operator<( 00099 typename Rcpp::traits::storage_type<RTYPE>::type rhs, 00100 const Rcpp::VectorBase<RTYPE,NA,T>& lhs 00101 ){ 00102 return Rcpp::sugar::Comparator_With_One_Value< 00103 RTYPE, 00104 Rcpp::sugar::greater<RTYPE>, 00105 NA, 00106 T 00107 >( 00108 lhs, rhs 00109 ) ; 00110 } 00111 00112 00113 00114 /* Vector <= primitive */ 00115 template <int RTYPE, bool NA, typename T> 00116 inline Rcpp::sugar::Comparator_With_One_Value< 00117 RTYPE , 00118 Rcpp::sugar::less_or_equal<RTYPE>, 00119 NA, 00120 T 00121 > 00122 operator<=( 00123 const Rcpp::VectorBase<RTYPE,NA,T>& lhs , 00124 typename Rcpp::traits::storage_type<RTYPE>::type rhs 00125 ){ 00126 return Rcpp::sugar::Comparator_With_One_Value< 00127 RTYPE, 00128 Rcpp::sugar::less_or_equal<RTYPE>, 00129 NA, 00130 T 00131 >( 00132 lhs, rhs 00133 ) ; 00134 } 00135 template <int RTYPE, bool NA, typename T> 00136 inline Rcpp::sugar::Comparator_With_One_Value< 00137 RTYPE , 00138 Rcpp::sugar::less_or_equal<RTYPE>, 00139 NA, 00140 T 00141 > 00142 operator>=( 00143 typename Rcpp::traits::storage_type<RTYPE>::type rhs, 00144 const Rcpp::VectorBase<RTYPE,NA,T>& lhs 00145 ){ 00146 return Rcpp::sugar::Comparator_With_One_Value< 00147 RTYPE, 00148 Rcpp::sugar::less_or_equal<RTYPE>, 00149 NA, 00150 T 00151 >( 00152 lhs, rhs 00153 ) ; 00154 } 00155 00156 00157 00158 00159 /* Vector >= primitive */ 00160 template <int RTYPE, bool NA, typename T> 00161 inline Rcpp::sugar::Comparator_With_One_Value< 00162 RTYPE , 00163 Rcpp::sugar::greater_or_equal<RTYPE>, 00164 NA, 00165 T 00166 > 00167 operator>=( 00168 const Rcpp::VectorBase<RTYPE,NA,T>& lhs , 00169 typename Rcpp::traits::storage_type<RTYPE>::type rhs 00170 ){ 00171 return Rcpp::sugar::Comparator_With_One_Value< 00172 RTYPE, 00173 Rcpp::sugar::greater_or_equal<RTYPE>, 00174 NA, 00175 T 00176 >( 00177 lhs, rhs 00178 ) ; 00179 } 00180 template <int RTYPE, bool NA, typename T> 00181 inline Rcpp::sugar::Comparator_With_One_Value< 00182 RTYPE , 00183 Rcpp::sugar::greater_or_equal<RTYPE>, 00184 NA, 00185 T 00186 > 00187 operator<=( 00188 typename Rcpp::traits::storage_type<RTYPE>::type rhs, 00189 const Rcpp::VectorBase<RTYPE,NA,T>& lhs 00190 ){ 00191 return Rcpp::sugar::Comparator_With_One_Value< 00192 RTYPE, 00193 Rcpp::sugar::greater_or_equal<RTYPE>, 00194 NA, 00195 T 00196 >( 00197 lhs, rhs 00198 ) ; 00199 } 00200 00201 00202 00203 /* Vector == primitive */ 00204 template <int RTYPE, bool NA, typename T> 00205 inline Rcpp::sugar::Comparator_With_One_Value< 00206 RTYPE , 00207 Rcpp::sugar::equal<RTYPE>, 00208 NA, 00209 T 00210 > 00211 operator==( 00212 const Rcpp::VectorBase<RTYPE,NA,T>& lhs , 00213 typename Rcpp::traits::storage_type<RTYPE>::type rhs 00214 ){ 00215 return Rcpp::sugar::Comparator_With_One_Value< 00216 RTYPE, 00217 Rcpp::sugar::equal<RTYPE>, 00218 NA, 00219 T 00220 >( 00221 lhs, rhs 00222 ) ; 00223 } 00224 template <int RTYPE, bool NA, typename T> 00225 inline Rcpp::sugar::Comparator_With_One_Value< 00226 RTYPE , 00227 Rcpp::sugar::equal<RTYPE>, 00228 NA, 00229 T 00230 > 00231 operator==( 00232 typename Rcpp::traits::storage_type<RTYPE>::type rhs, 00233 const Rcpp::VectorBase<RTYPE,NA,T>& lhs 00234 ){ 00235 return Rcpp::sugar::Comparator_With_One_Value< 00236 RTYPE, 00237 Rcpp::sugar::equal<RTYPE>, 00238 NA, 00239 T 00240 >( 00241 lhs, rhs 00242 ) ; 00243 } 00244 00245 00246 00247 /* Vector != primitive */ 00248 template <int RTYPE, bool NA, typename T> 00249 inline Rcpp::sugar::Comparator_With_One_Value< 00250 RTYPE , 00251 Rcpp::sugar::not_equal<RTYPE>, 00252 NA, 00253 T 00254 > 00255 operator!=( 00256 const Rcpp::VectorBase<RTYPE,NA,T>& lhs , 00257 typename Rcpp::traits::storage_type<RTYPE>::type rhs 00258 ){ 00259 return Rcpp::sugar::Comparator_With_One_Value< 00260 RTYPE, 00261 Rcpp::sugar::not_equal<RTYPE>, 00262 NA, 00263 T 00264 >( 00265 lhs, rhs 00266 ) ; 00267 } 00268 template <int RTYPE, bool NA, typename T> 00269 inline Rcpp::sugar::Comparator_With_One_Value< 00270 RTYPE , 00271 Rcpp::sugar::not_equal<RTYPE>, 00272 NA, 00273 T 00274 > 00275 operator!=( 00276 typename Rcpp::traits::storage_type<RTYPE>::type rhs, 00277 const Rcpp::VectorBase<RTYPE,NA,T>& lhs 00278 ){ 00279 return Rcpp::sugar::Comparator_With_One_Value< 00280 RTYPE, 00281 Rcpp::sugar::not_equal<RTYPE>, 00282 NA, 00283 T 00284 >( 00285 lhs, rhs 00286 ) ; 00287 } 00288 00289 00290 #endif