test_interval_quantifier_shared.hpp 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. /*-----------------------------------------------------------------------------+
  2. Copyright (c) 2008-2009: Joachim Faulhaber
  3. +------------------------------------------------------------------------------+
  4. Distributed under the Boost Software License, Version 1.0.
  5. (See accompanying file LICENCE.txt or copy at
  6. http://www.boost.org/LICENSE_1_0.txt)
  7. +-----------------------------------------------------------------------------*/
  8. #ifndef __TEST_INTERVAL_QUANTIFIER_SHARED_H_JOFA_090119__
  9. #define __TEST_INTERVAL_QUANTIFIER_SHARED_H_JOFA_090119__
  10. #include "portability.hpp"
  11. template
  12. <
  13. class T, class U, class Trt,
  14. #if (defined(__GNUC__) && (__GNUC__ < 4)) //MEMO Can be simplified, if gcc-3.4 is obsolete
  15. ICL_IntervalMap_TEMPLATE(T,U,Traits,Trt) IntervalMap
  16. #else
  17. ICL_IntervalMap_TEMPLATE(_T,_U,Traits,Trt) IntervalMap
  18. #endif
  19. >
  20. void make_3_itv_maps_and_derivatives_1
  21. (ICL_PORT_msvc_7_1_IntervalMap(T,U,Trt)& itv_map_a,
  22. ICL_PORT_msvc_7_1_IntervalMap(T,U,Trt)& itv_map_b,
  23. ICL_PORT_msvc_7_1_IntervalMap(T,U,Trt)& itv_map_c,
  24. typename ICL_PORT_msvc_7_1_IntervalMap(T,U,Trt)::interval_mapping_type& val_pair,
  25. mapping_pair<T,U>& map_pair)
  26. {
  27. typedef IntervalMap<T,U,Trt> IntervalMapT;
  28. itv_map_a.add(IDv(3,6,1)).add(IIv(5,7,1));
  29. itv_map_b.add(CDv(1,3,1)).add(IDv(8,9,1));
  30. itv_map_c.add(IDv(0,9,2)).add(IIv(3,6,1)).add(IDv(5,7,1));
  31. val_pair = IDv(6,9,1);
  32. map_pair = K_v(5,1);
  33. }
  34. //------------------------------------------------------------------------------
  35. // Monoid EAN
  36. //------------------------------------------------------------------------------
  37. template
  38. <
  39. class T, class U, class Trt,
  40. #if (defined(__GNUC__) && (__GNUC__ < 4)) //MEMO Can be simplified, if gcc-3.4 is obsolete
  41. ICL_IntervalMap_TEMPLATE(T,U,Traits,Trt) IntervalMap
  42. #else
  43. ICL_IntervalMap_TEMPLATE(_T,_U,Traits,Trt) IntervalMap
  44. #endif
  45. >
  46. void itv_quantifier_check_monoid_plus_4_bicremental_types()
  47. {
  48. typedef IntervalMap<T,U,Trt> IntervalMapT;
  49. IntervalMapT map_a, map_b, map_c;
  50. typename IntervalMapT::interval_mapping_type val_pair;
  51. mapping_pair<T,U> map_pair;
  52. make_3_itv_maps_and_derivatives_1(map_a, map_b, map_c, val_pair, map_pair);
  53. CHECK_MONOID_INSTANCE_WRT(plus) (map_a, map_b, map_c, val_pair, map_pair);
  54. CHECK_MONOID_INSTANCE_WRT(pipe) (map_a, map_b, map_c, val_pair, map_pair);
  55. }
  56. template
  57. <
  58. class T, class U, class Trt,
  59. #if (defined(__GNUC__) && (__GNUC__ < 4)) //MEMO Can be simplified, if gcc-3.4 is obsolete
  60. ICL_IntervalMap_TEMPLATE(T,U,Traits,Trt) IntervalMap
  61. #else
  62. ICL_IntervalMap_TEMPLATE(_T,_U,Traits,Trt) IntervalMap
  63. #endif
  64. >
  65. void itv_quantifier_check_monoid_et_4_bicremental_types()
  66. {
  67. typedef IntervalMap<T,U,Trt> IntervalMapT;
  68. IntervalMapT map_a, map_b, map_c;
  69. typename IntervalMapT::interval_mapping_type val_pair;
  70. mapping_pair<T,U> map_pair;
  71. make_3_itv_maps_and_derivatives_1(map_a, map_b, map_c, val_pair, map_pair);
  72. CHECK_MONOID_INSTANCE_WRT(et) (map_a, map_b, map_c, val_pair, map_pair);
  73. CHECK_MONOID_INSTANCE_WRT(caret)(map_a, map_b, map_c, val_pair, map_pair);
  74. }
  75. //------------------------------------------------------------------------------
  76. // Abelian monoid EANC
  77. //------------------------------------------------------------------------------
  78. template
  79. <
  80. class T, class U, class Trt,
  81. #if (defined(__GNUC__) && (__GNUC__ < 4)) //MEMO Can be simplified, if gcc-3.4 is obsolete
  82. ICL_IntervalMap_TEMPLATE(T,U,Traits,Trt) IntervalMap
  83. #else
  84. ICL_IntervalMap_TEMPLATE(_T,_U,Traits,Trt) IntervalMap
  85. #endif
  86. >
  87. void itv_quantifier_check_abelian_monoid_plus_4_bicremental_types()
  88. {
  89. typedef IntervalMap<T,U,Trt> IntervalMapT;
  90. IntervalMapT map_a, map_b, map_c;
  91. typename IntervalMapT::interval_mapping_type val_pair;
  92. mapping_pair<T,U> map_pair;
  93. make_3_itv_maps_and_derivatives_1(map_a, map_b, map_c, val_pair, map_pair);
  94. CHECK_ABELIAN_MONOID_INSTANCE_WRT(plus) (map_a, map_b, map_c, val_pair, map_pair);
  95. CHECK_ABELIAN_MONOID_INSTANCE_WRT(pipe) (map_a, map_b, map_c, val_pair, map_pair);
  96. }
  97. template
  98. <
  99. class T, class U, class Trt,
  100. #if (defined(__GNUC__) && (__GNUC__ < 4)) //MEMO Can be simplified, if gcc-3.4 is obsolete
  101. ICL_IntervalMap_TEMPLATE(T,U,Traits,Trt) IntervalMap
  102. #else
  103. ICL_IntervalMap_TEMPLATE(_T,_U,Traits,Trt) IntervalMap
  104. #endif
  105. >
  106. void itv_quantifier_check_abelian_monoid_et_4_bicremental_types()
  107. {
  108. typedef IntervalMap<T,U,Trt> IntervalMapT;
  109. IntervalMapT map_a, map_b, map_c;
  110. typename IntervalMapT::interval_mapping_type val_pair;
  111. mapping_pair<T,U> map_pair;
  112. make_3_itv_maps_and_derivatives_1(map_a, map_b, map_c, val_pair, map_pair);
  113. CHECK_ABELIAN_MONOID_INSTANCE_WRT(et) (map_a, map_b, map_c, val_pair, map_pair);
  114. CHECK_ABELIAN_MONOID_INSTANCE_WRT(caret)(map_a, map_b, map_c, val_pair, map_pair);
  115. }
  116. //------------------------------------------------------------------------------
  117. // Abelian partial invertive monoid
  118. //------------------------------------------------------------------------------
  119. template
  120. <
  121. class T, class U, class Trt,
  122. #if (defined(__GNUC__) && (__GNUC__ < 4)) //MEMO Can be simplified, if gcc-3.4 is obsolete
  123. ICL_IntervalMap_TEMPLATE(T,U,Traits,Trt) IntervalMap
  124. #else
  125. ICL_IntervalMap_TEMPLATE(_T,_U,Traits,Trt) IntervalMap
  126. #endif
  127. >
  128. void itv_quantifier_check_partial_invertive_monoid_plus_4_bicremental_types()
  129. {
  130. typedef IntervalMap<T,U,Trt> IntervalMapT;
  131. IntervalMapT map_a, map_b, map_c;
  132. typename IntervalMapT::interval_mapping_type val_pair;
  133. mapping_pair<T,U> map_pair;
  134. make_3_itv_maps_and_derivatives_1(map_a, map_b, map_c, val_pair, map_pair);
  135. CHECK_PARTIAL_INVERTIVE_MONOID_INSTANCE_WRT(plus) (map_a, map_b, map_c, val_pair, map_pair);
  136. CHECK_PARTIAL_INVERTIVE_MONOID_INSTANCE_WRT(pipe) (map_a, map_b, map_c, val_pair, map_pair);
  137. }
  138. //------------------------------------------------------------------------------
  139. // Abelian partial invertive monoid with distinct equality for inversion
  140. //------------------------------------------------------------------------------
  141. template
  142. <
  143. class T, class U, class Trt,
  144. #if (defined(__GNUC__) && (__GNUC__ < 4)) //MEMO Can be simplified, if gcc-3.4 is obsolete
  145. ICL_IntervalMap_TEMPLATE(T,U,Traits,Trt) IntervalMap
  146. #else
  147. ICL_IntervalMap_TEMPLATE(_T,_U,Traits,Trt) IntervalMap
  148. #endif
  149. >
  150. void itv_quantifier_check_partial_invertive_monoid_plus_prot_inv_4_bicremental_types()
  151. {
  152. typedef IntervalMap<T,U,Trt> IntervalMapT;
  153. IntervalMapT map_a, map_b, map_c;
  154. typename IntervalMapT::interval_mapping_type val_pair;
  155. mapping_pair<T,U> map_pair;
  156. make_3_itv_maps_and_derivatives_1(map_a, map_b, map_c, val_pair, map_pair);
  157. CHECK_ABELIAN_MONOID_INSTANCE_WRT(plus)(map_a, map_b, map_c, val_pair, map_pair);
  158. CHECK_ABELIAN_MONOID_INSTANCE_WRT(pipe)(map_a, map_b, map_c, val_pair, map_pair);
  159. #if !defined(_MSC_VER) || (_MSC_VER >= 1400) // 1310==MSVC-7.1 1400 ==MSVC-8.0
  160. CHECK_PARTIAL_INVERTIVE_MONOID_INSTANCE_WRT_EQUAL(plus)(is_distinct_equal, map_a, map_b, map_c, val_pair, map_pair);
  161. CHECK_PARTIAL_INVERTIVE_MONOID_INSTANCE_WRT_EQUAL(pipe)(is_distinct_equal, map_a, map_b, map_c, val_pair, map_pair);
  162. #endif
  163. }
  164. //------------------------------------------------------------------------------
  165. // Abelian group EANIC
  166. //------------------------------------------------------------------------------
  167. template
  168. <
  169. class T, class U, class Trt,
  170. #if (defined(__GNUC__) && (__GNUC__ < 4)) //MEMO Can be simplified, if gcc-3.4 is obsolete
  171. ICL_IntervalMap_TEMPLATE(T,U,Traits,Trt) IntervalMap
  172. #else
  173. ICL_IntervalMap_TEMPLATE(_T,_U,Traits,Trt) IntervalMap
  174. #endif
  175. >
  176. void itv_quantifier_check_abelian_group_plus_4_bicremental_types()
  177. {
  178. typedef IntervalMap<T,U,Trt> IntervalMapT;
  179. IntervalMapT map_a, map_b, map_c;
  180. typename IntervalMapT::interval_mapping_type val_pair;
  181. mapping_pair<T,U> map_pair;
  182. make_3_itv_maps_and_derivatives_1(map_a, map_b, map_c, val_pair, map_pair);
  183. CHECK_ABELIAN_GROUP_INSTANCE_WRT(plus) (map_a, map_b, map_c, val_pair, map_pair);
  184. CHECK_ABELIAN_GROUP_INSTANCE_WRT(pipe) (map_a, map_b, map_c, val_pair, map_pair);
  185. }
  186. //------------------------------------------------------------------------------
  187. // (0 - x) + x =d= 0
  188. //------------------------------------------------------------------------------
  189. template
  190. <
  191. class T, class U, class Trt,
  192. #if (defined(__GNUC__) && (__GNUC__ < 4)) //MEMO Can be simplified, if gcc-3.4 is obsolete
  193. ICL_IntervalMap_TEMPLATE(T,U,Traits,Trt) IntervalMap
  194. #else
  195. ICL_IntervalMap_TEMPLATE(_T,_U,Traits,Trt) IntervalMap
  196. #endif
  197. >
  198. void itv_quantifier_check_abelian_group_plus_prot_inv_4_bicremental_types()
  199. {
  200. // check abelian group wrt. + and inverability wrt. distinct equality =d= :
  201. // (1) (IntervalMapT, +) is an abelian group and
  202. // (2) The inverability law: (0 - x) + x =d= 0 holds.
  203. typedef IntervalMap<T,U,Trt> IntervalMapT;
  204. IntervalMapT map_a, map_b, map_c;
  205. typename IntervalMapT::interval_mapping_type val_pair;
  206. mapping_pair<T,U> map_pair;
  207. make_3_itv_maps_and_derivatives_1(map_a, map_b, map_c, val_pair, map_pair);
  208. CHECK_ABELIAN_MONOID_INSTANCE_WRT(plus) (map_a, map_b, map_c, val_pair, map_pair);
  209. CHECK_ABELIAN_MONOID_INSTANCE_WRT(pipe) (map_a, map_b, map_c, val_pair, map_pair);
  210. #if !defined(_MSC_VER) || (_MSC_VER >= 1400) // 1310==MSVC-7.1 1400 ==MSVC-8.0
  211. CHECK_ABELIAN_GROUP_INSTANCE_WRT_EQUAL(plus) (is_distinct_equal, map_a, map_b, map_c, val_pair, map_pair);
  212. CHECK_ABELIAN_GROUP_INSTANCE_WRT_EQUAL(pipe) (is_distinct_equal, map_a, map_b, map_c, val_pair, map_pair);
  213. #endif
  214. }
  215. //------------------------------------------------------------------------------
  216. // Inner complement
  217. //------------------------------------------------------------------------------
  218. template
  219. <
  220. class T, class U, class Trt,
  221. #if (defined(__GNUC__) && (__GNUC__ < 4)) //MEMO Can be simplified, if gcc-3.4 is obsolete
  222. ICL_IntervalMap_TEMPLATE(T,U,Traits,Trt) IntervalMap
  223. #else
  224. ICL_IntervalMap_TEMPLATE(_T,_U,Traits,Trt) IntervalMap
  225. #endif
  226. >
  227. void itv_quantifier_check_inner_complementarity_4_bicremental_types()
  228. {
  229. typedef IntervalMap<T,U,Trt> IntervalMapT;
  230. typedef typename IntervalMap<T,U,Trt>::set_type IntervalSetT;
  231. IntervalMapT map_a, map_b, map_c;
  232. typename IntervalMapT::interval_mapping_type val_pair;
  233. mapping_pair<T,U> map_pair;
  234. make_3_itv_maps_and_derivatives_1(map_a, map_b, map_c, val_pair, map_pair);
  235. has_inner_complementarity<IntervalMapT,IntervalSetT>(map_a);
  236. has_inner_complementarity<IntervalMapT,IntervalSetT>(map_b);
  237. has_inner_complementarity<IntervalMapT,IntervalSetT>(map_c);
  238. }
  239. template
  240. <
  241. class T, class U, class Trt,
  242. #if (defined(__GNUC__) && (__GNUC__ < 4)) //MEMO Can be simplified, if gcc-3.4 is obsolete
  243. ICL_IntervalMap_TEMPLATE(T,U,Traits,Trt) IntervalMap
  244. #else
  245. ICL_IntervalMap_TEMPLATE(_T,_U,Traits,Trt) IntervalMap
  246. #endif
  247. >
  248. void itv_quantifier_check_length_complementarity_4_bicremental_types()
  249. {
  250. typedef IntervalMap<T,U,Trt> IntervalMapT;
  251. typedef typename IntervalMap<T,U,Trt>::set_type IntervalSetT;
  252. IntervalMapT map_a, map_b, map_c;
  253. typename IntervalMapT::interval_mapping_type val_pair;
  254. mapping_pair<T,U> map_pair;
  255. make_3_itv_maps_and_derivatives_1(map_a, map_b, map_c, val_pair, map_pair);
  256. has_length_complementarity(map_a);
  257. has_length_complementarity(map_b);
  258. has_length_complementarity(map_c);
  259. has_length_as_distance<IntervalMapT,IntervalSetT>(map_a);
  260. has_length_as_distance<IntervalMapT,IntervalSetT>(map_b);
  261. has_length_as_distance<IntervalMapT,IntervalSetT>(map_c);
  262. }
  263. #endif // __TEST_INTERVAL_QUANTIFIER_SHARED_H_JOFA_090119__