Core 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384
  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 reporting useless warnings.
  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 compiler/OS/arch detections and define most defaults.
  16. #include "src/Core/util/Macros.h"
  17. // This detects SSE/AVX/NEON/etc. and configure alignment settings
  18. #include "src/Core/util/ConfigureVectorization.h"
  19. // We need cuda_runtime.h/hip_runtime.h to ensure that
  20. // the EIGEN_USING_STD macro works properly on the device side
  21. #if defined(EIGEN_CUDACC)
  22. #include <cuda_runtime.h>
  23. #elif defined(EIGEN_HIPCC)
  24. #include <hip/hip_runtime.h>
  25. #endif
  26. #ifdef EIGEN_EXCEPTIONS
  27. #include <new>
  28. #endif
  29. // Disable the ipa-cp-clone optimization flag with MinGW 6.x or newer (enabled by default with -O3)
  30. // See http://eigen.tuxfamily.org/bz/show_bug.cgi?id=556 for details.
  31. #if EIGEN_COMP_MINGW && EIGEN_GNUC_AT_LEAST(4,6) && EIGEN_GNUC_AT_MOST(5,5)
  32. #pragma GCC optimize ("-fno-ipa-cp-clone")
  33. #endif
  34. // Prevent ICC from specializing std::complex operators that silently fail
  35. // on device. This allows us to use our own device-compatible specializations
  36. // instead.
  37. #if defined(EIGEN_COMP_ICC) && defined(EIGEN_GPU_COMPILE_PHASE) \
  38. && !defined(_OVERRIDE_COMPLEX_SPECIALIZATION_)
  39. #define _OVERRIDE_COMPLEX_SPECIALIZATION_ 1
  40. #endif
  41. #include <complex>
  42. // this include file manages BLAS and MKL related macros
  43. // and inclusion of their respective header files
  44. #include "src/Core/util/MKL_support.h"
  45. #if defined(EIGEN_HAS_CUDA_FP16) || defined(EIGEN_HAS_HIP_FP16)
  46. #define EIGEN_HAS_GPU_FP16
  47. #endif
  48. #if defined(EIGEN_HAS_CUDA_BF16) || defined(EIGEN_HAS_HIP_BF16)
  49. #define EIGEN_HAS_GPU_BF16
  50. #endif
  51. #if (defined _OPENMP) && (!defined EIGEN_DONT_PARALLELIZE)
  52. #define EIGEN_HAS_OPENMP
  53. #endif
  54. #ifdef EIGEN_HAS_OPENMP
  55. #include <omp.h>
  56. #endif
  57. // MSVC for windows mobile does not have the errno.h file
  58. #if !(EIGEN_COMP_MSVC && EIGEN_OS_WINCE) && !EIGEN_COMP_ARM
  59. #define EIGEN_HAS_ERRNO
  60. #endif
  61. #ifdef EIGEN_HAS_ERRNO
  62. #include <cerrno>
  63. #endif
  64. #include <cstddef>
  65. #include <cstdlib>
  66. #include <cmath>
  67. #include <cassert>
  68. #include <functional>
  69. #include <sstream>
  70. #ifndef EIGEN_NO_IO
  71. #include <iosfwd>
  72. #endif
  73. #include <cstring>
  74. #include <string>
  75. #include <limits>
  76. #include <climits> // for CHAR_BIT
  77. // for min/max:
  78. #include <algorithm>
  79. #if EIGEN_HAS_CXX11
  80. #include <array>
  81. #endif
  82. // for std::is_nothrow_move_assignable
  83. #ifdef EIGEN_INCLUDE_TYPE_TRAITS
  84. #include <type_traits>
  85. #endif
  86. // for outputting debug info
  87. #ifdef EIGEN_DEBUG_ASSIGN
  88. #include <iostream>
  89. #endif
  90. // required for __cpuid, needs to be included after cmath
  91. #if EIGEN_COMP_MSVC && EIGEN_ARCH_i386_OR_x86_64 && !EIGEN_OS_WINCE
  92. #include <intrin.h>
  93. #endif
  94. #if defined(EIGEN_USE_SYCL)
  95. #undef min
  96. #undef max
  97. #undef isnan
  98. #undef isinf
  99. #undef isfinite
  100. #include <CL/sycl.hpp>
  101. #include <map>
  102. #include <memory>
  103. #include <utility>
  104. #include <thread>
  105. #ifndef EIGEN_SYCL_LOCAL_THREAD_DIM0
  106. #define EIGEN_SYCL_LOCAL_THREAD_DIM0 16
  107. #endif
  108. #ifndef EIGEN_SYCL_LOCAL_THREAD_DIM1
  109. #define EIGEN_SYCL_LOCAL_THREAD_DIM1 16
  110. #endif
  111. #endif
  112. #if defined EIGEN2_SUPPORT_STAGE40_FULL_EIGEN3_STRICTNESS || defined EIGEN2_SUPPORT_STAGE30_FULL_EIGEN3_API || defined EIGEN2_SUPPORT_STAGE20_RESOLVE_API_CONFLICTS || defined EIGEN2_SUPPORT_STAGE10_FULL_EIGEN2_API || defined EIGEN2_SUPPORT
  113. // This will generate an error message:
  114. #error Eigen2-support is only available up to version 3.2. Please go to "http://eigen.tuxfamily.org/index.php?title=Eigen2" for further information
  115. #endif
  116. namespace Eigen {
  117. // we use size_t frequently and we'll never remember to prepend it with std:: every time just to
  118. // ensure QNX/QCC support
  119. using std::size_t;
  120. // gcc 4.6.0 wants std:: for ptrdiff_t
  121. using std::ptrdiff_t;
  122. }
  123. /** \defgroup Core_Module Core module
  124. * This is the main module of Eigen providing dense matrix and vector support
  125. * (both fixed and dynamic size) with all the features corresponding to a BLAS library
  126. * and much more...
  127. *
  128. * \code
  129. * #include <Eigen/Core>
  130. * \endcode
  131. */
  132. #include "src/Core/util/Constants.h"
  133. #include "src/Core/util/Meta.h"
  134. #include "src/Core/util/ForwardDeclarations.h"
  135. #include "src/Core/util/StaticAssert.h"
  136. #include "src/Core/util/XprHelper.h"
  137. #include "src/Core/util/Memory.h"
  138. #include "src/Core/util/IntegralConstant.h"
  139. #include "src/Core/util/SymbolicIndex.h"
  140. #include "src/Core/NumTraits.h"
  141. #include "src/Core/MathFunctions.h"
  142. #include "src/Core/GenericPacketMath.h"
  143. #include "src/Core/MathFunctionsImpl.h"
  144. #include "src/Core/arch/Default/ConjHelper.h"
  145. // Generic half float support
  146. #include "src/Core/arch/Default/Half.h"
  147. #include "src/Core/arch/Default/BFloat16.h"
  148. #include "src/Core/arch/Default/TypeCasting.h"
  149. #include "src/Core/arch/Default/GenericPacketMathFunctionsFwd.h"
  150. #if defined EIGEN_VECTORIZE_AVX512
  151. #include "src/Core/arch/SSE/PacketMath.h"
  152. #include "src/Core/arch/SSE/TypeCasting.h"
  153. #include "src/Core/arch/SSE/Complex.h"
  154. #include "src/Core/arch/AVX/PacketMath.h"
  155. #include "src/Core/arch/AVX/TypeCasting.h"
  156. #include "src/Core/arch/AVX/Complex.h"
  157. #include "src/Core/arch/AVX512/PacketMath.h"
  158. #include "src/Core/arch/AVX512/TypeCasting.h"
  159. #include "src/Core/arch/AVX512/Complex.h"
  160. #include "src/Core/arch/SSE/MathFunctions.h"
  161. #include "src/Core/arch/AVX/MathFunctions.h"
  162. #include "src/Core/arch/AVX512/MathFunctions.h"
  163. #elif defined EIGEN_VECTORIZE_AVX
  164. // Use AVX for floats and doubles, SSE for integers
  165. #include "src/Core/arch/SSE/PacketMath.h"
  166. #include "src/Core/arch/SSE/TypeCasting.h"
  167. #include "src/Core/arch/SSE/Complex.h"
  168. #include "src/Core/arch/AVX/PacketMath.h"
  169. #include "src/Core/arch/AVX/TypeCasting.h"
  170. #include "src/Core/arch/AVX/Complex.h"
  171. #include "src/Core/arch/SSE/MathFunctions.h"
  172. #include "src/Core/arch/AVX/MathFunctions.h"
  173. #elif defined EIGEN_VECTORIZE_SSE
  174. #include "src/Core/arch/SSE/PacketMath.h"
  175. #include "src/Core/arch/SSE/TypeCasting.h"
  176. #include "src/Core/arch/SSE/MathFunctions.h"
  177. #include "src/Core/arch/SSE/Complex.h"
  178. #elif defined(EIGEN_VECTORIZE_ALTIVEC) || defined(EIGEN_VECTORIZE_VSX)
  179. #include "src/Core/arch/AltiVec/PacketMath.h"
  180. #include "src/Core/arch/AltiVec/MathFunctions.h"
  181. #include "src/Core/arch/AltiVec/Complex.h"
  182. #elif defined EIGEN_VECTORIZE_NEON
  183. #include "src/Core/arch/NEON/PacketMath.h"
  184. #include "src/Core/arch/NEON/TypeCasting.h"
  185. #include "src/Core/arch/NEON/MathFunctions.h"
  186. #include "src/Core/arch/NEON/Complex.h"
  187. #elif defined EIGEN_VECTORIZE_SVE
  188. #include "src/Core/arch/SVE/PacketMath.h"
  189. #include "src/Core/arch/SVE/TypeCasting.h"
  190. #include "src/Core/arch/SVE/MathFunctions.h"
  191. #elif defined EIGEN_VECTORIZE_ZVECTOR
  192. #include "src/Core/arch/ZVector/PacketMath.h"
  193. #include "src/Core/arch/ZVector/MathFunctions.h"
  194. #include "src/Core/arch/ZVector/Complex.h"
  195. #elif defined EIGEN_VECTORIZE_MSA
  196. #include "src/Core/arch/MSA/PacketMath.h"
  197. #include "src/Core/arch/MSA/MathFunctions.h"
  198. #include "src/Core/arch/MSA/Complex.h"
  199. #endif
  200. #if defined EIGEN_VECTORIZE_GPU
  201. #include "src/Core/arch/GPU/PacketMath.h"
  202. #include "src/Core/arch/GPU/MathFunctions.h"
  203. #include "src/Core/arch/GPU/TypeCasting.h"
  204. #endif
  205. #if defined(EIGEN_USE_SYCL)
  206. #include "src/Core/arch/SYCL/SyclMemoryModel.h"
  207. #include "src/Core/arch/SYCL/InteropHeaders.h"
  208. #if !defined(EIGEN_DONT_VECTORIZE_SYCL)
  209. #include "src/Core/arch/SYCL/PacketMath.h"
  210. #include "src/Core/arch/SYCL/MathFunctions.h"
  211. #include "src/Core/arch/SYCL/TypeCasting.h"
  212. #endif
  213. #endif
  214. #include "src/Core/arch/Default/Settings.h"
  215. // This file provides generic implementations valid for scalar as well
  216. #include "src/Core/arch/Default/GenericPacketMathFunctions.h"
  217. #include "src/Core/functors/TernaryFunctors.h"
  218. #include "src/Core/functors/BinaryFunctors.h"
  219. #include "src/Core/functors/UnaryFunctors.h"
  220. #include "src/Core/functors/NullaryFunctors.h"
  221. #include "src/Core/functors/StlFunctors.h"
  222. #include "src/Core/functors/AssignmentFunctors.h"
  223. // Specialized functors to enable the processing of complex numbers
  224. // on CUDA devices
  225. #ifdef EIGEN_CUDACC
  226. #include "src/Core/arch/CUDA/Complex.h"
  227. #endif
  228. #include "src/Core/util/IndexedViewHelper.h"
  229. #include "src/Core/util/ReshapedHelper.h"
  230. #include "src/Core/ArithmeticSequence.h"
  231. #ifndef EIGEN_NO_IO
  232. #include "src/Core/IO.h"
  233. #endif
  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. #include "src/Core/Product.h"
  239. #include "src/Core/CoreEvaluators.h"
  240. #include "src/Core/AssignEvaluator.h"
  241. #ifndef EIGEN_PARSED_BY_DOXYGEN // work around Doxygen bug triggered by Assign.h r814874
  242. // at least confirmed with Doxygen 1.5.5 and 1.5.6
  243. #include "src/Core/Assign.h"
  244. #endif
  245. #include "src/Core/ArrayBase.h"
  246. #include "src/Core/util/BlasUtil.h"
  247. #include "src/Core/DenseStorage.h"
  248. #include "src/Core/NestByValue.h"
  249. // #include "src/Core/ForceAlignedAccess.h"
  250. #include "src/Core/ReturnByValue.h"
  251. #include "src/Core/NoAlias.h"
  252. #include "src/Core/PlainObjectBase.h"
  253. #include "src/Core/Matrix.h"
  254. #include "src/Core/Array.h"
  255. #include "src/Core/CwiseTernaryOp.h"
  256. #include "src/Core/CwiseBinaryOp.h"
  257. #include "src/Core/CwiseUnaryOp.h"
  258. #include "src/Core/CwiseNullaryOp.h"
  259. #include "src/Core/CwiseUnaryView.h"
  260. #include "src/Core/SelfCwiseBinaryOp.h"
  261. #include "src/Core/Dot.h"
  262. #include "src/Core/StableNorm.h"
  263. #include "src/Core/Stride.h"
  264. #include "src/Core/MapBase.h"
  265. #include "src/Core/Map.h"
  266. #include "src/Core/Ref.h"
  267. #include "src/Core/Block.h"
  268. #include "src/Core/VectorBlock.h"
  269. #include "src/Core/IndexedView.h"
  270. #include "src/Core/Reshaped.h"
  271. #include "src/Core/Transpose.h"
  272. #include "src/Core/DiagonalMatrix.h"
  273. #include "src/Core/Diagonal.h"
  274. #include "src/Core/DiagonalProduct.h"
  275. #include "src/Core/Redux.h"
  276. #include "src/Core/Visitor.h"
  277. #include "src/Core/Fuzzy.h"
  278. #include "src/Core/Swap.h"
  279. #include "src/Core/CommaInitializer.h"
  280. #include "src/Core/GeneralProduct.h"
  281. #include "src/Core/Solve.h"
  282. #include "src/Core/Inverse.h"
  283. #include "src/Core/SolverBase.h"
  284. #include "src/Core/PermutationMatrix.h"
  285. #include "src/Core/Transpositions.h"
  286. #include "src/Core/TriangularMatrix.h"
  287. #include "src/Core/SelfAdjointView.h"
  288. #include "src/Core/products/GeneralBlockPanelKernel.h"
  289. #include "src/Core/products/Parallelizer.h"
  290. #include "src/Core/ProductEvaluators.h"
  291. #include "src/Core/products/GeneralMatrixVector.h"
  292. #include "src/Core/products/GeneralMatrixMatrix.h"
  293. #include "src/Core/SolveTriangular.h"
  294. #include "src/Core/products/GeneralMatrixMatrixTriangular.h"
  295. #include "src/Core/products/SelfadjointMatrixVector.h"
  296. #include "src/Core/products/SelfadjointMatrixMatrix.h"
  297. #include "src/Core/products/SelfadjointProduct.h"
  298. #include "src/Core/products/SelfadjointRank2Update.h"
  299. #include "src/Core/products/TriangularMatrixVector.h"
  300. #include "src/Core/products/TriangularMatrixMatrix.h"
  301. #include "src/Core/products/TriangularSolverMatrix.h"
  302. #include "src/Core/products/TriangularSolverVector.h"
  303. #include "src/Core/BandMatrix.h"
  304. #include "src/Core/CoreIterators.h"
  305. #include "src/Core/ConditionEstimator.h"
  306. #if defined(EIGEN_VECTORIZE_ALTIVEC) || defined(EIGEN_VECTORIZE_VSX)
  307. #include "src/Core/arch/AltiVec/MatrixProduct.h"
  308. #elif defined EIGEN_VECTORIZE_NEON
  309. #include "src/Core/arch/NEON/GeneralBlockPanelKernel.h"
  310. #endif
  311. #include "src/Core/BooleanRedux.h"
  312. #include "src/Core/Select.h"
  313. #include "src/Core/VectorwiseOp.h"
  314. #include "src/Core/PartialReduxEvaluator.h"
  315. #include "src/Core/Random.h"
  316. #include "src/Core/Replicate.h"
  317. #include "src/Core/Reverse.h"
  318. #include "src/Core/ArrayWrapper.h"
  319. #include "src/Core/StlIterators.h"
  320. #ifdef EIGEN_USE_BLAS
  321. #include "src/Core/products/GeneralMatrixMatrix_BLAS.h"
  322. #include "src/Core/products/GeneralMatrixVector_BLAS.h"
  323. #include "src/Core/products/GeneralMatrixMatrixTriangular_BLAS.h"
  324. #include "src/Core/products/SelfadjointMatrixMatrix_BLAS.h"
  325. #include "src/Core/products/SelfadjointMatrixVector_BLAS.h"
  326. #include "src/Core/products/TriangularMatrixMatrix_BLAS.h"
  327. #include "src/Core/products/TriangularMatrixVector_BLAS.h"
  328. #include "src/Core/products/TriangularSolverMatrix_BLAS.h"
  329. #endif // EIGEN_USE_BLAS
  330. #ifdef EIGEN_USE_MKL_VML
  331. #include "src/Core/Assign_MKL.h"
  332. #endif
  333. #include "src/Core/GlobalFunctions.h"
  334. #include "src/Core/util/ReenableStupidWarnings.h"
  335. #endif // EIGEN_CORE_H