You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

380 lines
12 KiB

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