config.hpp 7.7 KB

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