@smake/eigen 1.0.2 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (287) hide show
  1. package/README.md +1 -1
  2. package/eigen/COPYING.APACHE +203 -0
  3. package/eigen/COPYING.BSD +26 -0
  4. package/eigen/COPYING.GPL +674 -0
  5. package/eigen/COPYING.LGPL +502 -0
  6. package/eigen/COPYING.MINPACK +51 -0
  7. package/eigen/COPYING.MPL2 +373 -0
  8. package/eigen/COPYING.README +18 -0
  9. package/eigen/Eigen/Cholesky +0 -1
  10. package/eigen/Eigen/Core +108 -266
  11. package/eigen/Eigen/Eigenvalues +0 -1
  12. package/eigen/Eigen/Geometry +3 -6
  13. package/eigen/Eigen/Householder +0 -1
  14. package/eigen/Eigen/Jacobi +0 -1
  15. package/eigen/Eigen/KLUSupport +41 -0
  16. package/eigen/Eigen/LU +2 -5
  17. package/eigen/Eigen/OrderingMethods +0 -3
  18. package/eigen/Eigen/PaStiXSupport +1 -0
  19. package/eigen/Eigen/PardisoSupport +0 -0
  20. package/eigen/Eigen/QR +0 -1
  21. package/eigen/Eigen/QtAlignedMalloc +0 -1
  22. package/eigen/Eigen/SVD +0 -1
  23. package/eigen/Eigen/Sparse +0 -2
  24. package/eigen/Eigen/SparseCholesky +0 -8
  25. package/eigen/Eigen/SparseLU +4 -0
  26. package/eigen/Eigen/src/Cholesky/LDLT.h +42 -27
  27. package/eigen/Eigen/src/Cholesky/LLT.h +39 -23
  28. package/eigen/Eigen/src/CholmodSupport/CholmodSupport.h +90 -47
  29. package/eigen/Eigen/src/Core/ArithmeticSequence.h +413 -0
  30. package/eigen/Eigen/src/Core/Array.h +99 -11
  31. package/eigen/Eigen/src/Core/ArrayBase.h +1 -1
  32. package/eigen/Eigen/src/Core/ArrayWrapper.h +21 -21
  33. package/eigen/Eigen/src/Core/Assign.h +1 -1
  34. package/eigen/Eigen/src/Core/AssignEvaluator.h +125 -50
  35. package/eigen/Eigen/src/Core/Assign_MKL.h +10 -10
  36. package/eigen/Eigen/src/Core/BandMatrix.h +16 -16
  37. package/eigen/Eigen/src/Core/Block.h +56 -60
  38. package/eigen/Eigen/src/Core/BooleanRedux.h +29 -31
  39. package/eigen/Eigen/src/Core/CommaInitializer.h +7 -3
  40. package/eigen/Eigen/src/Core/CoreEvaluators.h +325 -272
  41. package/eigen/Eigen/src/Core/CoreIterators.h +5 -0
  42. package/eigen/Eigen/src/Core/CwiseBinaryOp.h +21 -22
  43. package/eigen/Eigen/src/Core/CwiseNullaryOp.h +153 -18
  44. package/eigen/Eigen/src/Core/CwiseUnaryOp.h +6 -6
  45. package/eigen/Eigen/src/Core/CwiseUnaryView.h +12 -10
  46. package/eigen/Eigen/src/Core/DenseBase.h +128 -39
  47. package/eigen/Eigen/src/Core/DenseCoeffsBase.h +25 -21
  48. package/eigen/Eigen/src/Core/DenseStorage.h +150 -68
  49. package/eigen/Eigen/src/Core/Diagonal.h +21 -23
  50. package/eigen/Eigen/src/Core/DiagonalMatrix.h +50 -2
  51. package/eigen/Eigen/src/Core/DiagonalProduct.h +1 -1
  52. package/eigen/Eigen/src/Core/Dot.h +10 -10
  53. package/eigen/Eigen/src/Core/EigenBase.h +10 -9
  54. package/eigen/Eigen/src/Core/ForceAlignedAccess.h +8 -4
  55. package/eigen/Eigen/src/Core/Fuzzy.h +3 -3
  56. package/eigen/Eigen/src/Core/GeneralProduct.h +20 -10
  57. package/eigen/Eigen/src/Core/GenericPacketMath.h +597 -147
  58. package/eigen/Eigen/src/Core/GlobalFunctions.h +40 -33
  59. package/eigen/Eigen/src/Core/IO.h +40 -7
  60. package/eigen/Eigen/src/Core/IndexedView.h +237 -0
  61. package/eigen/Eigen/src/Core/Inverse.h +9 -10
  62. package/eigen/Eigen/src/Core/Map.h +7 -7
  63. package/eigen/Eigen/src/Core/MapBase.h +5 -3
  64. package/eigen/Eigen/src/Core/MathFunctions.h +756 -120
  65. package/eigen/Eigen/src/Core/MathFunctionsImpl.h +118 -19
  66. package/eigen/Eigen/src/Core/Matrix.h +131 -25
  67. package/eigen/Eigen/src/Core/MatrixBase.h +19 -2
  68. package/eigen/Eigen/src/Core/NestByValue.h +25 -50
  69. package/eigen/Eigen/src/Core/NoAlias.h +4 -3
  70. package/eigen/Eigen/src/Core/NumTraits.h +107 -20
  71. package/eigen/Eigen/src/Core/PartialReduxEvaluator.h +232 -0
  72. package/eigen/Eigen/src/Core/PermutationMatrix.h +3 -3
  73. package/eigen/Eigen/src/Core/PlainObjectBase.h +145 -54
  74. package/eigen/Eigen/src/Core/Product.h +30 -25
  75. package/eigen/Eigen/src/Core/ProductEvaluators.h +183 -142
  76. package/eigen/Eigen/src/Core/Random.h +37 -1
  77. package/eigen/Eigen/src/Core/Redux.h +180 -170
  78. package/eigen/Eigen/src/Core/Ref.h +118 -21
  79. package/eigen/Eigen/src/Core/Replicate.h +8 -8
  80. package/eigen/Eigen/src/Core/Reshaped.h +454 -0
  81. package/eigen/Eigen/src/Core/ReturnByValue.h +7 -5
  82. package/eigen/Eigen/src/Core/Reverse.h +18 -12
  83. package/eigen/Eigen/src/Core/Select.h +8 -6
  84. package/eigen/Eigen/src/Core/SelfAdjointView.h +33 -20
  85. package/eigen/Eigen/src/Core/Solve.h +14 -14
  86. package/eigen/Eigen/src/Core/SolveTriangular.h +13 -13
  87. package/eigen/Eigen/src/Core/SolverBase.h +41 -3
  88. package/eigen/Eigen/src/Core/StableNorm.h +100 -70
  89. package/eigen/Eigen/src/Core/StlIterators.h +463 -0
  90. package/eigen/Eigen/src/Core/Stride.h +9 -4
  91. package/eigen/Eigen/src/Core/Swap.h +5 -4
  92. package/eigen/Eigen/src/Core/Transpose.h +86 -27
  93. package/eigen/Eigen/src/Core/Transpositions.h +26 -8
  94. package/eigen/Eigen/src/Core/TriangularMatrix.h +88 -72
  95. package/eigen/Eigen/src/Core/VectorBlock.h +5 -5
  96. package/eigen/Eigen/src/Core/VectorwiseOp.h +159 -70
  97. package/eigen/Eigen/src/Core/Visitor.h +137 -29
  98. package/eigen/Eigen/src/Core/arch/AVX/Complex.h +50 -129
  99. package/eigen/Eigen/src/Core/arch/AVX/MathFunctions.h +126 -337
  100. package/eigen/Eigen/src/Core/arch/AVX/PacketMath.h +1092 -155
  101. package/eigen/Eigen/src/Core/arch/AVX/TypeCasting.h +65 -1
  102. package/eigen/Eigen/src/Core/arch/AVX512/Complex.h +422 -0
  103. package/eigen/Eigen/src/Core/arch/AVX512/MathFunctions.h +186 -213
  104. package/eigen/Eigen/src/Core/arch/AVX512/PacketMath.h +1250 -252
  105. package/eigen/Eigen/src/Core/arch/AVX512/TypeCasting.h +89 -0
  106. package/eigen/Eigen/src/Core/arch/AltiVec/Complex.h +152 -165
  107. package/eigen/Eigen/src/Core/arch/AltiVec/MathFunctions.h +19 -251
  108. package/eigen/Eigen/src/Core/arch/AltiVec/MatrixProduct.h +2937 -0
  109. package/eigen/Eigen/src/Core/arch/AltiVec/MatrixProductCommon.h +221 -0
  110. package/eigen/Eigen/src/Core/arch/AltiVec/MatrixProductMMA.h +629 -0
  111. package/eigen/Eigen/src/Core/arch/AltiVec/PacketMath.h +2042 -392
  112. package/eigen/Eigen/src/Core/arch/CUDA/Complex.h +235 -80
  113. package/eigen/Eigen/src/Core/arch/Default/BFloat16.h +700 -0
  114. package/eigen/Eigen/src/Core/arch/Default/ConjHelper.h +102 -14
  115. package/eigen/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h +1649 -0
  116. package/eigen/Eigen/src/Core/arch/Default/GenericPacketMathFunctionsFwd.h +110 -0
  117. package/eigen/Eigen/src/Core/arch/Default/Half.h +942 -0
  118. package/eigen/Eigen/src/Core/arch/Default/Settings.h +1 -1
  119. package/eigen/Eigen/src/Core/arch/Default/TypeCasting.h +120 -0
  120. package/eigen/Eigen/src/Core/arch/{CUDA → GPU}/MathFunctions.h +16 -4
  121. package/eigen/Eigen/src/Core/arch/GPU/PacketMath.h +1685 -0
  122. package/eigen/Eigen/src/Core/arch/GPU/TypeCasting.h +80 -0
  123. package/eigen/Eigen/src/Core/arch/HIP/hcc/math_constants.h +23 -0
  124. package/eigen/Eigen/src/Core/arch/MSA/Complex.h +648 -0
  125. package/eigen/Eigen/src/Core/arch/MSA/MathFunctions.h +387 -0
  126. package/eigen/Eigen/src/Core/arch/MSA/PacketMath.h +1233 -0
  127. package/eigen/Eigen/src/Core/arch/NEON/Complex.h +313 -219
  128. package/eigen/Eigen/src/Core/arch/NEON/GeneralBlockPanelKernel.h +183 -0
  129. package/eigen/Eigen/src/Core/arch/NEON/MathFunctions.h +54 -70
  130. package/eigen/Eigen/src/Core/arch/NEON/PacketMath.h +4376 -549
  131. package/eigen/Eigen/src/Core/arch/NEON/TypeCasting.h +1419 -0
  132. package/eigen/Eigen/src/Core/arch/SSE/Complex.h +59 -179
  133. package/eigen/Eigen/src/Core/arch/SSE/MathFunctions.h +65 -428
  134. package/eigen/Eigen/src/Core/arch/SSE/PacketMath.h +893 -283
  135. package/eigen/Eigen/src/Core/arch/SSE/TypeCasting.h +65 -0
  136. package/eigen/Eigen/src/Core/arch/SVE/MathFunctions.h +44 -0
  137. package/eigen/Eigen/src/Core/arch/SVE/PacketMath.h +752 -0
  138. package/eigen/Eigen/src/Core/arch/SVE/TypeCasting.h +49 -0
  139. package/eigen/Eigen/src/Core/arch/SYCL/InteropHeaders.h +232 -0
  140. package/eigen/Eigen/src/Core/arch/SYCL/MathFunctions.h +301 -0
  141. package/eigen/Eigen/src/Core/arch/SYCL/PacketMath.h +670 -0
  142. package/eigen/Eigen/src/Core/arch/SYCL/SyclMemoryModel.h +694 -0
  143. package/eigen/Eigen/src/Core/arch/SYCL/TypeCasting.h +85 -0
  144. package/eigen/Eigen/src/Core/arch/ZVector/Complex.h +212 -183
  145. package/eigen/Eigen/src/Core/arch/ZVector/MathFunctions.h +101 -5
  146. package/eigen/Eigen/src/Core/arch/ZVector/PacketMath.h +510 -395
  147. package/eigen/Eigen/src/Core/functors/AssignmentFunctors.h +11 -2
  148. package/eigen/Eigen/src/Core/functors/BinaryFunctors.h +112 -46
  149. package/eigen/Eigen/src/Core/functors/NullaryFunctors.h +31 -30
  150. package/eigen/Eigen/src/Core/functors/StlFunctors.h +32 -2
  151. package/eigen/Eigen/src/Core/functors/UnaryFunctors.h +354 -15
  152. package/eigen/Eigen/src/Core/products/GeneralBlockPanelKernel.h +1073 -585
  153. package/eigen/Eigen/src/Core/products/GeneralMatrixMatrix.h +29 -7
  154. package/eigen/Eigen/src/Core/products/GeneralMatrixMatrixTriangular.h +4 -4
  155. package/eigen/Eigen/src/Core/products/GeneralMatrixMatrixTriangular_BLAS.h +1 -1
  156. package/eigen/Eigen/src/Core/products/GeneralMatrixVector.h +382 -483
  157. package/eigen/Eigen/src/Core/products/Parallelizer.h +23 -9
  158. package/eigen/Eigen/src/Core/products/SelfadjointMatrixMatrix.h +23 -6
  159. package/eigen/Eigen/src/Core/products/SelfadjointMatrixVector.h +8 -6
  160. package/eigen/Eigen/src/Core/products/SelfadjointProduct.h +2 -2
  161. package/eigen/Eigen/src/Core/products/SelfadjointRank2Update.h +5 -4
  162. package/eigen/Eigen/src/Core/products/TriangularMatrixMatrix.h +3 -3
  163. package/eigen/Eigen/src/Core/products/TriangularSolverMatrix.h +5 -3
  164. package/eigen/Eigen/src/Core/products/TriangularSolverVector.h +13 -10
  165. package/eigen/Eigen/src/Core/util/BlasUtil.h +208 -124
  166. package/eigen/Eigen/src/Core/util/ConfigureVectorization.h +512 -0
  167. package/eigen/Eigen/src/Core/util/Constants.h +25 -9
  168. package/eigen/Eigen/src/Core/util/DisableStupidWarnings.h +14 -2
  169. package/eigen/Eigen/src/Core/util/ForwardDeclarations.h +28 -4
  170. package/eigen/Eigen/src/Core/util/IndexedViewHelper.h +186 -0
  171. package/eigen/Eigen/src/Core/util/IntegralConstant.h +272 -0
  172. package/eigen/Eigen/src/Core/util/MKL_support.h +8 -1
  173. package/eigen/Eigen/src/Core/util/Macros.h +661 -250
  174. package/eigen/Eigen/src/Core/util/Memory.h +222 -52
  175. package/eigen/Eigen/src/Core/util/Meta.h +349 -105
  176. package/eigen/Eigen/src/Core/util/ReshapedHelper.h +51 -0
  177. package/eigen/Eigen/src/Core/util/StaticAssert.h +8 -5
  178. package/eigen/Eigen/src/Core/util/SymbolicIndex.h +293 -0
  179. package/eigen/Eigen/src/Core/util/XprHelper.h +48 -30
  180. package/eigen/Eigen/src/Eigenvalues/ComplexEigenSolver.h +1 -1
  181. package/eigen/Eigen/src/Eigenvalues/ComplexSchur.h +1 -1
  182. package/eigen/Eigen/src/Eigenvalues/EigenSolver.h +2 -2
  183. package/eigen/Eigen/src/Eigenvalues/GeneralizedSelfAdjointEigenSolver.h +1 -1
  184. package/eigen/Eigen/src/Eigenvalues/HessenbergDecomposition.h +2 -2
  185. package/eigen/Eigen/src/Eigenvalues/MatrixBaseEigenvalues.h +2 -2
  186. package/eigen/Eigen/src/Eigenvalues/RealQZ.h +9 -6
  187. package/eigen/Eigen/src/Eigenvalues/RealSchur.h +10 -5
  188. package/eigen/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h +75 -42
  189. package/eigen/Eigen/src/Eigenvalues/Tridiagonalization.h +20 -15
  190. package/eigen/Eigen/src/Geometry/AlignedBox.h +99 -5
  191. package/eigen/Eigen/src/Geometry/AngleAxis.h +4 -4
  192. package/eigen/Eigen/src/Geometry/EulerAngles.h +3 -3
  193. package/eigen/Eigen/src/Geometry/Homogeneous.h +15 -11
  194. package/eigen/Eigen/src/Geometry/Hyperplane.h +1 -1
  195. package/eigen/Eigen/src/Geometry/OrthoMethods.h +3 -2
  196. package/eigen/Eigen/src/Geometry/ParametrizedLine.h +39 -2
  197. package/eigen/Eigen/src/Geometry/Quaternion.h +52 -14
  198. package/eigen/Eigen/src/Geometry/Rotation2D.h +3 -3
  199. package/eigen/Eigen/src/Geometry/Scaling.h +22 -4
  200. package/eigen/Eigen/src/Geometry/Transform.h +86 -65
  201. package/eigen/Eigen/src/Geometry/Translation.h +6 -6
  202. package/eigen/Eigen/src/Geometry/arch/Geometry_SIMD.h +168 -0
  203. package/eigen/Eigen/src/Householder/BlockHouseholder.h +9 -2
  204. package/eigen/Eigen/src/Householder/Householder.h +8 -4
  205. package/eigen/Eigen/src/Householder/HouseholderSequence.h +123 -48
  206. package/eigen/Eigen/src/IterativeLinearSolvers/BasicPreconditioners.h +15 -15
  207. package/eigen/Eigen/src/IterativeLinearSolvers/BiCGSTAB.h +7 -23
  208. package/eigen/Eigen/src/IterativeLinearSolvers/ConjugateGradient.h +5 -22
  209. package/eigen/Eigen/src/IterativeLinearSolvers/IncompleteCholesky.h +41 -47
  210. package/eigen/Eigen/src/IterativeLinearSolvers/IncompleteLUT.h +51 -60
  211. package/eigen/Eigen/src/IterativeLinearSolvers/IterativeSolverBase.h +70 -20
  212. package/eigen/Eigen/src/IterativeLinearSolvers/LeastSquareConjugateGradient.h +2 -20
  213. package/eigen/Eigen/src/IterativeLinearSolvers/SolveWithGuess.h +11 -9
  214. package/eigen/Eigen/src/Jacobi/Jacobi.h +31 -10
  215. package/eigen/Eigen/src/KLUSupport/KLUSupport.h +358 -0
  216. package/eigen/Eigen/src/LU/Determinant.h +35 -19
  217. package/eigen/Eigen/src/LU/FullPivLU.h +29 -43
  218. package/eigen/Eigen/src/LU/InverseImpl.h +25 -8
  219. package/eigen/Eigen/src/LU/PartialPivLU.h +67 -57
  220. package/eigen/Eigen/src/LU/arch/InverseSize4.h +351 -0
  221. package/eigen/Eigen/src/OrderingMethods/Amd.h +7 -17
  222. package/eigen/Eigen/src/OrderingMethods/Eigen_Colamd.h +297 -277
  223. package/eigen/Eigen/src/OrderingMethods/Ordering.h +6 -10
  224. package/eigen/Eigen/src/PaStiXSupport/PaStiXSupport.h +1 -1
  225. package/eigen/Eigen/src/PardisoSupport/PardisoSupport.h +10 -9
  226. package/eigen/Eigen/src/QR/ColPivHouseholderQR.h +41 -20
  227. package/eigen/Eigen/src/QR/CompleteOrthogonalDecomposition.h +100 -27
  228. package/eigen/Eigen/src/QR/FullPivHouseholderQR.h +59 -22
  229. package/eigen/Eigen/src/QR/HouseholderQR.h +48 -23
  230. package/eigen/Eigen/src/SPQRSupport/SuiteSparseQRSupport.h +25 -3
  231. package/eigen/Eigen/src/SVD/BDCSVD.h +137 -48
  232. package/eigen/Eigen/src/SVD/JacobiSVD.h +22 -14
  233. package/eigen/Eigen/src/SVD/SVDBase.h +82 -21
  234. package/eigen/Eigen/src/SVD/UpperBidiagonalization.h +3 -3
  235. package/eigen/Eigen/src/SparseCholesky/SimplicialCholesky.h +16 -8
  236. package/eigen/Eigen/src/SparseCholesky/SimplicialCholesky_impl.h +11 -36
  237. package/eigen/Eigen/src/SparseCore/CompressedStorage.h +16 -0
  238. package/eigen/Eigen/src/SparseCore/ConservativeSparseSparseProduct.h +6 -6
  239. package/eigen/Eigen/src/SparseCore/SparseAssign.h +81 -27
  240. package/eigen/Eigen/src/SparseCore/SparseBlock.h +25 -57
  241. package/eigen/Eigen/src/SparseCore/SparseCompressedBase.h +40 -11
  242. package/eigen/Eigen/src/SparseCore/SparseCwiseBinaryOp.h +11 -15
  243. package/eigen/Eigen/src/SparseCore/SparseCwiseUnaryOp.h +2 -2
  244. package/eigen/Eigen/src/SparseCore/SparseDenseProduct.h +30 -8
  245. package/eigen/Eigen/src/SparseCore/SparseMatrix.h +124 -10
  246. package/eigen/Eigen/src/SparseCore/SparseMatrixBase.h +5 -12
  247. package/eigen/Eigen/src/SparseCore/SparseProduct.h +13 -1
  248. package/eigen/Eigen/src/SparseCore/SparseRef.h +7 -7
  249. package/eigen/Eigen/src/SparseCore/SparseSelfAdjointView.h +3 -0
  250. package/eigen/Eigen/src/SparseCore/SparseUtil.h +8 -0
  251. package/eigen/Eigen/src/SparseCore/SparseVector.h +1 -1
  252. package/eigen/Eigen/src/SparseLU/SparseLU.h +160 -10
  253. package/eigen/Eigen/src/SparseLU/SparseLU_Memory.h +1 -1
  254. package/eigen/Eigen/src/SparseLU/SparseLU_SupernodalMatrix.h +76 -2
  255. package/eigen/Eigen/src/SparseLU/SparseLU_column_dfs.h +2 -2
  256. package/eigen/Eigen/src/SparseLU/SparseLU_gemm_kernel.h +1 -1
  257. package/eigen/Eigen/src/SparseLU/SparseLU_panel_bmod.h +1 -1
  258. package/eigen/Eigen/src/SparseQR/SparseQR.h +19 -6
  259. package/eigen/Eigen/src/StlSupport/StdDeque.h +2 -14
  260. package/eigen/Eigen/src/StlSupport/StdList.h +2 -2
  261. package/eigen/Eigen/src/StlSupport/StdVector.h +2 -2
  262. package/eigen/Eigen/src/SuperLUSupport/SuperLUSupport.h +6 -8
  263. package/eigen/Eigen/src/UmfPackSupport/UmfPackSupport.h +175 -39
  264. package/eigen/Eigen/src/misc/lapacke.h +5 -4
  265. package/eigen/Eigen/src/plugins/ArrayCwiseBinaryOps.h +27 -1
  266. package/eigen/Eigen/src/plugins/ArrayCwiseUnaryOps.h +155 -11
  267. package/eigen/Eigen/src/plugins/BlockMethods.h +626 -242
  268. package/eigen/Eigen/src/plugins/CommonCwiseUnaryOps.h +14 -0
  269. package/eigen/Eigen/src/plugins/IndexedViewMethods.h +262 -0
  270. package/eigen/Eigen/src/plugins/MatrixCwiseBinaryOps.h +4 -4
  271. package/eigen/Eigen/src/plugins/MatrixCwiseUnaryOps.h +10 -0
  272. package/eigen/Eigen/src/plugins/ReshapedMethods.h +149 -0
  273. package/eigen/README.md +5 -0
  274. package/lib/LibEigen.d.ts +4 -0
  275. package/lib/LibEigen.js +14 -0
  276. package/lib/index.d.ts +1 -1
  277. package/lib/index.js +7 -3
  278. package/package.json +2 -10
  279. package/eigen/Eigen/CMakeLists.txt +0 -19
  280. package/eigen/Eigen/src/Core/arch/CUDA/Half.h +0 -675
  281. package/eigen/Eigen/src/Core/arch/CUDA/PacketMath.h +0 -333
  282. package/eigen/Eigen/src/Core/arch/CUDA/PacketMathHalf.h +0 -1124
  283. package/eigen/Eigen/src/Core/arch/CUDA/TypeCasting.h +0 -212
  284. package/eigen/Eigen/src/Geometry/arch/Geometry_SSE.h +0 -161
  285. package/eigen/Eigen/src/LU/arch/Inverse_SSE.h +0 -338
  286. package/lib/eigen.d.ts +0 -2
  287. package/lib/eigen.js +0 -15
