1 // This file is part of Eigen, a lightweight C++ template library
4 // Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>
5 // Copyright (C) 2007-2011 Benoit Jacob <jacob.benoit.1@gmail.com>
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/.
14 // first thing Eigen does: stop the compiler from committing suicide
15 #include "src/Core/util/DisableStupidWarnings.h"
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"
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")
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"
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
37 #ifndef EIGEN_DONT_VECTORIZE
38 #define EIGEN_DONT_VECTORIZE
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
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
58 #ifndef EIGEN_DONT_VECTORIZE
60 #if defined (EIGEN_SSE2_ON_NON_MSVC_BUT_NOT_OLD_GCC) || defined(EIGEN_SSE2_ON_MSVC_2008_OR_LATER)
62 // Defines symbols for compile-time detection of which instructions are
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
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.
74 #define EIGEN_VECTORIZE_SSE3
77 #define EIGEN_VECTORIZE_SSSE3
80 #define EIGEN_VECTORIZE_SSE4_1
83 #define EIGEN_VECTORIZE_SSE4_2
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.
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>
101 #include <emmintrin.h>
102 #include <xmmintrin.h>
103 #ifdef EIGEN_VECTORIZE_SSE3
104 #include <pmmintrin.h>
106 #ifdef EIGEN_VECTORIZE_SSSE3
107 #include <tmmintrin.h>
109 #ifdef EIGEN_VECTORIZE_SSE4_1
110 #include <smmintrin.h>
112 #ifdef EIGEN_VECTORIZE_SSE4_2
113 #include <nmmintrin.h>
117 #elif defined __ALTIVEC__
118 #define EIGEN_VECTORIZE
119 #define EIGEN_VECTORIZE_ALTIVEC
121 // We need to #undef all these ugly tokens defined in <altivec.h>
122 // => use __vector instead of vector
126 #elif defined __ARM_NEON
127 #define EIGEN_VECTORIZE
128 #define EIGEN_VECTORIZE_NEON
129 #include <arm_neon.h>
133 #if (defined _OPENMP) && (!defined EIGEN_DONT_PARALLELIZE)
134 #define EIGEN_HAS_OPENMP
137 #ifdef EIGEN_HAS_OPENMP
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
146 #ifdef EIGEN_HAS_ERRNO
153 #include <functional>
158 #include <climits> // for CHAR_BIT
162 // for outputting debug info
163 #ifdef EIGEN_DEBUG_ASSIGN
167 // required for __cpuid, needs to be included after cmath
168 #if defined(_MSC_VER) && (defined(_M_IX86)||defined(_M_X64)) && (!defined(_WIN32_WCE))
172 #if defined(_CPPUNWIND) || defined(__EXCEPTIONS)
173 #define EIGEN_EXCEPTIONS
176 #ifdef EIGEN_EXCEPTIONS
180 /** \brief Namespace containing all symbols from the %Eigen library. */
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)
194 #elif defined(EIGEN_VECTORIZE_ALTIVEC)
196 #elif defined(EIGEN_VECTORIZE_NEON)
203 } // end namespace Eigen
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
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
228 #define EIGEN2_SUPPORT_STAGE STAGE99_NO_EIGEN2_SUPPORT
231 #ifdef EIGEN2_SUPPORT
235 // we use size_t frequently and we'll never remember to prepend it with std:: everytime just to
236 // ensure QNX/QCC support
238 // gcc 4.6.0 wants std:: for ptrdiff_t
239 using std::ptrdiff_t;
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
247 * #include <Eigen/Core>
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"
258 #include "src/Core/NumTraits.h"
259 #include "src/Core/MathFunctions.h"
260 #include "src/Core/GenericPacketMath.h"
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"
274 #include "src/Core/arch/Default/Settings.h"
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"
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"
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"
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"
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
364 #ifdef EIGEN_USE_MKL_VML
365 #include "src/Core/Assign_MKL.h"
368 #include "src/Core/GlobalFunctions.h"
370 #include "src/Core/util/ReenableStupidWarnings.h"
372 #ifdef EIGEN2_SUPPORT
373 #include "Eigen2Support"
376 #endif // EIGEN_CORE_H