2 // Copyright (c) 2000-2002
3 // Joerg Walter, Mathias Koch
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)
9 // The authors gratefully acknowledge the support of
10 // GeNeSys mbH & Co. KG in producing this work.
13 #ifndef _BOOST_UBLAS_CONFIG_
14 #define _BOOST_UBLAS_CONFIG_
21 #include <boost/config.hpp>
22 #include <boost/static_assert.hpp>
23 #include <boost/noncopyable.hpp>
24 #include <boost/mpl/if.hpp>
25 #include <boost/mpl/and.hpp>
26 #include <boost/type_traits/is_same.hpp>
27 #include <boost/type_traits/is_convertible.hpp>
28 #include <boost/type_traits/is_const.hpp>
29 #include <boost/type_traits/remove_reference.hpp>
32 #if defined(__cplusplus) && __cplusplus >= 201103L
34 #define BOOST_UBLAS_CPP_GE_2011
36 #elif BOOST_MSVC >= 1800
38 #define BOOST_UBLAS_CPP_GE_2011
42 #undef BOOST_UBLAS_CPP_GE_2011 // Make sure no one defined it
46 // Microsoft Visual C++
47 #if defined (BOOST_MSVC) && ! defined (BOOST_STRICT_CONFIG)
50 #if BOOST_MSVC == 1310
51 // One of these workarounds is needed for MSVC 7.1 AFAIK
52 // (thanks to John Maddock and Martin Lauer).
53 #if !(defined(BOOST_UBLAS_NO_NESTED_CLASS_RELATION) || defined(BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION))
54 #define BOOST_UBLAS_NO_NESTED_CLASS_RELATION
62 // GNU Compiler Collection
63 #if defined (__GNUC__) && ! defined (BOOST_STRICT_CONFIG)
65 #if __GNUC__ >= 4 || (__GNUC__ >= 3 && __GNUC_MINOR__ >= 4)
66 // Specified by ABI definition see GCC bug id 9982
67 #define BOOST_UBLAS_USEFUL_ARRAY_PLACEMENT_NEW
71 #define BOOST_UBLAS_UNSUPPORTED_COMPILER 1
78 #if defined (BOOST_INTEL) && ! defined (BOOST_STRICT_CONFIG)
80 #if defined (BOOST_INTEL_LINUX) && (BOOST_INTEL_LINUX >= 800)
81 // By inspection of compiler results
82 #define BOOST_UBLAS_USEFUL_ARRAY_PLACEMENT_NEW
85 #if (BOOST_INTEL < 700)
86 #define BOOST_UBLAS_UNSUPPORTED_COMPILER 1
89 // Define swap for index_pair and triple.
90 #if (BOOST_INTEL <= 800)
91 namespace boost { namespace numeric { namespace ublas {
92 template<class C, class IC>
93 class indexed_iterator;
104 void swap (boost::numeric::ublas::index_pair<V> i1, boost::numeric::ublas::index_pair<V> i2) {
109 void swap (boost::numeric::ublas::index_triple<M> i1, boost::numeric::ublas::index_triple<M> i2) {
112 // iter_swap also needed for ICC on Itanium?
113 template<class C, class IC>
115 void iter_swap (boost::numeric::ublas::indexed_iterator<C, IC> it1,
116 boost::numeric::ublas::indexed_iterator<C, IC> it2) {
125 // Comeau compiler - thanks to Kresimir Fresl
126 #if defined (__COMO__) && ! defined (BOOST_STRICT_CONFIG)
128 // Missing std::abs overloads for float types in <cmath> are in <cstdlib>
129 #if defined(__LIBCOMO__) && (__LIBCOMO_VERSION__ <= 31)
137 #define BOOST_UBLAS_UNSUPPORTED_COMPILER 0
140 // HP aCC C++ compiler
141 #if defined (__HP_aCC) && ! defined (BOOST_STRICT_CONFIG)
142 # if (__HP_aCC >= 60000 )
143 # define BOOST_UBLAS_USEFUL_ARRAY_PLACEMENT_NEW
148 // SGI MIPSpro C++ compiler
149 #if defined (__sgi) && ! defined (BOOST_STRICT_CONFIG)
151 // Missing std::abs overloads for float types in <cmath> are in <cstdlib>
152 // This test should be library version specific.
155 #if __COMPILER_VERSION >=650
156 // By inspection of compiler results - thanks to Peter Schmitteckert
157 #define BOOST_UBLAS_USEFUL_ARRAY_PLACEMENT_NEW
163 // Metrowerks Codewarrior
164 #if defined (__MWERKS__) && ! defined (BOOST_STRICT_CONFIG)
167 #if __MWERKS__ <= 0x3003
168 #define BOOST_UBLAS_UNSUPPORTED_COMPILER 1
174 // Detect other compilers with serious defects - override by defineing BOOST_UBLAS_UNSUPPORTED_COMPILER=0
175 #ifndef BOOST_UBLAS_UNSUPPORTED_COMPILER
176 #if defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) || defined(BOOST_NO_SFINAE) || defined(BOOST_NO_STDC_NAMESPACE)
177 #define BOOST_UBLAS_UNSUPPORTED_COMPILER 1
181 // Cannot continue with an unsupported compiler
182 #if defined(BOOST_UBLAS_UNSUPPORTED_COMPILER) && (BOOST_UBLAS_UNSUPPORTED_COMPILER != 0)
183 #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.
188 // Enable performance options in RELEASE mode
189 #if defined (NDEBUG) || defined (BOOST_UBLAS_NDEBUG)
191 #ifndef BOOST_UBLAS_INLINE
192 #define BOOST_UBLAS_INLINE inline
195 // Do not check sizes!
196 #define BOOST_UBLAS_USE_FAST_SAME
198 // NO runtime error checks with BOOST_UBLAS_CHECK macro
199 #ifndef BOOST_UBLAS_CHECK_ENABLE
200 #define BOOST_UBLAS_CHECK_ENABLE 0
203 // NO type compatibility numeric checks
204 #ifndef BOOST_UBLAS_TYPE_CHECK
205 #define BOOST_UBLAS_TYPE_CHECK 0
209 // Disable performance options in DEBUG mode
212 #ifndef BOOST_UBLAS_INLINE
213 #define BOOST_UBLAS_INLINE
216 // Enable runtime error checks with BOOST_UBLAS_CHECK macro. Check bounds etc
217 #ifndef BOOST_UBLAS_CHECK_ENABLE
218 #define BOOST_UBLAS_CHECK_ENABLE 1
221 // Type compatibiltity numeric checks
222 #ifndef BOOST_UBLAS_TYPE_CHECK
223 #define BOOST_UBLAS_TYPE_CHECK 1
230 * Type compatibility checks
231 * Control type compatibility numeric runtime checks for non dense matrices.
232 * Require additional storage and complexity
234 #if BOOST_UBLAS_TYPE_CHECK
235 template <class Dummy>
236 struct disable_type_check
240 template <class Dummy>
241 bool disable_type_check<Dummy>::value = false;
243 #ifndef BOOST_UBLAS_TYPE_CHECK_EPSILON
244 #define BOOST_UBLAS_TYPE_CHECK_EPSILON (type_traits<real_type>::type_sqrt (std::numeric_limits<real_type>::epsilon ()))
246 #ifndef BOOST_UBLAS_TYPE_CHECK_MIN
247 #define BOOST_UBLAS_TYPE_CHECK_MIN (type_traits<real_type>::type_sqrt ( (std::numeric_limits<real_type>::min) ()))
252 * General Configuration
255 // Proxy shortcuts overload the alreadly heavily over used operator ()
256 //#define BOOST_UBLAS_ENABLE_PROXY_SHORTCUTS
258 // In order to simplify debugging is is possible to simplify expression template
259 // so they are restricted to a single operation
260 // #define BOOST_UBLAS_SIMPLE_ET_DEBUG
262 // Use invariant hoisting.
263 // #define BOOST_UBLAS_USE_INVARIANT_HOISTING
265 // Use Duff's device in element access loops
266 // #define BOOST_UBLAS_USE_DUFF_DEVICE
268 // Choose evaluation method for dense vectors and matrices
269 #if !(defined(BOOST_UBLAS_USE_INDEXING) || defined(BOOST_UBLAS_USE_ITERATING))
270 #define BOOST_UBLAS_USE_INDEXING
272 // #define BOOST_UBLAS_ITERATOR_THRESHOLD 0
274 // Use indexed iterators - unsupported implementation experiment
275 // #define BOOST_UBLAS_USE_INDEXED_ITERATOR
277 // Alignment of bounded_array type
278 #ifndef BOOST_UBLAS_BOUNDED_ARRAY_ALIGN
279 #define BOOST_UBLAS_BOUNDED_ARRAY_ALIGN
282 // Enable different sparse element proxies
283 #ifndef BOOST_UBLAS_NO_ELEMENT_PROXIES
284 // Sparse proxies prevent reference invalidation problems in expressions such as:
285 // a [1] = a [0] = 1 Thanks to Marc Duflot for spotting this.
286 // #define BOOST_UBLAS_STRICT_MAP_ARRAY
287 #define BOOST_UBLAS_STRICT_VECTOR_SPARSE
288 #define BOOST_UBLAS_STRICT_MATRIX_SPARSE
289 // Hermitian matrices use element proxies to allow assignment to conjugate triangle
290 #define BOOST_UBLAS_STRICT_HERMITIAN
293 // Define to configure special settings for reference returning members
294 // #define BOOST_UBLAS_REFERENCE_CONST_MEMBER
295 // #define BOOST_UBLAS_PROXY_CONST_MEMBER
298 // Include type declerations and functions
299 #include <boost/numeric/ublas/fwd.hpp>
300 #include <boost/numeric/ublas/detail/definitions.hpp>