@@ -2,6 +2,7 @@
2
2
  // for linear algebra.
3
3
  //
4
4
  // Copyright (C) 2006-2010 Benoit Jacob <jacob.benoit.1@gmail.com>
5
+ // Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
5
6
  //
6
7
  // This Source Code Form is subject to the terms of the Mozilla
7
8
  // Public License v. 2.0. If a copy of the MPL was not distributed
@@ -10,10 +11,11 @@
10
11
  #ifndef EIGEN_MATHFUNCTIONS_H
11
12
  #define EIGEN_MATHFUNCTIONS_H
12
13
 
13
- // source: http://www.geom.uiuc.edu/~huberty/math5337/groupe/digits.html
14
14
  // TODO this should better be moved to NumTraits
15
- #define EIGEN_PI 3.141592653589793238462643383279502884197169399375105820974944592307816406L
16
-
15
+ // Source: WolframAlpha
16
+ #define EIGEN_PI 3.141592653589793238462643383279502884197169399375105820974944592307816406L
17
+ #define EIGEN_LOG2E 1.442695040888963407359924681001892137426645954152985934135449406931109219L
18
+ #define EIGEN_LN2 0.693147180559945309417232121458176568075500134360255254120680009493393621L
17
19
 
18
20
  namespace Eigen {
19
21
 
@@ -97,7 +99,7 @@ struct real_default_impl<Scalar,true>
97
99
 
98
100
  template<typename Scalar> struct real_impl : real_default_impl<Scalar> {};
99
101
 
100
- #ifdef __CUDA_ARCH__
102
+ #if defined(EIGEN_GPU_COMPILE_PHASE)
101
103
  template<typename T>
102
104
  struct real_impl<std::complex<T> >
103
105
  {
@@ -145,7 +147,7 @@ struct imag_default_impl<Scalar,true>
145
147
 
146
148
  template<typename Scalar> struct imag_impl : imag_default_impl<Scalar> {};
147
149
 
148
- #ifdef __CUDA_ARCH__
150
+ #if defined(EIGEN_GPU_COMPILE_PHASE)
149
151
  template<typename T>
150
152
  struct imag_impl<std::complex<T> >
151
153
  {
@@ -213,12 +215,12 @@ struct imag_ref_default_impl
213
215
  template<typename Scalar>
214
216
  struct imag_ref_default_impl<Scalar, false>
215
217
  {
216
- EIGEN_DEVICE_FUNC
218
+ EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
217
219
  static inline Scalar run(Scalar&)
218
220
  {
219
221
  return Scalar(0);
220
222
  }
221
- EIGEN_DEVICE_FUNC
223
+ EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
222
224
  static inline const Scalar run(const Scalar&)
223
225
  {
224
226
  return Scalar(0);
@@ -239,7 +241,7 @@ struct imag_ref_retval
239
241
  ****************************************************************************/
240
242
 
241
243
  template<typename Scalar, bool IsComplex = NumTraits<Scalar>::IsComplex>
242
- struct conj_impl
244
+ struct conj_default_impl
243
245
  {
244
246
  EIGEN_DEVICE_FUNC
245
247
  static inline Scalar run(const Scalar& x)
@@ -249,7 +251,7 @@ struct conj_impl
249
251
  };
250
252
 
251
253
  template<typename Scalar>
252
- struct conj_impl<Scalar,true>
254
+ struct conj_default_impl<Scalar,true>
253
255
  {
254
256
  EIGEN_DEVICE_FUNC
255
257
  static inline Scalar run(const Scalar& x)
@@ -259,6 +261,9 @@ struct conj_impl<Scalar,true>
259
261
  }
260
262
  };
261
263
 
264
+ template<typename Scalar, bool IsComplex = NumTraits<Scalar>::IsComplex>
265
+ struct conj_impl : conj_default_impl<Scalar, IsComplex> {};
266
+
262
267
  template<typename Scalar>
263
268
  struct conj_retval
264
269
  {
@@ -308,6 +313,65 @@ struct abs2_retval
308
313
  typedef typename NumTraits<Scalar>::Real type;
309
314
  };
310
315
 
316
+ /****************************************************************************
317
+ * Implementation of sqrt/rsqrt *
318
+ ****************************************************************************/
319
+
320
+ template<typename Scalar>
321
+ struct sqrt_impl
322
+ {
323
+ EIGEN_DEVICE_FUNC
324
+ static EIGEN_ALWAYS_INLINE Scalar run(const Scalar& x)
325
+ {
326
+ EIGEN_USING_STD(sqrt);
327
+ return sqrt(x);
328
+ }
329
+ };
330
+
331
+ // Complex sqrt defined in MathFunctionsImpl.h.
332
+ template<typename T> EIGEN_DEVICE_FUNC std::complex<T> complex_sqrt(const std::complex<T>& a_x);
333
+
334
+ // Custom implementation is faster than `std::sqrt`, works on
335
+ // GPU, and correctly handles special cases (unlike MSVC).
336
+ template<typename T>
337
+ struct sqrt_impl<std::complex<T> >
338
+ {
339
+ EIGEN_DEVICE_FUNC
340
+ static EIGEN_ALWAYS_INLINE std::complex<T> run(const std::complex<T>& x)
341
+ {
342
+ return complex_sqrt<T>(x);
343
+ }
344
+ };
345
+
346
+ template<typename Scalar>
347
+ struct sqrt_retval
348
+ {
349
+ typedef Scalar type;
350
+ };
351
+
352
+ // Default implementation relies on numext::sqrt, at bottom of file.
353
+ template<typename T>
354
+ struct rsqrt_impl;
355
+
356
+ // Complex rsqrt defined in MathFunctionsImpl.h.
357
+ template<typename T> EIGEN_DEVICE_FUNC std::complex<T> complex_rsqrt(const std::complex<T>& a_x);
358
+
359
+ template<typename T>
360
+ struct rsqrt_impl<std::complex<T> >
361
+ {
362
+ EIGEN_DEVICE_FUNC
363
+ static EIGEN_ALWAYS_INLINE std::complex<T> run(const std::complex<T>& x)
364
+ {
365
+ return complex_rsqrt<T>(x);
366
+ }
367
+ };
368
+
369
+ template<typename Scalar>
370
+ struct rsqrt_retval
371
+ {
372
+ typedef Scalar type;
373
+ };
374
+
311
375
  /****************************************************************************
312
376
  * Implementation of norm1 *
313
377
  ****************************************************************************/
@@ -322,7 +386,7 @@ struct norm1_default_impl<Scalar,true>
322
386
  EIGEN_DEVICE_FUNC
323
387
  static inline RealScalar run(const Scalar& x)
324
388
  {
325
- EIGEN_USING_STD_MATH(abs);
389
+ EIGEN_USING_STD(abs);
326
390
  return abs(x.real()) + abs(x.imag());
327
391
  }
328
392
  };
@@ -333,7 +397,7 @@ struct norm1_default_impl<Scalar, false>
333
397
  EIGEN_DEVICE_FUNC
334
398
  static inline Scalar run(const Scalar& x)
335
399
  {
336
- EIGEN_USING_STD_MATH(abs);
400
+ EIGEN_USING_STD(abs);
337
401
  return abs(x);
338
402
  }
339
403
  };
@@ -363,7 +427,7 @@ struct hypot_retval
363
427
  * Implementation of cast *
364
428
  ****************************************************************************/
365
429
 
366
- template<typename OldType, typename NewType>
430
+ template<typename OldType, typename NewType, typename EnableIf = void>
367
431
  struct cast_impl
368
432
  {
369
433
  EIGEN_DEVICE_FUNC
@@ -373,6 +437,22 @@ struct cast_impl
373
437
  }
374
438
  };
375
439
 
440
+ // Casting from S -> Complex<T> leads to an implicit conversion from S to T,
441
+ // generating warnings on clang. Here we explicitly cast the real component.
442
+ template<typename OldType, typename NewType>
443
+ struct cast_impl<OldType, NewType,
444
+ typename internal::enable_if<
445
+ !NumTraits<OldType>::IsComplex && NumTraits<NewType>::IsComplex
446
+ >::type>
447
+ {
448
+ EIGEN_DEVICE_FUNC
449
+ static inline NewType run(const OldType& x)
450
+ {
451
+ typedef typename NumTraits<NewType>::Real NewReal;
452
+ return static_cast<NewType>(static_cast<NewReal>(x));
453
+ }
454
+ };
455
+
376
456
  // here, for once, we're plainly returning NewType: we don't want cast to do weird things.
377
457
 
378
458
  template<typename OldType, typename NewType>
@@ -386,29 +466,59 @@ inline NewType cast(const OldType& x)
386
466
  * Implementation of round *
387
467
  ****************************************************************************/
388
468
 
469
+ template<typename Scalar>
470
+ struct round_impl
471
+ {
472
+ EIGEN_DEVICE_FUNC
473
+ static inline Scalar run(const Scalar& x)
474
+ {
475
+ EIGEN_STATIC_ASSERT((!NumTraits<Scalar>::IsComplex), NUMERIC_TYPE_MUST_BE_REAL)
389
476
  #if EIGEN_HAS_CXX11_MATH
390
- template<typename Scalar>
391
- struct round_impl {
392
- static inline Scalar run(const Scalar& x)
393
- {
394
- EIGEN_STATIC_ASSERT((!NumTraits<Scalar>::IsComplex), NUMERIC_TYPE_MUST_BE_REAL)
395
- using std::round;
396
- return round(x);
397
- }
398
- };
477
+ EIGEN_USING_STD(round);
478
+ #endif
479
+ return Scalar(round(x));
480
+ }
481
+ };
482
+
483
+ #if !EIGEN_HAS_CXX11_MATH
484
+ #if EIGEN_HAS_C99_MATH
485
+ // Use ::roundf for float.
486
+ template<>
487
+ struct round_impl<float> {
488
+ EIGEN_DEVICE_FUNC
489
+ static inline float run(const float& x)
490
+ {
491
+ return ::roundf(x);
492
+ }
493
+ };
399
494
  #else
400
- template<typename Scalar>
401
- struct round_impl
495
+ template<typename Scalar>
496
+ struct round_using_floor_ceil_impl
497
+ {
498
+ EIGEN_DEVICE_FUNC
499
+ static inline Scalar run(const Scalar& x)
402
500
  {
403
- static inline Scalar run(const Scalar& x)
404
- {
405
- EIGEN_STATIC_ASSERT((!NumTraits<Scalar>::IsComplex), NUMERIC_TYPE_MUST_BE_REAL)
406
- EIGEN_USING_STD_MATH(floor);
407
- EIGEN_USING_STD_MATH(ceil);
408
- return (x > Scalar(0)) ? floor(x + Scalar(0.5)) : ceil(x - Scalar(0.5));
501
+ EIGEN_STATIC_ASSERT((!NumTraits<Scalar>::IsComplex), NUMERIC_TYPE_MUST_BE_REAL)
502
+ // Without C99 round/roundf, resort to floor/ceil.
503
+ EIGEN_USING_STD(floor);
504
+ EIGEN_USING_STD(ceil);
505
+ // If not enough precision to resolve a decimal at all, return the input.
506
+ // Otherwise, adding 0.5 can trigger an increment by 1.
507
+ const Scalar limit = Scalar(1ull << (NumTraits<Scalar>::digits() - 1));
508
+ if (x >= limit || x <= -limit) {
509
+ return x;
409
510
  }
410
- };
411
- #endif
511
+ return (x > Scalar(0)) ? Scalar(floor(x + Scalar(0.5))) : Scalar(ceil(x - Scalar(0.5)));
512
+ }
513
+ };
514
+
515
+ template<>
516
+ struct round_impl<float> : round_using_floor_ceil_impl<float> {};
517
+
518
+ template<>
519
+ struct round_impl<double> : round_using_floor_ceil_impl<double> {};
520
+ #endif // EIGEN_HAS_C99_MATH
521
+ #endif // !EIGEN_HAS_CXX11_MATH
412
522
 
413
523
  template<typename Scalar>
414
524
  struct round_retval
@@ -417,43 +527,112 @@ struct round_retval
417
527
  };
