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