Core 12.5 KB
Newer Older
1
// This file is part of Eigen, a lightweight C++ template library
2
// for linear algebra.
3
//
Gael Guennebaud's avatar
Gael Guennebaud committed
4
// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>
5
// Copyright (C) 2007-2011 Benoit Jacob <jacob.benoit.1@gmail.com>
6
//
7
8
9
// This Source Code Form is subject to the terms of the Mozilla
// Public License v. 2.0. If a copy of the MPL was not distributed
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
10

11
12
13
#ifndef EIGEN_CORE_H
#define EIGEN_CORE_H

Benoit Jacob's avatar
Benoit Jacob committed
14
15
// first thing Eigen does: stop the compiler from committing suicide
#include "src/Core/util/DisableStupidWarnings.h"
16

17
18
19
// then include this file where all our macros are defined. It's really important to do it first because
// it's where we do all the alignment settings (platform detection and honoring the user's will if he
// 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
23
24
25
26
27
// Disable the ipa-cp-clone optimization flag with MinGW 6.x or newer (enabled by default with -O3)
// See http://eigen.tuxfamily.org/bz/show_bug.cgi?id=556 for details.
#if defined(__MINGW32__) && EIGEN_GNUC_AT_LEAST(4,6)
  #pragma GCC optimize ("-fno-ipa-cp-clone")
#endif

28
29
#include <complex>

30
31
32
33
// this include file manages BLAS and MKL related macros
// and inclusion of their respective header files
#include "src/Core/util/MKL_support.h"

34
35
36
37
38
39
40
41
// if alignment is disabled, then disable vectorization. Note: EIGEN_ALIGN is the proper check, it takes into
// account both the user's will (EIGEN_DONT_ALIGN) and our own platform checks
#if !EIGEN_ALIGN
  #ifndef EIGEN_DONT_VECTORIZE
    #define EIGEN_DONT_VECTORIZE
  #endif
#endif

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
46
47
48
    // Remember that usage of defined() in a #define is undefined by the standard.
    // a user reported that in 64-bit mode, MSVC doesn't care to define _M_IX86_FP.
    #if (defined(_M_IX86_FP) && (_M_IX86_FP >= 2)) || defined(_M_X64)
      #define EIGEN_SSE2_ON_MSVC_2008_OR_LATER
49
    #endif
50
  #endif
51
52
#else
  // 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
55
    #define EIGEN_SSE2_ON_NON_MSVC_BUT_NOT_OLD_GCC
  #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
63
64

    // Defines symbols for compile-time detection of which instructions are
    // used.
    // EIGEN_VECTORIZE_YY is defined if and only if the instruction set YY is used
65
66
    #define EIGEN_VECTORIZE
    #define EIGEN_VECTORIZE_SSE
67
68
69
    #define EIGEN_VECTORIZE_SSE2

    // Detect sse3/ssse3/sse4:
Benoit Jacob's avatar
Benoit Jacob committed
70
    // gcc and icc defines __SSE3__, ...
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
    // there is no way to know about this on msvc. You can define EIGEN_VECTORIZE_SSE* if you
    // want to force the use of those instructions with msvc.
    #ifdef __SSE3__
      #define EIGEN_VECTORIZE_SSE3
    #endif
    #ifdef __SSSE3__
      #define EIGEN_VECTORIZE_SSSE3
    #endif
    #ifdef __SSE4_1__
      #define EIGEN_VECTORIZE_SSE4_1
    #endif
    #ifdef __SSE4_2__
      #define EIGEN_VECTORIZE_SSE4_2
    #endif

    // include files
Eamon Nerbonne's avatar
Eamon Nerbonne committed
87

Benoit Jacob's avatar
Benoit Jacob committed
88
    // This extern "C" works around a MINGW-w64 compilation issue
Eamon Nerbonne's avatar
Eamon Nerbonne committed
89
90
91
92
93
    // https://sourceforge.net/tracker/index.php?func=detail&aid=3018394&group_id=202880&atid=983354
    // In essence, intrin.h is included by windows.h and also declares intrinsics (just as emmintrin.h etc. below do).
    // However, intrin.h uses an extern "C" declaration, and g++ thus complains of duplicate declarations
    // with conflicting linkage.  The linkage for intrinsics doesn't matter, but at that stage the compiler doesn't know;
    // so, to avoid compile errors when windows.h is included after Eigen/Core, ensure intrinsics are extern "C" here too.
Benoit Jacob's avatar
Benoit Jacob committed
94
    // notice that since these are C headers, the extern "C" is theoretically needed anyways.