418
528
 
419
529
  /****************************************************************************
420
- * Implementation of arg *
530
+ * Implementation of rint *
421
531
  ****************************************************************************/
422
532
 
533
+ template<typename Scalar>
534
+ struct rint_impl {
535
+ EIGEN_DEVICE_FUNC
536
+ static inline Scalar run(const Scalar& x)
537
+ {
538
+ EIGEN_STATIC_ASSERT((!NumTraits<Scalar>::IsComplex), NUMERIC_TYPE_MUST_BE_REAL)
423
539
  #if EIGEN_HAS_CXX11_MATH
424
- template<typename Scalar>
425
- struct arg_impl {
426
- static inline Scalar run(const Scalar& x)
427
- {
428
- EIGEN_USING_STD_MATH(arg);
429
- return arg(x);
430
- }
431
- };
432
- #else
433
- template<typename Scalar, bool IsComplex = NumTraits<Scalar>::IsComplex>
434
- struct arg_default_impl
540
+ EIGEN_USING_STD(rint);
541
+ #endif
542
+ return rint(x);
543
+ }
544
+ };
545
+
546
+ #if !EIGEN_HAS_CXX11_MATH
547
+ template<>
548
+ struct rint_impl<double> {
549
+ EIGEN_DEVICE_FUNC
550
+ static inline double run(const double& x)
435
551
  {
436
- typedef typename NumTraits<Scalar>::Real RealScalar;
437
- EIGEN_DEVICE_FUNC
438
- static inline RealScalar run(const Scalar& x)
439
- {
440
- return (x < Scalar(0)) ? Scalar(EIGEN_PI) : Scalar(0); }
441
- };
552
+ return ::rint(x);
553
+ }
554
+ };
555
+ template<>
556
+ struct rint_impl<float> {
557
+ EIGEN_DEVICE_FUNC
558
+ static inline float run(const float& x)
559
+ {
560
+ return ::rintf(x);
561
+ }
562
+ };
563
+ #endif
442
564
 
