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.

366 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. #include <emmintrin.h>
  78. #include <xmmintrin.h>
  79. #ifdef EIGEN_VECTORIZE_SSE3
  80. #include <pmmintrin.h>
  81. #endif
  82. #ifdef EIGEN_VECTORIZE_SSSE3
  83. #include <tmmintrin.h>
  84. #endif
  85. #ifdef EIGEN_VECTORIZE_SSE4_1
  86. #include <smmintrin.h>
  87. #endif
  88. #ifdef EIGEN_VECTORIZE_SSE4_2
  89. #include <nmmintrin.h>
  90. #endif
  91. } // end extern "C"
  92. #elif defined __ALTIVEC__
  93. #define EIGEN_VECTORIZE
  94. #define EIGEN_VECTORIZE_ALTIVEC
  95. #include <altivec.h>
  96. // We need to #undef all these ugly tokens defined in <altivec.h>
  97. // => use __vector instead of vector
  98. #undef bool
  99. #undef vector
  100. #undef pixel
  101. #elif defined __ARM_NEON__
  102. #define EIGEN_VECTORIZE
  103. #define EIGEN_VECTORIZE_NEON
  104. #include <arm_neon.h>
  105. #endif
  106. #endif
  107. #if (defined _OPENMP) && (!defined EIGEN_DONT_PARALLELIZE)
  108. #define EIGEN_HAS_OPENMP
  109. #endif
  110. #ifdef EIGEN_HAS_OPENMP
  111. #include <omp.h>
  112. #endif
  113. // MSVC for windows mobile does not have the errno.h file
  114. #if !(defined(_MSC_VER) && defined(_WIN32_WCE)) && !defined(__ARMCC_VERSION)
  115. #define EIGEN_HAS_ERRNO
  116. #endif
  117. #ifdef EIGEN_HAS_ERRNO
  118. #include <cerrno>
  119. #endif
  120. #include <cstddef>
  121. #include <cstdlib>
  122. #include <cmath>
  123. #include <cassert>
  124. #include <functional>
  125. #include <iosfwd>
  126. #include <cstring>
  127. #include <string>
  128. #include <limits>
  129. #include <climits> // for CHAR_BIT
  130. // for min/max:
  131. #include <algorithm>
  132. // for outputting debug info
  133. #ifdef EIGEN_DEBUG_ASSIGN
  134. #include <iostream>
  135. #endif
  136. // required for __cpuid, needs to be included after cmath
  137. #if defined(_MSC_VER) && (defined(_M_IX86)||defined(_M_X64))
  138. #include <intrin.h>
  139. #endif
  140. #if defined(_CPPUNWIND) || defined(__EXCEPTIONS)
  141. #define EIGEN_EXCEPTIONS
  142. #endif
  143. #ifdef EIGEN_EXCEPTIONS
  144. #include <new>
  145. #endif
  146. /** \brief Namespace containing all symbols from the %Eigen library. */
  147. namespace Eigen {
  148. inline static const char *SimdInstructionSetsInUse(void) {
  149. #if defined(EIGEN_VECTORIZE_SSE4_2)
  150. return "SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2";
  151. #elif defined(EIGEN_VECTORIZE_SSE4_1)
  152. return "SSE, SSE2, SSE3, SSSE3, SSE4.1";
  153. #elif defined(EIGEN_VECTORIZE_SSSE3)
  154. return "SSE, SSE2, SSE3, SSSE3";
  155. #elif defined(EIGEN_VECTORIZE_SSE3)
  156. return "SSE, SSE2, SSE3";
  157. #elif defined(EIGEN_VECTORIZE_SSE2)
  158. return "SSE, SSE2";
  159. #elif defined(EIGEN_VECTORIZE_ALTIVEC)
  160. return "AltiVec";
  161. #elif defined(EIGEN_VECTORIZE_NEON)
  162. return "ARM NEON";
  163. #else
  164. return "None";
  165. #endif
  166. }
  167. } // end namespace Eigen
  168. #define STAGE10_FULL_EIGEN2_API 10
  169. #define STAGE20_RESOLVE_API_CONFLICTS 20
  170. #define STAGE30_FULL_EIGEN3_API 30
  171. #define STAGE40_FULL_EIGEN3_STRICTNESS 40
  172. #define STAGE99_NO_EIGEN2_SUPPORT 99
  173. #if defined EIGEN2_SUPPORT_STAGE40_FULL_EIGEN3_STRICTNESS
  174. #define EIGEN2_SUPPORT
  175. #define EIGEN2_SUPPORT_STAGE STAGE40_FULL_EIGEN3_STRICTNESS
  176. #elif defined EIGEN2_SUPPORT_STAGE30_FULL_EIGEN3_API
  177. #define EIGEN2_SUPPORT
  178. #define EIGEN2_SUPPORT_STAGE STAGE30_FULL_EIGEN3_API
  179. #elif defined EIGEN2_SUPPORT_STAGE20_RESOLVE_API_CONFLICTS
  180. #define EIGEN2_SUPPORT
  181. #define EIGEN2_SUPPORT_STAGE STAGE20_RESOLVE_API_CONFLICTS
  182. #elif defined EIGEN2_SUPPORT_STAGE10_FULL_EIGEN2_API
  183. #define EIGEN2_SUPPORT
  184. #define EIGEN2_SUPPORT_STAGE STAGE10_FULL_EIGEN2_API
  185. #elif defined EIGEN2_SUPPORT
  186. // default to stage 3, that's what it's always meant
  187. #define EIGEN2_SUPPORT_STAGE30_FULL_EIGEN3_API
  188. #define EIGEN2_SUPPORT_STAGE STAGE30_FULL_EIGEN3_API
  189. #else
  190. #define EIGEN2_SUPPORT_STAGE STAGE99_NO_EIGEN2_SUPPORT
  191. #endif
  192. #ifdef EIGEN2_SUPPORT
  193. #undef minor
  194. #endif
  195. // we use size_t frequently and we'll never remember to prepend it with std:: everytime just to
  196. // ensure QNX/QCC support
  197. using std::size_t;
  198. // gcc 4.6.0 wants std:: for ptrdiff_t
  199. using std::ptrdiff_t;
  200. /** \defgroup Core_Module Core module
  201. * This is the main module of Eigen providing dense matrix and vector support
  202. * (both fixed and dynamic size) with all the features corresponding to a BLAS library
  203. * and much more...
  204. *
  205. * \code
  206. * #include <Eigen/Core>
  207. * \endcode
  208. */
  209. /** \defgroup Support_modules Support modules [category]
  210. * Category of modules which add support for external libraries.
  211. */
  212. #include "src/Core/util/Constants.h"
  213. #include "src/Core/util/ForwardDeclarations.h"
  214. #include "src/Core/util/Meta.h"
  215. #include "src/Core/util/XprHelper.h"
  216. #include "src/Core/util/StaticAssert.h"
  217. #include "src/Core/util/Memory.h"
  218. #include "src/Core/NumTraits.h"
  219. #include "src/Core/MathFunctions.h"
  220. #include "src/Core/GenericPacketMath.h"
  221. #if defined EIGEN_VECTORIZE_SSE
  222. #include "src/Core/arch/SSE/PacketMath.h"
  223. #include "src/Core/arch/SSE/MathFunctions.h"
  224. #include "src/Core/arch/SSE/Complex.h"
  225. #elif defined EIGEN_VECTORIZE_ALTIVEC
  226. #include "src/Core/arch/AltiVec/PacketMath.h"
  227. #include "src/Core/arch/AltiVec/Complex.h"
  228. #elif defined EIGEN_VECTORIZE_NEON
  229. #include "src/Core/arch/NEON/PacketMath.h"
  230. #include "src/Core/arch/NEON/Complex.h"
  231. #endif
  232. #include "src/Core/arch/Default/Settings.h"
  233. #include "src/Core/Functors.h"
  234. #include "src/Core/DenseCoeffsBase.h"
  235. #include "src/Core/DenseBase.h"
  236. #include "src/Core/MatrixBase.h"
  237. #include "src/Core/EigenBase.h"
  238. #ifndef EIGEN_PARSED_BY_DOXYGEN // work around Doxygen bug triggered by Assign.h r814874
  239. // at least confirmed with Doxygen 1.5.5 and 1.5.6
  240. #include "src/Core/Assign.h"
  241. #endif
  242. #include "src/Core/util/BlasUtil.h"
  243. #include "src/Core/DenseStorage.h"
  244. #include "src/Core/NestByValue.h"
  245. #include "src/Core/ForceAlignedAccess.h"
  246. #include "src/Core/ReturnByValue.h"
  247. #include "src/Core/NoAlias.h"
  248. #include "src/Core/PlainObjectBase.h"
  249. #include "src/Core/Matrix.h"
  250. #include "src/Core/Array.h"
  251. #include "src/Core/CwiseBinaryOp.h"
  252. #include "src/Core/CwiseUnaryOp.h"
  253. #include "src/Core/CwiseNullaryOp.h"
  254. #include "src/Core/CwiseUnaryView.h"
  255. #include "src/Core/SelfCwiseBinaryOp.h"
  256. #include "src/Core/Dot.h"
  257. #include "src/Core/StableNorm.h"
  258. #include "src/Core/MapBase.h"
  259. #include "src/Core/Stride.h"
  260. #include "src/Core/Map.h"
  261. #include "src/Core/Block.h"
  262. #include "src/Core/VectorBlock.h"
  263. #include "src/Core/Transpose.h"
  264. #include "src/Core/DiagonalMatrix.h"
  265. #include "src/Core/Diagonal.h"
  266. #include "src/Core/DiagonalProduct.h"
  267. #include "src/Core/PermutationMatrix.h"
  268. #include "src/Core/Transpositions.h"
  269. #include "src/Core/Redux.h"
  270. #include "src/Core/Visitor.h"
  271. #include "src/Core/Fuzzy.h"
  272. #include "src/Core/IO.h"
  273. #include "src/Core/Swap.h"
  274. #include "src/Core/CommaInitializer.h"
  275. #include "src/Core/Flagged.h"
  276. #include "src/Core/ProductBase.h"
  277. #include "src/Core/GeneralProduct.h"
  278. #include "src/Core/TriangularMatrix.h"
  279. #include "src/Core/SelfAdjointView.h"
  280. #include "src/Core/products/GeneralBlockPanelKernel.h"
  281. #include "src/Core/products/Parallelizer.h"
  282. #include "src/Core/products/CoeffBasedProduct.h"
  283. #include "src/Core/products/GeneralMatrixVector.h"
  284. #include "src/Core/products/GeneralMatrixMatrix.h"
  285. #include "src/Core/SolveTriangular.h"
  286. #include "src/Core/products/GeneralMatrixMatrixTriangular.h"
  287. #include "src/Core/products/SelfadjointMatrixVector.h"
  288. #include "src/Core/products/SelfadjointMatrixMatrix.h"
  289. #include "src/Core/products/SelfadjointProduct.h"
  290. #include "src/Core/products/SelfadjointRank2Update.h"
  291. #include "src/Core/products/TriangularMatrixVector.h"
  292. #include "src/Core/products/TriangularMatrixMatrix.h"
  293. #include "src/Core/products/TriangularSolverMatrix.h"
  294. #include "src/Core/products/TriangularSolverVector.h"
  295. #include "src/Core/BandMatrix.h"
  296. #include "src/Core/BooleanRedux.h"
  297. #include "src/Core/Select.h"
  298. #include "src/Core/VectorwiseOp.h"
  299. #include "src/Core/Random.h"
  300. #include "src/Core/Replicate.h"
  301. #include "src/Core/Reverse.h"
  302. #include "src/Core/ArrayBase.h"
  303. #include "src/Core/ArrayWrapper.h"
  304. #ifdef EIGEN_USE_BLAS
  305. #include "src/Core/products/GeneralMatrixMatrix_MKL.h"
  306. #include "src/Core/products/GeneralMatrixVector_MKL.h"
  307. #include "src/Core/products/GeneralMatrixMatrixTriangular_MKL.h"
  308. #include "src/Core/products/SelfadjointMatrixMatrix_MKL.h"
  309. #include "src/Core/products/SelfadjointMatrixVector_MKL.h"
  310. #include "src/Core/products/TriangularMatrixMatrix_MKL.h"
  311. #include "src/Core/products/TriangularMatrixVector_MKL.h"
  312. #include "src/Core/products/TriangularSolverMatrix_MKL.h"
  313. #endif // EIGEN_USE_BLAS
  314. #ifdef EIGEN_USE_MKL_VML
  315. #include "src/Core/Assign_MKL.h"
  316. #endif
  317. #include "src/Core/GlobalFunctions.h"
  318. #include "src/Core/util/ReenableStupidWarnings.h"
  319. #ifdef EIGEN2_SUPPORT
  320. #include "Eigen2Support"
  321. #endif
  322. #endif // EIGEN_CORE_H