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