443
- template<typename Scalar>
444
- struct arg_default_impl<Scalar,true>
565
+ template<typename Scalar>
566
+ struct rint_retval
567
+ {
568
+ typedef Scalar type;
569
+ };
570
+
571
+ /****************************************************************************
572
+ * Implementation of arg *
573
+ ****************************************************************************/
574
+
575
+ // Visual Studio 2017 has a bug where arg(float) returns 0 for negative inputs.
576
+ // This seems to be fixed in VS 2019.
577
+ #if EIGEN_HAS_CXX11_MATH && (!EIGEN_COMP_MSVC || EIGEN_COMP_MSVC >= 1920)
578
+ // std::arg is only defined for types of std::complex, or integer types or float/double/long double
579
+ template<typename Scalar,
580
+ bool HasStdImpl = NumTraits<Scalar>::IsComplex || is_integral<Scalar>::value
581
+ || is_same<Scalar, float>::value || is_same<Scalar, double>::value
582
+ || is_same<Scalar, long double>::value >
583
+ struct arg_default_impl;
584
+
585
+ template<typename Scalar>
586
+ struct arg_default_impl<Scalar, true> {
587
+ typedef typename NumTraits<Scalar>::Real RealScalar;
588
+ EIGEN_DEVICE_FUNC
589
+ static inline RealScalar run(const Scalar& x)
445
590
  {
446
- typedef typename NumTraits<Scalar>::Real RealScalar;
447
- EIGEN_DEVICE_FUNC
448
- static inline RealScalar run(const Scalar& x)
449
- {
450
- EIGEN_USING_STD_MATH(arg);
451
- return arg(x);
452
- }
453
- };
591
+ #if defined(EIGEN_HIP_DEVICE_COMPILE)
592
+ // HIP does not seem to have a native device side implementation for the math routine "arg"
593
+ using std::arg;
594
+ #else
595
+ EIGEN_USING_STD(arg);
596
+ #endif
597
+ return static_cast<RealScalar>(arg(x));
598
+ }
599
+ };
600
+
601
+ // Must be non-complex floating-point type (e.g. half/bfloat16).
602
+ template<typename Scalar>
603
+ struct arg_default_impl<Scalar, false> {
604
+ typedef typename NumTraits<Scalar>::Real RealScalar;
605
+ EIGEN_DEVICE_FUNC
606
+ static inline RealScalar run(const Scalar& x)
607
+ {
608
+ return (x < Scalar(0)) ? RealScalar(EIGEN_PI) : RealScalar(0);
609
+ }
610
+ };
611
+ #else
612
+ template<typename Scalar, bool IsComplex = NumTraits<Scalar>::IsComplex>
613
+ struct arg_default_impl
614
+ {
615
+ typedef typename NumTraits<Scalar>::Real RealScalar;
616
+ EIGEN_DEVICE_FUNC
617
+ static inline RealScalar run(const Scalar& x)
618
+ {
619
+ return (x < RealScalar(0)) ? RealScalar(EIGEN_PI) : RealScalar(0);
620
+ }
621
+ };
454
622
 
455
- template<typename Scalar> struct arg_impl : arg_default_impl<Scalar> {};
623
+ template<typename Scalar>
624
+ struct arg_default_impl<Scalar,true>
625
+ {
626
+ typedef typename NumTraits<Scalar>::Real RealScalar;
627
+ EIGEN_DEVICE_FUNC
628
+ static inline RealScalar run(const Scalar& x)
629
+ {
630
+ EIGEN_USING_STD(arg);
631
+ return arg(x);
632
+ }
633
+ };
456
634
  #endif
635
+ template<typename Scalar> struct arg_impl : arg_default_impl<Scalar> {};
457
636
 
458
637
  template<typename Scalar>
459
638
  struct arg_retval
@@ -461,6 +640,80 @@ struct arg_retval
461
640
  typedef typename NumTraits<Scalar>::Real type;
462
641
  };
463
642
 
643
+ /****************************************************************************
644
+ * Implementation of expm1 *
645
+ ****************************************************************************/
646
+
647
+ // This implementation is based on GSL Math's expm1.
648
+ namespace std_fallback {
649
+ // fallback expm1 implementation in case there is no expm1(Scalar) function in namespace of Scalar,
650
+ // or that there is no suitable std::expm1 function available. Implementation
651
+ // attributed to Kahan. See: http://www.plunk.org/~hatch/rightway.php.
652
+ template<typename Scalar>
653
+ EIGEN_DEVICE_FUNC inline Scalar expm1(const Scalar& x) {
654
+ EIGEN_STATIC_ASSERT_NON_INTEGER(Scalar)
655
+ typedef typename NumTraits<Scalar>::Real RealScalar;
656
+
657
+ EIGEN_USING_STD(exp);
658
+ Scalar u = exp(x);
659
+ if (numext::equal_strict(u, Scalar(1))) {
660
+ return x;
661
+ }
662
+ Scalar um1 = u - RealScalar(1);
663
+ if (numext::equal_strict(um1, Scalar(-1))) {
664
+ return RealScalar(-1);
665
+ }
666
+
667
+ EIGEN_USING_STD(log);
668
+ Scalar logu = log(u);
669
+ return numext::equal_strict(u, logu) ? u : (u - RealScalar(1)) * x / logu;
670
+ }
671
+ }
672
+
673
+ template<typename Scalar>
674
+ struct expm1_impl {
675
+ EIGEN_DEVICE_FUNC static inline Scalar run(const Scalar& x)
676
+ {
677
+ EIGEN_STATIC_ASSERT_NON_INTEGER(Scalar)
678
+ #if EIGEN_HAS_CXX11_MATH
679
+ using std::expm1;
680
+ #else
681
+ using std_fallback::expm1;
682
+ #endif
683
+ return expm1(x);
684
+ }
685
+ };
686
+
687
+ template<typename Scalar>
688
+ struct expm1_retval
689
+ {
690
+ typedef Scalar type;
691
+ };
692
+
693
+ /****************************************************************************
694
+ * Implementation of log *
695
+ ****************************************************************************/
696
+
697
+ // Complex log defined in MathFunctionsImpl.h.
698
+ template<typename T> EIGEN_DEVICE_FUNC std::complex<T> complex_log(const std::complex<T>& z);
699
+
700
+ template<typename Scalar>
701
+ struct log_impl {
702
+ EIGEN_DEVICE_FUNC static inline Scalar run(const Scalar& x)
703
+ {
704
+ EIGEN_USING_STD(log);
705
+ return static_cast<Scalar>(log(x));
706
+ }
707
+ };
708
+
709
+ template<typename Scalar>
710
+ struct log_impl<std::complex<Scalar> > {
711
+ EIGEN_DEVICE_FUNC static inline std::complex<Scalar> run(const std::complex<Scalar>& z)
712
+ {
713
+ return complex_log(z);
714
+ }
715
+ };
716
+
464
717
  /****************************************************************************
465
718
  * Implementation of log1p *
466
719
  ****************************************************************************/