Eamon Nerbonne's avatar
Eamon Nerbonne committed
95
    extern "C" {
96
97
      // In theory we should only include immintrin.h and not the other *mmintrin.h header files directly.
      // 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
        #include <immintrin.h>
      #else
        #include <emmintrin.h>
        #include <xmmintrin.h>
        #ifdef  EIGEN_VECTORIZE_SSE3
        #include <pmmintrin.h>
        #endif
        #ifdef EIGEN_VECTORIZE_SSSE3
        #include <tmmintrin.h>
        #endif
        #ifdef EIGEN_VECTORIZE_SSE4_1
        #include <smmintrin.h>
        #endif
        #ifdef EIGEN_VECTORIZE_SSE4_2
        #include <nmmintrin.h>
        #endif
      #endif
Eamon Nerbonne's avatar
Eamon Nerbonne committed
116
    } // end extern "C"
117
  #elif defined __ALTIVEC__
118
119
120
    #define EIGEN_VECTORIZE
    #define EIGEN_VECTORIZE_ALTIVEC
    #include <altivec.h>
121
    // We need to #undef all these ugly tokens defined in <altivec.h>
122
123
124
125
    // => use __vector instead of vector
    #undef bool
    #undef vector
    #undef pixel
126
127
128
  #elif defined  __ARM_NEON__
    #define EIGEN_VECTORIZE
    #define EIGEN_VECTORIZE_NEON
129
    #include <arm_neon.h>
130
131
132
  #endif
#endif

133
#if (defined _OPENMP) && (!defined EIGEN_DONT_PARALLELIZE)
Gael Guennebaud's avatar
Gael Guennebaud committed
134
135
136
137
138
139
140
  #define EIGEN_HAS_OPENMP
#endif

#ifdef EIGEN_HAS_OPENMP
#include <omp.h>
#endif

141
// MSVC for windows mobile does not have the errno.h file
Unknown's avatar
Unknown committed
142
#if !(defined(_MSC_VER) && defined(_WIN32_WCE)) && !defined(__ARMCC_VERSION)
143
144
145
146
#define EIGEN_HAS_ERRNO
#endif

#ifdef EIGEN_HAS_ERRNO
147
#include <cerrno>
148
#endif
149
#include <cstddef>
150
151
152
153
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
154
#include <iosfwd>
155
#include <cstring>
156
#include <string>
157
#include <limits>
158
#include <climits> // for CHAR_BIT
159
160
// for min/max:
#include <algorithm>
161

162
163
// for outputting debug info
#ifdef EIGEN_DEBUG_ASSIGN
164
#include <iostream>
165
166
#endif

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
170
171
  #include <intrin.h>
#endif

172
#if defined(_CPPUNWIND) || defined(__EXCEPTIONS)
173
174
175
176
177
  #define EIGEN_EXCEPTIONS
#endif

#ifdef EIGEN_EXCEPTIONS
  #include <new>
178
179
#endif

180
/** \brief Namespace containing all symbols from the %Eigen library. */
181
182
namespace Eigen {

183
inline static const char *SimdInstructionSetsInUse(void) {
184
#if defined(EIGEN_VECTORIZE_SSE4_2)
185
  return "SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2";
Thomas Capricelli's avatar
Thomas Capricelli committed
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
197
#elif defined(EIGEN_VECTORIZE_NEON)
  return "ARM NEON";
198
199
200
201
202
#else
  return "None";
#endif
}

203
204
} // end namespace Eigen

205
206
207
208
209
#define STAGE10_FULL_EIGEN2_API             10
#define STAGE20_RESOLVE_API_CONFLICTS       20
#define STAGE30_FULL_EIGEN3_API             30
#define STAGE40_FULL_EIGEN3_STRICTNESS      40
#define STAGE99_NO_EIGEN2_SUPPORT           99
210

211
#if   defined EIGEN2_SUPPORT_STAGE40_FULL_EIGEN3_STRICTNESS
212
  #define EIGEN2_SUPPORT
213
214
  #define EIGEN2_SUPPORT_STAGE STAGE40_FULL_EIGEN3_STRICTNESS
#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
224
#elif defined EIGEN2_SUPPORT
  // default to stage 3, that's what it's always meant
225
226
  #define EIGEN2_SUPPORT_STAGE30_FULL_EIGEN3_API
  #define EIGEN2_SUPPORT_STAGE STAGE30_FULL_EIGEN3_API
227
#else
228
  #define EIGEN2_SUPPORT_STAGE STAGE99_NO_EIGEN2_SUPPORT
229
#endif
230

Benoit Jacob's avatar
Benoit Jacob committed
231
232
233
234
#ifdef EIGEN2_SUPPORT
#undef minor
#endif

