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