config.hpp 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. //
  2. // Copyright (c) 2000-2002
  3. // Joerg Walter, Mathias Koch
  4. //
  5. // Distributed under the Boost Software License, Version 1.0. (See
  6. // accompanying file LICENSE_1_0.txt or copy at
  7. // http://www.boost.org/LICENSE_1_0.txt)
  8. //
  9. // The authors gratefully acknowledge the support of
  10. // GeNeSys mbH & Co. KG in producing this work.
  11. //
  12. #ifndef _BOOST_UBLAS_CONFIG_
  13. #define _BOOST_UBLAS_CONFIG_
  14. #include <cassert>
  15. #include <cstddef>
  16. #include <algorithm>
  17. #include <limits>
  18. #include <boost/config.hpp>
  19. #include <boost/static_assert.hpp>
  20. #include <boost/noncopyable.hpp>
  21. #include <boost/mpl/if.hpp>
  22. #include <boost/mpl/and.hpp>
  23. #include <boost/type_traits/is_same.hpp>
  24. #include <boost/type_traits/is_convertible.hpp>
  25. #include <boost/type_traits/is_const.hpp>
  26. #include <boost/type_traits/remove_reference.hpp>
  27. // C++11
  28. #if defined(__cplusplus) && __cplusplus >= 201103L
  29. #define BOOST_UBLAS_CPP_GE_2011
  30. #elif BOOST_MSVC >= 1800
  31. #define BOOST_UBLAS_CPP_GE_2011
  32. #else
  33. #undef BOOST_UBLAS_CPP_GE_2011 // Make sure no one defined it
  34. #endif
  35. // Microsoft Visual C++
  36. #if defined (BOOST_MSVC) && ! defined (BOOST_STRICT_CONFIG)
  37. // Version 7.1
  38. #if BOOST_MSVC == 1310
  39. // One of these workarounds is needed for MSVC 7.1 AFAIK
  40. // (thanks to John Maddock and Martin Lauer).
  41. #if !(defined(BOOST_UBLAS_NO_NESTED_CLASS_RELATION) || defined(BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION))
  42. #define BOOST_UBLAS_NO_NESTED_CLASS_RELATION
  43. #endif
  44. #endif
  45. #endif
  46. // GNU Compiler Collection
  47. #if defined (__GNUC__) && ! defined (BOOST_STRICT_CONFIG)
  48. #if __GNUC__ >= 4 || (__GNUC__ >= 3 && __GNUC_MINOR__ >= 4)
  49. // Specified by ABI definition see GCC bug id 9982
  50. #define BOOST_UBLAS_USEFUL_ARRAY_PLACEMENT_NEW
  51. #endif
  52. #if __GNUC__ < 3
  53. #define BOOST_UBLAS_UNSUPPORTED_COMPILER 1
  54. #endif
  55. #endif
  56. // Intel Compiler
  57. #if defined (BOOST_INTEL) && ! defined (BOOST_STRICT_CONFIG)
  58. #if defined (BOOST_INTEL_LINUX) && (BOOST_INTEL_LINUX >= 800)
  59. // By inspection of compiler results
  60. #define BOOST_UBLAS_USEFUL_ARRAY_PLACEMENT_NEW
  61. #endif
  62. #if (BOOST_INTEL < 700)
  63. #define BOOST_UBLAS_UNSUPPORTED_COMPILER 1
  64. #endif
  65. // Define swap for index_pair and triple.
  66. #if (BOOST_INTEL <= 800)
  67. namespace boost { namespace numeric { namespace ublas {
  68. template<class C, class IC>
  69. class indexed_iterator;
  70. template<class V>
  71. class index_pair;
  72. template<class M>
  73. class index_triple;
  74. }}}
  75. namespace std {
  76. template<class V>
  77. inline
  78. void swap (boost::numeric::ublas::index_pair<V> i1, boost::numeric::ublas::index_pair<V> i2) {
  79. i1.swap (i2);
  80. }
  81. template<class M>
  82. inline
  83. void swap (boost::numeric::ublas::index_triple<M> i1, boost::numeric::ublas::index_triple<M> i2) {
  84. i1.swap (i2);
  85. }
  86. // iter_swap also needed for ICC on Itanium?
  87. template<class C, class IC>
  88. inline
  89. void iter_swap (boost::numeric::ublas::indexed_iterator<C, IC> it1,
  90. boost::numeric::ublas::indexed_iterator<C, IC> it2) {
  91. swap (*it1, *it2);
  92. }
  93. }
  94. #endif
  95. #endif
  96. // Comeau compiler - thanks to Kresimir Fresl
  97. #if defined (__COMO__) && ! defined (BOOST_STRICT_CONFIG)
  98. // Missing std::abs overloads for float types in <cmath> are in <cstdlib>
  99. #if defined(__LIBCOMO__) && (__LIBCOMO_VERSION__ <= 31)
  100. #include <cstdlib>
  101. #endif
  102. #endif
  103. // PGI compiler
  104. #ifdef __PGIC__
  105. #define BOOST_UBLAS_UNSUPPORTED_COMPILER 0
  106. #endif
  107. // HP aCC C++ compiler
  108. #if defined (__HP_aCC) && ! defined (BOOST_STRICT_CONFIG)
  109. # if (__HP_aCC >= 60000 )
  110. # define BOOST_UBLAS_USEFUL_ARRAY_PLACEMENT_NEW
  111. #endif
  112. #endif
  113. // SGI MIPSpro C++ compiler
  114. #if defined (__sgi) && ! defined (BOOST_STRICT_CONFIG)
  115. // Missing std::abs overloads for float types in <cmath> are in <cstdlib>
  116. // This test should be library version specific.
  117. #include <cstdlib>
  118. #if __COMPILER_VERSION >=650
  119. // By inspection of compiler results - thanks to Peter Schmitteckert
  120. #define BOOST_UBLAS_USEFUL_ARRAY_PLACEMENT_NEW
  121. #endif
  122. #endif
  123. // Metrowerks Codewarrior
  124. #if defined (__MWERKS__) && ! defined (BOOST_STRICT_CONFIG)
  125. // 8.x
  126. #if __MWERKS__ <= 0x3003
  127. #define BOOST_UBLAS_UNSUPPORTED_COMPILER 1
  128. #endif
  129. #endif
  130. // Detect other compilers with serious defects - override by defineing BOOST_UBLAS_UNSUPPORTED_COMPILER=0
  131. #ifndef BOOST_UBLAS_UNSUPPORTED_COMPILER
  132. #if defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) || defined(BOOST_NO_SFINAE) || defined(BOOST_NO_STDC_NAMESPACE)
  133. #define BOOST_UBLAS_UNSUPPORTED_COMPILER 1
  134. #endif
  135. #endif
  136. // Cannot continue with an unsupported compiler
  137. #if defined(BOOST_UBLAS_UNSUPPORTED_COMPILER) && (BOOST_UBLAS_UNSUPPORTED_COMPILER != 0)
  138. #error Your compiler and/or configuration is unsupported by this verions of uBLAS. Define BOOST_UBLAS_UNSUPPORTED_COMPILER=0 to override this message. Boost 1.32.0 includes uBLAS with support for many older compilers.
  139. #endif
  140. // Enable performance options in RELEASE mode
  141. #if defined (NDEBUG) || defined (BOOST_UBLAS_NDEBUG)
  142. #ifndef BOOST_UBLAS_INLINE
  143. #define BOOST_UBLAS_INLINE inline
  144. #endif
  145. // Do not check sizes!
  146. #define BOOST_UBLAS_USE_FAST_SAME
  147. // NO runtime error checks with BOOST_UBLAS_CHECK macro
  148. #ifndef BOOST_UBLAS_CHECK_ENABLE
  149. #define BOOST_UBLAS_CHECK_ENABLE 0
  150. #endif
  151. // NO type compatibility numeric checks
  152. #ifndef BOOST_UBLAS_TYPE_CHECK
  153. #define BOOST_UBLAS_TYPE_CHECK 0
  154. #endif
  155. // Disable performance options in DEBUG mode
  156. #else
  157. #ifndef BOOST_UBLAS_INLINE
  158. #define BOOST_UBLAS_INLINE
  159. #endif
  160. // Enable runtime error checks with BOOST_UBLAS_CHECK macro. Check bounds etc
  161. #ifndef BOOST_UBLAS_CHECK_ENABLE
  162. #define BOOST_UBLAS_CHECK_ENABLE 1
  163. #endif
  164. // Type compatibiltity numeric checks
  165. #ifndef BOOST_UBLAS_TYPE_CHECK
  166. #define BOOST_UBLAS_TYPE_CHECK 1
  167. #endif
  168. #endif
  169. /*
  170. * Type compatibility checks
  171. * Control type compatibility numeric runtime checks for non dense matrices.
  172. * Require additional storage and complexity
  173. */
  174. #if BOOST_UBLAS_TYPE_CHECK
  175. template <class Dummy>
  176. struct disable_type_check
  177. {
  178. static bool value;
  179. };
  180. template <class Dummy>
  181. bool disable_type_check<Dummy>::value = false;
  182. #endif
  183. #ifndef BOOST_UBLAS_TYPE_CHECK_EPSILON
  184. #define BOOST_UBLAS_TYPE_CHECK_EPSILON (type_traits<real_type>::type_sqrt (std::numeric_limits<real_type>::epsilon ()))
  185. #endif
  186. #ifndef BOOST_UBLAS_TYPE_CHECK_MIN
  187. #define BOOST_UBLAS_TYPE_CHECK_MIN (type_traits<real_type>::type_sqrt ( (std::numeric_limits<real_type>::min) ()))
  188. #endif
  189. /*
  190. * General Configuration
  191. */
  192. // Proxy shortcuts overload the alreadly heavily over used operator ()
  193. //#define BOOST_UBLAS_ENABLE_PROXY_SHORTCUTS
  194. // In order to simplify debugging is is possible to simplify expression template
  195. // so they are restricted to a single operation
  196. // #define BOOST_UBLAS_SIMPLE_ET_DEBUG
  197. // Use invariant hoisting.
  198. // #define BOOST_UBLAS_USE_INVARIANT_HOISTING
  199. // Use Duff's device in element access loops
  200. // #define BOOST_UBLAS_USE_DUFF_DEVICE
  201. // Choose evaluation method for dense vectors and matrices
  202. #if !(defined(BOOST_UBLAS_USE_INDEXING) || defined(BOOST_UBLAS_USE_ITERATING))
  203. #define BOOST_UBLAS_USE_INDEXING
  204. #endif
  205. // #define BOOST_UBLAS_ITERATOR_THRESHOLD 0
  206. // Use indexed iterators - unsupported implementation experiment
  207. // #define BOOST_UBLAS_USE_INDEXED_ITERATOR
  208. // Alignment of bounded_array type
  209. #ifndef BOOST_UBLAS_BOUNDED_ARRAY_ALIGN
  210. #define BOOST_UBLAS_BOUNDED_ARRAY_ALIGN
  211. #endif
  212. // Enable different sparse element proxies
  213. #ifndef BOOST_UBLAS_NO_ELEMENT_PROXIES
  214. // Sparse proxies prevent reference invalidation problems in expressions such as:
  215. // a [1] = a [0] = 1 Thanks to Marc Duflot for spotting this.
  216. // #define BOOST_UBLAS_STRICT_MAP_ARRAY
  217. #define BOOST_UBLAS_STRICT_VECTOR_SPARSE
  218. #define BOOST_UBLAS_STRICT_MATRIX_SPARSE
  219. // Hermitian matrices use element proxies to allow assignment to conjugate triangle
  220. #define BOOST_UBLAS_STRICT_HERMITIAN
  221. #endif
  222. // Define to configure special settings for reference returning members
  223. // #define BOOST_UBLAS_REFERENCE_CONST_MEMBER
  224. // #define BOOST_UBLAS_PROXY_CONST_MEMBER
  225. // Include type declerations and functions
  226. #include <boost/numeric/ublas/fwd.hpp>
  227. #include <boost/numeric/ublas/detail/definitions.hpp>
  228. #endif