235
236
237
// we use size_t frequently and we'll never remember to prepend it with std:: everytime just to
// ensure QNX/QCC support
using std::size_t;
238
239
// gcc 4.6.0 wants std:: for ptrdiff_t 
using std::ptrdiff_t;
240

241
/** \defgroup Core_Module Core module
242
243
244
  * This is the main module of Eigen providing dense matrix and vector support
  * (both fixed and dynamic size) with all the features corresponding to a BLAS library
  * and much more...
245
246
247
248
249
250
  *
  * \code
  * #include <Eigen/Core>
  * \endcode
  */

251
252
253
254
#include "src/Core/util/Constants.h"
#include "src/Core/util/ForwardDeclarations.h"
#include "src/Core/util/Meta.h"
#include "src/Core/util/StaticAssert.h"
255
#include "src/Core/util/XprHelper.h"
256
#include "src/Core/util/Memory.h"
257

258
259
#include "src/Core/NumTraits.h"
#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
270
#elif defined EIGEN_VECTORIZE_NEON
  #include "src/Core/arch/NEON/PacketMath.h"
271
  #include "src/Core/arch/NEON/Complex.h"
272
273
#endif

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
283
#ifndef EIGEN_PARSED_BY_DOXYGEN // work around Doxygen bug triggered by Assign.h r814874
                                // 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"
Gael Guennebaud's avatar
Gael Guennebaud committed
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
310
#include "src/Core/Transpose.h"
#include "src/Core/DiagonalMatrix.h"
311
#include "src/Core/Diagonal.h"
312
#include "src/Core/DiagonalProduct.h"
Benoit Jacob's avatar
Benoit Jacob committed
313
#include "src/Core/PermutationMatrix.h"
314
#include "src/Core/Transpositions.h"
315
316
#include "src/Core/Redux.h"
#include "src/Core/Visitor.h"
317
318
#include "src/Core/Fuzzy.h"
#include "src/Core/IO.h"
Benoit Jacob's avatar
Benoit Jacob committed
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
325
#include "src/Core/TriangularMatrix.h"
#include "src/Core/SelfAdjointView.h"
326
#include "src/Core/products/GeneralBlockPanelKernel.h"
Gael Guennebaud's avatar
Gael Guennebaud committed
327
#include "src/Core/products/Parallelizer.h"
328
#include "src/Core/products/CoeffBasedProduct.h"
Gael Guennebaud's avatar
Gael Guennebaud committed
329
330
#include "src/Core/products/GeneralMatrixVector.h"
#include "src/Core/products/GeneralMatrixMatrix.h"
Gael Guennebaud's avatar
Gael Guennebaud committed
331
#include "src/Core/SolveTriangular.h"
332
#include "src/Core/products/GeneralMatrixMatrixTriangular.h"
Gael Guennebaud's avatar
Gael Guennebaud committed
333
334
#include "src/Core/products/SelfadjointMatrixVector.h"
#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"
Gael Guennebaud's avatar
Gael Guennebaud committed
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
345
346
347
348
349
350
351
#include "src/Core/BooleanRedux.h"
#include "src/Core/Select.h"
#include "src/Core/VectorwiseOp.h"
#include "src/Core/Random.h"
#include "src/Core/Replicate.h"
#include "src/Core/Reverse.h"
#include "src/Core/ArrayBase.h"
#include "src/Core/ArrayWrapper.h"
Hauke Heibel's avatar
Hauke Heibel committed
352

353
354
355
356
357
358
359
360
361
362
363
364
#ifdef EIGEN_USE_BLAS
#include "src/Core/products/GeneralMatrixMatrix_MKL.h"
#include "src/Core/products/GeneralMatrixVector_MKL.h"
#include "src/Core/products/GeneralMatrixMatrixTriangular_MKL.h"
#include "src/Core/products/SelfadjointMatrixMatrix_MKL.h"
#include "src/Core/products/SelfadjointMatrixVector_MKL.h"
#include "src/Core/products/TriangularMatrixMatrix_MKL.h"
#include "src/Core/products/TriangularMatrixVector_MKL.h"
#include "src/Core/products/TriangularSolverMatrix_MKL.h"
#endif // EIGEN_USE_BLAS

#ifdef EIGEN_USE_MKL_VML
Unknown's avatar
Unknown committed
365
366
#include "src/Core/Assign_MKL.h"
#endif
Gael Guennebaud's avatar
Gael Guennebaud committed
367

368
#include "src/Core/GlobalFunctions.h"
369

Benoit Jacob's avatar
Benoit Jacob committed
370
#include "src/Core/util/ReenableStupidWarnings.h"
371

372
373
374
375
#ifdef EIGEN2_SUPPORT
#include "Eigen2Support"
#endif

376
#endif // EIGEN_CORE_H