operator_relational.hpp 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441
  1. // Copyright 2008-2016 Conrad Sanderson (http://conradsanderson.id.au)
  2. // Copyright 2008-2016 National ICT Australia (NICTA)
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. // ------------------------------------------------------------------------
  15. //! \addtogroup operator_relational
  16. //! @{
  17. // < : lt
  18. // > : gt
  19. // <= : lteq
  20. // >= : gteq
  21. // == : eq
  22. // != : noteq
  23. // && : and
  24. // || : or
  25. template<typename T1, typename T2>
  26. inline
  27. typename
  28. enable_if2
  29. <
  30. (is_arma_type<T1>::value && is_arma_type<T2>::value && (is_cx<typename T1::elem_type>::no) && (is_cx<typename T2::elem_type>::no)),
  31. const mtGlue<uword, T1, T2, glue_rel_lt>
  32. >::result
  33. operator<
  34. (const T1& X, const T2& Y)
  35. {
  36. arma_extra_debug_sigprint();
  37. return mtGlue<uword, T1, T2, glue_rel_lt>( X, Y );
  38. }
  39. template<typename T1, typename T2>
  40. inline
  41. typename
  42. enable_if2
  43. <
  44. (is_arma_type<T1>::value && is_arma_type<T2>::value && (is_cx<typename T1::elem_type>::no) && (is_cx<typename T2::elem_type>::no)),
  45. const mtGlue<uword, T1, T2, glue_rel_gt>
  46. >::result
  47. operator>
  48. (const T1& X, const T2& Y)
  49. {
  50. arma_extra_debug_sigprint();
  51. return mtGlue<uword, T1, T2, glue_rel_gt>( X, Y );
  52. }
  53. template<typename T1, typename T2>
  54. inline
  55. typename
  56. enable_if2
  57. <
  58. (is_arma_type<T1>::value && is_arma_type<T2>::value && (is_cx<typename T1::elem_type>::no) && (is_cx<typename T2::elem_type>::no)),
  59. const mtGlue<uword, T1, T2, glue_rel_lteq>
  60. >::result
  61. operator<=
  62. (const T1& X, const T2& Y)
  63. {
  64. arma_extra_debug_sigprint();
  65. return mtGlue<uword, T1, T2, glue_rel_lteq>( X, Y );
  66. }
  67. template<typename T1, typename T2>
  68. inline
  69. typename
  70. enable_if2
  71. <
  72. (is_arma_type<T1>::value && is_arma_type<T2>::value && (is_cx<typename T1::elem_type>::no) && (is_cx<typename T2::elem_type>::no)),
  73. const mtGlue<uword, T1, T2, glue_rel_gteq>
  74. >::result
  75. operator>=
  76. (const T1& X, const T2& Y)
  77. {
  78. arma_extra_debug_sigprint();
  79. return mtGlue<uword, T1, T2, glue_rel_gteq>( X, Y );
  80. }
  81. template<typename T1, typename T2>
  82. inline
  83. typename
  84. enable_if2
  85. <
  86. (is_arma_type<T1>::value && is_arma_type<T2>::value),
  87. const mtGlue<uword, T1, T2, glue_rel_eq>
  88. >::result
  89. operator==
  90. (const T1& X, const T2& Y)
  91. {
  92. arma_extra_debug_sigprint();
  93. return mtGlue<uword, T1, T2, glue_rel_eq>( X, Y );
  94. }
  95. template<typename T1, typename T2>
  96. inline
  97. typename
  98. enable_if2
  99. <
  100. (is_arma_type<T1>::value && is_arma_type<T2>::value),
  101. const mtGlue<uword, T1, T2, glue_rel_noteq>
  102. >::result
  103. operator!=
  104. (const T1& X, const T2& Y)
  105. {
  106. arma_extra_debug_sigprint();
  107. return mtGlue<uword, T1, T2, glue_rel_noteq>( X, Y );
  108. }
  109. template<typename T1, typename T2>
  110. inline
  111. typename
  112. enable_if2
  113. <
  114. (is_arma_type<T1>::value && is_arma_type<T2>::value && (is_cx<typename T1::elem_type>::no) && (is_cx<typename T2::elem_type>::no)),
  115. const mtGlue<uword, T1, T2, glue_rel_and>
  116. >::result
  117. operator&&
  118. (const T1& X, const T2& Y)
  119. {
  120. arma_extra_debug_sigprint();
  121. return mtGlue<uword, T1, T2, glue_rel_and>( X, Y );
  122. }
  123. template<typename T1, typename T2>
  124. inline
  125. typename
  126. enable_if2
  127. <
  128. (is_arma_type<T1>::value && is_arma_type<T2>::value && (is_cx<typename T1::elem_type>::no) && (is_cx<typename T2::elem_type>::no)),
  129. const mtGlue<uword, T1, T2, glue_rel_or>
  130. >::result
  131. operator||
  132. (const T1& X, const T2& Y)
  133. {
  134. arma_extra_debug_sigprint();
  135. return mtGlue<uword, T1, T2, glue_rel_or>( X, Y );
  136. }
  137. //
  138. //
  139. //
  140. template<typename T1>
  141. inline
  142. typename
  143. enable_if2
  144. <
  145. (is_arma_type<T1>::value && (is_cx<typename T1::elem_type>::no)),
  146. const mtOp<uword, T1, op_rel_lt_pre>
  147. >::result
  148. operator<
  149. (const typename T1::elem_type val, const T1& X)
  150. {
  151. arma_extra_debug_sigprint();
  152. return mtOp<uword, T1, op_rel_lt_pre>(X, val);
  153. }
  154. template<typename T1>
  155. inline
  156. typename
  157. enable_if2
  158. <
  159. (is_arma_type<T1>::value && (is_cx<typename T1::elem_type>::no)),
  160. const mtOp<uword, T1, op_rel_lt_post>
  161. >::result
  162. operator<
  163. (const T1& X, const typename T1::elem_type val)
  164. {
  165. arma_extra_debug_sigprint();
  166. return mtOp<uword, T1, op_rel_lt_post>(X, val);
  167. }
  168. template<typename T1>
  169. inline
  170. typename
  171. enable_if2
  172. <
  173. (is_arma_type<T1>::value && (is_cx<typename T1::elem_type>::no)),
  174. const mtOp<uword, T1, op_rel_gt_pre>
  175. >::result
  176. operator>
  177. (const typename T1::elem_type val, const T1& X)
  178. {
  179. arma_extra_debug_sigprint();
  180. return mtOp<uword, T1, op_rel_gt_pre>(X, val);
  181. }
  182. template<typename T1>
  183. inline
  184. typename
  185. enable_if2
  186. <
  187. (is_arma_type<T1>::value && (is_cx<typename T1::elem_type>::no)),
  188. const mtOp<uword, T1, op_rel_gt_post>
  189. >::result
  190. operator>
  191. (const T1& X, const typename T1::elem_type val)
  192. {
  193. arma_extra_debug_sigprint();
  194. return mtOp<uword, T1, op_rel_gt_post>(X, val);
  195. }
  196. template<typename T1>
  197. inline
  198. typename
  199. enable_if2
  200. <
  201. (is_arma_type<T1>::value && (is_cx<typename T1::elem_type>::no)),
  202. const mtOp<uword, T1, op_rel_lteq_pre>
  203. >::result
  204. operator<=
  205. (const typename T1::elem_type val, const T1& X)
  206. {
  207. arma_extra_debug_sigprint();
  208. return mtOp<uword, T1, op_rel_lteq_pre>(X, val);
  209. }
  210. template<typename T1>
  211. inline
  212. typename
  213. enable_if2
  214. <
  215. (is_arma_type<T1>::value && (is_cx<typename T1::elem_type>::no)),
  216. const mtOp<uword, T1, op_rel_lteq_post>
  217. >::result
  218. operator<=
  219. (const T1& X, const typename T1::elem_type val)
  220. {
  221. arma_extra_debug_sigprint();
  222. return mtOp<uword, T1, op_rel_lteq_post>(X, val);
  223. }
  224. template<typename T1>
  225. inline
  226. typename
  227. enable_if2
  228. <
  229. (is_arma_type<T1>::value && (is_cx<typename T1::elem_type>::no)),
  230. const mtOp<uword, T1, op_rel_gteq_pre>
  231. >::result
  232. operator>=
  233. (const typename T1::elem_type val, const T1& X)
  234. {
  235. arma_extra_debug_sigprint();
  236. return mtOp<uword, T1, op_rel_gteq_pre>(X, val);
  237. }
  238. template<typename T1>
  239. inline
  240. typename
  241. enable_if2
  242. <
  243. (is_arma_type<T1>::value && (is_cx<typename T1::elem_type>::no)),
  244. const mtOp<uword, T1, op_rel_gteq_post>
  245. >::result
  246. operator>=
  247. (const T1& X, const typename T1::elem_type val)
  248. {
  249. arma_extra_debug_sigprint();
  250. return mtOp<uword, T1, op_rel_gteq_post>(X, val);
  251. }
  252. template<typename T1>
  253. inline
  254. typename
  255. enable_if2
  256. <
  257. is_arma_type<T1>::value,
  258. const mtOp<uword, T1, op_rel_eq>
  259. >::result
  260. operator==
  261. (const typename T1::elem_type val, const T1& X)
  262. {
  263. arma_extra_debug_sigprint();
  264. return mtOp<uword, T1, op_rel_eq>(X, val);
  265. }
  266. template<typename T1>
  267. inline
  268. typename
  269. enable_if2
  270. <
  271. is_arma_type<T1>::value,
  272. const mtOp<uword, T1, op_rel_eq>
  273. >::result
  274. operator==
  275. (const T1& X, const typename T1::elem_type val)
  276. {
  277. arma_extra_debug_sigprint();
  278. return mtOp<uword, T1, op_rel_eq>(X, val);
  279. }
  280. template<typename T1>
  281. inline
  282. typename
  283. enable_if2
  284. <
  285. is_arma_type<T1>::value,
  286. const mtOp<uword, T1, op_rel_noteq>
  287. >::result
  288. operator!=
  289. (const typename T1::elem_type val, const T1& X)
  290. {
  291. arma_extra_debug_sigprint();
  292. return mtOp<uword, T1, op_rel_noteq>(X, val);
  293. }
  294. template<typename T1>
  295. inline
  296. typename
  297. enable_if2
  298. <
  299. is_arma_type<T1>::value,
  300. const mtOp<uword, T1, op_rel_noteq>
  301. >::result
  302. operator!=
  303. (const T1& X, const typename T1::elem_type val)
  304. {
  305. arma_extra_debug_sigprint();
  306. return mtOp<uword, T1, op_rel_noteq>(X, val);
  307. }
  308. //
  309. template<typename T1, typename T2>
  310. inline
  311. typename
  312. enable_if2
  313. <
  314. (is_arma_sparse_type<T1>::value && is_arma_sparse_type<T2>::value && (is_cx<typename T1::elem_type>::no) && (is_cx<typename T2::elem_type>::no)),
  315. const mtSpGlue<uword, T1, T2, spglue_rel_lt>
  316. >::result
  317. operator<
  318. (const T1& X, const T2& Y)
  319. {
  320. arma_extra_debug_sigprint();
  321. // TODO: ensure T1::elem_type and T2::elem_type are the same
  322. return mtSpGlue<uword, T1, T2, spglue_rel_lt>( X, Y );
  323. }
  324. template<typename T1, typename T2>
  325. inline
  326. typename
  327. enable_if2
  328. <
  329. (is_arma_sparse_type<T1>::value && is_arma_sparse_type<T2>::value && (is_cx<typename T1::elem_type>::no) && (is_cx<typename T2::elem_type>::no)),
  330. const mtSpGlue<uword, T1, T2, spglue_rel_gt>
  331. >::result
  332. operator>
  333. (const T1& X, const T2& Y)
  334. {
  335. arma_extra_debug_sigprint();
  336. // TODO: ensure T1::elem_type and T2::elem_type are the same
  337. return mtSpGlue<uword, T1, T2, spglue_rel_gt>( X, Y );
  338. }
  339. //! @}