Core 13 KB

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