1 | // This file is part of Eigen, a lightweight C++ template library
|
---|
2 | // for linear algebra.
|
---|
3 | //
|
---|
4 | // Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>
|
---|
5 | // Copyright (C) 2007-2011 Benoit Jacob <jacob.benoit.1@gmail.com>
|
---|
6 | //
|
---|
7 | // This Source Code Form is subject to the terms of the Mozilla
|
---|
8 | // Public License v. 2.0. If a copy of the MPL was not distributed
|
---|
9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
---|
10 |
|
---|
11 | #ifndef EIGEN_CORE_H
|
---|
12 | #define EIGEN_CORE_H
|
---|
13 |
|
---|
14 | // first thing Eigen does: stop the compiler from committing suicide
|
---|
15 | #include "src/Core/util/DisableStupidWarnings.h"
|
---|
16 |
|
---|
17 | // then include this file where all our macros are defined. It's really important to do it first because
|
---|
18 | // it's where we do all the alignment settings (platform detection and honoring the user's will if he
|
---|
19 | // defined e.g. EIGEN_DONT_ALIGN) so it needs to be done before we do anything with vectorization.
|
---|
20 | #include "src/Core/util/Macros.h"
|
---|
21 |
|
---|
22 | // Disable the ipa-cp-clone optimization flag with MinGW 6.x or newer (enabled by default with -O3)
|
---|
23 | // See http://eigen.tuxfamily.org/bz/show_bug.cgi?id=556 for details.
|
---|
24 | #if defined(__MINGW32__) && EIGEN_GNUC_AT_LEAST(4,6)
|
---|
25 | #pragma GCC optimize ("-fno-ipa-cp-clone")
|
---|
26 | #endif
|
---|
27 |
|
---|
28 | #include <complex>
|
---|
29 |
|
---|
30 | // this include file manages BLAS and MKL related macros
|
---|
31 | // and inclusion of their respective header files
|
---|
32 | #include "src/Core/util/MKL_support.h"
|
---|
33 |
|
---|
34 | // if alignment is disabled, then disable vectorization. Note: EIGEN_ALIGN is the proper check, it takes into
|
---|
35 | // account both the user's will (EIGEN_DONT_ALIGN) and our own platform checks
|
---|
36 | #if !EIGEN_ALIGN
|
---|
37 | #ifndef EIGEN_DONT_VECTORIZE
|
---|
38 | #define EIGEN_DONT_VECTORIZE
|
---|
39 | #endif
|
---|
40 | #endif
|
---|
41 |
|
---|
42 | #ifdef _MSC_VER
|
---|
43 | #include <malloc.h> // for _aligned_malloc -- need it regardless of whether vectorization is enabled
|
---|
44 | #if (_MSC_VER >= 1500) // 2008 or later
|
---|
45 | // Remember that usage of defined() in a #define is undefined by the standard.
|
---|
46 | // a user reported that in 64-bit mode, MSVC doesn't care to define _M_IX86_FP.
|
---|
47 | #if (defined(_M_IX86_FP) && (_M_IX86_FP >= 2)) || defined(_M_X64)
|
---|
48 | #define EIGEN_SSE2_ON_MSVC_2008_OR_LATER
|
---|
49 | #endif
|
---|
50 | #endif
|
---|
51 | #else
|
---|
52 | // Remember that usage of defined() in a #define is undefined by the standard
|
---|
53 | #if (defined __SSE2__) && ( (!defined __GNUC__) || (defined __INTEL_COMPILER) || EIGEN_GNUC_AT_LEAST(4,2) )
|
---|
54 | #define EIGEN_SSE2_ON_NON_MSVC_BUT_NOT_OLD_GCC
|
---|
55 | #endif
|
---|
56 | #endif
|
---|
57 |
|
---|
58 | #ifndef EIGEN_DONT_VECTORIZE
|
---|
59 |
|
---|
60 | #if defined (EIGEN_SSE2_ON_NON_MSVC_BUT_NOT_OLD_GCC) || defined(EIGEN_SSE2_ON_MSVC_2008_OR_LATER)
|
---|
61 |
|
---|
62 | // Defines symbols for compile-time detection of which instructions are
|
---|
63 | // used.
|
---|
64 | // EIGEN_VECTORIZE_YY is defined if and only if the instruction set YY is used
|
---|
65 | #define EIGEN_VECTORIZE
|
---|
66 | #define EIGEN_VECTORIZE_SSE
|
---|
67 | #define EIGEN_VECTORIZE_SSE2
|
---|
68 |
|
---|
69 | // Detect sse3/ssse3/sse4:
|
---|
70 | // gcc and icc defines __SSE3__, ...
|
---|
71 | // there is no way to know about this on msvc. You can define EIGEN_VECTORIZE_SSE* if you
|
---|
72 | // want to force the use of those instructions with msvc.
|
---|
73 | #ifdef __SSE3__
|
---|
74 | #define EIGEN_VECTORIZE_SSE3
|
---|
75 | #endif
|
---|
76 | #ifdef __SSSE3__
|
---|
77 | #define EIGEN_VECTORIZE_SSSE3
|
---|
78 | #endif
|
---|
79 | #ifdef __SSE4_1__
|
---|
80 | #define EIGEN_VECTORIZE_SSE4_1
|
---|
81 | #endif
|
---|
82 | #ifdef __SSE4_2__
|
---|
83 | #define EIGEN_VECTORIZE_SSE4_2
|
---|
84 | #endif
|
---|
85 |
|
---|
86 | // include files
|
---|
87 |
|
---|
88 | // This extern "C" works around a MINGW-w64 compilation issue
|
---|
89 | // https://sourceforge.net/tracker/index.php?func=detail&aid=3018394&group_id=202880&atid=983354
|
---|
90 | // In essence, intrin.h is included by windows.h and also declares intrinsics (just as emmintrin.h etc. below do).
|
---|
91 | // However, intrin.h uses an extern "C" declaration, and g++ thus complains of duplicate declarations
|
---|
92 | // with conflicting linkage. The linkage for intrinsics doesn't matter, but at that stage the compiler doesn't know;
|
---|
93 | // so, to avoid compile errors when windows.h is included after Eigen/Core, ensure intrinsics are extern "C" here too.
|
---|
94 | // notice that since these are C headers, the extern "C" is theoretically needed anyways.
|
---|
95 | extern "C" {
|
---|
96 | // In theory we should only include immintrin.h and not the other *mmintrin.h header files directly.
|
---|
97 | // Doing so triggers some issues with ICC. However old gcc versions seems to not have this file, thus:
|
---|
98 | #if defined(__INTEL_COMPILER) && __INTEL_COMPILER >= 1110
|
---|
99 | #include <immintrin.h>
|
---|
100 | #else
|
---|
101 | #include <emmintrin.h>
|
---|
102 | #include <xmmintrin.h>
|
---|
103 | #ifdef EIGEN_VECTORIZE_SSE3
|
---|
104 | #include <pmmintrin.h>
|
---|
105 | #endif
|
---|
106 | #ifdef EIGEN_VECTORIZE_SSSE3
|
---|
107 | #include <tmmintrin.h>
|
---|
108 | #endif
|
---|
109 | #ifdef EIGEN_VECTORIZE_SSE4_1
|
---|
110 | #include <smmintrin.h>
|
---|
111 | #endif
|
---|
112 | #ifdef EIGEN_VECTORIZE_SSE4_2
|
---|
113 | #include <nmmintrin.h>
|
---|
114 | #endif
|
---|
115 | #endif
|
---|
116 | } // end extern "C"
|
---|
117 | #elif defined __ALTIVEC__
|
---|
118 | #define EIGEN_VECTORIZE
|
---|
119 | #define EIGEN_VECTORIZE_ALTIVEC
|
---|
120 | #include <altivec.h>
|
---|
121 | // We need to #undef all these ugly tokens defined in <altivec.h>
|
---|
122 | // => use __vector instead of vector
|
---|
123 | #undef bool
|
---|
124 | #undef vector
|
---|
125 | #undef pixel
|
---|
126 | #elif defined __ARM_NEON
|
---|
127 | #define EIGEN_VECTORIZE
|
---|
128 | #define EIGEN_VECTORIZE_NEON
|
---|
129 | #include <arm_neon.h>
|
---|
130 | #endif
|
---|
131 | #endif
|
---|
132 |
|
---|
133 | #if (defined _OPENMP) && (!defined EIGEN_DONT_PARALLELIZE)
|
---|
134 | #define EIGEN_HAS_OPENMP
|
---|
135 | #endif
|
---|
136 |
|
---|
137 | #ifdef EIGEN_HAS_OPENMP
|
---|
138 | #include <omp.h>
|
---|
139 | #endif
|
---|
140 |
|
---|
141 | // MSVC for windows mobile does not have the errno.h file
|
---|
142 | #if !(defined(_MSC_VER) && defined(_WIN32_WCE)) && !defined(__ARMCC_VERSION)
|
---|
143 | #define EIGEN_HAS_ERRNO
|
---|
144 | #endif
|
---|
145 |
|
---|
146 | #ifdef EIGEN_HAS_ERRNO
|
---|
147 | #include <cerrno>
|
---|
148 | #endif
|
---|
149 | #include <cstddef>
|
---|
150 | #include <cstdlib>
|
---|
151 | #include <cmath>
|
---|
152 | #include <cassert>
|
---|
153 | #include <functional>
|
---|
154 | #include <iosfwd>
|
---|
155 | #include <cstring>
|
---|
156 | #include <string>
|
---|
157 | #include <limits>
|
---|
158 | #include <climits> // for CHAR_BIT
|
---|
159 | // for min/max:
|
---|
160 | #include <algorithm>
|
---|
161 |
|
---|
162 | // for outputting debug info
|
---|
163 | #ifdef EIGEN_DEBUG_ASSIGN
|
---|
164 | #include <iostream>
|
---|
165 | #endif
|
---|
166 |
|
---|
167 | // required for __cpuid, needs to be included after cmath
|
---|
168 | #if defined(_MSC_VER) && (defined(_M_IX86)||defined(_M_X64)) && (!defined(_WIN32_WCE))
|
---|
169 | #include <intrin.h>
|
---|
170 | #endif
|
---|
171 |
|
---|
172 | #if defined(_CPPUNWIND) || defined(__EXCEPTIONS)
|
---|
173 | #define EIGEN_EXCEPTIONS
|
---|
174 | #endif
|
---|
175 |
|
---|
176 | #ifdef EIGEN_EXCEPTIONS
|
---|
177 | #include <new>
|
---|
178 | #endif
|
---|
179 |
|
---|
180 | /** \brief Namespace containing all symbols from the %Eigen library. */
|
---|
181 | namespace Eigen {
|
---|
182 |
|
---|
183 | inline static const char *SimdInstructionSetsInUse(void) {
|
---|
184 | #if defined(EIGEN_VECTORIZE_SSE4_2)
|
---|
185 | return "SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2";
|
---|
186 | #elif defined(EIGEN_VECTORIZE_SSE4_1)
|
---|
187 | return "SSE, SSE2, SSE3, SSSE3, SSE4.1";
|
---|
188 | #elif defined(EIGEN_VECTORIZE_SSSE3)
|
---|
189 | return "SSE, SSE2, SSE3, SSSE3";
|
---|
190 | #elif defined(EIGEN_VECTORIZE_SSE3)
|
---|
191 | return "SSE, SSE2, SSE3";
|
---|
192 | #elif defined(EIGEN_VECTORIZE_SSE2)
|
---|
193 | return "SSE, SSE2";
|
---|
194 | #elif defined(EIGEN_VECTORIZE_ALTIVEC)
|
---|
195 | return "AltiVec";
|
---|
196 | #elif defined(EIGEN_VECTORIZE_NEON)
|
---|
197 | return "ARM NEON";
|
---|
198 | #else
|
---|
199 | return "None";
|
---|
200 | #endif
|
---|
201 | }
|
---|
202 |
|
---|
203 | } // end namespace Eigen
|
---|
204 |
|
---|
205 | #define STAGE10_FULL_EIGEN2_API 10
|
---|
206 | #define STAGE20_RESOLVE_API_CONFLICTS 20
|
---|
207 | #define STAGE30_FULL_EIGEN3_API 30
|
---|
208 | #define STAGE40_FULL_EIGEN3_STRICTNESS 40
|
---|
209 | #define STAGE99_NO_EIGEN2_SUPPORT 99
|
---|
210 |
|
---|
211 | #if defined EIGEN2_SUPPORT_STAGE40_FULL_EIGEN3_STRICTNESS
|
---|
212 | #define EIGEN2_SUPPORT
|
---|
213 | #define EIGEN2_SUPPORT_STAGE STAGE40_FULL_EIGEN3_STRICTNESS
|
---|
214 | #elif defined EIGEN2_SUPPORT_STAGE30_FULL_EIGEN3_API
|
---|
215 | #define EIGEN2_SUPPORT
|
---|
216 | #define EIGEN2_SUPPORT_STAGE STAGE30_FULL_EIGEN3_API
|
---|
217 | #elif defined EIGEN2_SUPPORT_STAGE20_RESOLVE_API_CONFLICTS
|
---|
218 | #define EIGEN2_SUPPORT
|
---|
219 | #define EIGEN2_SUPPORT_STAGE STAGE20_RESOLVE_API_CONFLICTS
|
---|
220 | #elif defined EIGEN2_SUPPORT_STAGE10_FULL_EIGEN2_API
|
---|
221 | #define EIGEN2_SUPPORT
|
---|
222 | #define EIGEN2_SUPPORT_STAGE STAGE10_FULL_EIGEN2_API
|
---|
223 | #elif defined EIGEN2_SUPPORT
|
---|
224 | // default to stage 3, that's what it's always meant
|
---|
225 | #define EIGEN2_SUPPORT_STAGE30_FULL_EIGEN3_API
|
---|
226 | #define EIGEN2_SUPPORT_STAGE STAGE30_FULL_EIGEN3_API
|
---|
227 | #else
|
---|
228 | #define EIGEN2_SUPPORT_STAGE STAGE99_NO_EIGEN2_SUPPORT
|
---|
229 | #endif
|
---|
230 |
|
---|
231 | #ifdef EIGEN2_SUPPORT
|
---|
232 | #undef minor
|
---|
233 | #endif
|
---|
234 |
|
---|
235 | // we use size_t frequently and we'll never remember to prepend it with std:: everytime just to
|
---|
236 | // ensure QNX/QCC support
|
---|
237 | using std::size_t;
|
---|
238 | // gcc 4.6.0 wants std:: for ptrdiff_t
|
---|
239 | using std::ptrdiff_t;
|
---|
240 |
|
---|
241 | /** \defgroup Core_Module Core module
|
---|
242 | * This is the main module of Eigen providing dense matrix and vector support
|
---|
243 | * (both fixed and dynamic size) with all the features corresponding to a BLAS library
|
---|
244 | * and much more...
|
---|
245 | *
|
---|
246 | * \code
|
---|
247 | * #include <Eigen/Core>
|
---|
248 | * \endcode
|
---|
249 | */
|
---|
250 |
|
---|
251 | #include "src/Core/util/Constants.h"
|
---|
252 | #include "src/Core/util/ForwardDeclarations.h"
|
---|
253 | #include "src/Core/util/Meta.h"
|
---|
254 | #include "src/Core/util/StaticAssert.h"
|
---|
255 | #include "src/Core/util/XprHelper.h"
|
---|
256 | #include "src/Core/util/Memory.h"
|
---|
257 |
|
---|
258 | #include "src/Core/NumTraits.h"
|
---|
259 | #include "src/Core/MathFunctions.h"
|
---|
260 | #include "src/Core/GenericPacketMath.h"
|
---|
261 |
|
---|
262 | #if defined EIGEN_VECTORIZE_SSE
|
---|
263 | #include "src/Core/arch/SSE/PacketMath.h"
|
---|
264 | #include "src/Core/arch/SSE/MathFunctions.h"
|
---|
265 | #include "src/Core/arch/SSE/Complex.h"
|
---|
266 | #elif defined EIGEN_VECTORIZE_ALTIVEC
|
---|
267 | #include "src/Core/arch/AltiVec/PacketMath.h"
|
---|
268 | #include "src/Core/arch/AltiVec/Complex.h"
|
---|
269 | #elif defined EIGEN_VECTORIZE_NEON
|
---|
270 | #include "src/Core/arch/NEON/PacketMath.h"
|
---|
271 | #include "src/Core/arch/NEON/Complex.h"
|
---|
272 | #endif
|
---|
273 |
|
---|
274 | #include "src/Core/arch/Default/Settings.h"
|
---|
275 |
|
---|
276 | #include "src/Core/Functors.h"
|
---|
277 | #include "src/Core/DenseCoeffsBase.h"
|
---|
278 | #include "src/Core/DenseBase.h"
|
---|
279 | #include "src/Core/MatrixBase.h"
|
---|
280 | #include "src/Core/EigenBase.h"
|
---|
281 |
|
---|
282 | #ifndef EIGEN_PARSED_BY_DOXYGEN // work around Doxygen bug triggered by Assign.h r814874
|
---|
283 | // at least confirmed with Doxygen 1.5.5 and 1.5.6
|
---|
284 | #include "src/Core/Assign.h"
|
---|
285 | #endif
|
---|
286 |
|
---|
287 | #include "src/Core/util/BlasUtil.h"
|
---|
288 | #include "src/Core/DenseStorage.h"
|
---|
289 | #include "src/Core/NestByValue.h"
|
---|
290 | #include "src/Core/ForceAlignedAccess.h"
|
---|
291 | #include "src/Core/ReturnByValue.h"
|
---|
292 | #include "src/Core/NoAlias.h"
|
---|
293 | #include "src/Core/PlainObjectBase.h"
|
---|
294 | #include "src/Core/Matrix.h"
|
---|
295 | #include "src/Core/Array.h"
|
---|
296 | #include "src/Core/CwiseBinaryOp.h"
|
---|
297 | #include "src/Core/CwiseUnaryOp.h"
|
---|
298 | #include "src/Core/CwiseNullaryOp.h"
|
---|
299 | #include "src/Core/CwiseUnaryView.h"
|
---|
300 | #include "src/Core/SelfCwiseBinaryOp.h"
|
---|
301 | #include "src/Core/Dot.h"
|
---|
302 | #include "src/Core/StableNorm.h"
|
---|
303 | #include "src/Core/MapBase.h"
|
---|
304 | #include "src/Core/Stride.h"
|
---|
305 | #include "src/Core/Map.h"
|
---|
306 | #include "src/Core/Block.h"
|
---|
307 | #include "src/Core/VectorBlock.h"
|
---|
308 | #include "src/Core/Ref.h"
|
---|
309 | #include "src/Core/Transpose.h"
|
---|
310 | #include "src/Core/DiagonalMatrix.h"
|
---|
311 | #include "src/Core/Diagonal.h"
|
---|
312 | #include "src/Core/DiagonalProduct.h"
|
---|
313 | #include "src/Core/PermutationMatrix.h"
|
---|
314 | #include "src/Core/Transpositions.h"
|
---|
315 | #include "src/Core/Redux.h"
|
---|
316 | #include "src/Core/Visitor.h"
|
---|
317 | #include "src/Core/Fuzzy.h"
|
---|
318 | #include "src/Core/IO.h"
|
---|
319 | #include "src/Core/Swap.h"
|
---|
320 | #include "src/Core/CommaInitializer.h"
|
---|
321 | #include "src/Core/Flagged.h"
|
---|
322 | #include "src/Core/ProductBase.h"
|
---|
323 | #include "src/Core/GeneralProduct.h"
|
---|
324 | #include "src/Core/TriangularMatrix.h"
|
---|
325 | #include "src/Core/SelfAdjointView.h"
|
---|
326 | #include "src/Core/products/GeneralBlockPanelKernel.h"
|
---|
327 | #include "src/Core/products/Parallelizer.h"
|
---|
328 | #include "src/Core/products/CoeffBasedProduct.h"
|
---|
329 | #include "src/Core/products/GeneralMatrixVector.h"
|
---|
330 | #include "src/Core/products/GeneralMatrixMatrix.h"
|
---|
331 | #include "src/Core/SolveTriangular.h"
|
---|
332 | #include "src/Core/products/GeneralMatrixMatrixTriangular.h"
|
---|
333 | #include "src/Core/products/SelfadjointMatrixVector.h"
|
---|
334 | #include "src/Core/products/SelfadjointMatrixMatrix.h"
|
---|
335 | #include "src/Core/products/SelfadjointProduct.h"
|
---|
336 | #include "src/Core/products/SelfadjointRank2Update.h"
|
---|
337 | #include "src/Core/products/TriangularMatrixVector.h"
|
---|
338 | #include "src/Core/products/TriangularMatrixMatrix.h"
|
---|
339 | #include "src/Core/products/TriangularSolverMatrix.h"
|
---|
340 | #include "src/Core/products/TriangularSolverVector.h"
|
---|
341 | #include "src/Core/BandMatrix.h"
|
---|
342 | #include "src/Core/CoreIterators.h"
|
---|
343 |
|
---|
344 | #include "src/Core/BooleanRedux.h"
|
---|
345 | #include "src/Core/Select.h"
|
---|
346 | #include "src/Core/VectorwiseOp.h"
|
---|
347 | #include "src/Core/Random.h"
|
---|
348 | #include "src/Core/Replicate.h"
|
---|
349 | #include "src/Core/Reverse.h"
|
---|
350 | #include "src/Core/ArrayBase.h"
|
---|
351 | #include "src/Core/ArrayWrapper.h"
|
---|
352 |
|
---|
353 | #ifdef EIGEN_USE_BLAS
|
---|
354 | #include "src/Core/products/GeneralMatrixMatrix_MKL.h"
|
---|
355 | #include "src/Core/products/GeneralMatrixVector_MKL.h"
|
---|
356 | #include "src/Core/products/GeneralMatrixMatrixTriangular_MKL.h"
|
---|
357 | #include "src/Core/products/SelfadjointMatrixMatrix_MKL.h"
|
---|
358 | #include "src/Core/products/SelfadjointMatrixVector_MKL.h"
|
---|
359 | #include "src/Core/products/TriangularMatrixMatrix_MKL.h"
|
---|
360 | #include "src/Core/products/TriangularMatrixVector_MKL.h"
|
---|
361 | #include "src/Core/products/TriangularSolverMatrix_MKL.h"
|
---|
362 | #endif // EIGEN_USE_BLAS
|
---|
363 |
|
---|
364 | #ifdef EIGEN_USE_MKL_VML
|
---|
365 | #include "src/Core/Assign_MKL.h"
|
---|
366 | #endif
|
---|
367 |
|
---|
368 | #include "src/Core/GlobalFunctions.h"
|
---|
369 |
|
---|
370 | #include "src/Core/util/ReenableStupidWarnings.h"
|
---|
371 |
|
---|
372 | #ifdef EIGEN2_SUPPORT
|
---|
373 | #include "Eigen2Support"
|
---|
374 | #endif
|
---|
375 |
|
---|
376 | #endif // EIGEN_CORE_H
|
---|