@@ -472,25 +725,38 @@ namespace std_fallback {
472
725
  EIGEN_DEVICE_FUNC inline Scalar log1p(const Scalar& x) {
473
726
  EIGEN_STATIC_ASSERT_NON_INTEGER(Scalar)
474
727
  typedef typename NumTraits<Scalar>::Real RealScalar;
475
- EIGEN_USING_STD_MATH(log);
728
+ EIGEN_USING_STD(log);
476
729
  Scalar x1p = RealScalar(1) + x;
477
- return numext::equal_strict(x1p, Scalar(1)) ? x : x * ( log(x1p) / (x1p - RealScalar(1)) );
730
+ Scalar log_1p = log_impl<Scalar>::run(x1p);
731
+ const bool is_small = numext::equal_strict(x1p, Scalar(1));
732
+ const bool is_inf = numext::equal_strict(x1p, log_1p);
733
+ return (is_small || is_inf) ? x : x * (log_1p / (x1p - RealScalar(1)));
478
734
  }
479
735
  }
480
736
 
481
737
  template<typename Scalar>
482
738
  struct log1p_impl {
483
- static inline Scalar run(const Scalar& x)
739
+ EIGEN_DEVICE_FUNC static inline Scalar run(const Scalar& x)
484
740
  {
485
741
  EIGEN_STATIC_ASSERT_NON_INTEGER(Scalar)
486
742
  #if EIGEN_HAS_CXX11_MATH
487
743
  using std::log1p;
488
- #endif
744
+ #else
489
745
  using std_fallback::log1p;
746
+ #endif
490
747
  return log1p(x);
491
748
  }
492
749
  };
493
750
 
751
+ // Specialization for complex types that are not supported by std::log1p.
752
+ template <typename RealScalar>
753
+ struct log1p_impl<std::complex<RealScalar> > {
754
+ EIGEN_DEVICE_FUNC static inline std::complex<RealScalar> run(
755
+ const std::complex<RealScalar>& x) {
756
+ EIGEN_STATIC_ASSERT_NON_INTEGER(RealScalar)
757
+ return std_fallback::log1p(x);
758
+ }
759
+ };
494
760
 
495
761
  template<typename Scalar>
496
762
  struct log1p_retval
@@ -509,7 +775,7 @@ struct pow_impl
509
775
  typedef typename ScalarBinaryOpTraits<ScalarX,ScalarY,internal::scalar_pow_op<ScalarX,ScalarY> >::ReturnType result_type;
510
776
  static EIGEN_DEVICE_FUNC inline result_type run(const ScalarX& x, const ScalarY& y)
511
777
  {
512
- EIGEN_USING_STD_MATH(pow);
778
+ EIGEN_USING_STD(pow);
513
779
  return pow(x, y);
514
780
  }
515
781
  };
@@ -687,7 +953,7 @@ inline EIGEN_MATHFUNC_RETVAL(random, Scalar) random()
687
953
  return EIGEN_MATHFUNC_IMPL(random, Scalar)::run();
688
954
  }
689
955
 
690
- // Implementatin of is* functions
956
+ // Implementation of is* functions
691
957
 
692
958
  // std::is* do not work with fast-math and gcc, std::is* are available on MSVC 2013 and newer, as well as in clang.
693
959
  #if (EIGEN_HAS_CXX11_MATH && !(EIGEN_COMP_GNUC_STRICT && __FINITE_MATH_ONLY__)) || (EIGEN_COMP_MSVC>=1800) || (EIGEN_COMP_CLANG)
@@ -716,7 +982,7 @@ EIGEN_DEVICE_FUNC
716
982
  typename internal::enable_if<(!internal::is_integral<T>::value)&&(!NumTraits<T>::IsComplex),bool>::type
717
983
  isfinite_impl(const T& x)
718
984
  {
719
- #ifdef __CUDA_ARCH__
985
+ #if defined(EIGEN_GPU_COMPILE_PHASE)
720
986
  return (::isfinite)(x);
721
987
  #elif EIGEN_USE_STD_FPCLASSIFY
722
988
  using std::isfinite;
@@ -731,7 +997,7 @@ EIGEN_DEVICE_FUNC
731
997
  typename internal::enable_if<(!internal::is_integral<T>::value)&&(!NumTraits<T>::IsComplex),bool>::type
732
998
  isinf_impl(const T& x)
733
999
  {
734
- #ifdef __CUDA_ARCH__
1000
+ #if defined(EIGEN_GPU_COMPILE_PHASE)
735
1001
  return (::isinf)(x);
736
1002
  #elif EIGEN_USE_STD_FPCLASSIFY
737
1003
  using std::isinf;
@@ -746,7 +1012,7 @@ EIGEN_DEVICE_FUNC
746
1012
  typename internal::enable_if<(!internal::is_integral<T>::value)&&(!NumTraits<T>::IsComplex),bool>::type
747
1013
  isnan_impl(const T& x)
748
1014
  {
749
- #ifdef __CUDA_ARCH__
1015
+ #if defined(EIGEN_GPU_COMPILE_PHASE)
750
1016
  return (::isnan)(x);
751
1017
  #elif EIGEN_USE_STD_FPCLASSIFY
752
1018
  using std::isnan;
@@ -803,7 +1069,6 @@ template<typename T> EIGEN_DEVICE_FUNC bool isnan_impl(const std::complex<T>& x)
803
1069
  template<typename T> EIGEN_DEVICE_FUNC bool isinf_impl(const std::complex<T>& x);
804
1070
 
805
1071
  template<typename T> T generic_fast_tanh_float(const T& a_x);
806
-
807
1072
  } // end namespace internal
808
1073
 
809
1074
  /****************************************************************************
@@ -812,12 +1077,12 @@ template<typename T> T generic_fast_tanh_float(const T& a_x);
812
1077
 
813
1078
  namespace numext {
814
1079
 
815
- #ifndef __CUDA_ARCH__
1080
+ #if (!defined(EIGEN_GPUCC) || defined(EIGEN_CONSTEXPR_ARE_DEVICE_FUNC))
816
1081
  template<typename T>
817
1082
  EIGEN_DEVICE_FUNC
818
1083
  EIGEN_ALWAYS_INLINE T mini(const T& x, const T& y)
819
1084
  {
820
- EIGEN_USING_STD_MATH(min);
1085
+ EIGEN_USING_STD(min)
821
1086
  return min EIGEN_NOT_A_MACRO (x,y);
822
1087
  }
823
1088
 
@@ -825,7 +1090,7 @@ template<typename T>
825
1090
  EIGEN_DEVICE_FUNC
826
1091
  EIGEN_ALWAYS_INLINE T maxi(const T& x, const T& y)
827
1092
  {
828
- EIGEN_USING_STD_MATH(max);
1093
+ EIGEN_USING_STD(max)
829
1094
  return max EIGEN_NOT_A_MACRO (x,y);
830
1095
  }
831
1096
  #else
@@ -841,6 +1106,24 @@ EIGEN_ALWAYS_INLINE float mini(const float& x, const float& y)
841
1106
  {
842
1107
  return fminf(x, y);
843
1108
  }
1109
+ template<>
1110
+ EIGEN_DEVICE_FUNC
1111
+ EIGEN_ALWAYS_INLINE double mini(const double& x, const double& y)
1112
+ {
1113
+ return fmin(x, y);
1114
+ }
1115
+ template<>
1116
+ EIGEN_DEVICE_FUNC
1117
+ EIGEN_ALWAYS_INLINE long double mini(const long double& x, const long double& y)
1118
+ {
1119
+ #if defined(EIGEN_HIPCC)
1120
+ // no "fminl" on HIP yet
1121
+ return (x < y) ? x : y;
1122
+ #else
1123
+ return fminl(x, y);
1124
+ #endif
1125
+ }
1126
+
844
1127
  template<typename T>
845
1128
  EIGEN_DEVICE_FUNC
846
1129
  EIGEN_ALWAYS_INLINE T maxi(const T& x, const T& y)
@@ -853,6 +1136,92 @@ EIGEN_ALWAYS_INLINE float maxi(const float& x, const float& y)
853
1136
  {
854
1137
  return fmaxf(x, y);
855
1138
  }
1139
+ template<>
1140
+ EIGEN_DEVICE_FUNC
1141
+ EIGEN_ALWAYS_INLINE double maxi(const double& x, const double& y)
1142
+ {
1143
+ return fmax(x, y);
1144
+ }
1145
+ template<>
1146
+ EIGEN_DEVICE_FUNC
1147
+ EIGEN_ALWAYS_INLINE long double maxi(const long double& x, const long double& y)
1148
+ {
1149
+ #if defined(EIGEN_HIPCC)
1150
+ // no "fmaxl" on HIP yet
1151
+ return (x > y) ? x : y;
1152
+ #else
1153
+ return fmaxl(x, y);
1154
+ #endif
1155
+ }
1156
+ #endif
1157
+
1158
+ #if defined(SYCL_DEVICE_ONLY)
1159
+
1160
+
1161
+ #define SYCL_SPECIALIZE_SIGNED_INTEGER_TYPES_BINARY(NAME, FUNC) \
1162
+ SYCL_SPECIALIZE_BINARY_FUNC(NAME, FUNC, cl::sycl::cl_char) \
1163
+ SYCL_SPECIALIZE_BINARY_FUNC(NAME, FUNC, cl::sycl::cl_short) \
1164
+ SYCL_SPECIALIZE_BINARY_FUNC(NAME, FUNC, cl::sycl::cl_int) \
1165
+ SYCL_SPECIALIZE_BINARY_FUNC(NAME, FUNC, cl::sycl::cl_long)
1166
+ #define SYCL_SPECIALIZE_SIGNED_INTEGER_TYPES_UNARY(NAME, FUNC) \
1167
+ SYCL_SPECIALIZE_UNARY_FUNC(NAME, FUNC, cl::sycl::cl_char) \
1168
+ SYCL_SPECIALIZE_UNARY_FUNC(NAME, FUNC, cl::sycl::cl_short) \
1169
+ SYCL_SPECIALIZE_UNARY_FUNC(NAME, FUNC, cl::sycl::cl_int) \
1170
+ SYCL_SPECIALIZE_UNARY_FUNC(NAME, FUNC, cl::sycl::cl_long)
1171
+ #define SYCL_SPECIALIZE_UNSIGNED_INTEGER_TYPES_BINARY(NAME, FUNC) \
1172
+ SYCL_SPECIALIZE_BINARY_FUNC(NAME, FUNC, cl::sycl::cl_uchar) \
1173
+ SYCL_SPECIALIZE_BINARY_FUNC(NAME, FUNC, cl::sycl::cl_ushort) \
1174
+ SYCL_SPECIALIZE_BINARY_FUNC(NAME, FUNC, cl::sycl::cl_uint) \
1175
+ SYCL_SPECIALIZE_BINARY_FUNC(NAME, FUNC, cl::sycl::cl_ulong)
1176
+ #define SYCL_SPECIALIZE_UNSIGNED_INTEGER_TYPES_UNARY(NAME, FUNC) \
1177
+ SYCL_SPECIALIZE_UNARY_FUNC(NAME, FUNC, cl::sycl::cl_uchar) \
1178
+ SYCL_SPECIALIZE_UNARY_FUNC(NAME, FUNC, cl::sycl::cl_ushort) \
1179
+ SYCL_SPECIALIZE_UNARY_FUNC(NAME, FUNC, cl::sycl::cl_uint) \
1180
+ SYCL_SPECIALIZE_UNARY_FUNC(NAME, FUNC, cl::sycl::cl_ulong)
1181
+ #define SYCL_SPECIALIZE_INTEGER_TYPES_BINARY(NAME, FUNC) \
1182
+ SYCL_SPECIALIZE_SIGNED_INTEGER_TYPES_BINARY(NAME, FUNC) \
1183
+ SYCL_SPECIALIZE_UNSIGNED_INTEGER_TYPES_BINARY(NAME, FUNC)
1184
+ #define SYCL_SPECIALIZE_INTEGER_TYPES_UNARY(NAME, FUNC) \
1185
+ SYCL_SPECIALIZE_SIGNED_INTEGER_TYPES_UNARY(NAME, FUNC) \
1186
+ SYCL_SPECIALIZE_UNSIGNED_INTEGER_TYPES_UNARY(NAME, FUNC)
1187
+ #define SYCL_SPECIALIZE_FLOATING_TYPES_BINARY(NAME, FUNC) \
1188
+ SYCL_SPECIALIZE_BINARY_FUNC(NAME, FUNC, cl::sycl::cl_float) \
1189
+ SYCL_SPECIALIZE_BINARY_FUNC(NAME, FUNC,cl::sycl::cl_double)
1190
+ #define SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(NAME, FUNC) \
1191
+ SYCL_SPECIALIZE_UNARY_FUNC(NAME, FUNC, cl::sycl::cl_float) \
1192
+ SYCL_SPECIALIZE_UNARY_FUNC(NAME, FUNC,cl::sycl::cl_double)
1193
+ #define SYCL_SPECIALIZE_FLOATING_TYPES_UNARY_FUNC_RET_TYPE(NAME, FUNC, RET_TYPE) \
1194
+ SYCL_SPECIALIZE_GEN_UNARY_FUNC(NAME, FUNC, RET_TYPE, cl::sycl::cl_float) \
1195
+ SYCL_SPECIALIZE_GEN_UNARY_FUNC(NAME, FUNC, RET_TYPE, cl::sycl::cl_double)
1196
+
1197
+ #define SYCL_SPECIALIZE_GEN_UNARY_FUNC(NAME, FUNC, RET_TYPE, ARG_TYPE) \
1198
+ template<> \
1199
+ EIGEN_DEVICE_FUNC \
1200
+ EIGEN_ALWAYS_INLINE RET_TYPE NAME(const ARG_TYPE& x) { \
1201
+ return cl::sycl::FUNC(x); \
1202
+ }
1203
+
1204
+ #define SYCL_SPECIALIZE_UNARY_FUNC(NAME, FUNC, TYPE) \
1205
+ SYCL_SPECIALIZE_GEN_UNARY_FUNC(NAME, FUNC, TYPE, TYPE)
1206
+
1207
+ #define SYCL_SPECIALIZE_GEN1_BINARY_FUNC(NAME, FUNC, RET_TYPE, ARG_TYPE1, ARG_TYPE2) \
1208
+ template<> \
1209
+ EIGEN_DEVICE_FUNC \
1210
+ EIGEN_ALWAYS_INLINE RET_TYPE NAME(const ARG_TYPE1& x, const ARG_TYPE2& y) { \
1211
+ return cl::sycl::FUNC(x, y); \
1212
+ }
1213
+
1214
+ #define SYCL_SPECIALIZE_GEN2_BINARY_FUNC(NAME, FUNC, RET_TYPE, ARG_TYPE) \
1215
+ SYCL_SPECIALIZE_GEN1_BINARY_FUNC(NAME, FUNC, RET_TYPE, ARG_TYPE, ARG_TYPE)
1216
+
1217
+ #define SYCL_SPECIALIZE_BINARY_FUNC(NAME, FUNC, TYPE) \
1218
+ SYCL_SPECIALIZE_GEN2_BINARY_FUNC(NAME, FUNC, TYPE, TYPE)
1219
+
1220
+ SYCL_SPECIALIZE_INTEGER_TYPES_BINARY(mini, min)
1221
+ SYCL_SPECIALIZE_FLOATING_TYPES_BINARY(mini, fmin)
1222
+ SYCL_SPECIALIZE_INTEGER_TYPES_BINARY(maxi, max)
1223
+ SYCL_SPECIALIZE_FLOATING_TYPES_BINARY(maxi, fmax)
1224
+
856
1225
  #endif
857
1226
 
858
1227
 
@@ -922,6 +1291,34 @@ inline EIGEN_MATHFUNC_RETVAL(abs2, Scalar) abs2(const Scalar& x)
922
1291
  EIGEN_DEVICE_FUNC
923
1292
  inline bool abs2(bool x) { return x; }
924
1293
 
1294
+ template<typename T>
1295
+ EIGEN_DEVICE_FUNC
1296
+ EIGEN_ALWAYS_INLINE T absdiff(const T& x, const T& y)
1297
+ {
1298
+ return x > y ? x - y : y - x;
1299
+ }
1300
+ template<>
1301
+ EIGEN_DEVICE_FUNC
1302
+ EIGEN_ALWAYS_INLINE float absdiff(const float& x, const float& y)
1303
+ {
1304
+ return fabsf(x - y);
1305
+ }
1306
+ template<>
1307
+ EIGEN_DEVICE_FUNC
1308
+ EIGEN_ALWAYS_INLINE double absdiff(const double& x, const double& y)
1309
+ {
1310
+ return fabs(x - y);
1311
+ }
1312
+
1313
+ #if !defined(EIGEN_GPUCC)
1314
+ // HIP and CUDA do not support long double.
1315
+ template<>
1316
+ EIGEN_DEVICE_FUNC
1317
+ EIGEN_ALWAYS_INLINE long double absdiff(const long double& x, const long double& y) {
1318
+ return fabsl(x - y);
1319
+ }
1320
+ #endif
1321
+
925
1322
  template<typename Scalar>
926
1323
  EIGEN_DEVICE_FUNC
927
1324
  inline EIGEN_MATHFUNC_RETVAL(norm1, Scalar) norm1(const Scalar& x)
@@ -936,6 +1333,10 @@ inline EIGEN_MATHFUNC_RETVAL(hypot, Scalar) hypot(const Scalar& x, const Scalar&
936
1333
  return EIGEN_MATHFUNC_IMPL(hypot, Scalar)::run(x, y);
937
1334
  }
938
1335
 
1336
+ #if defined(SYCL_DEVICE_ONLY)
1337
+ SYCL_SPECIALIZE_FLOATING_TYPES_BINARY(hypot, hypot)
1338
+ #endif
1339
+
939
1340
  template<typename Scalar>
940
1341
  EIGEN_DEVICE_FUNC
941
1342
  inline EIGEN_MATHFUNC_RETVAL(log1p, Scalar) log1p(const Scalar& x)
@@ -943,7 +1344,11 @@ inline EIGEN_MATHFUNC_RETVAL(log1p, Scalar) log1p(const Scalar& x)
943
1344
  return EIGEN_MATHFUNC_IMPL(log1p, Scalar)::run(x);
944
1345
  }
945
1346
 
946
- #ifdef __CUDACC__
1347
+ #if defined(SYCL_DEVICE_ONLY)
1348
+ SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(log1p, log1p)
1349
+ #endif
1350
+
1351
+ #if defined(EIGEN_GPUCC)
947
1352
  template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
948
1353
  float log1p(const float &x) { return ::log1pf(x); }
949
1354
 
@@ -958,10 +1363,27 @@ inline typename internal::pow_impl<ScalarX,ScalarY>::result_type pow(const Scala
958
1363
  return internal::pow_impl<ScalarX,ScalarY>::run(x, y);
959
1364
  }
960
1365
 
1366
+ #if defined(SYCL_DEVICE_ONLY)
1367
+ SYCL_SPECIALIZE_FLOATING_TYPES_BINARY(pow, pow)
1368
+ #endif
1369
+
961
1370
  template<typename T> EIGEN_DEVICE_FUNC bool (isnan) (const T &x) { return internal::isnan_impl(x); }
962
1371
  template<typename T> EIGEN_DEVICE_FUNC bool (isinf) (const T &x) { return internal::isinf_impl(x); }
963
1372
  template<typename T> EIGEN_DEVICE_FUNC bool (isfinite)(const T &x) { return internal::isfinite_impl(x); }
964
1373
 
1374
+ #if defined(SYCL_DEVICE_ONLY)
1375
+ SYCL_SPECIALIZE_FLOATING_TYPES_UNARY_FUNC_RET_TYPE(isnan, isnan, bool)
1376
+ SYCL_SPECIALIZE_FLOATING_TYPES_UNARY_FUNC_RET_TYPE(isinf, isinf, bool)
1377
+ SYCL_SPECIALIZE_FLOATING_TYPES_UNARY_FUNC_RET_TYPE(isfinite, isfinite, bool)
1378
+ #endif
1379
+
1380
+ template<typename Scalar>
1381
+ EIGEN_DEVICE_FUNC
1382
+ inline EIGEN_MATHFUNC_RETVAL(rint, Scalar) rint(const Scalar& x)
1383
+ {
1384
+ return EIGEN_MATHFUNC_IMPL(rint, Scalar)::run(x);
1385
+ }
1386
+
965
1387
  template<typename Scalar>
966
1388
  EIGEN_DEVICE_FUNC
967
1389
  inline EIGEN_MATHFUNC_RETVAL(round, Scalar) round(const Scalar& x)
@@ -969,15 +1391,23 @@ inline EIGEN_MATHFUNC_RETVAL(round, Scalar) round(const Scalar& x)
969
1391
  return EIGEN_MATHFUNC_IMPL(round, Scalar)::run(x);
970
1392
  }
971
1393
 
1394
+ #if defined(SYCL_DEVICE_ONLY)
1395
+ SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(round, round)
1396
+ #endif
1397
+
972
1398
  template<typename T>
973
1399
  EIGEN_DEVICE_FUNC
974
1400
  T (floor)(const T& x)
975
1401
  {
976
- EIGEN_USING_STD_MATH(floor);
1402
+ EIGEN_USING_STD(floor)
977
1403
  return floor(x);
978
1404
  }
979
1405
 
980
- #ifdef __CUDACC__
1406
+ #if defined(SYCL_DEVICE_ONLY)
1407
+ SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(floor, floor)
1408
+ #endif
1409
+
1410
+ #if defined(EIGEN_GPUCC)
981
1411
  template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
982
1412
  float floor(const float &x) { return ::floorf(x); }
983
1413
 
@@ -989,11 +1419,15 @@ template<typename T>
989
1419
  EIGEN_DEVICE_FUNC
990
1420
  T (ceil)(const T& x)
991
1421
  {
992
- EIGEN_USING_STD_MATH(ceil);
1422
+ EIGEN_USING_STD(ceil);
993
1423
  return ceil(x);
994
1424
  }
995
1425
 
996
- #ifdef __CUDACC__
1426
+ #if defined(SYCL_DEVICE_ONLY)
1427
+ SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(ceil, ceil)
1428
+ #endif
1429
+
1430
+ #if defined(EIGEN_GPUCC)
997
1431
  template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
998
1432
  float ceil(const float &x) { return ::ceilf(x); }
999
1433
 
@@ -1026,22 +1460,42 @@ inline int log2(int x)
1026
1460
  *
1027
1461
  * It's usage is justified in performance critical functions, like norm/normalize.
1028
1462
  */
1463
+ template<typename Scalar>
1464
+ EIGEN_DEVICE_FUNC
1465
+ EIGEN_ALWAYS_INLINE EIGEN_MATHFUNC_RETVAL(sqrt, Scalar) sqrt(const Scalar& x)
1466
+ {
1467
+ return EIGEN_MATHFUNC_IMPL(sqrt, Scalar)::run(x);
1468
+ }
1469
+
1470
+ // Boolean specialization, avoids implicit float to bool conversion (-Wimplicit-conversion-floating-point-to-bool).
1471
+ template<>
1472
+ EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_DEVICE_FUNC
1473
+ bool sqrt<bool>(const bool &x) { return x; }
1474
+
1475
+ #if defined(SYCL_DEVICE_ONLY)
1476
+ SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(sqrt, sqrt)
1477
+ #endif
1478
+
1479
+ /** \returns the reciprocal square root of \a x. **/
1029
1480
  template<typename T>
1030
1481
  EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1031
- T sqrt(const T &x)
1482
+ T rsqrt(const T& x)
1032
1483
  {
1033
- EIGEN_USING_STD_MATH(sqrt);
1034
- return sqrt(x);
1484
+ return internal::rsqrt_impl<T>::run(x);
1035
1485
  }
1036
1486
 
1037
1487
  template<typename T>
1038
1488
  EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1039
1489
  T log(const T &x) {
1040
- EIGEN_USING_STD_MATH(log);
1041
- return log(x);
1490
+ return internal::log_impl<T>::run(x);
1042
1491
  }
1043
1492
 
1044
- #ifdef __CUDACC__
1493
+ #if defined(SYCL_DEVICE_ONLY)
1494
+ SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(log, log)
1495
+ #endif
1496
+
1497
+
1498
+ #if defined(EIGEN_GPUCC)
1045
1499
  template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1046
1500
  float log(const float &x) { return ::logf(x); }
1047
1501
 
@@ -1053,7 +1507,7 @@ template<typename T>
1053
1507
  EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1054
1508
  typename internal::enable_if<NumTraits<T>::IsSigned || NumTraits<T>::IsComplex,typename NumTraits<T>::Real>::type
1055
1509
  abs(const T &x) {
1056
- EIGEN_USING_STD_MATH(abs);
1510
+ EIGEN_USING_STD(abs);
1057
1511
  return abs(x);
1058
1512
  }
1059
1513
 
@@ -1064,12 +1518,12 @@ abs(const T &x) {
1064
1518
  return x;
1065
1519
  }
1066
1520
 
1067
- #if defined(__SYCL_DEVICE_ONLY__)
1068
- EIGEN_ALWAYS_INLINE float abs(float x) { return cl::sycl::fabs(x); }
1069
- EIGEN_ALWAYS_INLINE double abs(double x) { return cl::sycl::fabs(x); }
1070
- #endif // defined(__SYCL_DEVICE_ONLY__)
1521
+ #if defined(SYCL_DEVICE_ONLY)
1522
+ SYCL_SPECIALIZE_INTEGER_TYPES_UNARY(abs, abs)
1523
+ SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(abs, fabs)
1524
+ #endif
1071
1525
 
1072
- #ifdef __CUDACC__
1526
+ #if defined(EIGEN_GPUCC)
1073
1527
  template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1074
1528
  float abs(const float &x) { return ::fabsf(x); }
1075
1529
 
@@ -1090,26 +1544,69 @@ double abs(const std::complex<double>& x) {
1090
1544
  template<typename T>
1091
1545
  EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1092
1546
  T exp(const T &x) {
1093
- EIGEN_USING_STD_MATH(exp);
1547
+ EIGEN_USING_STD(exp);
1094
1548
  return exp(x);
1095
1549
  }
1096
1550
 
1097
- #ifdef __CUDACC__
1551
+ #if defined(SYCL_DEVICE_ONLY)
1552
+ SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(exp, exp)
1553
+ #endif
1554
+
1555
+ #if defined(EIGEN_GPUCC)
1098
1556
  template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1099
1557
  float exp(const float &x) { return ::expf(x); }
1100
1558
 
1101
1559
  template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1102
1560
  double exp(const double &x) { return ::exp(x); }
1561
+
1562
+ template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1563
+ std::complex<float> exp(const std::complex<float>& x) {
1564
+ float com = ::expf(x.real());
1565
+ float res_real = com * ::cosf(x.imag());
1566
+ float res_imag = com * ::sinf(x.imag());
1567
+ return std::complex<float>(res_real, res_imag);
1568
+ }
1569
+
1570
+ template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1571
+ std::complex<double> exp(const std::complex<double>& x) {
1572
+ double com = ::exp(x.real());
1573
+ double res_real = com * ::cos(x.imag());
1574
+ double res_imag = com * ::sin(x.imag());
1575
+ return std::complex<double>(res_real, res_imag);
1576
+ }
1577
+ #endif
1578
+
1579
+ template<typename Scalar>
1580
+ EIGEN_DEVICE_FUNC
1581
+ inline EIGEN_MATHFUNC_RETVAL(expm1, Scalar) expm1(const Scalar& x)
1582
+ {
1583
+ return EIGEN_MATHFUNC_IMPL(expm1, Scalar)::run(x);
1584
+ }
1585
+
1586
+ #if defined(SYCL_DEVICE_ONLY)
1587
+ SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(expm1, expm1)
1588
+ #endif
1589
+
1590
+ #if defined(EIGEN_GPUCC)
1591
+ template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1592
+ float expm1(const float &x) { return ::expm1f(x); }
1593
+
1594
+ template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1595
+ double expm1(const double &x) { return ::expm1(x); }
1103
1596
  #endif
1104
1597
 
1105
1598
  template<typename T>
1106
1599
  EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1107
1600
  T cos(const T &x) {
1108
- EIGEN_USING_STD_MATH(cos);
1601
+ EIGEN_USING_STD(cos);
1109
1602
  return cos(x);
1110
1603
  }
1111
1604
 
1112
- #ifdef __CUDACC__
1605
+ #if defined(SYCL_DEVICE_ONLY)
1606
+ SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(cos,cos)
1607
+ #endif
1608
+
1609
+ #if defined(EIGEN_GPUCC)
1113
1610
  template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1114
1611
  float cos(const float &x) { return ::cosf(x); }
1115
1612
 
@@ -1120,11 +1617,15 @@ double cos(const double &x) { return ::cos(x); }
1120
1617
  template<typename T>
1121
1618
  EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1122
1619
  T sin(const T &x) {
1123
- EIGEN_USING_STD_MATH(sin);
1620
+ EIGEN_USING_STD(sin);
1124
1621
  return sin(x);
1125
1622
  }
1126
1623
 
1127
- #ifdef __CUDACC__
1624
+ #if defined(SYCL_DEVICE_ONLY)
1625
+ SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(sin, sin)
1626
+ #endif
1627
+
1628
+ #if defined(EIGEN_GPUCC)
1128
1629
  template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1129
1630
  float sin(const float &x) { return ::sinf(x); }
1130
1631
 
@@ -1135,11 +1636,15 @@ double sin(const double &x) { return ::sin(x); }
1135
1636
  template<typename T>
1136
1637
  EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1137
1638
  T tan(const T &x) {
1138
- EIGEN_USING_STD_MATH(tan);
1639
+ EIGEN_USING_STD(tan);
1139
1640
  return tan(x);
1140
1641
  }
1141
1642
 
1142
- #ifdef __CUDACC__
1643
+ #if defined(SYCL_DEVICE_ONLY)
1644
+ SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(tan, tan)
1645
+ #endif
1646
+
1647
+ #if defined(EIGEN_GPUCC)
1143
1648
  template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1144
1649
  float tan(const float &x) { return ::tanf(x); }
1145
1650
 
@@ -1150,11 +1655,25 @@ double tan(const double &x) { return ::tan(x); }
1150
1655
  template<typename T>
1151
1656
  EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1152
1657
  T acos(const T &x) {
1153
- EIGEN_USING_STD_MATH(acos);
1658
+ EIGEN_USING_STD(acos);
1154
1659
  return acos(x);
1155
1660
  }
1156
1661
 
1157
- #ifdef __CUDACC__
1662
+ #if EIGEN_HAS_CXX11_MATH
1663
+ template<typename T>
1664
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1665
+ T acosh(const T &x) {
1666
+ EIGEN_USING_STD(acosh);
1667
+ return static_cast<T>(acosh(x));
1668
+ }
1669
+ #endif
1670
+
1671
+ #if defined(SYCL_DEVICE_ONLY)
1672
+ SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(acos, acos)
1673
+ SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(acosh, acosh)
1674
+ #endif
1675
+
1676
+ #if defined(EIGEN_GPUCC)
1158
1677
  template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1159
1678
  float acos(const float &x) { return ::acosf(x); }
1160
1679
 
@@ -1165,11 +1684,25 @@ double acos(const double &x) { return ::acos(x); }
1165
1684
  template<typename T>
1166
1685
  EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1167
1686
  T asin(const T &x) {
1168
- EIGEN_USING_STD_MATH(asin);
1687
+ EIGEN_USING_STD(asin);
1169
1688
  return asin(x);
1170
1689
  }
1171
1690
 
1172
- #ifdef __CUDACC__
1691
+ #if EIGEN_HAS_CXX11_MATH
1692
+ template<typename T>
1693
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1694
+ T asinh(const T &x) {
1695
+ EIGEN_USING_STD(asinh);
1696
+ return static_cast<T>(asinh(x));
1697
+ }
1698
+ #endif
1699
+
1700
+ #if defined(SYCL_DEVICE_ONLY)
1701
+ SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(asin, asin)
1702
+ SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(asinh, asinh)
1703
+ #endif
1704
+
1705
+ #if defined(EIGEN_GPUCC)
1173
1706
  template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1174
1707
  float asin(const float &x) { return ::asinf(x); }
1175
1708
 
@@ -1180,11 +1713,25 @@ double asin(const double &x) { return ::asin(x); }
1180
1713
  template<typename T>
1181
1714
  EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1182
1715
  T atan(const T &x) {
1183
- EIGEN_USING_STD_MATH(atan);
1184
- return atan(x);
1716
+ EIGEN_USING_STD(atan);
1717
+ return static_cast<T>(atan(x));
1718
+ }
1719
+
1720
+ #if EIGEN_HAS_CXX11_MATH
1721
+ template<typename T>
1722
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1723
+ T atanh(const T &x) {
1724
+ EIGEN_USING_STD(atanh);
1725
+ return static_cast<T>(atanh(x));
1185
1726
  }
1727
+ #endif
1728
+
1729
+ #if defined(SYCL_DEVICE_ONLY)
1730
+ SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(atan, atan)
1731
+ SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(atanh, atanh)
1732
+ #endif
1186
1733
 
1187
- #ifdef __CUDACC__
1734
+ #if defined(EIGEN_GPUCC)
1188
1735
  template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1189
1736
  float atan(const float &x) { return ::atanf(x); }
1190
1737
 
@@ -1196,11 +1743,15 @@ double atan(const double &x) { return ::atan(x); }
1196
1743
  template<typename T>
1197
1744
  EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1198
1745
  T cosh(const T &x) {
1199
- EIGEN_USING_STD_MATH(cosh);
1200
- return cosh(x);
1746
+ EIGEN_USING_STD(cosh);
1747
+ return static_cast<T>(cosh(x));
1201
1748
  }
1202
1749
 
1203
- #ifdef __CUDACC__
1750
+ #if defined(SYCL_DEVICE_ONLY)
1751
+ SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(cosh, cosh)
1752
+ #endif
1753
+
1754
+ #if defined(EIGEN_GPUCC)
1204
1755
  template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1205
1756
  float cosh(const float &x) { return ::coshf(x); }
1206
1757
 
@@ -1211,11 +1762,15 @@ double cosh(const double &x) { return ::cosh(x); }
1211
1762
  template<typename T>
1212
1763
  EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1213
1764
  T sinh(const T &x) {
1214
- EIGEN_USING_STD_MATH(sinh);
1215
- return sinh(x);
1765
+ EIGEN_USING_STD(sinh);
1766
+ return static_cast<T>(sinh(x));
1216
1767
  }
1217
1768
 
1218
- #ifdef __CUDACC__
1769
+ #if defined(SYCL_DEVICE_ONLY)
1770
+ SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(sinh, sinh)
1771
+ #endif
1772
+
1773
+ #if defined(EIGEN_GPUCC)
1219
1774
  template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1220
1775
  float sinh(const float &x) { return ::sinhf(x); }
1221
1776
 
@@ -1226,16 +1781,20 @@ double sinh(const double &x) { return ::sinh(x); }
1226
1781
  template<typename T>
1227
1782
  EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1228
1783
  T tanh(const T &x) {
1229
- EIGEN_USING_STD_MATH(tanh);
1784
+ EIGEN_USING_STD(tanh);
1230
1785
  return tanh(x);
1231
1786
  }
1232
1787
 
1233
- #if (!defined(__CUDACC__)) && EIGEN_FAST_MATH
1788
+ #if (!defined(EIGEN_GPUCC)) && EIGEN_FAST_MATH && !defined(SYCL_DEVICE_ONLY)
1234
1789
  EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1235
1790
  float tanh(float x) { return internal::generic_fast_tanh_float(x); }
1236
1791
  #endif
1237
1792
 
1238
- #ifdef __CUDACC__
1793
+ #if defined(SYCL_DEVICE_ONLY)
1794
+ SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(tanh, tanh)
1795
+ #endif
1796
+
1797
+ #if defined(EIGEN_GPUCC)
1239
1798
  template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1240
1799
  float tanh(const float &x) { return ::tanhf(x); }
1241
1800
 
@@ -1246,11 +1805,15 @@ double tanh(const double &x) { return ::tanh(x); }
1246
1805
  template <typename T>
1247
1806
  EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1248
1807
  T fmod(const T& a, const T& b) {
1249
- EIGEN_USING_STD_MATH(fmod);
1808
+ EIGEN_USING_STD(fmod);
1250
1809
  return fmod(a, b);
1251
1810
  }
1252
1811
 
1253
- #ifdef __CUDACC__
1812
+ #if defined(SYCL_DEVICE_ONLY)
1813
+ SYCL_SPECIALIZE_FLOATING_TYPES_BINARY(fmod, fmod)
1814
+ #endif
1815
+
1816
+ #if defined(EIGEN_GPUCC)
1254
1817
  template <>
1255
1818
  EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1256
1819
  float fmod(const float& a, const float& b) {
@@ -1264,6 +1827,23 @@ double fmod(const double& a, const double& b) {
1264
1827
  }
1265
1828
  #endif
1266
1829
 
1830
+ #if defined(SYCL_DEVICE_ONLY)
1831
+ #undef SYCL_SPECIALIZE_SIGNED_INTEGER_TYPES_BINARY
1832
+ #undef SYCL_SPECIALIZE_SIGNED_INTEGER_TYPES_UNARY
1833
+ #undef SYCL_SPECIALIZE_UNSIGNED_INTEGER_TYPES_BINARY
1834
+ #undef SYCL_SPECIALIZE_UNSIGNED_INTEGER_TYPES_UNARY
1835
+ #undef SYCL_SPECIALIZE_INTEGER_TYPES_BINARY
1836
+ #undef SYCL_SPECIALIZE_UNSIGNED_INTEGER_TYPES_UNARY
1837
+ #undef SYCL_SPECIALIZE_FLOATING_TYPES_BINARY
1838
+ #undef SYCL_SPECIALIZE_FLOATING_TYPES_UNARY
1839
+ #undef SYCL_SPECIALIZE_FLOATING_TYPES_UNARY_FUNC_RET_TYPE
1840
+ #undef SYCL_SPECIALIZE_GEN_UNARY_FUNC
1841
+ #undef SYCL_SPECIALIZE_UNARY_FUNC
1842
+ #undef SYCL_SPECIALIZE_GEN1_BINARY_FUNC
1843
+ #undef SYCL_SPECIALIZE_GEN2_BINARY_FUNC
1844
+ #undef SYCL_SPECIALIZE_BINARY_FUNC
1845
+ #endif
1846
+
1267
1847
  } // end namespace numext
1268
1848
 
1269
1849
  namespace internal {
@@ -1387,18 +1967,23 @@ template<> struct random_impl<bool>
1387
1967
  {
1388
1968
  return random<int>(0,1)==0 ? false : true;
1389
1969
  }
1970
+
1971
+ static inline bool run(const bool& a, const bool& b)
1972
+ {
1973
+ return random<int>(a, b)==0 ? false : true;
1974
+ }
1390
1975
  };
1391
1976
 
1392
1977
  template<> struct scalar_fuzzy_impl<bool>
1393
1978
  {
1394
1979
  typedef bool RealScalar;
1395
-
1980
+
1396
1981
  template<typename OtherScalar> EIGEN_DEVICE_FUNC
1397
1982
  static inline bool isMuchSmallerThan(const bool& x, const bool&, const bool&)
1398
1983
  {
1399
1984
  return !x;
1400
1985
  }
1401
-
1986
+
1402
1987
  EIGEN_DEVICE_FUNC
1403
1988
  static inline bool isApprox(bool x, bool y, bool)
1404
1989
  {
@@ -1410,10 +1995,61 @@ template<> struct scalar_fuzzy_impl<bool>
1410
1995
  {
1411
1996
  return (!x) || y;
1412
1997
  }
1413
-
1998
+
1999
+ };
2000
+
2001
+ } // end namespace internal
2002
+
2003
+ // Default implementations that rely on other numext implementations
2004
+ namespace internal {
2005
+
2006
+ // Specialization for complex types that are not supported by std::expm1.
2007
+ template <typename RealScalar>
2008
+ struct expm1_impl<std::complex<RealScalar> > {
2009
+ EIGEN_DEVICE_FUNC static inline std::complex<RealScalar> run(
2010
+ const std::complex<RealScalar>& x) {
2011
+ EIGEN_STATIC_ASSERT_NON_INTEGER(RealScalar)
2012
+ RealScalar xr = x.real();
2013
+ RealScalar xi = x.imag();
2014
+ // expm1(z) = exp(z) - 1
2015
+ // = exp(x + i * y) - 1
2016
+ // = exp(x) * (cos(y) + i * sin(y)) - 1
2017
+ // = exp(x) * cos(y) - 1 + i * exp(x) * sin(y)
2018
+ // Imag(expm1(z)) = exp(x) * sin(y)
2019
+ // Real(expm1(z)) = exp(x) * cos(y) - 1
2020
+ // = exp(x) * cos(y) - 1.
2021
+ // = expm1(x) + exp(x) * (cos(y) - 1)
2022
+ // = expm1(x) + exp(x) * (2 * sin(y / 2) ** 2)
2023
+ RealScalar erm1 = numext::expm1<RealScalar>(xr);
2024
+ RealScalar er = erm1 + RealScalar(1.);
2025
+ RealScalar sin2 = numext::sin(xi / RealScalar(2.));
2026
+ sin2 = sin2 * sin2;
2027
+ RealScalar s = numext::sin(xi);
2028
+ RealScalar real_part = erm1 - RealScalar(2.) * er * sin2;
2029
+ return std::complex<RealScalar>(real_part, er * s);
2030
+ }
1414
2031
  };
1415
2032
 
1416
-
2033
+ template<typename T>
2034
+ struct rsqrt_impl {
2035
+ EIGEN_DEVICE_FUNC
2036
+ static EIGEN_ALWAYS_INLINE T run(const T& x) {
2037
+ return T(1)/numext::sqrt(x);
2038
+ }
2039
+ };
2040
+
2041
+ #if defined(EIGEN_GPU_COMPILE_PHASE)
2042
+ template<typename T>
2043
+ struct conj_impl<std::complex<T>, true>
2044
+ {
2045
+ EIGEN_DEVICE_FUNC
2046
+ static inline std::complex<T> run(const std::complex<T>& x)
2047
+ {
2048
+ return std::complex<T>(numext::real(x), -numext::imag(x));
2049
+ }
2050
+ };
2051
+ #endif
2052
+
1417
2053
  } // end namespace internal
1418
2054
 
1419
2055
  } // end namespace Eigen