@smake/eigen 1.0.2 → 1.1.1

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 (435) hide show
  1. package/README.md +1 -1
  2. package/eigen/Eigen/AccelerateSupport +52 -0
  3. package/eigen/Eigen/Cholesky +18 -21
  4. package/eigen/Eigen/CholmodSupport +28 -28
  5. package/eigen/Eigen/Core +235 -326
  6. package/eigen/Eigen/Eigenvalues +16 -14
  7. package/eigen/Eigen/Geometry +21 -24
  8. package/eigen/Eigen/Householder +9 -8
  9. package/eigen/Eigen/IterativeLinearSolvers +8 -4
  10. package/eigen/Eigen/Jacobi +14 -14
  11. package/eigen/Eigen/KLUSupport +43 -0
  12. package/eigen/Eigen/LU +16 -20
  13. package/eigen/Eigen/MetisSupport +12 -12
  14. package/eigen/Eigen/OrderingMethods +54 -54
  15. package/eigen/Eigen/PaStiXSupport +23 -20
  16. package/eigen/Eigen/PardisoSupport +17 -14
  17. package/eigen/Eigen/QR +18 -21
  18. package/eigen/Eigen/QtAlignedMalloc +5 -13
  19. package/eigen/Eigen/SPQRSupport +21 -14
  20. package/eigen/Eigen/SVD +23 -18
  21. package/eigen/Eigen/Sparse +1 -4
  22. package/eigen/Eigen/SparseCholesky +18 -23
  23. package/eigen/Eigen/SparseCore +18 -17
  24. package/eigen/Eigen/SparseLU +12 -8
  25. package/eigen/Eigen/SparseQR +16 -14
  26. package/eigen/Eigen/StdDeque +5 -2
  27. package/eigen/Eigen/StdList +5 -2
  28. package/eigen/Eigen/StdVector +5 -2
  29. package/eigen/Eigen/SuperLUSupport +30 -24
  30. package/eigen/Eigen/ThreadPool +80 -0
  31. package/eigen/Eigen/UmfPackSupport +19 -17
  32. package/eigen/Eigen/Version +14 -0
  33. package/eigen/Eigen/src/AccelerateSupport/AccelerateSupport.h +423 -0
  34. package/eigen/Eigen/src/AccelerateSupport/InternalHeaderCheck.h +3 -0
  35. package/eigen/Eigen/src/Cholesky/InternalHeaderCheck.h +3 -0
  36. package/eigen/Eigen/src/Cholesky/LDLT.h +377 -401
  37. package/eigen/Eigen/src/Cholesky/LLT.h +332 -360
  38. package/eigen/Eigen/src/Cholesky/LLT_LAPACKE.h +81 -56
  39. package/eigen/Eigen/src/CholmodSupport/CholmodSupport.h +620 -521
  40. package/eigen/Eigen/src/CholmodSupport/InternalHeaderCheck.h +3 -0
  41. package/eigen/Eigen/src/Core/ArithmeticSequence.h +239 -0
  42. package/eigen/Eigen/src/Core/Array.h +341 -294
  43. package/eigen/Eigen/src/Core/ArrayBase.h +190 -203
  44. package/eigen/Eigen/src/Core/ArrayWrapper.h +127 -171
  45. package/eigen/Eigen/src/Core/Assign.h +30 -40
  46. package/eigen/Eigen/src/Core/AssignEvaluator.h +711 -589
  47. package/eigen/Eigen/src/Core/Assign_MKL.h +130 -125
  48. package/eigen/Eigen/src/Core/BandMatrix.h +268 -283
  49. package/eigen/Eigen/src/Core/Block.h +375 -398
  50. package/eigen/Eigen/src/Core/CommaInitializer.h +86 -97
  51. package/eigen/Eigen/src/Core/ConditionEstimator.h +51 -53
  52. package/eigen/Eigen/src/Core/CoreEvaluators.h +1356 -1026
  53. package/eigen/Eigen/src/Core/CoreIterators.h +73 -59
  54. package/eigen/Eigen/src/Core/CwiseBinaryOp.h +114 -132
  55. package/eigen/Eigen/src/Core/CwiseNullaryOp.h +726 -617
  56. package/eigen/Eigen/src/Core/CwiseTernaryOp.h +77 -103
  57. package/eigen/Eigen/src/Core/CwiseUnaryOp.h +56 -68
  58. package/eigen/Eigen/src/Core/CwiseUnaryView.h +132 -95
  59. package/eigen/Eigen/src/Core/DenseBase.h +632 -571
  60. package/eigen/Eigen/src/Core/DenseCoeffsBase.h +511 -624
  61. package/eigen/Eigen/src/Core/DenseStorage.h +512 -509
  62. package/eigen/Eigen/src/Core/DeviceWrapper.h +153 -0
  63. package/eigen/Eigen/src/Core/Diagonal.h +169 -210
  64. package/eigen/Eigen/src/Core/DiagonalMatrix.h +351 -274
  65. package/eigen/Eigen/src/Core/DiagonalProduct.h +12 -10
  66. package/eigen/Eigen/src/Core/Dot.h +172 -222
  67. package/eigen/Eigen/src/Core/EigenBase.h +75 -85
  68. package/eigen/Eigen/src/Core/Fill.h +138 -0
  69. package/eigen/Eigen/src/Core/FindCoeff.h +464 -0
  70. package/eigen/Eigen/src/Core/ForceAlignedAccess.h +90 -109
  71. package/eigen/Eigen/src/Core/Fuzzy.h +82 -105
  72. package/eigen/Eigen/src/Core/GeneralProduct.h +327 -263
  73. package/eigen/Eigen/src/Core/GenericPacketMath.h +1472 -360
  74. package/eigen/Eigen/src/Core/GlobalFunctions.h +194 -151
  75. package/eigen/Eigen/src/Core/IO.h +147 -139
  76. package/eigen/Eigen/src/Core/IndexedView.h +321 -0
  77. package/eigen/Eigen/src/Core/InnerProduct.h +260 -0
  78. package/eigen/Eigen/src/Core/InternalHeaderCheck.h +3 -0
  79. package/eigen/Eigen/src/Core/Inverse.h +56 -66
  80. package/eigen/Eigen/src/Core/Map.h +124 -142
  81. package/eigen/Eigen/src/Core/MapBase.h +256 -281
  82. package/eigen/Eigen/src/Core/MathFunctions.h +1620 -938
  83. package/eigen/Eigen/src/Core/MathFunctionsImpl.h +233 -71
  84. package/eigen/Eigen/src/Core/Matrix.h +491 -416
  85. package/eigen/Eigen/src/Core/MatrixBase.h +468 -453
  86. package/eigen/Eigen/src/Core/NestByValue.h +66 -85
  87. package/eigen/Eigen/src/Core/NoAlias.h +79 -85
  88. package/eigen/Eigen/src/Core/NumTraits.h +235 -148
  89. package/eigen/Eigen/src/Core/PartialReduxEvaluator.h +253 -0
  90. package/eigen/Eigen/src/Core/PermutationMatrix.h +461 -511
  91. package/eigen/Eigen/src/Core/PlainObjectBase.h +871 -894
  92. package/eigen/Eigen/src/Core/Product.h +260 -139
  93. package/eigen/Eigen/src/Core/ProductEvaluators.h +863 -714
  94. package/eigen/Eigen/src/Core/Random.h +161 -136
  95. package/eigen/Eigen/src/Core/RandomImpl.h +262 -0
  96. package/eigen/Eigen/src/Core/RealView.h +250 -0
  97. package/eigen/Eigen/src/Core/Redux.h +366 -336
  98. package/eigen/Eigen/src/Core/Ref.h +308 -209
  99. package/eigen/Eigen/src/Core/Replicate.h +94 -106
  100. package/eigen/Eigen/src/Core/Reshaped.h +398 -0
  101. package/eigen/Eigen/src/Core/ReturnByValue.h +49 -55
  102. package/eigen/Eigen/src/Core/Reverse.h +136 -145
  103. package/eigen/Eigen/src/Core/Select.h +70 -140
  104. package/eigen/Eigen/src/Core/SelfAdjointView.h +262 -285
  105. package/eigen/Eigen/src/Core/SelfCwiseBinaryOp.h +23 -20
  106. package/eigen/Eigen/src/Core/SkewSymmetricMatrix3.h +382 -0
  107. package/eigen/Eigen/src/Core/Solve.h +97 -111
  108. package/eigen/Eigen/src/Core/SolveTriangular.h +131 -129
  109. package/eigen/Eigen/src/Core/SolverBase.h +138 -101
  110. package/eigen/Eigen/src/Core/StableNorm.h +156 -160
  111. package/eigen/Eigen/src/Core/StlIterators.h +619 -0
  112. package/eigen/Eigen/src/Core/Stride.h +91 -88
  113. package/eigen/Eigen/src/Core/Swap.h +70 -38
  114. package/eigen/Eigen/src/Core/Transpose.h +295 -273
  115. package/eigen/Eigen/src/Core/Transpositions.h +272 -317
  116. package/eigen/Eigen/src/Core/TriangularMatrix.h +670 -755
  117. package/eigen/Eigen/src/Core/VectorBlock.h +59 -72
  118. package/eigen/Eigen/src/Core/VectorwiseOp.h +668 -630
  119. package/eigen/Eigen/src/Core/Visitor.h +480 -216
  120. package/eigen/Eigen/src/Core/arch/AVX/Complex.h +407 -293
  121. package/eigen/Eigen/src/Core/arch/AVX/MathFunctions.h +79 -388
  122. package/eigen/Eigen/src/Core/arch/AVX/PacketMath.h +2935 -491
  123. package/eigen/Eigen/src/Core/arch/AVX/Reductions.h +353 -0
  124. package/eigen/Eigen/src/Core/arch/AVX/TypeCasting.h +279 -22
  125. package/eigen/Eigen/src/Core/arch/AVX512/Complex.h +472 -0
  126. package/eigen/Eigen/src/Core/arch/AVX512/GemmKernel.h +1245 -0
  127. package/eigen/Eigen/src/Core/arch/AVX512/MathFunctions.h +85 -333
  128. package/eigen/Eigen/src/Core/arch/AVX512/MathFunctionsFP16.h +75 -0
  129. package/eigen/Eigen/src/Core/arch/AVX512/PacketMath.h +2490 -649
  130. package/eigen/Eigen/src/Core/arch/AVX512/PacketMathFP16.h +1413 -0
  131. package/eigen/Eigen/src/Core/arch/AVX512/Reductions.h +297 -0
  132. package/eigen/Eigen/src/Core/arch/AVX512/TrsmKernel.h +1167 -0
  133. package/eigen/Eigen/src/Core/arch/AVX512/TrsmUnrolls.inc +1219 -0
  134. package/eigen/Eigen/src/Core/arch/AVX512/TypeCasting.h +277 -0
  135. package/eigen/Eigen/src/Core/arch/AVX512/TypeCastingFP16.h +130 -0
  136. package/eigen/Eigen/src/Core/arch/AltiVec/Complex.h +521 -298
  137. package/eigen/Eigen/src/Core/arch/AltiVec/MathFunctions.h +39 -280
  138. package/eigen/Eigen/src/Core/arch/AltiVec/MatrixProduct.h +3686 -0
  139. package/eigen/Eigen/src/Core/arch/AltiVec/MatrixProductCommon.h +205 -0
  140. package/eigen/Eigen/src/Core/arch/AltiVec/MatrixProductMMA.h +901 -0
  141. package/eigen/Eigen/src/Core/arch/AltiVec/MatrixProductMMAbfloat16.h +742 -0
  142. package/eigen/Eigen/src/Core/arch/AltiVec/MatrixVectorProduct.inc +2818 -0
  143. package/eigen/Eigen/src/Core/arch/AltiVec/PacketMath.h +3391 -723
  144. package/eigen/Eigen/src/Core/arch/AltiVec/TypeCasting.h +153 -0
  145. package/eigen/Eigen/src/Core/arch/Default/BFloat16.h +866 -0
  146. package/eigen/Eigen/src/Core/arch/Default/ConjHelper.h +113 -14
  147. package/eigen/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h +2634 -0
  148. package/eigen/Eigen/src/Core/arch/Default/GenericPacketMathFunctionsFwd.h +227 -0
  149. package/eigen/Eigen/src/Core/arch/Default/Half.h +1091 -0
  150. package/eigen/Eigen/src/Core/arch/Default/Settings.h +11 -13
  151. package/eigen/Eigen/src/Core/arch/GPU/Complex.h +244 -0
  152. package/eigen/Eigen/src/Core/arch/GPU/MathFunctions.h +104 -0
  153. package/eigen/Eigen/src/Core/arch/GPU/PacketMath.h +1712 -0
  154. package/eigen/Eigen/src/Core/arch/GPU/Tuple.h +268 -0
  155. package/eigen/Eigen/src/Core/arch/GPU/TypeCasting.h +77 -0
  156. package/eigen/Eigen/src/Core/arch/HIP/hcc/math_constants.h +23 -0
  157. package/eigen/Eigen/src/Core/arch/HVX/PacketMath.h +1088 -0
  158. package/eigen/Eigen/src/Core/arch/LSX/Complex.h +520 -0
  159. package/eigen/Eigen/src/Core/arch/LSX/GeneralBlockPanelKernel.h +23 -0
  160. package/eigen/Eigen/src/Core/arch/LSX/MathFunctions.h +43 -0
  161. package/eigen/Eigen/src/Core/arch/LSX/PacketMath.h +2866 -0
  162. package/eigen/Eigen/src/Core/arch/LSX/TypeCasting.h +526 -0
  163. package/eigen/Eigen/src/Core/arch/MSA/Complex.h +620 -0
  164. package/eigen/Eigen/src/Core/arch/MSA/MathFunctions.h +379 -0
  165. package/eigen/Eigen/src/Core/arch/MSA/PacketMath.h +1237 -0
  166. package/eigen/Eigen/src/Core/arch/NEON/Complex.h +531 -289
  167. package/eigen/Eigen/src/Core/arch/NEON/GeneralBlockPanelKernel.h +243 -0
  168. package/eigen/Eigen/src/Core/arch/NEON/MathFunctions.h +50 -73
  169. package/eigen/Eigen/src/Core/arch/NEON/PacketMath.h +5915 -579
  170. package/eigen/Eigen/src/Core/arch/NEON/TypeCasting.h +1642 -0
  171. package/eigen/Eigen/src/Core/arch/NEON/UnaryFunctors.h +57 -0
  172. package/eigen/Eigen/src/Core/arch/SSE/Complex.h +366 -334
  173. package/eigen/Eigen/src/Core/arch/SSE/MathFunctions.h +40 -514
  174. package/eigen/Eigen/src/Core/arch/SSE/PacketMath.h +2164 -675
  175. package/eigen/Eigen/src/Core/arch/SSE/Reductions.h +324 -0
  176. package/eigen/Eigen/src/Core/arch/SSE/TypeCasting.h +188 -35
  177. package/eigen/Eigen/src/Core/arch/SVE/MathFunctions.h +48 -0
  178. package/eigen/Eigen/src/Core/arch/SVE/PacketMath.h +674 -0
  179. package/eigen/Eigen/src/Core/arch/SVE/TypeCasting.h +52 -0
  180. package/eigen/Eigen/src/Core/arch/SYCL/InteropHeaders.h +227 -0
  181. package/eigen/Eigen/src/Core/arch/SYCL/MathFunctions.h +303 -0
  182. package/eigen/Eigen/src/Core/arch/SYCL/PacketMath.h +576 -0
  183. package/eigen/Eigen/src/Core/arch/SYCL/TypeCasting.h +83 -0
  184. package/eigen/Eigen/src/Core/arch/ZVector/Complex.h +434 -261
  185. package/eigen/Eigen/src/Core/arch/ZVector/MathFunctions.h +160 -53
  186. package/eigen/Eigen/src/Core/arch/ZVector/PacketMath.h +1073 -605
  187. package/eigen/Eigen/src/Core/functors/AssignmentFunctors.h +123 -117
  188. package/eigen/Eigen/src/Core/functors/BinaryFunctors.h +594 -322
  189. package/eigen/Eigen/src/Core/functors/NullaryFunctors.h +204 -118
  190. package/eigen/Eigen/src/Core/functors/StlFunctors.h +110 -97
  191. package/eigen/Eigen/src/Core/functors/TernaryFunctors.h +34 -7
  192. package/eigen/Eigen/src/Core/functors/UnaryFunctors.h +1158 -530
  193. package/eigen/Eigen/src/Core/products/GeneralBlockPanelKernel.h +2329 -1333
  194. package/eigen/Eigen/src/Core/products/GeneralMatrixMatrix.h +328 -364
  195. package/eigen/Eigen/src/Core/products/GeneralMatrixMatrixTriangular.h +191 -178
  196. package/eigen/Eigen/src/Core/products/GeneralMatrixMatrixTriangular_BLAS.h +85 -82
  197. package/eigen/Eigen/src/Core/products/GeneralMatrixMatrix_BLAS.h +154 -73
  198. package/eigen/Eigen/src/Core/products/GeneralMatrixVector.h +396 -542
  199. package/eigen/Eigen/src/Core/products/GeneralMatrixVector_BLAS.h +80 -77
  200. package/eigen/Eigen/src/Core/products/Parallelizer.h +208 -92
  201. package/eigen/Eigen/src/Core/products/SelfadjointMatrixMatrix.h +331 -375
  202. package/eigen/Eigen/src/Core/products/SelfadjointMatrixMatrix_BLAS.h +206 -224
  203. package/eigen/Eigen/src/Core/products/SelfadjointMatrixVector.h +139 -146
  204. package/eigen/Eigen/src/Core/products/SelfadjointMatrixVector_BLAS.h +58 -61
  205. package/eigen/Eigen/src/Core/products/SelfadjointProduct.h +71 -71
  206. package/eigen/Eigen/src/Core/products/SelfadjointRank2Update.h +48 -46
  207. package/eigen/Eigen/src/Core/products/TriangularMatrixMatrix.h +294 -369
  208. package/eigen/Eigen/src/Core/products/TriangularMatrixMatrix_BLAS.h +246 -238
  209. package/eigen/Eigen/src/Core/products/TriangularMatrixVector.h +244 -247
  210. package/eigen/Eigen/src/Core/products/TriangularMatrixVector_BLAS.h +212 -192
  211. package/eigen/Eigen/src/Core/products/TriangularSolverMatrix.h +328 -275
  212. package/eigen/Eigen/src/Core/products/TriangularSolverMatrix_BLAS.h +108 -109
  213. package/eigen/Eigen/src/Core/products/TriangularSolverVector.h +70 -93
  214. package/eigen/Eigen/src/Core/util/Assert.h +158 -0
  215. package/eigen/Eigen/src/Core/util/BlasUtil.h +413 -290
  216. package/eigen/Eigen/src/Core/util/ConfigureVectorization.h +543 -0
  217. package/eigen/Eigen/src/Core/util/Constants.h +314 -263
  218. package/eigen/Eigen/src/Core/util/DisableStupidWarnings.h +130 -78
  219. package/eigen/Eigen/src/Core/util/EmulateArray.h +270 -0
  220. package/eigen/Eigen/src/Core/util/ForwardDeclarations.h +450 -224
  221. package/eigen/Eigen/src/Core/util/GpuHipCudaDefines.inc +101 -0
  222. package/eigen/Eigen/src/Core/util/GpuHipCudaUndefines.inc +45 -0
  223. package/eigen/Eigen/src/Core/util/IndexedViewHelper.h +487 -0
  224. package/eigen/Eigen/src/Core/util/IntegralConstant.h +279 -0
  225. package/eigen/Eigen/src/Core/util/MKL_support.h +39 -30
  226. package/eigen/Eigen/src/Core/util/Macros.h +939 -646
  227. package/eigen/Eigen/src/Core/util/MaxSizeVector.h +139 -0
  228. package/eigen/Eigen/src/Core/util/Memory.h +1042 -650
  229. package/eigen/Eigen/src/Core/util/Meta.h +618 -426
  230. package/eigen/Eigen/src/Core/util/MoreMeta.h +638 -0
  231. package/eigen/Eigen/src/Core/util/ReenableStupidWarnings.h +32 -19
  232. package/eigen/Eigen/src/Core/util/ReshapedHelper.h +51 -0
  233. package/eigen/Eigen/src/Core/util/Serializer.h +209 -0
  234. package/eigen/Eigen/src/Core/util/StaticAssert.h +51 -164
  235. package/eigen/Eigen/src/Core/util/SymbolicIndex.h +445 -0
  236. package/eigen/Eigen/src/Core/util/XprHelper.h +793 -538
  237. package/eigen/Eigen/src/Eigenvalues/ComplexEigenSolver.h +246 -277
  238. package/eigen/Eigen/src/Eigenvalues/ComplexSchur.h +299 -319
  239. package/eigen/Eigen/src/Eigenvalues/ComplexSchur_LAPACKE.h +52 -48
  240. package/eigen/Eigen/src/Eigenvalues/EigenSolver.h +413 -456
  241. package/eigen/Eigen/src/Eigenvalues/GeneralizedEigenSolver.h +309 -325
  242. package/eigen/Eigen/src/Eigenvalues/GeneralizedSelfAdjointEigenSolver.h +157 -171
  243. package/eigen/Eigen/src/Eigenvalues/HessenbergDecomposition.h +292 -310
  244. package/eigen/Eigen/src/Eigenvalues/InternalHeaderCheck.h +3 -0
  245. package/eigen/Eigen/src/Eigenvalues/MatrixBaseEigenvalues.h +91 -107
  246. package/eigen/Eigen/src/Eigenvalues/RealQZ.h +539 -606
  247. package/eigen/Eigen/src/Eigenvalues/RealSchur.h +348 -382
  248. package/eigen/Eigen/src/Eigenvalues/RealSchur_LAPACKE.h +41 -35
  249. package/eigen/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h +579 -600
  250. package/eigen/Eigen/src/Eigenvalues/SelfAdjointEigenSolver_LAPACKE.h +47 -44
  251. package/eigen/Eigen/src/Eigenvalues/Tridiagonalization.h +434 -461
  252. package/eigen/Eigen/src/Geometry/AlignedBox.h +307 -214
  253. package/eigen/Eigen/src/Geometry/AngleAxis.h +135 -137
  254. package/eigen/Eigen/src/Geometry/EulerAngles.h +163 -74
  255. package/eigen/Eigen/src/Geometry/Homogeneous.h +289 -333
  256. package/eigen/Eigen/src/Geometry/Hyperplane.h +152 -161
  257. package/eigen/Eigen/src/Geometry/InternalHeaderCheck.h +3 -0
  258. package/eigen/Eigen/src/Geometry/OrthoMethods.h +168 -145
  259. package/eigen/Eigen/src/Geometry/ParametrizedLine.h +141 -104
  260. package/eigen/Eigen/src/Geometry/Quaternion.h +595 -497
  261. package/eigen/Eigen/src/Geometry/Rotation2D.h +110 -108
  262. package/eigen/Eigen/src/Geometry/RotationBase.h +148 -145
  263. package/eigen/Eigen/src/Geometry/Scaling.h +115 -90
  264. package/eigen/Eigen/src/Geometry/Transform.h +896 -953
  265. package/eigen/Eigen/src/Geometry/Translation.h +100 -98
  266. package/eigen/Eigen/src/Geometry/Umeyama.h +79 -84
  267. package/eigen/Eigen/src/Geometry/arch/Geometry_SIMD.h +154 -0
  268. package/eigen/Eigen/src/Householder/BlockHouseholder.h +54 -42
  269. package/eigen/Eigen/src/Householder/Householder.h +104 -122
  270. package/eigen/Eigen/src/Householder/HouseholderSequence.h +416 -382
  271. package/eigen/Eigen/src/Householder/InternalHeaderCheck.h +3 -0
  272. package/eigen/Eigen/src/IterativeLinearSolvers/BasicPreconditioners.h +153 -166
  273. package/eigen/Eigen/src/IterativeLinearSolvers/BiCGSTAB.h +127 -138
  274. package/eigen/Eigen/src/IterativeLinearSolvers/ConjugateGradient.h +95 -124
  275. package/eigen/Eigen/src/IterativeLinearSolvers/IncompleteCholesky.h +269 -267
  276. package/eigen/Eigen/src/IterativeLinearSolvers/IncompleteLUT.h +246 -259
  277. package/eigen/Eigen/src/IterativeLinearSolvers/InternalHeaderCheck.h +3 -0
  278. package/eigen/Eigen/src/IterativeLinearSolvers/IterativeSolverBase.h +218 -217
  279. package/eigen/Eigen/src/IterativeLinearSolvers/LeastSquareConjugateGradient.h +80 -103
  280. package/eigen/Eigen/src/IterativeLinearSolvers/SolveWithGuess.h +59 -63
  281. package/eigen/Eigen/src/Jacobi/InternalHeaderCheck.h +3 -0
  282. package/eigen/Eigen/src/Jacobi/Jacobi.h +256 -291
  283. package/eigen/Eigen/src/KLUSupport/InternalHeaderCheck.h +3 -0
  284. package/eigen/Eigen/src/KLUSupport/KLUSupport.h +339 -0
  285. package/eigen/Eigen/src/LU/Determinant.h +60 -63
  286. package/eigen/Eigen/src/LU/FullPivLU.h +561 -626
  287. package/eigen/Eigen/src/LU/InternalHeaderCheck.h +3 -0
  288. package/eigen/Eigen/src/LU/InverseImpl.h +213 -275
  289. package/eigen/Eigen/src/LU/PartialPivLU.h +407 -435
  290. package/eigen/Eigen/src/LU/PartialPivLU_LAPACKE.h +54 -40
  291. package/eigen/Eigen/src/LU/arch/InverseSize4.h +353 -0
  292. package/eigen/Eigen/src/MetisSupport/InternalHeaderCheck.h +3 -0
  293. package/eigen/Eigen/src/MetisSupport/MetisSupport.h +81 -93
  294. package/eigen/Eigen/src/OrderingMethods/Amd.h +250 -282
  295. package/eigen/Eigen/src/OrderingMethods/Eigen_Colamd.h +950 -1103
  296. package/eigen/Eigen/src/OrderingMethods/InternalHeaderCheck.h +3 -0
  297. package/eigen/Eigen/src/OrderingMethods/Ordering.h +111 -122
  298. package/eigen/Eigen/src/PaStiXSupport/InternalHeaderCheck.h +3 -0
  299. package/eigen/Eigen/src/PaStiXSupport/PaStiXSupport.h +524 -570
  300. package/eigen/Eigen/src/PardisoSupport/InternalHeaderCheck.h +3 -0
  301. package/eigen/Eigen/src/PardisoSupport/PardisoSupport.h +385 -429
  302. package/eigen/Eigen/src/QR/ColPivHouseholderQR.h +494 -473
  303. package/eigen/Eigen/src/QR/ColPivHouseholderQR_LAPACKE.h +120 -56
  304. package/eigen/Eigen/src/QR/CompleteOrthogonalDecomposition.h +223 -137
  305. package/eigen/Eigen/src/QR/FullPivHouseholderQR.h +517 -460
  306. package/eigen/Eigen/src/QR/HouseholderQR.h +412 -278
  307. package/eigen/Eigen/src/QR/HouseholderQR_LAPACKE.h +32 -23
  308. package/eigen/Eigen/src/QR/InternalHeaderCheck.h +3 -0
  309. package/eigen/Eigen/src/SPQRSupport/InternalHeaderCheck.h +3 -0
  310. package/eigen/Eigen/src/SPQRSupport/SuiteSparseQRSupport.h +263 -261
  311. package/eigen/Eigen/src/SVD/BDCSVD.h +872 -679
  312. package/eigen/Eigen/src/SVD/BDCSVD_LAPACKE.h +174 -0
  313. package/eigen/Eigen/src/SVD/InternalHeaderCheck.h +3 -0
  314. package/eigen/Eigen/src/SVD/JacobiSVD.h +585 -543
  315. package/eigen/Eigen/src/SVD/JacobiSVD_LAPACKE.h +85 -49
  316. package/eigen/Eigen/src/SVD/SVDBase.h +281 -160
  317. package/eigen/Eigen/src/SVD/UpperBidiagonalization.h +202 -237
  318. package/eigen/Eigen/src/SparseCholesky/InternalHeaderCheck.h +3 -0
  319. package/eigen/Eigen/src/SparseCholesky/SimplicialCholesky.h +769 -590
  320. package/eigen/Eigen/src/SparseCholesky/SimplicialCholesky_impl.h +318 -129
  321. package/eigen/Eigen/src/SparseCore/AmbiVector.h +202 -251
  322. package/eigen/Eigen/src/SparseCore/CompressedStorage.h +184 -236
  323. package/eigen/Eigen/src/SparseCore/ConservativeSparseSparseProduct.h +140 -184
  324. package/eigen/Eigen/src/SparseCore/InternalHeaderCheck.h +3 -0
  325. package/eigen/Eigen/src/SparseCore/SparseAssign.h +174 -111
  326. package/eigen/Eigen/src/SparseCore/SparseBlock.h +408 -477
  327. package/eigen/Eigen/src/SparseCore/SparseColEtree.h +100 -112
  328. package/eigen/Eigen/src/SparseCore/SparseCompressedBase.h +531 -280
  329. package/eigen/Eigen/src/SparseCore/SparseCwiseBinaryOp.h +559 -347
  330. package/eigen/Eigen/src/SparseCore/SparseCwiseUnaryOp.h +100 -108
  331. package/eigen/Eigen/src/SparseCore/SparseDenseProduct.h +185 -191
  332. package/eigen/Eigen/src/SparseCore/SparseDiagonalProduct.h +71 -71
  333. package/eigen/Eigen/src/SparseCore/SparseDot.h +49 -47
  334. package/eigen/Eigen/src/SparseCore/SparseFuzzy.h +13 -11
  335. package/eigen/Eigen/src/SparseCore/SparseMap.h +243 -253
  336. package/eigen/Eigen/src/SparseCore/SparseMatrix.h +1614 -1142
  337. package/eigen/Eigen/src/SparseCore/SparseMatrixBase.h +403 -357
  338. package/eigen/Eigen/src/SparseCore/SparsePermutation.h +186 -115
  339. package/eigen/Eigen/src/SparseCore/SparseProduct.h +100 -91
  340. package/eigen/Eigen/src/SparseCore/SparseRedux.h +22 -24
  341. package/eigen/Eigen/src/SparseCore/SparseRef.h +268 -295
  342. package/eigen/Eigen/src/SparseCore/SparseSelfAdjointView.h +371 -414
  343. package/eigen/Eigen/src/SparseCore/SparseSolverBase.h +78 -87
  344. package/eigen/Eigen/src/SparseCore/SparseSparseProductWithPruning.h +81 -95
  345. package/eigen/Eigen/src/SparseCore/SparseTranspose.h +62 -71
  346. package/eigen/Eigen/src/SparseCore/SparseTriangularView.h +132 -144
  347. package/eigen/Eigen/src/SparseCore/SparseUtil.h +146 -115
  348. package/eigen/Eigen/src/SparseCore/SparseVector.h +426 -372
  349. package/eigen/Eigen/src/SparseCore/SparseView.h +164 -193
  350. package/eigen/Eigen/src/SparseCore/TriangularSolver.h +129 -170
  351. package/eigen/Eigen/src/SparseLU/InternalHeaderCheck.h +3 -0
  352. package/eigen/Eigen/src/SparseLU/SparseLU.h +814 -618
  353. package/eigen/Eigen/src/SparseLU/SparseLUImpl.h +61 -48
  354. package/eigen/Eigen/src/SparseLU/SparseLU_Memory.h +102 -118
  355. package/eigen/Eigen/src/SparseLU/SparseLU_Structs.h +38 -35
  356. package/eigen/Eigen/src/SparseLU/SparseLU_SupernodalMatrix.h +273 -255
  357. package/eigen/Eigen/src/SparseLU/SparseLU_Utils.h +44 -49
  358. package/eigen/Eigen/src/SparseLU/SparseLU_column_bmod.h +104 -108
  359. package/eigen/Eigen/src/SparseLU/SparseLU_column_dfs.h +90 -101
  360. package/eigen/Eigen/src/SparseLU/SparseLU_copy_to_ucol.h +57 -58
  361. package/eigen/Eigen/src/SparseLU/SparseLU_heap_relax_snode.h +43 -55
  362. package/eigen/Eigen/src/SparseLU/SparseLU_kernel_bmod.h +74 -71
  363. package/eigen/Eigen/src/SparseLU/SparseLU_panel_bmod.h +125 -133
  364. package/eigen/Eigen/src/SparseLU/SparseLU_panel_dfs.h +136 -159
  365. package/eigen/Eigen/src/SparseLU/SparseLU_pivotL.h +51 -52
  366. package/eigen/Eigen/src/SparseLU/SparseLU_pruneL.h +67 -73
  367. package/eigen/Eigen/src/SparseLU/SparseLU_relax_snode.h +24 -26
  368. package/eigen/Eigen/src/SparseQR/InternalHeaderCheck.h +3 -0
  369. package/eigen/Eigen/src/SparseQR/SparseQR.h +451 -490
  370. package/eigen/Eigen/src/StlSupport/StdDeque.h +28 -105
  371. package/eigen/Eigen/src/StlSupport/StdList.h +28 -84
  372. package/eigen/Eigen/src/StlSupport/StdVector.h +28 -108
  373. package/eigen/Eigen/src/StlSupport/details.h +48 -50
  374. package/eigen/Eigen/src/SuperLUSupport/InternalHeaderCheck.h +3 -0
  375. package/eigen/Eigen/src/SuperLUSupport/SuperLUSupport.h +634 -732
  376. package/eigen/Eigen/src/ThreadPool/Barrier.h +70 -0
  377. package/eigen/Eigen/src/ThreadPool/CoreThreadPoolDevice.h +336 -0
  378. package/eigen/Eigen/src/ThreadPool/EventCount.h +241 -0
  379. package/eigen/Eigen/src/ThreadPool/ForkJoin.h +140 -0
  380. package/eigen/Eigen/src/ThreadPool/InternalHeaderCheck.h +4 -0
  381. package/eigen/Eigen/src/ThreadPool/NonBlockingThreadPool.h +587 -0
  382. package/eigen/Eigen/src/ThreadPool/RunQueue.h +230 -0
  383. package/eigen/Eigen/src/ThreadPool/ThreadCancel.h +21 -0
  384. package/eigen/Eigen/src/ThreadPool/ThreadEnvironment.h +43 -0
  385. package/eigen/Eigen/src/ThreadPool/ThreadLocal.h +289 -0
  386. package/eigen/Eigen/src/ThreadPool/ThreadPoolInterface.h +50 -0
  387. package/eigen/Eigen/src/ThreadPool/ThreadYield.h +16 -0
  388. package/eigen/Eigen/src/UmfPackSupport/InternalHeaderCheck.h +3 -0
  389. package/eigen/Eigen/src/UmfPackSupport/UmfPackSupport.h +480 -380
  390. package/eigen/Eigen/src/misc/Image.h +41 -43
  391. package/eigen/Eigen/src/misc/InternalHeaderCheck.h +3 -0
  392. package/eigen/Eigen/src/misc/Kernel.h +39 -41
  393. package/eigen/Eigen/src/misc/RealSvd2x2.h +19 -21
  394. package/eigen/Eigen/src/misc/blas.h +83 -426
  395. package/eigen/Eigen/src/misc/lapacke.h +9976 -16182
  396. package/eigen/Eigen/src/misc/lapacke_helpers.h +163 -0
  397. package/eigen/Eigen/src/misc/lapacke_mangling.h +4 -5
  398. package/eigen/Eigen/src/plugins/ArrayCwiseBinaryOps.inc +344 -0
  399. package/eigen/Eigen/src/plugins/ArrayCwiseUnaryOps.inc +544 -0
  400. package/eigen/Eigen/src/plugins/BlockMethods.inc +1370 -0
  401. package/eigen/Eigen/src/plugins/CommonCwiseBinaryOps.inc +116 -0
  402. package/eigen/Eigen/src/plugins/CommonCwiseUnaryOps.inc +167 -0
  403. package/eigen/Eigen/src/plugins/IndexedViewMethods.inc +192 -0
  404. package/eigen/Eigen/src/plugins/InternalHeaderCheck.inc +3 -0
  405. package/eigen/Eigen/src/plugins/MatrixCwiseBinaryOps.inc +331 -0
  406. package/eigen/Eigen/src/plugins/MatrixCwiseUnaryOps.inc +118 -0
  407. package/eigen/Eigen/src/plugins/ReshapedMethods.inc +133 -0
  408. package/lib/LibEigen.d.ts +4 -0
  409. package/lib/LibEigen.js +14 -0
  410. package/lib/index.d.ts +1 -1
  411. package/lib/index.js +7 -3
  412. package/package.json +2 -10
  413. package/eigen/Eigen/CMakeLists.txt +0 -19
  414. package/eigen/Eigen/src/Core/BooleanRedux.h +0 -164
  415. package/eigen/Eigen/src/Core/arch/CUDA/Complex.h +0 -103
  416. package/eigen/Eigen/src/Core/arch/CUDA/Half.h +0 -675
  417. package/eigen/Eigen/src/Core/arch/CUDA/MathFunctions.h +0 -91
  418. package/eigen/Eigen/src/Core/arch/CUDA/PacketMath.h +0 -333
  419. package/eigen/Eigen/src/Core/arch/CUDA/PacketMathHalf.h +0 -1124
  420. package/eigen/Eigen/src/Core/arch/CUDA/TypeCasting.h +0 -212
  421. package/eigen/Eigen/src/Core/util/NonMPL2.h +0 -3
  422. package/eigen/Eigen/src/Geometry/arch/Geometry_SSE.h +0 -161
  423. package/eigen/Eigen/src/LU/arch/Inverse_SSE.h +0 -338
  424. package/eigen/Eigen/src/SparseCore/MappedSparseMatrix.h +0 -67
  425. package/eigen/Eigen/src/SparseLU/SparseLU_gemm_kernel.h +0 -280
  426. package/eigen/Eigen/src/misc/lapack.h +0 -152
  427. package/eigen/Eigen/src/plugins/ArrayCwiseBinaryOps.h +0 -332
  428. package/eigen/Eigen/src/plugins/ArrayCwiseUnaryOps.h +0 -552
  429. package/eigen/Eigen/src/plugins/BlockMethods.h +0 -1058
  430. package/eigen/Eigen/src/plugins/CommonCwiseBinaryOps.h +0 -115
  431. package/eigen/Eigen/src/plugins/CommonCwiseUnaryOps.h +0 -163
  432. package/eigen/Eigen/src/plugins/MatrixCwiseBinaryOps.h +0 -152
  433. package/eigen/Eigen/src/plugins/MatrixCwiseUnaryOps.h +0 -85
  434. package/lib/eigen.d.ts +0 -2
  435. 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,1005 +11,1358 @@
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
+ // Source: WolframAlpha
15
16
  #define EIGEN_PI 3.141592653589793238462643383279502884197169399375105820974944592307816406L
17
+ #define EIGEN_LOG2E 1.442695040888963407359924681001892137426645954152985934135449406931109219L
18
+ #define EIGEN_LN2 0.693147180559945309417232121458176568075500134360255254120680009493393621L
16
19
 
20
+ // IWYU pragma: private
21
+ #include "./InternalHeaderCheck.h"
17
22
 
18
23
  namespace Eigen {
19
24
 
20
- // On WINCE, std::abs is defined for int only, so let's defined our own overloads:
21
- // This issue has been confirmed with MSVC 2008 only, but the issue might exist for more recent versions too.
22
- #if EIGEN_OS_WINCE && EIGEN_COMP_MSVC && EIGEN_COMP_MSVC<=1500
23
- long abs(long x) { return (labs(x)); }
24
- double abs(double x) { return (fabs(x)); }
25
- float abs(float x) { return (fabsf(x)); }
26
- long double abs(long double x) { return (fabsl(x)); }
27
- #endif
28
-
29
25
  namespace internal {
30
26
 
31
27
  /** \internal \class global_math_functions_filtering_base
32
- *
33
- * What it does:
34
- * Defines a typedef 'type' as follows:
35
- * - if type T has a member typedef Eigen_BaseClassForSpecializationOfGlobalMathFuncImpl, then
36
- * global_math_functions_filtering_base<T>::type is a typedef for it.
37
- * - otherwise, global_math_functions_filtering_base<T>::type is a typedef for T.
38
- *
39
- * How it's used:
40
- * To allow to defined the global math functions (like sin...) in certain cases, like the Array expressions.
41
- * When you do sin(array1+array2), the object array1+array2 has a complicated expression type, all what you want to know
42
- * is that it inherits ArrayBase. So we implement a partial specialization of sin_impl for ArrayBase<Derived>.
43
- * So we must make sure to use sin_impl<ArrayBase<Derived> > and not sin_impl<Derived>, otherwise our partial specialization
44
- * won't be used. How does sin know that? That's exactly what global_math_functions_filtering_base tells it.
45
- *
46
- * How it's implemented:
47
- * SFINAE in the style of enable_if. Highly susceptible of breaking compilers. With GCC, it sure does work, but if you replace
48
- * the typename dummy by an integer template parameter, it doesn't work anymore!
49
- */
50
-
51
- template<typename T, typename dummy = void>
52
- struct global_math_functions_filtering_base
53
- {
28
+ *
29
+ * What it does:
30
+ * Defines a typedef 'type' as follows:
31
+ * - if type T has a member typedef Eigen_BaseClassForSpecializationOfGlobalMathFuncImpl, then
32
+ * global_math_functions_filtering_base<T>::type is a typedef for it.
33
+ * - otherwise, global_math_functions_filtering_base<T>::type is a typedef for T.
34
+ *
35
+ * How it's used:
36
+ * To allow to defined the global math functions (like sin...) in certain cases, like the Array expressions.
37
+ * When you do sin(array1+array2), the object array1+array2 has a complicated expression type, all what you want to know
38
+ * is that it inherits ArrayBase. So we implement a partial specialization of sin_impl for ArrayBase<Derived>.
39
+ * So we must make sure to use sin_impl<ArrayBase<Derived> > and not sin_impl<Derived>, otherwise our partial
40
+ * specialization won't be used. How does sin know that? That's exactly what global_math_functions_filtering_base tells
41
+ * it.
42
+ *
43
+ * How it's implemented:
44
+ * SFINAE in the style of enable_if. Highly susceptible of breaking compilers. With GCC, it sure does work, but if you
45
+ * replace the typename dummy by an integer template parameter, it doesn't work anymore!
46
+ */
47
+
48
+ template <typename T, typename dummy = void>
49
+ struct global_math_functions_filtering_base {
54
50
  typedef T type;
55
51
  };
56
52
 
57
- template<typename T> struct always_void { typedef void type; };
53
+ template <typename T>
54
+ struct always_void {
55
+ typedef void type;
56
+ };
58
57
 
59
- template<typename T>
60
- struct global_math_functions_filtering_base
61
- <T,
62
- typename always_void<typename T::Eigen_BaseClassForSpecializationOfGlobalMathFuncImpl>::type
63
- >
64
- {
58
+ template <typename T>
59
+ struct global_math_functions_filtering_base<
60
+ T, typename always_void<typename T::Eigen_BaseClassForSpecializationOfGlobalMathFuncImpl>::type> {
65
61
  typedef typename T::Eigen_BaseClassForSpecializationOfGlobalMathFuncImpl type;
66
62
  };
67
63
 
68
- #define EIGEN_MATHFUNC_IMPL(func, scalar) Eigen::internal::func##_impl<typename Eigen::internal::global_math_functions_filtering_base<scalar>::type>
69
- #define EIGEN_MATHFUNC_RETVAL(func, scalar) typename Eigen::internal::func##_retval<typename Eigen::internal::global_math_functions_filtering_base<scalar>::type>::type
64
+ #define EIGEN_MATHFUNC_IMPL(func, scalar) \
65
+ Eigen::internal::func##_impl<typename Eigen::internal::global_math_functions_filtering_base<scalar>::type>
66
+ #define EIGEN_MATHFUNC_RETVAL(func, scalar) \
67
+ typename Eigen::internal::func##_retval< \
68
+ typename Eigen::internal::global_math_functions_filtering_base<scalar>::type>::type
70
69
 
71
70
  /****************************************************************************
72
- * Implementation of real *
73
- ****************************************************************************/
71
+ * Implementation of real *
72
+ ****************************************************************************/
74
73
 
75
- template<typename Scalar, bool IsComplex = NumTraits<Scalar>::IsComplex>
76
- struct real_default_impl
77
- {
74
+ template <typename Scalar, bool IsComplex = NumTraits<Scalar>::IsComplex>
75
+ struct real_default_impl {
78
76
  typedef typename NumTraits<Scalar>::Real RealScalar;
79
- EIGEN_DEVICE_FUNC
80
- static inline RealScalar run(const Scalar& x)
81
- {
82
- return x;
83
- }
77
+ EIGEN_DEVICE_FUNC static inline RealScalar run(const Scalar& x) { return x; }
84
78
  };
85
79
 
86
- template<typename Scalar>
87
- struct real_default_impl<Scalar,true>
88
- {
80
+ template <typename Scalar>
81
+ struct real_default_impl<Scalar, true> {
89
82
  typedef typename NumTraits<Scalar>::Real RealScalar;
90
- EIGEN_DEVICE_FUNC
91
- static inline RealScalar run(const Scalar& x)
92
- {
83
+ EIGEN_DEVICE_FUNC static inline RealScalar run(const Scalar& x) {
93
84
  using std::real;
94
85
  return real(x);
95
86
  }
96
87
  };
97
88
 
98
- template<typename Scalar> struct real_impl : real_default_impl<Scalar> {};
89
+ template <typename Scalar>
90
+ struct real_impl : real_default_impl<Scalar> {};
99
91
 
100
- #ifdef __CUDA_ARCH__
101
- template<typename T>
102
- struct real_impl<std::complex<T> >
103
- {
92
+ #if defined(EIGEN_GPU_COMPILE_PHASE)
93
+ template <typename T>
94
+ struct real_impl<std::complex<T>> {
104
95
  typedef T RealScalar;
105
- EIGEN_DEVICE_FUNC
106
- static inline T run(const std::complex<T>& x)
107
- {
108
- return x.real();
109
- }
96
+ EIGEN_DEVICE_FUNC static inline T run(const std::complex<T>& x) { return x.real(); }
110
97
  };
111
98
  #endif
112
99
 
113
- template<typename Scalar>
114
- struct real_retval
115
- {
100
+ template <typename Scalar>
101
+ struct real_retval {
116
102
  typedef typename NumTraits<Scalar>::Real type;
117
103
  };
118
104
 
119
105
  /****************************************************************************
120
- * Implementation of imag *
121
- ****************************************************************************/
106
+ * Implementation of imag *
107
+ ****************************************************************************/
122
108
 
123
- template<typename Scalar, bool IsComplex = NumTraits<Scalar>::IsComplex>
124
- struct imag_default_impl
125
- {
109
+ template <typename Scalar, bool IsComplex = NumTraits<Scalar>::IsComplex>
110
+ struct imag_default_impl {
126
111
  typedef typename NumTraits<Scalar>::Real RealScalar;
127
- EIGEN_DEVICE_FUNC
128
- static inline RealScalar run(const Scalar&)
129
- {
130
- return RealScalar(0);
131
- }
112
+ EIGEN_DEVICE_FUNC static inline RealScalar run(const Scalar&) { return RealScalar(0); }
132
113
  };
133
114
 
134
- template<typename Scalar>
135
- struct imag_default_impl<Scalar,true>
136
- {
115
+ template <typename Scalar>
116
+ struct imag_default_impl<Scalar, true> {
137
117
  typedef typename NumTraits<Scalar>::Real RealScalar;
138
- EIGEN_DEVICE_FUNC
139
- static inline RealScalar run(const Scalar& x)
140
- {
118
+ EIGEN_DEVICE_FUNC static inline RealScalar run(const Scalar& x) {
141
119
  using std::imag;
142
120
  return imag(x);
143
121
  }
144
122
  };
145
123
 
146
- template<typename Scalar> struct imag_impl : imag_default_impl<Scalar> {};
124
+ template <typename Scalar>
125
+ struct imag_impl : imag_default_impl<Scalar> {};
147
126
 
148
- #ifdef __CUDA_ARCH__
149
- template<typename T>
150
- struct imag_impl<std::complex<T> >
151
- {
127
+ #if defined(EIGEN_GPU_COMPILE_PHASE)
128
+ template <typename T>
129
+ struct imag_impl<std::complex<T>> {
152
130
  typedef T RealScalar;
153
- EIGEN_DEVICE_FUNC
154
- static inline T run(const std::complex<T>& x)
155
- {
156
- return x.imag();
157
- }
131
+ EIGEN_DEVICE_FUNC static inline T run(const std::complex<T>& x) { return x.imag(); }
158
132
  };
159
133
  #endif
160
134
 
161
- template<typename Scalar>
162
- struct imag_retval
163
- {
135
+ template <typename Scalar>
136
+ struct imag_retval {
164
137
  typedef typename NumTraits<Scalar>::Real type;
165
138
  };
166
139
 
167
140
  /****************************************************************************
168
- * Implementation of real_ref *
169
- ****************************************************************************/
141
+ * Implementation of real_ref *
142
+ ****************************************************************************/
170
143
 
171
- template<typename Scalar>
172
- struct real_ref_impl
173
- {
144
+ template <typename Scalar>
145
+ struct real_ref_impl {
174
146
  typedef typename NumTraits<Scalar>::Real RealScalar;
175
- EIGEN_DEVICE_FUNC
176
- static inline RealScalar& run(Scalar& x)
177
- {
178
- return reinterpret_cast<RealScalar*>(&x)[0];
179
- }
180
- EIGEN_DEVICE_FUNC
181
- static inline const RealScalar& run(const Scalar& x)
182
- {
147
+ EIGEN_DEVICE_FUNC static inline RealScalar& run(Scalar& x) { return reinterpret_cast<RealScalar*>(&x)[0]; }
148
+ EIGEN_DEVICE_FUNC static inline const RealScalar& run(const Scalar& x) {
183
149
  return reinterpret_cast<const RealScalar*>(&x)[0];
184
150
  }
185
151
  };
186
152
 
187
- template<typename Scalar>
188
- struct real_ref_retval
189
- {
190
- typedef typename NumTraits<Scalar>::Real & type;
153
+ template <typename Scalar>
154
+ struct real_ref_retval {
155
+ typedef typename NumTraits<Scalar>::Real& type;
191
156
  };
192
157
 
193
158
  /****************************************************************************
194
- * Implementation of imag_ref *
195
- ****************************************************************************/
159
+ * Implementation of imag_ref *
160
+ ****************************************************************************/
196
161
 
197
- template<typename Scalar, bool IsComplex>
198
- struct imag_ref_default_impl
199
- {
162
+ template <typename Scalar, bool IsComplex>
163
+ struct imag_ref_default_impl {
200
164
  typedef typename NumTraits<Scalar>::Real RealScalar;
201
- EIGEN_DEVICE_FUNC
202
- static inline RealScalar& run(Scalar& x)
203
- {
204
- return reinterpret_cast<RealScalar*>(&x)[1];
205
- }
206
- EIGEN_DEVICE_FUNC
207
- static inline const RealScalar& run(const Scalar& x)
208
- {
209
- return reinterpret_cast<RealScalar*>(&x)[1];
165
+ EIGEN_DEVICE_FUNC static inline RealScalar& run(Scalar& x) { return reinterpret_cast<RealScalar*>(&x)[1]; }
166
+ EIGEN_DEVICE_FUNC static inline const RealScalar& run(const Scalar& x) {
167
+ return reinterpret_cast<const RealScalar*>(&x)[1];
210
168
  }
211
169
  };
212
170
 
213
- template<typename Scalar>
214
- struct imag_ref_default_impl<Scalar, false>
215
- {
216
- EIGEN_DEVICE_FUNC
217
- static inline Scalar run(Scalar&)
218
- {
219
- return Scalar(0);
220
- }
221
- EIGEN_DEVICE_FUNC
222
- static inline const Scalar run(const Scalar&)
223
- {
224
- return Scalar(0);
225
- }
171
+ template <typename Scalar>
172
+ struct imag_ref_default_impl<Scalar, false> {
173
+ EIGEN_DEVICE_FUNC constexpr static Scalar run(Scalar&) { return Scalar(0); }
174
+ EIGEN_DEVICE_FUNC constexpr static const Scalar run(const Scalar&) { return Scalar(0); }
226
175
  };
227
176
 
228
- template<typename Scalar>
177
+ template <typename Scalar>
229
178
  struct imag_ref_impl : imag_ref_default_impl<Scalar, NumTraits<Scalar>::IsComplex> {};
230
179
 
231
- template<typename Scalar>
232
- struct imag_ref_retval
233
- {
234
- typedef typename NumTraits<Scalar>::Real & type;
180
+ template <typename Scalar>
181
+ struct imag_ref_retval {
182
+ typedef typename NumTraits<Scalar>::Real& type;
235
183
  };
236
184
 
185
+ } // namespace internal
186
+
187
+ namespace numext {
188
+
189
+ template <typename Scalar>
190
+ EIGEN_DEVICE_FUNC inline EIGEN_MATHFUNC_RETVAL(real, Scalar) real(const Scalar& x) {
191
+ return EIGEN_MATHFUNC_IMPL(real, Scalar)::run(x);
192
+ }
193
+
194
+ template <typename Scalar>
195
+ EIGEN_DEVICE_FUNC inline internal::add_const_on_value_type_t<EIGEN_MATHFUNC_RETVAL(real_ref, Scalar)> real_ref(
196
+ const Scalar& x) {
197
+ return internal::real_ref_impl<Scalar>::run(x);
198
+ }
199
+
200
+ template <typename Scalar>
201
+ EIGEN_DEVICE_FUNC inline EIGEN_MATHFUNC_RETVAL(real_ref, Scalar) real_ref(Scalar& x) {
202
+ return EIGEN_MATHFUNC_IMPL(real_ref, Scalar)::run(x);
203
+ }
204
+
205
+ template <typename Scalar>
206
+ EIGEN_DEVICE_FUNC inline EIGEN_MATHFUNC_RETVAL(imag, Scalar) imag(const Scalar& x) {
207
+ return EIGEN_MATHFUNC_IMPL(imag, Scalar)::run(x);
208
+ }
209
+
210
+ template <typename Scalar>
211
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar select(const Scalar& mask, const Scalar& a, const Scalar& b) {
212
+ return numext::is_exactly_zero(mask) ? b : a;
213
+ }
214
+
215
+ } // namespace numext
216
+
217
+ namespace internal {
218
+
237
219
  /****************************************************************************
238
- * Implementation of conj *
239
- ****************************************************************************/
220
+ * Implementation of conj *
221
+ ****************************************************************************/
240
222
 
241
- template<typename Scalar, bool IsComplex = NumTraits<Scalar>::IsComplex>
242
- struct conj_impl
243
- {
244
- EIGEN_DEVICE_FUNC
245
- static inline Scalar run(const Scalar& x)
246
- {
247
- return x;
248
- }
223
+ template <typename Scalar, bool IsComplex = NumTraits<Scalar>::IsComplex>
224
+ struct conj_default_impl {
225
+ EIGEN_DEVICE_FUNC static inline Scalar run(const Scalar& x) { return x; }
249
226
  };
250
227
 
251
- template<typename Scalar>
252
- struct conj_impl<Scalar,true>
253
- {
254
- EIGEN_DEVICE_FUNC
255
- static inline Scalar run(const Scalar& x)
256
- {
228
+ template <typename Scalar>
229
+ struct conj_default_impl<Scalar, true> {
230
+ EIGEN_DEVICE_FUNC static inline Scalar run(const Scalar& x) {
257
231
  using std::conj;
258
232
  return conj(x);
259
233
  }
260
234
  };
261
235
 
262
- template<typename Scalar>
263
- struct conj_retval
264
- {
236
+ template <typename Scalar, bool IsComplex = NumTraits<Scalar>::IsComplex>
237
+ struct conj_impl : conj_default_impl<Scalar, IsComplex> {};
238
+
239
+ template <typename Scalar>
240
+ struct conj_retval {
265
241
  typedef Scalar type;
266
242
  };
267
243
 
268
244
  /****************************************************************************
269
- * Implementation of abs2 *
270
- ****************************************************************************/
245
+ * Implementation of abs2 *
246
+ ****************************************************************************/
271
247
 
272
- template<typename Scalar,bool IsComplex>
273
- struct abs2_impl_default
274
- {
248
+ template <typename Scalar, bool IsComplex>
249
+ struct abs2_impl_default {
275
250
  typedef typename NumTraits<Scalar>::Real RealScalar;
276
- EIGEN_DEVICE_FUNC
277
- static inline RealScalar run(const Scalar& x)
278
- {
279
- return x*x;
280
- }
251
+ EIGEN_DEVICE_FUNC static inline RealScalar run(const Scalar& x) { return x * x; }
281
252
  };
282
253
 
283
- template<typename Scalar>
284
- struct abs2_impl_default<Scalar, true> // IsComplex
254
+ template <typename Scalar>
255
+ struct abs2_impl_default<Scalar, true> // IsComplex
285
256
  {
286
257
  typedef typename NumTraits<Scalar>::Real RealScalar;
287
- EIGEN_DEVICE_FUNC
288
- static inline RealScalar run(const Scalar& x)
289
- {
290
- return x.real()*x.real() + x.imag()*x.imag();
258
+ EIGEN_DEVICE_FUNC static inline RealScalar run(const Scalar& x) {
259
+ return numext::real(x) * numext::real(x) + numext::imag(x) * numext::imag(x);
291
260
  }
292
261
  };
293
262
 
294
- template<typename Scalar>
295
- struct abs2_impl
296
- {
263
+ template <typename Scalar>
264
+ struct abs2_impl {
297
265
  typedef typename NumTraits<Scalar>::Real RealScalar;
298
- EIGEN_DEVICE_FUNC
299
- static inline RealScalar run(const Scalar& x)
300
- {
301
- return abs2_impl_default<Scalar,NumTraits<Scalar>::IsComplex>::run(x);
266
+ EIGEN_DEVICE_FUNC static inline RealScalar run(const Scalar& x) {
267
+ return abs2_impl_default<Scalar, NumTraits<Scalar>::IsComplex>::run(x);
302
268
  }
303
269
  };
304
270
 
305
- template<typename Scalar>
306
- struct abs2_retval
307
- {
271
+ template <typename Scalar>
272
+ struct abs2_retval {
308
273
  typedef typename NumTraits<Scalar>::Real type;
309
274
  };
310
275
 
311
276
  /****************************************************************************
312
- * Implementation of norm1 *
313
- ****************************************************************************/
277
+ * Implementation of sqrt/rsqrt *
278
+ ****************************************************************************/
279
+
280
+ template <typename Scalar>
281
+ struct sqrt_impl {
282
+ EIGEN_DEVICE_FUNC static EIGEN_ALWAYS_INLINE Scalar run(const Scalar& x) {
283
+ EIGEN_USING_STD(sqrt);
284
+ return sqrt(x);
285
+ }
286
+ };
287
+
288
+ // Complex sqrt defined in MathFunctionsImpl.h.
289
+ template <typename ComplexT>
290
+ EIGEN_DEVICE_FUNC ComplexT complex_sqrt(const ComplexT& a_x);
291
+
292
+ // Custom implementation is faster than `std::sqrt`, works on
293
+ // GPU, and correctly handles special cases (unlike MSVC).
294
+ template <typename T>
295
+ struct sqrt_impl<std::complex<T>> {
296
+ EIGEN_DEVICE_FUNC static EIGEN_ALWAYS_INLINE std::complex<T> run(const std::complex<T>& x) { return complex_sqrt(x); }
297
+ };
298
+
299
+ template <typename Scalar>
300
+ struct sqrt_retval {
301
+ typedef Scalar type;
302
+ };
303
+
304
+ // Default implementation relies on numext::sqrt, at bottom of file.
305
+ template <typename T>
306
+ struct rsqrt_impl;
307
+
308
+ // Complex rsqrt defined in MathFunctionsImpl.h.
309
+ template <typename ComplexT>
310
+ EIGEN_DEVICE_FUNC ComplexT complex_rsqrt(const ComplexT& a_x);
311
+
312
+ template <typename T>
313
+ struct rsqrt_impl<std::complex<T>> {
314
+ EIGEN_DEVICE_FUNC static EIGEN_ALWAYS_INLINE std::complex<T> run(const std::complex<T>& x) {
315
+ return complex_rsqrt(x);
316
+ }
317
+ };
318
+
319
+ template <typename Scalar>
320
+ struct rsqrt_retval {
321
+ typedef Scalar type;
322
+ };
323
+
324
+ /****************************************************************************
325
+ * Implementation of norm1 *
326
+ ****************************************************************************/
314
327
 
315
- template<typename Scalar, bool IsComplex>
328
+ template <typename Scalar, bool IsComplex>
316
329
  struct norm1_default_impl;
317
330
 
318
- template<typename Scalar>
319
- struct norm1_default_impl<Scalar,true>
320
- {
331
+ template <typename Scalar>
332
+ struct norm1_default_impl<Scalar, true> {
321
333
  typedef typename NumTraits<Scalar>::Real RealScalar;
322
- EIGEN_DEVICE_FUNC
323
- static inline RealScalar run(const Scalar& x)
324
- {
325
- EIGEN_USING_STD_MATH(abs);
326
- return abs(x.real()) + abs(x.imag());
334
+ EIGEN_DEVICE_FUNC static inline RealScalar run(const Scalar& x) {
335
+ EIGEN_USING_STD(abs);
336
+ return abs(numext::real(x)) + abs(numext::imag(x));
327
337
  }
328
338
  };
329
339
 
330
- template<typename Scalar>
331
- struct norm1_default_impl<Scalar, false>
332
- {
333
- EIGEN_DEVICE_FUNC
334
- static inline Scalar run(const Scalar& x)
335
- {
336
- EIGEN_USING_STD_MATH(abs);
340
+ template <typename Scalar>
341
+ struct norm1_default_impl<Scalar, false> {
342
+ EIGEN_DEVICE_FUNC static inline Scalar run(const Scalar& x) {
343
+ EIGEN_USING_STD(abs);
337
344
  return abs(x);
338
345
  }
339
346
  };
340
347
 
341
- template<typename Scalar>
348
+ template <typename Scalar>
342
349
  struct norm1_impl : norm1_default_impl<Scalar, NumTraits<Scalar>::IsComplex> {};
343
350
 
344
- template<typename Scalar>
345
- struct norm1_retval
346
- {
351
+ template <typename Scalar>
352
+ struct norm1_retval {
347
353
  typedef typename NumTraits<Scalar>::Real type;
348
354
  };
349
355
 
350
356
  /****************************************************************************
351
- * Implementation of hypot *
352
- ****************************************************************************/
357
+ * Implementation of hypot *
358
+ ****************************************************************************/
353
359
 
354
- template<typename Scalar> struct hypot_impl;
360
+ template <typename Scalar>
361
+ struct hypot_impl;
355
362
 
356
- template<typename Scalar>
357
- struct hypot_retval
358
- {
363
+ template <typename Scalar>
364
+ struct hypot_retval {
359
365
  typedef typename NumTraits<Scalar>::Real type;
360
366
  };
361
367
 
362
368
  /****************************************************************************
363
- * Implementation of cast *
364
- ****************************************************************************/
369
+ * Implementation of cast *
370
+ ****************************************************************************/
365
371
 
366
- template<typename OldType, typename NewType>
367
- struct cast_impl
368
- {
369
- EIGEN_DEVICE_FUNC
370
- static inline NewType run(const OldType& x)
371
- {
372
- return static_cast<NewType>(x);
372
+ template <typename OldType, typename NewType, typename EnableIf = void>
373
+ struct cast_impl {
374
+ EIGEN_DEVICE_FUNC static inline NewType run(const OldType& x) { return static_cast<NewType>(x); }
375
+ };
376
+
377
+ template <typename OldType>
378
+ struct cast_impl<OldType, bool> {
379
+ EIGEN_DEVICE_FUNC static inline bool run(const OldType& x) { return x != OldType(0); }
380
+ };
381
+
382
+ // Casting from S -> Complex<T> leads to an implicit conversion from S to T,
383
+ // generating warnings on clang. Here we explicitly cast the real component.
384
+ template <typename OldType, typename NewType>
385
+ struct cast_impl<OldType, NewType,
386
+ typename std::enable_if_t<!NumTraits<OldType>::IsComplex && NumTraits<NewType>::IsComplex>> {
387
+ EIGEN_DEVICE_FUNC static inline NewType run(const OldType& x) {
388
+ typedef typename NumTraits<NewType>::Real NewReal;
389
+ return static_cast<NewType>(static_cast<NewReal>(x));
373
390
  }
374
391
  };
375
392
 
376
393
  // here, for once, we're plainly returning NewType: we don't want cast to do weird things.
377
394
 
378
- template<typename OldType, typename NewType>
379
- EIGEN_DEVICE_FUNC
380
- inline NewType cast(const OldType& x)
381
- {
395
+ template <typename OldType, typename NewType>
396
+ EIGEN_DEVICE_FUNC inline NewType cast(const OldType& x) {
382
397
  return cast_impl<OldType, NewType>::run(x);
383
398
  }
384
399
 
385
400
  /****************************************************************************
386
- * Implementation of round *
387
- ****************************************************************************/
388
-
389
- #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
- };
399
- #else
400
- template<typename Scalar>
401
- struct round_impl
402
- {
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));
409
- }
410
- };
411
- #endif
412
-
413
- template<typename Scalar>
414
- struct round_retval
415
- {
416
- typedef Scalar type;
401
+ * Implementation of arg *
402
+ ****************************************************************************/
403
+
404
+ // Visual Studio 2017 has a bug where arg(float) returns 0 for negative inputs.
405
+ // This seems to be fixed in VS 2019.
406
+ #if (!EIGEN_COMP_MSVC || EIGEN_COMP_MSVC >= 1920)
407
+ // std::arg is only defined for types of std::complex, or integer types or float/double/long double
408
+ template <typename Scalar, bool HasStdImpl = NumTraits<Scalar>::IsComplex || is_integral<Scalar>::value ||
409
+ is_same<Scalar, float>::value || is_same<Scalar, double>::value ||
410
+ is_same<Scalar, long double>::value>
411
+ struct arg_default_impl;
412
+
413
+ template <typename Scalar>
414
+ struct arg_default_impl<Scalar, true> {
415
+ typedef typename NumTraits<Scalar>::Real RealScalar;
416
+ EIGEN_DEVICE_FUNC static inline RealScalar run(const Scalar& x) {
417
+ // There is no official ::arg on device in CUDA/HIP, so we always need to use std::arg.
418
+ using std::arg;
419
+ return static_cast<RealScalar>(arg(x));
420
+ }
417
421
  };
418
422
 
419
- /****************************************************************************
420
- * Implementation of arg *
421
- ****************************************************************************/
422
-
423
- #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
- };
423
+ // Must be non-complex floating-point type (e.g. half/bfloat16).
424
+ template <typename Scalar>
425
+ struct arg_default_impl<Scalar, false> {
426
+ typedef typename NumTraits<Scalar>::Real RealScalar;
427
+ EIGEN_DEVICE_FUNC static inline RealScalar run(const Scalar& x) {
428
+ return (x < Scalar(0)) ? RealScalar(EIGEN_PI) : RealScalar(0);
429
+ }
430
+ };
432
431
  #else
433
- template<typename Scalar, bool IsComplex = NumTraits<Scalar>::IsComplex>
434
- struct arg_default_impl
435
- {
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
- };
442
-
443
- template<typename Scalar>
444
- struct arg_default_impl<Scalar,true>
445
- {
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
- };
432
+ template <typename Scalar, bool IsComplex = NumTraits<Scalar>::IsComplex>
433
+ struct arg_default_impl {
434
+ typedef typename NumTraits<Scalar>::Real RealScalar;
435
+ EIGEN_DEVICE_FUNC static inline RealScalar run(const Scalar& x) {
436
+ return (x < RealScalar(0)) ? RealScalar(EIGEN_PI) : RealScalar(0);
437
+ }
438
+ };
454
439
 
455
- template<typename Scalar> struct arg_impl : arg_default_impl<Scalar> {};
440
+ template <typename Scalar>
441
+ struct arg_default_impl<Scalar, true> {
442
+ typedef typename NumTraits<Scalar>::Real RealScalar;
443
+ EIGEN_DEVICE_FUNC static inline RealScalar run(const Scalar& x) {
444
+ EIGEN_USING_STD(arg);
445
+ return arg(x);
446
+ }
447
+ };
456
448
  #endif
449
+ template <typename Scalar>
450
+ struct arg_impl : arg_default_impl<Scalar> {};
457
451
 
458
- template<typename Scalar>
459
- struct arg_retval
460
- {
452
+ template <typename Scalar>
453
+ struct arg_retval {
461
454
  typedef typename NumTraits<Scalar>::Real type;
462
455
  };
463
456
 
464
457
  /****************************************************************************
465
- * Implementation of log1p *
466
- ****************************************************************************/
458
+ * Implementation of expm1 *
459
+ ****************************************************************************/
467
460
 
461
+ // This implementation is based on GSL Math's expm1.
468
462
  namespace std_fallback {
469
- // fallback log1p implementation in case there is no log1p(Scalar) function in namespace of Scalar,
470
- // or that there is no suitable std::log1p function available
471
- template<typename Scalar>
472
- EIGEN_DEVICE_FUNC inline Scalar log1p(const Scalar& x) {
463
+ // fallback expm1 implementation in case there is no expm1(Scalar) function in namespace of Scalar,
464
+ // or that there is no suitable std::expm1 function available. Implementation
465
+ // attributed to Kahan. See: http://www.plunk.org/~hatch/rightway.php.
466
+ template <typename Scalar>
467
+ EIGEN_DEVICE_FUNC inline Scalar expm1(const Scalar& x) {
468
+ EIGEN_STATIC_ASSERT_NON_INTEGER(Scalar)
469
+ typedef typename NumTraits<Scalar>::Real RealScalar;
470
+
471
+ EIGEN_USING_STD(exp);
472
+ Scalar u = exp(x);
473
+ if (numext::equal_strict(u, Scalar(1))) {
474
+ return x;
475
+ }
476
+ Scalar um1 = u - RealScalar(1);
477
+ if (numext::equal_strict(um1, Scalar(-1))) {
478
+ return RealScalar(-1);
479
+ }
480
+
481
+ EIGEN_USING_STD(log);
482
+ Scalar logu = log(u);
483
+ return numext::equal_strict(u, logu) ? u : (u - RealScalar(1)) * x / logu;
484
+ }
485
+ } // namespace std_fallback
486
+
487
+ template <typename Scalar>
488
+ struct expm1_impl {
489
+ EIGEN_DEVICE_FUNC static inline Scalar run(const Scalar& x) {
473
490
  EIGEN_STATIC_ASSERT_NON_INTEGER(Scalar)
474
- typedef typename NumTraits<Scalar>::Real RealScalar;
475
- EIGEN_USING_STD_MATH(log);
476
- Scalar x1p = RealScalar(1) + x;
477
- return numext::equal_strict(x1p, Scalar(1)) ? x : x * ( log(x1p) / (x1p - RealScalar(1)) );
491
+ EIGEN_USING_STD(expm1);
492
+ return expm1(x);
478
493
  }
494
+ };
495
+
496
+ template <typename Scalar>
497
+ struct expm1_retval {
498
+ typedef Scalar type;
499
+ };
500
+
501
+ /****************************************************************************
502
+ * Implementation of log *
503
+ ****************************************************************************/
504
+
505
+ // Complex log defined in MathFunctionsImpl.h.
506
+ template <typename ComplexT>
507
+ EIGEN_DEVICE_FUNC ComplexT complex_log(const ComplexT& z);
508
+
509
+ template <typename Scalar>
510
+ struct log_impl {
511
+ EIGEN_DEVICE_FUNC static inline Scalar run(const Scalar& x) {
512
+ EIGEN_USING_STD(log);
513
+ return static_cast<Scalar>(log(x));
514
+ }
515
+ };
516
+
517
+ template <typename Scalar>
518
+ struct log_impl<std::complex<Scalar>> {
519
+ EIGEN_DEVICE_FUNC static inline std::complex<Scalar> run(const std::complex<Scalar>& z) { return complex_log(z); }
520
+ };
521
+
522
+ /****************************************************************************
523
+ * Implementation of log1p *
524
+ ****************************************************************************/
525
+
526
+ namespace std_fallback {
527
+ // fallback log1p implementation in case there is no log1p(Scalar) function in namespace of Scalar,
528
+ // or that there is no suitable std::log1p function available
529
+ template <typename Scalar>
530
+ EIGEN_DEVICE_FUNC inline Scalar log1p(const Scalar& x) {
531
+ EIGEN_STATIC_ASSERT_NON_INTEGER(Scalar)
532
+ typedef typename NumTraits<Scalar>::Real RealScalar;
533
+ EIGEN_USING_STD(log);
534
+ Scalar x1p = RealScalar(1) + x;
535
+ Scalar log_1p = log_impl<Scalar>::run(x1p);
536
+ const bool is_small = numext::equal_strict(x1p, Scalar(1));
537
+ const bool is_inf = numext::equal_strict(x1p, log_1p);
538
+ return (is_small || is_inf) ? x : x * (log_1p / (x1p - RealScalar(1)));
479
539
  }
540
+ } // namespace std_fallback
480
541
 
481
- template<typename Scalar>
542
+ template <typename Scalar>
482
543
  struct log1p_impl {
483
- static inline Scalar run(const Scalar& x)
484
- {
485
- EIGEN_STATIC_ASSERT_NON_INTEGER(Scalar)
486
- #if EIGEN_HAS_CXX11_MATH
487
- using std::log1p;
488
- #endif
489
- using std_fallback::log1p;
544
+ EIGEN_STATIC_ASSERT_NON_INTEGER(Scalar)
545
+
546
+ EIGEN_DEVICE_FUNC static inline Scalar run(const Scalar& x) {
547
+ EIGEN_USING_STD(log1p);
490
548
  return log1p(x);
491
549
  }
492
550
  };
493
551
 
552
+ // Specialization for complex types that are not supported by std::log1p.
553
+ template <typename RealScalar>
554
+ struct log1p_impl<std::complex<RealScalar>> {
555
+ EIGEN_STATIC_ASSERT_NON_INTEGER(RealScalar)
494
556
 
495
- template<typename Scalar>
496
- struct log1p_retval
497
- {
557
+ EIGEN_DEVICE_FUNC static inline std::complex<RealScalar> run(const std::complex<RealScalar>& x) {
558
+ return std_fallback::log1p(x);
559
+ }
560
+ };
561
+
562
+ template <typename Scalar>
563
+ struct log1p_retval {
498
564
  typedef Scalar type;
499
565
  };
500
566
 
501
567
  /****************************************************************************
502
- * Implementation of pow *
503
- ****************************************************************************/
504
-
505
- template<typename ScalarX,typename ScalarY, bool IsInteger = NumTraits<ScalarX>::IsInteger&&NumTraits<ScalarY>::IsInteger>
506
- struct pow_impl
507
- {
508
- //typedef Scalar retval;
509
- typedef typename ScalarBinaryOpTraits<ScalarX,ScalarY,internal::scalar_pow_op<ScalarX,ScalarY> >::ReturnType result_type;
510
- static EIGEN_DEVICE_FUNC inline result_type run(const ScalarX& x, const ScalarY& y)
511
- {
512
- EIGEN_USING_STD_MATH(pow);
568
+ * Implementation of pow *
569
+ ****************************************************************************/
570
+
571
+ template <typename ScalarX, typename ScalarY,
572
+ bool IsInteger = NumTraits<ScalarX>::IsInteger && NumTraits<ScalarY>::IsInteger>
573
+ struct pow_impl {
574
+ // typedef Scalar retval;
575
+ typedef typename ScalarBinaryOpTraits<ScalarX, ScalarY, internal::scalar_pow_op<ScalarX, ScalarY>>::ReturnType
576
+ result_type;
577
+ static EIGEN_DEVICE_FUNC inline result_type run(const ScalarX& x, const ScalarY& y) {
578
+ EIGEN_USING_STD(pow);
513
579
  return pow(x, y);
514
580
  }
515
581
  };
516
582
 
517
- template<typename ScalarX,typename ScalarY>
518
- struct pow_impl<ScalarX,ScalarY, true>
519
- {
583
+ template <typename ScalarX, typename ScalarY>
584
+ struct pow_impl<ScalarX, ScalarY, true> {
520
585
  typedef ScalarX result_type;
521
- static EIGEN_DEVICE_FUNC inline ScalarX run(ScalarX x, ScalarY y)
522
- {
586
+ static EIGEN_DEVICE_FUNC inline ScalarX run(ScalarX x, ScalarY y) {
523
587
  ScalarX res(1);
524
588
  eigen_assert(!NumTraits<ScalarY>::IsSigned || y >= 0);
525
- if(y & 1) res *= x;
589
+ if (y & 1) res *= x;
526
590
  y >>= 1;
527
- while(y)
528
- {
591
+ while (y) {
529
592
  x *= x;
530
- if(y&1) res *= x;
593
+ if (y & 1) res *= x;
531
594
  y >>= 1;
532
595
  }
533
596
  return res;
534
597
  }
535
598
  };
536
599
 
537
- /****************************************************************************
538
- * Implementation of random *
539
- ****************************************************************************/
600
+ enum { meta_floor_log2_terminate, meta_floor_log2_move_up, meta_floor_log2_move_down, meta_floor_log2_bogus };
540
601
 
541
- template<typename Scalar,
542
- bool IsComplex,
543
- bool IsInteger>
544
- struct random_default_impl {};
602
+ template <unsigned int n, int lower, int upper>
603
+ struct meta_floor_log2_selector {
604
+ enum {
605
+ middle = (lower + upper) / 2,
606
+ value = (upper <= lower + 1) ? int(meta_floor_log2_terminate)
607
+ : (n < (1 << middle)) ? int(meta_floor_log2_move_down)
608
+ : (n == 0) ? int(meta_floor_log2_bogus)
609
+ : int(meta_floor_log2_move_up)
610
+ };
611
+ };
545
612
 
546
- template<typename Scalar>
547
- struct random_impl : random_default_impl<Scalar, NumTraits<Scalar>::IsComplex, NumTraits<Scalar>::IsInteger> {};
613
+ template <unsigned int n, int lower = 0, int upper = sizeof(unsigned int) * CHAR_BIT - 1,
614
+ int selector = meta_floor_log2_selector<n, lower, upper>::value>
615
+ struct meta_floor_log2 {};
548
616
 
549
- template<typename Scalar>
550
- struct random_retval
551
- {
552
- typedef Scalar type;
617
+ template <unsigned int n, int lower, int upper>
618
+ struct meta_floor_log2<n, lower, upper, meta_floor_log2_move_down> {
619
+ enum { value = meta_floor_log2<n, lower, meta_floor_log2_selector<n, lower, upper>::middle>::value };
620
+ };
621
+
622
+ template <unsigned int n, int lower, int upper>
623
+ struct meta_floor_log2<n, lower, upper, meta_floor_log2_move_up> {
624
+ enum { value = meta_floor_log2<n, meta_floor_log2_selector<n, lower, upper>::middle, upper>::value };
553
625
  };
554
626
 
555
- template<typename Scalar> inline EIGEN_MATHFUNC_RETVAL(random, Scalar) random(const Scalar& x, const Scalar& y);
556
- template<typename Scalar> inline EIGEN_MATHFUNC_RETVAL(random, Scalar) random();
627
+ template <unsigned int n, int lower, int upper>
628
+ struct meta_floor_log2<n, lower, upper, meta_floor_log2_terminate> {
629
+ enum { value = (n >= ((unsigned int)(1) << (lower + 1))) ? lower + 1 : lower };
630
+ };
557
631
 
558
- template<typename Scalar>
559
- struct random_default_impl<Scalar, false, false>
560
- {
561
- static inline Scalar run(const Scalar& x, const Scalar& y)
562
- {
563
- return x + (y-x) * Scalar(std::rand()) / Scalar(RAND_MAX);
632
+ template <unsigned int n, int lower, int upper>
633
+ struct meta_floor_log2<n, lower, upper, meta_floor_log2_bogus> {
634
+ // no value, error at compile time
635
+ };
636
+
637
+ template <typename BitsType, typename EnableIf = void>
638
+ struct count_bits_impl {
639
+ static_assert(std::is_integral<BitsType>::value && std::is_unsigned<BitsType>::value,
640
+ "BitsType must be an unsigned integer");
641
+ static EIGEN_DEVICE_FUNC inline int clz(BitsType bits) {
642
+ int n = CHAR_BIT * sizeof(BitsType);
643
+ int shift = n / 2;
644
+ while (bits > 0 && shift > 0) {
645
+ BitsType y = bits >> shift;
646
+ if (y > 0) {
647
+ n -= shift;
648
+ bits = y;
649
+ }
650
+ shift /= 2;
651
+ }
652
+ if (shift == 0) {
653
+ --n;
654
+ }
655
+ return n;
564
656
  }
565
- static inline Scalar run()
566
- {
567
- return run(Scalar(NumTraits<Scalar>::IsSigned ? -1 : 0), Scalar(1));
657
+
658
+ static EIGEN_DEVICE_FUNC inline int ctz(BitsType bits) {
659
+ int n = CHAR_BIT * sizeof(BitsType);
660
+ int shift = n / 2;
661
+ while (bits > 0 && shift > 0) {
662
+ BitsType y = bits << shift;
663
+ if (y > 0) {
664
+ n -= shift;
665
+ bits = y;
666
+ }
667
+ shift /= 2;
668
+ }
669
+ if (shift == 0) {
670
+ --n;
671
+ }
672
+ return n;
568
673
  }
569
674
  };
570
675
 
571
- enum {
572
- meta_floor_log2_terminate,
573
- meta_floor_log2_move_up,
574
- meta_floor_log2_move_down,
575
- meta_floor_log2_bogus
576
- };
676
+ // Count leading zeros.
677
+ template <typename BitsType>
678
+ EIGEN_DEVICE_FUNC inline int clz(BitsType bits) {
679
+ return count_bits_impl<BitsType>::clz(bits);
680
+ }
577
681
 
578
- template<unsigned int n, int lower, int upper> struct meta_floor_log2_selector
579
- {
580
- enum { middle = (lower + upper) / 2,
581
- value = (upper <= lower + 1) ? int(meta_floor_log2_terminate)
582
- : (n < (1 << middle)) ? int(meta_floor_log2_move_down)
583
- : (n==0) ? int(meta_floor_log2_bogus)
584
- : int(meta_floor_log2_move_up)
585
- };
586
- };
682
+ // Count trailing zeros.
683
+ template <typename BitsType>
684
+ EIGEN_DEVICE_FUNC inline int ctz(BitsType bits) {
685
+ return count_bits_impl<BitsType>::ctz(bits);
686
+ }
587
687
 
588
- template<unsigned int n,
589
- int lower = 0,
590
- int upper = sizeof(unsigned int) * CHAR_BIT - 1,
591
- int selector = meta_floor_log2_selector<n, lower, upper>::value>
592
- struct meta_floor_log2 {};
688
+ #if EIGEN_COMP_GNUC || EIGEN_COMP_CLANG
593
689
 
594
- template<unsigned int n, int lower, int upper>
595
- struct meta_floor_log2<n, lower, upper, meta_floor_log2_move_down>
596
- {
597
- enum { value = meta_floor_log2<n, lower, meta_floor_log2_selector<n, lower, upper>::middle>::value };
690
+ template <typename BitsType>
691
+ struct count_bits_impl<
692
+ BitsType, std::enable_if_t<std::is_integral<BitsType>::value && sizeof(BitsType) <= sizeof(unsigned int)>> {
693
+ static constexpr int kNumBits = static_cast<int>(sizeof(BitsType) * CHAR_BIT);
694
+ static EIGEN_DEVICE_FUNC inline int clz(BitsType bits) {
695
+ static constexpr int kLeadingBitsOffset = (sizeof(unsigned int) - sizeof(BitsType)) * CHAR_BIT;
696
+ return bits == 0 ? kNumBits : __builtin_clz(static_cast<unsigned int>(bits)) - kLeadingBitsOffset;
697
+ }
698
+
699
+ static EIGEN_DEVICE_FUNC inline int ctz(BitsType bits) {
700
+ return bits == 0 ? kNumBits : __builtin_ctz(static_cast<unsigned int>(bits));
701
+ }
598
702
  };
599
703
 
600
- template<unsigned int n, int lower, int upper>
601
- struct meta_floor_log2<n, lower, upper, meta_floor_log2_move_up>
602
- {
603
- enum { value = meta_floor_log2<n, meta_floor_log2_selector<n, lower, upper>::middle, upper>::value };
704
+ template <typename BitsType>
705
+ struct count_bits_impl<BitsType,
706
+ std::enable_if_t<std::is_integral<BitsType>::value && sizeof(unsigned int) < sizeof(BitsType) &&
707
+ sizeof(BitsType) <= sizeof(unsigned long)>> {
708
+ static constexpr int kNumBits = static_cast<int>(sizeof(BitsType) * CHAR_BIT);
709
+ static EIGEN_DEVICE_FUNC inline int clz(BitsType bits) {
710
+ static constexpr int kLeadingBitsOffset = (sizeof(unsigned long) - sizeof(BitsType)) * CHAR_BIT;
711
+ return bits == 0 ? kNumBits : __builtin_clzl(static_cast<unsigned long>(bits)) - kLeadingBitsOffset;
712
+ }
713
+
714
+ static EIGEN_DEVICE_FUNC inline int ctz(BitsType bits) {
715
+ return bits == 0 ? kNumBits : __builtin_ctzl(static_cast<unsigned long>(bits));
716
+ }
604
717
  };
605
718
 
606
- template<unsigned int n, int lower, int upper>
607
- struct meta_floor_log2<n, lower, upper, meta_floor_log2_terminate>
608
- {
609
- enum { value = (n >= ((unsigned int)(1) << (lower+1))) ? lower+1 : lower };
719
+ template <typename BitsType>
720
+ struct count_bits_impl<BitsType,
721
+ std::enable_if_t<std::is_integral<BitsType>::value && sizeof(unsigned long) < sizeof(BitsType) &&
722
+ sizeof(BitsType) <= sizeof(unsigned long long)>> {
723
+ static constexpr int kNumBits = static_cast<int>(sizeof(BitsType) * CHAR_BIT);
724
+ static EIGEN_DEVICE_FUNC inline int clz(BitsType bits) {
725
+ static constexpr int kLeadingBitsOffset = (sizeof(unsigned long long) - sizeof(BitsType)) * CHAR_BIT;
726
+ return bits == 0 ? kNumBits : __builtin_clzll(static_cast<unsigned long long>(bits)) - kLeadingBitsOffset;
727
+ }
728
+
729
+ static EIGEN_DEVICE_FUNC inline int ctz(BitsType bits) {
730
+ return bits == 0 ? kNumBits : __builtin_ctzll(static_cast<unsigned long long>(bits));
731
+ }
610
732
  };
611
733
 
612
- template<unsigned int n, int lower, int upper>
613
- struct meta_floor_log2<n, lower, upper, meta_floor_log2_bogus>
614
- {
615
- // no value, error at compile time
734
+ #elif EIGEN_COMP_MSVC
735
+
736
+ template <typename BitsType>
737
+ struct count_bits_impl<
738
+ BitsType, std::enable_if_t<std::is_integral<BitsType>::value && sizeof(BitsType) <= sizeof(unsigned long)>> {
739
+ static constexpr int kNumBits = static_cast<int>(sizeof(BitsType) * CHAR_BIT);
740
+ static EIGEN_DEVICE_FUNC inline int clz(BitsType bits) {
741
+ unsigned long out;
742
+ _BitScanReverse(&out, static_cast<unsigned long>(bits));
743
+ return bits == 0 ? kNumBits : (kNumBits - 1) - static_cast<int>(out);
744
+ }
745
+
746
+ static EIGEN_DEVICE_FUNC inline int ctz(BitsType bits) {
747
+ unsigned long out;
748
+ _BitScanForward(&out, static_cast<unsigned long>(bits));
749
+ return bits == 0 ? kNumBits : static_cast<int>(out);
750
+ }
616
751
  };
617
752
 
618
- template<typename Scalar>
619
- struct random_default_impl<Scalar, false, true>
620
- {
621
- static inline Scalar run(const Scalar& x, const Scalar& y)
622
- {
623
- if (y <= x)
624
- return x;
625
- // ScalarU is the unsigned counterpart of Scalar, possibly Scalar itself.
626
- typedef typename make_unsigned<Scalar>::type ScalarU;
627
- // ScalarX is the widest of ScalarU and unsigned int.
628
- // We'll deal only with ScalarX and unsigned int below thus avoiding signed
629
- // types and arithmetic and signed overflows (which are undefined behavior).
630
- typedef typename conditional<(ScalarU(-1) > unsigned(-1)), ScalarU, unsigned>::type ScalarX;
631
- // The following difference doesn't overflow, provided our integer types are two's
632
- // complement and have the same number of padding bits in signed and unsigned variants.
633
- // This is the case in most modern implementations of C++.
634
- ScalarX range = ScalarX(y) - ScalarX(x);
635
- ScalarX offset = 0;
636
- ScalarX divisor = 1;
637
- ScalarX multiplier = 1;
638
- const unsigned rand_max = RAND_MAX;
639
- if (range <= rand_max) divisor = (rand_max + 1) / (range + 1);
640
- else multiplier = 1 + range / (rand_max + 1);
641
- // Rejection sampling.
642
- do {
643
- offset = (unsigned(std::rand()) * multiplier) / divisor;
644
- } while (offset > range);
645
- return Scalar(ScalarX(x) + offset);
646
- }
647
-
648
- static inline Scalar run()
649
- {
650
- #ifdef EIGEN_MAKING_DOCS
651
- return run(Scalar(NumTraits<Scalar>::IsSigned ? -10 : 0), Scalar(10));
652
- #else
653
- enum { rand_bits = meta_floor_log2<(unsigned int)(RAND_MAX)+1>::value,
654
- scalar_bits = sizeof(Scalar) * CHAR_BIT,
655
- shift = EIGEN_PLAIN_ENUM_MAX(0, int(rand_bits) - int(scalar_bits)),
656
- offset = NumTraits<Scalar>::IsSigned ? (1 << (EIGEN_PLAIN_ENUM_MIN(rand_bits,scalar_bits)-1)) : 0
657
- };
658
- return Scalar((std::rand() >> shift) - offset);
659
- #endif
753
+ #ifdef _WIN64
754
+
755
+ template <typename BitsType>
756
+ struct count_bits_impl<BitsType,
757
+ std::enable_if_t<std::is_integral<BitsType>::value && sizeof(unsigned long) < sizeof(BitsType) &&
758
+ sizeof(BitsType) <= sizeof(__int64)>> {
759
+ static constexpr int kNumBits = static_cast<int>(sizeof(BitsType) * CHAR_BIT);
760
+ static EIGEN_DEVICE_FUNC inline int clz(BitsType bits) {
761
+ unsigned long out;
762
+ _BitScanReverse64(&out, static_cast<unsigned __int64>(bits));
763
+ return bits == 0 ? kNumBits : (kNumBits - 1) - static_cast<int>(out);
764
+ }
765
+
766
+ static EIGEN_DEVICE_FUNC inline int ctz(BitsType bits) {
767
+ unsigned long out;
768
+ _BitScanForward64(&out, static_cast<unsigned __int64>(bits));
769
+ return bits == 0 ? kNumBits : static_cast<int>(out);
660
770
  }
661
771
  };
662
772
 
663
- template<typename Scalar>
664
- struct random_default_impl<Scalar, true, false>
665
- {
666
- static inline Scalar run(const Scalar& x, const Scalar& y)
667
- {
668
- return Scalar(random(x.real(), y.real()),
669
- random(x.imag(), y.imag()));
773
+ #endif // _WIN64
774
+
775
+ #endif // EIGEN_COMP_GNUC || EIGEN_COMP_CLANG
776
+
777
+ template <typename BitsType>
778
+ struct log_2_impl {
779
+ static constexpr int kTotalBits = sizeof(BitsType) * CHAR_BIT;
780
+ static EIGEN_DEVICE_FUNC inline int run_ceil(const BitsType& x) {
781
+ const int n = kTotalBits - clz(x);
782
+ bool power_of_two = (x & (x - 1)) == 0;
783
+ return x == 0 ? 0 : power_of_two ? (n - 1) : n;
670
784
  }
671
- static inline Scalar run()
672
- {
673
- typedef typename NumTraits<Scalar>::Real RealScalar;
674
- return Scalar(random<RealScalar>(), random<RealScalar>());
785
+ static EIGEN_DEVICE_FUNC inline int run_floor(const BitsType& x) {
786
+ const int n = kTotalBits - clz(x);
787
+ return x == 0 ? 0 : n - 1;
675
788
  }
676
789
  };
677
790
 
678
- template<typename Scalar>
679
- inline EIGEN_MATHFUNC_RETVAL(random, Scalar) random(const Scalar& x, const Scalar& y)
680
- {
681
- return EIGEN_MATHFUNC_IMPL(random, Scalar)::run(x, y);
791
+ template <typename BitsType>
792
+ int log2_ceil(const BitsType& x) {
793
+ return log_2_impl<BitsType>::run_ceil(x);
682
794
  }
683
795
 
684
- template<typename Scalar>
685
- inline EIGEN_MATHFUNC_RETVAL(random, Scalar) random()
686
- {
687
- return EIGEN_MATHFUNC_IMPL(random, Scalar)::run();
796
+ template <typename BitsType>
797
+ int log2_floor(const BitsType& x) {
798
+ return log_2_impl<BitsType>::run_floor(x);
688
799
  }
689
800
 
690
- // Implementatin of is* functions
691
-
692
- // 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
- #if (EIGEN_HAS_CXX11_MATH && !(EIGEN_COMP_GNUC_STRICT && __FINITE_MATH_ONLY__)) || (EIGEN_COMP_MSVC>=1800) || (EIGEN_COMP_CLANG)
694
- #define EIGEN_USE_STD_FPCLASSIFY 1
695
- #else
696
- #define EIGEN_USE_STD_FPCLASSIFY 0
697
- #endif
698
-
699
- template<typename T>
700
- EIGEN_DEVICE_FUNC
701
- typename internal::enable_if<internal::is_integral<T>::value,bool>::type
702
- isnan_impl(const T&) { return false; }
801
+ // Implementation of is* functions
703
802
 
704
- template<typename T>
705
- EIGEN_DEVICE_FUNC
706
- typename internal::enable_if<internal::is_integral<T>::value,bool>::type
707
- isinf_impl(const T&) { return false; }
803
+ template <typename T>
804
+ EIGEN_DEVICE_FUNC std::enable_if_t<!(std::numeric_limits<T>::has_infinity || std::numeric_limits<T>::has_quiet_NaN ||
805
+ std::numeric_limits<T>::has_signaling_NaN),
806
+ bool>
807
+ isfinite_impl(const T&) {
808
+ return true;
809
+ }
708
810
 
709
- template<typename T>
710
- EIGEN_DEVICE_FUNC
711
- typename internal::enable_if<internal::is_integral<T>::value,bool>::type
712
- isfinite_impl(const T&) { return true; }
811
+ template <typename T>
812
+ EIGEN_DEVICE_FUNC std::enable_if_t<(std::numeric_limits<T>::has_infinity || std::numeric_limits<T>::has_quiet_NaN ||
813
+ std::numeric_limits<T>::has_signaling_NaN) &&
814
+ (!NumTraits<T>::IsComplex),
815
+ bool>
816
+ isfinite_impl(const T& x) {
817
+ EIGEN_USING_STD(isfinite);
818
+ return isfinite EIGEN_NOT_A_MACRO(x);
819
+ }
713
820
 
714
- template<typename T>
715
- EIGEN_DEVICE_FUNC
716
- typename internal::enable_if<(!internal::is_integral<T>::value)&&(!NumTraits<T>::IsComplex),bool>::type
717
- isfinite_impl(const T& x)
718
- {
719
- #ifdef __CUDA_ARCH__
720
- return (::isfinite)(x);
721
- #elif EIGEN_USE_STD_FPCLASSIFY
722
- using std::isfinite;
723
- return isfinite EIGEN_NOT_A_MACRO (x);
724
- #else
725
- return x<=NumTraits<T>::highest() && x>=NumTraits<T>::lowest();
726
- #endif
821
+ template <typename T>
822
+ EIGEN_DEVICE_FUNC std::enable_if_t<!std::numeric_limits<T>::has_infinity, bool> isinf_impl(const T&) {
823
+ return false;
727
824
  }
728
825
 
729
- template<typename T>
730
- EIGEN_DEVICE_FUNC
731
- typename internal::enable_if<(!internal::is_integral<T>::value)&&(!NumTraits<T>::IsComplex),bool>::type
732
- isinf_impl(const T& x)
733
- {
734
- #ifdef __CUDA_ARCH__
735
- return (::isinf)(x);
736
- #elif EIGEN_USE_STD_FPCLASSIFY
737
- using std::isinf;
738
- return isinf EIGEN_NOT_A_MACRO (x);
739
- #else
740
- return x>NumTraits<T>::highest() || x<NumTraits<T>::lowest();
741
- #endif
826
+ template <typename T>
827
+ EIGEN_DEVICE_FUNC std::enable_if_t<(std::numeric_limits<T>::has_infinity && !NumTraits<T>::IsComplex), bool> isinf_impl(
828
+ const T& x) {
829
+ EIGEN_USING_STD(isinf);
830
+ return isinf EIGEN_NOT_A_MACRO(x);
742
831
  }
743
832
 
744
- template<typename T>
833
+ template <typename T>
745
834
  EIGEN_DEVICE_FUNC
746
- typename internal::enable_if<(!internal::is_integral<T>::value)&&(!NumTraits<T>::IsComplex),bool>::type
747
- isnan_impl(const T& x)
748
- {
749
- #ifdef __CUDA_ARCH__
750
- return (::isnan)(x);
751
- #elif EIGEN_USE_STD_FPCLASSIFY
752
- using std::isnan;
753
- return isnan EIGEN_NOT_A_MACRO (x);
754
- #else
755
- return x != x;
756
- #endif
835
+ std::enable_if_t<!(std::numeric_limits<T>::has_quiet_NaN || std::numeric_limits<T>::has_signaling_NaN), bool>
836
+ isnan_impl(const T&) {
837
+ return false;
757
838
  }
758
839
 
759
- #if (!EIGEN_USE_STD_FPCLASSIFY)
760
-
761
- #if EIGEN_COMP_MSVC
762
-
763
- template<typename T> EIGEN_DEVICE_FUNC bool isinf_msvc_helper(T x)
764
- {
765
- return _fpclass(x)==_FPCLASS_NINF || _fpclass(x)==_FPCLASS_PINF;
840
+ template <typename T>
841
+ EIGEN_DEVICE_FUNC std::enable_if_t<
842
+ (std::numeric_limits<T>::has_quiet_NaN || std::numeric_limits<T>::has_signaling_NaN) && (!NumTraits<T>::IsComplex),
843
+ bool>
844
+ isnan_impl(const T& x) {
845
+ EIGEN_USING_STD(isnan);
846
+ return isnan EIGEN_NOT_A_MACRO(x);
766
847
  }
767
848
 
768
- //MSVC defines a _isnan builtin function, but for double only
769
- EIGEN_DEVICE_FUNC inline bool isnan_impl(const long double& x) { return _isnan(x)!=0; }
770
- EIGEN_DEVICE_FUNC inline bool isnan_impl(const double& x) { return _isnan(x)!=0; }
771
- EIGEN_DEVICE_FUNC inline bool isnan_impl(const float& x) { return _isnan(x)!=0; }
849
+ // The following overload are defined at the end of this file
850
+ template <typename T>
851
+ EIGEN_DEVICE_FUNC bool isfinite_impl(const std::complex<T>& x);
852
+ template <typename T>
853
+ EIGEN_DEVICE_FUNC bool isnan_impl(const std::complex<T>& x);
854
+ template <typename T>
855
+ EIGEN_DEVICE_FUNC bool isinf_impl(const std::complex<T>& x);
856
+ template <typename T>
857
+ EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS T ptanh_float(const T& a_x);
772
858
 
773
- EIGEN_DEVICE_FUNC inline bool isinf_impl(const long double& x) { return isinf_msvc_helper(x); }
774
- EIGEN_DEVICE_FUNC inline bool isinf_impl(const double& x) { return isinf_msvc_helper(x); }
775
- EIGEN_DEVICE_FUNC inline bool isinf_impl(const float& x) { return isinf_msvc_helper(x); }
859
+ /****************************************************************************
860
+ * Implementation of sign *
861
+ ****************************************************************************/
862
+ template <typename Scalar, bool IsComplex = (NumTraits<Scalar>::IsComplex != 0),
863
+ bool IsInteger = (NumTraits<Scalar>::IsInteger != 0)>
864
+ struct sign_impl {
865
+ EIGEN_DEVICE_FUNC static inline Scalar run(const Scalar& a) { return Scalar((a > Scalar(0)) - (a < Scalar(0))); }
866
+ };
776
867
 
777
- #elif (defined __FINITE_MATH_ONLY__ && __FINITE_MATH_ONLY__ && EIGEN_COMP_GNUC)
868
+ template <typename Scalar>
869
+ struct sign_impl<Scalar, false, false> {
870
+ EIGEN_DEVICE_FUNC static inline Scalar run(const Scalar& a) {
871
+ return (isnan_impl<Scalar>)(a) ? a : Scalar((a > Scalar(0)) - (a < Scalar(0)));
872
+ }
873
+ };
778
874
 
779
- #if EIGEN_GNUC_AT_LEAST(5,0)
780
- #define EIGEN_TMP_NOOPT_ATTRIB EIGEN_DEVICE_FUNC inline __attribute__((optimize("no-finite-math-only")))
781
- #else
782
- // NOTE the inline qualifier and noinline attribute are both needed: the former is to avoid linking issue (duplicate symbol),
783
- // while the second prevent too aggressive optimizations in fast-math mode:
784
- #define EIGEN_TMP_NOOPT_ATTRIB EIGEN_DEVICE_FUNC inline __attribute__((noinline,optimize("no-finite-math-only")))
785
- #endif
875
+ template <typename Scalar, bool IsInteger>
876
+ struct sign_impl<Scalar, true, IsInteger> {
877
+ EIGEN_DEVICE_FUNC static inline Scalar run(const Scalar& a) {
878
+ using real_type = typename NumTraits<Scalar>::Real;
879
+ EIGEN_USING_STD(abs);
880
+ real_type aa = abs(a);
881
+ if (aa == real_type(0)) return Scalar(0);
882
+ aa = real_type(1) / aa;
883
+ return Scalar(numext::real(a) * aa, numext::imag(a) * aa);
884
+ }
885
+ };
786
886
 
787
- template<> EIGEN_TMP_NOOPT_ATTRIB bool isnan_impl(const long double& x) { return __builtin_isnan(x); }
788
- template<> EIGEN_TMP_NOOPT_ATTRIB bool isnan_impl(const double& x) { return __builtin_isnan(x); }
789
- template<> EIGEN_TMP_NOOPT_ATTRIB bool isnan_impl(const float& x) { return __builtin_isnan(x); }
790
- template<> EIGEN_TMP_NOOPT_ATTRIB bool isinf_impl(const double& x) { return __builtin_isinf(x); }
791
- template<> EIGEN_TMP_NOOPT_ATTRIB bool isinf_impl(const float& x) { return __builtin_isinf(x); }
792
- template<> EIGEN_TMP_NOOPT_ATTRIB bool isinf_impl(const long double& x) { return __builtin_isinf(x); }
887
+ // The sign function for bool is the identity.
888
+ template <>
889
+ struct sign_impl<bool, false, true> {
890
+ EIGEN_DEVICE_FUNC static inline bool run(const bool& a) { return a; }
891
+ };
793
892
 
794
- #undef EIGEN_TMP_NOOPT_ATTRIB
893
+ template <typename Scalar>
894
+ struct sign_retval {
895
+ typedef Scalar type;
896
+ };
795
897
 
796
- #endif
898
+ // suppress "unary minus operator applied to unsigned type, result still unsigned" warnings on MSVC
899
+ // note: `0 - a` is distinct from `-a` when Scalar is a floating point type and `a` is zero
797
900
 
798
- #endif
901
+ template <typename Scalar, bool IsInteger = NumTraits<Scalar>::IsInteger>
902
+ struct negate_impl {
903
+ static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE Scalar run(const Scalar& a) { return -a; }
904
+ };
799
905
 
800
- // The following overload are defined at the end of this file
801
- template<typename T> EIGEN_DEVICE_FUNC bool isfinite_impl(const std::complex<T>& x);
802
- template<typename T> EIGEN_DEVICE_FUNC bool isnan_impl(const std::complex<T>& x);
803
- template<typename T> EIGEN_DEVICE_FUNC bool isinf_impl(const std::complex<T>& x);
906
+ template <typename Scalar>
907
+ struct negate_impl<Scalar, true> {
908
+ EIGEN_STATIC_ASSERT((!is_same<Scalar, bool>::value), NEGATE IS NOT DEFINED FOR BOOLEAN TYPES)
909
+ static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE Scalar run(const Scalar& a) { return Scalar(0) - a; }
910
+ };
804
911
 
805
- template<typename T> T generic_fast_tanh_float(const T& a_x);
912
+ template <typename Scalar>
913
+ struct negate_retval {
914
+ typedef Scalar type;
915
+ };
806
916
 
807
- } // end namespace internal
917
+ template <typename Scalar, bool IsInteger = NumTraits<typename unpacket_traits<Scalar>::type>::IsInteger>
918
+ struct nearest_integer_impl {
919
+ static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar run_floor(const Scalar& x) {
920
+ EIGEN_USING_STD(floor) return floor(x);
921
+ }
922
+ static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar run_ceil(const Scalar& x) {
923
+ EIGEN_USING_STD(ceil) return ceil(x);
924
+ }
925
+ static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar run_rint(const Scalar& x) {
926
+ EIGEN_USING_STD(rint) return rint(x);
927
+ }
928
+ static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar run_round(const Scalar& x) {
929
+ EIGEN_USING_STD(round) return round(x);
930
+ }
931
+ static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar run_trunc(const Scalar& x) {
932
+ EIGEN_USING_STD(trunc) return trunc(x);
933
+ }
934
+ };
935
+ template <typename Scalar>
936
+ struct nearest_integer_impl<Scalar, true> {
937
+ static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar run_floor(const Scalar& x) { return x; }
938
+ static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar run_ceil(const Scalar& x) { return x; }
939
+ static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar run_rint(const Scalar& x) { return x; }
940
+ static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar run_round(const Scalar& x) { return x; }
941
+ static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar run_trunc(const Scalar& x) { return x; }
942
+ };
943
+
944
+ // Extra namespace to prevent leaking std::fma into Eigen::internal.
945
+ namespace has_fma_detail {
946
+
947
+ template <typename T, typename EnableIf = void>
948
+ struct has_fma_impl : public std::false_type {};
949
+
950
+ using std::fma;
951
+
952
+ template <typename T>
953
+ struct has_fma_impl<
954
+ T, std::enable_if_t<std::is_same<T, decltype(fma(std::declval<T>(), std::declval<T>(), std::declval<T>()))>::value>>
955
+ : public std::true_type {};
956
+
957
+ } // namespace has_fma_detail
958
+
959
+ template <typename T>
960
+ struct has_fma : public has_fma_detail::has_fma_impl<T> {};
961
+
962
+ // Default implementation.
963
+ template <typename T, typename Enable = void>
964
+ struct fma_impl {
965
+ static_assert(has_fma<T>::value, "No function fma(...) for type. Please provide an implementation.");
966
+ };
967
+
968
+ // STD or ADL version if it exists.
969
+ template <typename T>
970
+ struct fma_impl<T, std::enable_if_t<has_fma<T>::value>> {
971
+ static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T run(const T& a, const T& b, const T& c) {
972
+ using std::fma;
973
+ return fma(a, b, c);
974
+ }
975
+ };
976
+
977
+ #if defined(EIGEN_GPUCC)
978
+ template <>
979
+ struct has_fma<float> : public true_type {};
980
+
981
+ template <>
982
+ struct fma_impl<float, void> {
983
+ static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float run(const float& a, const float& b, const float& c) {
984
+ return ::fmaf(a, b, c);
985
+ }
986
+ };
987
+
988
+ template <>
989
+ struct has_fma<double> : public true_type {};
990
+
991
+ template <>
992
+ struct fma_impl<double, void> {
993
+ static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double run(const double& a, const double& b, const double& c) {
994
+ return ::fma(a, b, c);
995
+ }
996
+ };
997
+ #endif
998
+
999
+ // Basic multiply-add.
1000
+ template <typename Scalar, typename EnableIf = void>
1001
+ struct madd_impl {
1002
+ static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar run(const Scalar& x, const Scalar& y, const Scalar& z) {
1003
+ return x * y + z;
1004
+ }
1005
+ };
1006
+
1007
+ #if EIGEN_SCALAR_MADD_USE_FMA
1008
+ template <typename Scalar>
1009
+ struct madd_impl<Scalar, std::enable_if_t<has_fma<Scalar>::value>> {
1010
+ static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar run(const Scalar& x, const Scalar& y, const Scalar& z) {
1011
+ return fma_impl<Scalar>::run(x, y, z);
1012
+ }
1013
+ };
1014
+ #endif
1015
+
1016
+ } // end namespace internal
808
1017
 
809
1018
  /****************************************************************************
810
- * Generic math functions *
811
- ****************************************************************************/
1019
+ * Generic math functions *
1020
+ ****************************************************************************/
812
1021
 
813
1022
  namespace numext {
814
1023
 
815
- #ifndef __CUDA_ARCH__
816
- template<typename T>
817
- EIGEN_DEVICE_FUNC
818
- EIGEN_ALWAYS_INLINE T mini(const T& x, const T& y)
819
- {
820
- EIGEN_USING_STD_MATH(min);
821
- return min EIGEN_NOT_A_MACRO (x,y);
1024
+ #if (!defined(EIGEN_GPUCC) || defined(EIGEN_CONSTEXPR_ARE_DEVICE_FUNC))
1025
+ template <typename T>
1026
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T mini(const T& x, const T& y) {
1027
+ EIGEN_USING_STD(min)
1028
+ return min EIGEN_NOT_A_MACRO(x, y);
822
1029
  }
823
1030
 
824
- template<typename T>
825
- EIGEN_DEVICE_FUNC
826
- EIGEN_ALWAYS_INLINE T maxi(const T& x, const T& y)
827
- {
828
- EIGEN_USING_STD_MATH(max);
829
- return max EIGEN_NOT_A_MACRO (x,y);
1031
+ template <typename T>
1032
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T maxi(const T& x, const T& y) {
1033
+ EIGEN_USING_STD(max)
1034
+ return max EIGEN_NOT_A_MACRO(x, y);
830
1035
  }
831
1036
  #else
832
- template<typename T>
833
- EIGEN_DEVICE_FUNC
834
- EIGEN_ALWAYS_INLINE T mini(const T& x, const T& y)
835
- {
1037
+ template <typename T>
1038
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T mini(const T& x, const T& y) {
836
1039
  return y < x ? y : x;
837
1040
  }
838
- template<>
839
- EIGEN_DEVICE_FUNC
840
- EIGEN_ALWAYS_INLINE float mini(const float& x, const float& y)
841
- {
1041
+ template <>
1042
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE float mini(const float& x, const float& y) {
842
1043
  return fminf(x, y);
843
1044
  }
844
- template<typename T>
845
- EIGEN_DEVICE_FUNC
846
- EIGEN_ALWAYS_INLINE T maxi(const T& x, const T& y)
847
- {
1045
+ template <>
1046
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE double mini(const double& x, const double& y) {
1047
+ return fmin(x, y);
1048
+ }
1049
+
1050
+ #ifndef EIGEN_GPU_COMPILE_PHASE
1051
+ template <>
1052
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE long double mini(const long double& x, const long double& y) {
1053
+ #if defined(EIGEN_HIPCC)
1054
+ // no "fminl" on HIP yet
1055
+ return (x < y) ? x : y;
1056
+ #else
1057
+ return fminl(x, y);
1058
+ #endif
1059
+ }
1060
+ #endif
1061
+
1062
+ template <typename T>
1063
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T maxi(const T& x, const T& y) {
848
1064
  return x < y ? y : x;
849
1065
  }
850
- template<>
851
- EIGEN_DEVICE_FUNC
852
- EIGEN_ALWAYS_INLINE float maxi(const float& x, const float& y)
853
- {
1066
+ template <>
1067
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE float maxi(const float& x, const float& y) {
854
1068
  return fmaxf(x, y);
855
1069
  }
1070
+ template <>
1071
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE double maxi(const double& x, const double& y) {
1072
+ return fmax(x, y);
1073
+ }
1074
+ #ifndef EIGEN_GPU_COMPILE_PHASE
1075
+ template <>
1076
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE long double maxi(const long double& x, const long double& y) {
1077
+ #if defined(EIGEN_HIPCC)
1078
+ // no "fmaxl" on HIP yet
1079
+ return (x > y) ? x : y;
1080
+ #else
1081
+ return fmaxl(x, y);
1082
+ #endif
1083
+ }
1084
+ #endif
856
1085
  #endif
857
1086
 
1087
+ #if defined(SYCL_DEVICE_ONLY)
1088
+
1089
+ #define SYCL_SPECIALIZE_SIGNED_INTEGER_TYPES_BINARY(NAME, FUNC) \
1090
+ SYCL_SPECIALIZE_BINARY_FUNC(NAME, FUNC, cl::sycl::cl_char) \
1091
+ SYCL_SPECIALIZE_BINARY_FUNC(NAME, FUNC, cl::sycl::cl_short) \
1092
+ SYCL_SPECIALIZE_BINARY_FUNC(NAME, FUNC, cl::sycl::cl_int) \
1093
+ SYCL_SPECIALIZE_BINARY_FUNC(NAME, FUNC, cl::sycl::cl_long)
1094
+ #define SYCL_SPECIALIZE_SIGNED_INTEGER_TYPES_UNARY(NAME, FUNC) \
1095
+ SYCL_SPECIALIZE_UNARY_FUNC(NAME, FUNC, cl::sycl::cl_char) \
1096
+ SYCL_SPECIALIZE_UNARY_FUNC(NAME, FUNC, cl::sycl::cl_short) \
1097
+ SYCL_SPECIALIZE_UNARY_FUNC(NAME, FUNC, cl::sycl::cl_int) \
1098
+ SYCL_SPECIALIZE_UNARY_FUNC(NAME, FUNC, cl::sycl::cl_long)
1099
+ #define SYCL_SPECIALIZE_UNSIGNED_INTEGER_TYPES_BINARY(NAME, FUNC) \
1100
+ SYCL_SPECIALIZE_BINARY_FUNC(NAME, FUNC, cl::sycl::cl_uchar) \
1101
+ SYCL_SPECIALIZE_BINARY_FUNC(NAME, FUNC, cl::sycl::cl_ushort) \
1102
+ SYCL_SPECIALIZE_BINARY_FUNC(NAME, FUNC, cl::sycl::cl_uint) \
1103
+ SYCL_SPECIALIZE_BINARY_FUNC(NAME, FUNC, cl::sycl::cl_ulong)
1104
+ #define SYCL_SPECIALIZE_UNSIGNED_INTEGER_TYPES_UNARY(NAME, FUNC) \
1105
+ SYCL_SPECIALIZE_UNARY_FUNC(NAME, FUNC, cl::sycl::cl_uchar) \
1106
+ SYCL_SPECIALIZE_UNARY_FUNC(NAME, FUNC, cl::sycl::cl_ushort) \
1107
+ SYCL_SPECIALIZE_UNARY_FUNC(NAME, FUNC, cl::sycl::cl_uint) \
1108
+ SYCL_SPECIALIZE_UNARY_FUNC(NAME, FUNC, cl::sycl::cl_ulong)
1109
+ #define SYCL_SPECIALIZE_INTEGER_TYPES_BINARY(NAME, FUNC) \
1110
+ SYCL_SPECIALIZE_SIGNED_INTEGER_TYPES_BINARY(NAME, FUNC) \
1111
+ SYCL_SPECIALIZE_UNSIGNED_INTEGER_TYPES_BINARY(NAME, FUNC)
1112
+ #define SYCL_SPECIALIZE_INTEGER_TYPES_UNARY(NAME, FUNC) \
1113
+ SYCL_SPECIALIZE_SIGNED_INTEGER_TYPES_UNARY(NAME, FUNC) \
1114
+ SYCL_SPECIALIZE_UNSIGNED_INTEGER_TYPES_UNARY(NAME, FUNC)
1115
+ #define SYCL_SPECIALIZE_FLOATING_TYPES_BINARY(NAME, FUNC) \
1116
+ SYCL_SPECIALIZE_BINARY_FUNC(NAME, FUNC, cl::sycl::cl_float) \
1117
+ SYCL_SPECIALIZE_BINARY_FUNC(NAME, FUNC, cl::sycl::cl_double)
1118
+ #define SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(NAME, FUNC) \
1119
+ SYCL_SPECIALIZE_UNARY_FUNC(NAME, FUNC, cl::sycl::cl_float) \
1120
+ SYCL_SPECIALIZE_UNARY_FUNC(NAME, FUNC, cl::sycl::cl_double)
1121
+ #define SYCL_SPECIALIZE_FLOATING_TYPES_UNARY_FUNC_RET_TYPE(NAME, FUNC, RET_TYPE) \
1122
+ SYCL_SPECIALIZE_GEN_UNARY_FUNC(NAME, FUNC, RET_TYPE, cl::sycl::cl_float) \
1123
+ SYCL_SPECIALIZE_GEN_UNARY_FUNC(NAME, FUNC, RET_TYPE, cl::sycl::cl_double)
1124
+
1125
+ #define SYCL_SPECIALIZE_GEN_UNARY_FUNC(NAME, FUNC, RET_TYPE, ARG_TYPE) \
1126
+ template <> \
1127
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE RET_TYPE NAME(const ARG_TYPE& x) { \
1128
+ return cl::sycl::FUNC(x); \
1129
+ }
858
1130
 
859
- template<typename Scalar>
860
- EIGEN_DEVICE_FUNC
861
- inline EIGEN_MATHFUNC_RETVAL(real, Scalar) real(const Scalar& x)
862
- {
863
- return EIGEN_MATHFUNC_IMPL(real, Scalar)::run(x);
864
- }
1131
+ #define SYCL_SPECIALIZE_UNARY_FUNC(NAME, FUNC, TYPE) SYCL_SPECIALIZE_GEN_UNARY_FUNC(NAME, FUNC, TYPE, TYPE)
865
1132
 
866
- template<typename Scalar>
867
- EIGEN_DEVICE_FUNC
868
- inline typename internal::add_const_on_value_type< EIGEN_MATHFUNC_RETVAL(real_ref, Scalar) >::type real_ref(const Scalar& x)
869
- {
870
- return internal::real_ref_impl<Scalar>::run(x);
871
- }
1133
+ #define SYCL_SPECIALIZE_GEN1_BINARY_FUNC(NAME, FUNC, RET_TYPE, ARG_TYPE1, ARG_TYPE2) \
1134
+ template <> \
1135
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE RET_TYPE NAME(const ARG_TYPE1& x, const ARG_TYPE2& y) { \
1136
+ return cl::sycl::FUNC(x, y); \
1137
+ }
872
1138
 
873
- template<typename Scalar>
874
- EIGEN_DEVICE_FUNC
875
- inline EIGEN_MATHFUNC_RETVAL(real_ref, Scalar) real_ref(Scalar& x)
876
- {
877
- return EIGEN_MATHFUNC_IMPL(real_ref, Scalar)::run(x);
878
- }
1139
+ #define SYCL_SPECIALIZE_GEN2_BINARY_FUNC(NAME, FUNC, RET_TYPE, ARG_TYPE) \
1140
+ SYCL_SPECIALIZE_GEN1_BINARY_FUNC(NAME, FUNC, RET_TYPE, ARG_TYPE, ARG_TYPE)
879
1141
 
880
- template<typename Scalar>
881
- EIGEN_DEVICE_FUNC
882
- inline EIGEN_MATHFUNC_RETVAL(imag, Scalar) imag(const Scalar& x)
883
- {
884
- return EIGEN_MATHFUNC_IMPL(imag, Scalar)::run(x);
885
- }
1142
+ #define SYCL_SPECIALIZE_BINARY_FUNC(NAME, FUNC, TYPE) SYCL_SPECIALIZE_GEN2_BINARY_FUNC(NAME, FUNC, TYPE, TYPE)
886
1143
 
887
- template<typename Scalar>
888
- EIGEN_DEVICE_FUNC
889
- inline EIGEN_MATHFUNC_RETVAL(arg, Scalar) arg(const Scalar& x)
890
- {
1144
+ SYCL_SPECIALIZE_INTEGER_TYPES_BINARY(mini, min)
1145
+ SYCL_SPECIALIZE_FLOATING_TYPES_BINARY(mini, fmin)
1146
+ SYCL_SPECIALIZE_INTEGER_TYPES_BINARY(maxi, max)
1147
+ SYCL_SPECIALIZE_FLOATING_TYPES_BINARY(maxi, fmax)
1148
+
1149
+ #endif
1150
+
1151
+ template <typename Scalar>
1152
+ EIGEN_DEVICE_FUNC inline EIGEN_MATHFUNC_RETVAL(arg, Scalar) arg(const Scalar& x) {
891
1153
  return EIGEN_MATHFUNC_IMPL(arg, Scalar)::run(x);
892
1154
  }
893
1155
 
894
- template<typename Scalar>
895
- EIGEN_DEVICE_FUNC
896
- inline typename internal::add_const_on_value_type< EIGEN_MATHFUNC_RETVAL(imag_ref, Scalar) >::type imag_ref(const Scalar& x)
897
- {
1156
+ template <typename Scalar>
1157
+ EIGEN_DEVICE_FUNC inline internal::add_const_on_value_type_t<EIGEN_MATHFUNC_RETVAL(imag_ref, Scalar)> imag_ref(
1158
+ const Scalar& x) {
898
1159
  return internal::imag_ref_impl<Scalar>::run(x);
899
1160
  }
900
1161
 
901
- template<typename Scalar>
902
- EIGEN_DEVICE_FUNC
903
- inline EIGEN_MATHFUNC_RETVAL(imag_ref, Scalar) imag_ref(Scalar& x)
904
- {
1162
+ template <typename Scalar>
1163
+ EIGEN_DEVICE_FUNC inline EIGEN_MATHFUNC_RETVAL(imag_ref, Scalar) imag_ref(Scalar& x) {
905
1164
  return EIGEN_MATHFUNC_IMPL(imag_ref, Scalar)::run(x);
906
1165
  }
907
1166
 
908
- template<typename Scalar>
909
- EIGEN_DEVICE_FUNC
910
- inline EIGEN_MATHFUNC_RETVAL(conj, Scalar) conj(const Scalar& x)
911
- {
1167
+ template <typename Scalar>
1168
+ EIGEN_DEVICE_FUNC inline EIGEN_MATHFUNC_RETVAL(conj, Scalar) conj(const Scalar& x) {
912
1169
  return EIGEN_MATHFUNC_IMPL(conj, Scalar)::run(x);
913
1170
  }
914
1171
 
915
- template<typename Scalar>
916
- EIGEN_DEVICE_FUNC
917
- inline EIGEN_MATHFUNC_RETVAL(abs2, Scalar) abs2(const Scalar& x)
918
- {
1172
+ template <typename Scalar>
1173
+ EIGEN_DEVICE_FUNC inline EIGEN_MATHFUNC_RETVAL(sign, Scalar) sign(const Scalar& x) {
1174
+ return EIGEN_MATHFUNC_IMPL(sign, Scalar)::run(x);
1175
+ }
1176
+
1177
+ template <typename Scalar>
1178
+ EIGEN_DEVICE_FUNC inline EIGEN_MATHFUNC_RETVAL(negate, Scalar) negate(const Scalar& x) {
1179
+ return EIGEN_MATHFUNC_IMPL(negate, Scalar)::run(x);
1180
+ }
1181
+
1182
+ template <typename Scalar>
1183
+ EIGEN_DEVICE_FUNC inline EIGEN_MATHFUNC_RETVAL(abs2, Scalar) abs2(const Scalar& x) {
919
1184
  return EIGEN_MATHFUNC_IMPL(abs2, Scalar)::run(x);
920
1185
  }
921
1186
 
922
- EIGEN_DEVICE_FUNC
923
- inline bool abs2(bool x) { return x; }
1187
+ EIGEN_DEVICE_FUNC inline bool abs2(bool x) { return x; }
924
1188
 
925
- template<typename Scalar>
926
- EIGEN_DEVICE_FUNC
927
- inline EIGEN_MATHFUNC_RETVAL(norm1, Scalar) norm1(const Scalar& x)
928
- {
1189
+ template <typename T>
1190
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T absdiff(const T& x, const T& y) {
1191
+ return x > y ? x - y : y - x;
1192
+ }
1193
+ template <>
1194
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE float absdiff(const float& x, const float& y) {
1195
+ return fabsf(x - y);
1196
+ }
1197
+ template <>
1198
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE double absdiff(const double& x, const double& y) {
1199
+ return fabs(x - y);
1200
+ }
1201
+
1202
+ // HIP and CUDA do not support long double.
1203
+ #ifndef EIGEN_GPU_COMPILE_PHASE
1204
+ template <>
1205
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE long double absdiff(const long double& x, const long double& y) {
1206
+ return fabsl(x - y);
1207
+ }
1208
+ #endif
1209
+
1210
+ template <typename Scalar>
1211
+ EIGEN_DEVICE_FUNC inline EIGEN_MATHFUNC_RETVAL(norm1, Scalar) norm1(const Scalar& x) {
929
1212
  return EIGEN_MATHFUNC_IMPL(norm1, Scalar)::run(x);
930
1213
  }
931
1214
 
932
- template<typename Scalar>
933
- EIGEN_DEVICE_FUNC
934
- inline EIGEN_MATHFUNC_RETVAL(hypot, Scalar) hypot(const Scalar& x, const Scalar& y)
935
- {
1215
+ template <typename Scalar>
1216
+ EIGEN_DEVICE_FUNC inline EIGEN_MATHFUNC_RETVAL(hypot, Scalar) hypot(const Scalar& x, const Scalar& y) {
936
1217
  return EIGEN_MATHFUNC_IMPL(hypot, Scalar)::run(x, y);
937
1218
  }
938
1219
 
939
- template<typename Scalar>
940
- EIGEN_DEVICE_FUNC
941
- inline EIGEN_MATHFUNC_RETVAL(log1p, Scalar) log1p(const Scalar& x)
942
- {
1220
+ #if defined(SYCL_DEVICE_ONLY)
1221
+ SYCL_SPECIALIZE_FLOATING_TYPES_BINARY(hypot, hypot)
1222
+ #endif
1223
+
1224
+ template <typename Scalar>
1225
+ EIGEN_DEVICE_FUNC inline EIGEN_MATHFUNC_RETVAL(log1p, Scalar) log1p(const Scalar& x) {
943
1226
  return EIGEN_MATHFUNC_IMPL(log1p, Scalar)::run(x);
944
1227
  }
945
1228
 
946
- #ifdef __CUDACC__
947
- template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
948
- float log1p(const float &x) { return ::log1pf(x); }
1229
+ #if defined(SYCL_DEVICE_ONLY)
1230
+ SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(log1p, log1p)
1231
+ #endif
1232
+
1233
+ #if defined(EIGEN_GPUCC)
1234
+ template <>
1235
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE float log1p(const float& x) {
1236
+ return ::log1pf(x);
1237
+ }
949
1238
 
950
- template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
951
- double log1p(const double &x) { return ::log1p(x); }
1239
+ template <>
1240
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE double log1p(const double& x) {
1241
+ return ::log1p(x);
1242
+ }
952
1243
  #endif
953
1244
 
954
- template<typename ScalarX,typename ScalarY>
955
- EIGEN_DEVICE_FUNC
956
- inline typename internal::pow_impl<ScalarX,ScalarY>::result_type pow(const ScalarX& x, const ScalarY& y)
957
- {
958
- return internal::pow_impl<ScalarX,ScalarY>::run(x, y);
1245
+ template <typename ScalarX, typename ScalarY>
1246
+ EIGEN_DEVICE_FUNC inline typename internal::pow_impl<ScalarX, ScalarY>::result_type pow(const ScalarX& x,
1247
+ const ScalarY& y) {
1248
+ return internal::pow_impl<ScalarX, ScalarY>::run(x, y);
959
1249
  }
960
1250
 
961
- template<typename T> EIGEN_DEVICE_FUNC bool (isnan) (const T &x) { return internal::isnan_impl(x); }
962
- template<typename T> EIGEN_DEVICE_FUNC bool (isinf) (const T &x) { return internal::isinf_impl(x); }
963
- template<typename T> EIGEN_DEVICE_FUNC bool (isfinite)(const T &x) { return internal::isfinite_impl(x); }
1251
+ #if defined(SYCL_DEVICE_ONLY)
1252
+ SYCL_SPECIALIZE_FLOATING_TYPES_BINARY(pow, pow)
1253
+ #endif
964
1254
 
965
- template<typename Scalar>
966
- EIGEN_DEVICE_FUNC
967
- inline EIGEN_MATHFUNC_RETVAL(round, Scalar) round(const Scalar& x)
968
- {
969
- return EIGEN_MATHFUNC_IMPL(round, Scalar)::run(x);
1255
+ template <typename T>
1256
+ EIGEN_DEVICE_FUNC bool(isnan)(const T& x) {
1257
+ return internal::isnan_impl(x);
1258
+ }
1259
+ template <typename T>
1260
+ EIGEN_DEVICE_FUNC bool(isinf)(const T& x) {
1261
+ return internal::isinf_impl(x);
1262
+ }
1263
+ template <typename T>
1264
+ EIGEN_DEVICE_FUNC bool(isfinite)(const T& x) {
1265
+ return internal::isfinite_impl(x);
970
1266
  }
971
1267
 
972
- template<typename T>
973
- EIGEN_DEVICE_FUNC
974
- T (floor)(const T& x)
975
- {
976
- EIGEN_USING_STD_MATH(floor);
977
- return floor(x);
1268
+ #if defined(SYCL_DEVICE_ONLY)
1269
+ SYCL_SPECIALIZE_FLOATING_TYPES_UNARY_FUNC_RET_TYPE(isnan, isnan, bool)
1270
+ SYCL_SPECIALIZE_FLOATING_TYPES_UNARY_FUNC_RET_TYPE(isinf, isinf, bool)
1271
+ SYCL_SPECIALIZE_FLOATING_TYPES_UNARY_FUNC_RET_TYPE(isfinite, isfinite, bool)
1272
+ #endif
1273
+
1274
+ template <typename Scalar>
1275
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar rint(const Scalar& x) {
1276
+ return internal::nearest_integer_impl<Scalar>::run_rint(x);
978
1277
  }
979
1278
 
980
- #ifdef __CUDACC__
981
- template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
982
- float floor(const float &x) { return ::floorf(x); }
1279
+ template <typename Scalar>
1280
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar round(const Scalar& x) {
1281
+ return internal::nearest_integer_impl<Scalar>::run_round(x);
1282
+ }
983
1283
 
984
- template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
985
- double floor(const double &x) { return ::floor(x); }
986
- #endif
1284
+ template <typename Scalar>
1285
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar(floor)(const Scalar& x) {
1286
+ return internal::nearest_integer_impl<Scalar>::run_floor(x);
1287
+ }
987
1288
 
988
- template<typename T>
989
- EIGEN_DEVICE_FUNC
990
- T (ceil)(const T& x)
991
- {
992
- EIGEN_USING_STD_MATH(ceil);
993
- return ceil(x);
1289
+ template <typename Scalar>
1290
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar(ceil)(const Scalar& x) {
1291
+ return internal::nearest_integer_impl<Scalar>::run_ceil(x);
994
1292
  }
995
1293
 
996
- #ifdef __CUDACC__
997
- template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
998
- float ceil(const float &x) { return ::ceilf(x); }
1294
+ template <typename Scalar>
1295
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar(trunc)(const Scalar& x) {
1296
+ return internal::nearest_integer_impl<Scalar>::run_trunc(x);
1297
+ }
999
1298
 
1000
- template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1001
- double ceil(const double &x) { return ::ceil(x); }
1299
+ #if defined(SYCL_DEVICE_ONLY)
1300
+ SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(round, round)
1301
+ SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(floor, floor)
1302
+ SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(ceil, ceil)
1303
+ SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(trunc, trunc)
1002
1304
  #endif
1003
1305
 
1306
+ #if defined(EIGEN_GPUCC)
1307
+ template <>
1308
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE float floor(const float& x) {
1309
+ return ::floorf(x);
1310
+ }
1311
+ template <>
1312
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE double floor(const double& x) {
1313
+ return ::floor(x);
1314
+ }
1315
+ template <>
1316
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE float ceil(const float& x) {
1317
+ return ::ceilf(x);
1318
+ }
1319
+ template <>
1320
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE double ceil(const double& x) {
1321
+ return ::ceil(x);
1322
+ }
1323
+ template <>
1324
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE float trunc(const float& x) {
1325
+ return ::truncf(x);
1326
+ }
1327
+ template <>
1328
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE double trunc(const double& x) {
1329
+ return ::trunc(x);
1330
+ }
1331
+ #endif
1332
+
1333
+ // Integer division with rounding up.
1334
+ // T is assumed to be an integer type with a>=0, and b>0
1335
+ template <typename T>
1336
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE constexpr T div_ceil(T a, T b) {
1337
+ using UnsignedT = typename internal::make_unsigned<T>::type;
1338
+ EIGEN_STATIC_ASSERT((NumTraits<T>::IsInteger), THIS FUNCTION IS FOR INTEGER TYPES)
1339
+ // Note: explicitly declaring a and b as non-negative values allows the compiler to use better optimizations
1340
+ const UnsignedT ua = UnsignedT(a);
1341
+ const UnsignedT ub = UnsignedT(b);
1342
+ // Note: This form is used because it cannot overflow.
1343
+ return ua == 0 ? 0 : (ua - 1) / ub + 1;
1344
+ }
1345
+
1346
+ // Integer round down to nearest power of b
1347
+ // T is assumed to be an integer type with a>=0, and b>0
1348
+ template <typename T, typename U>
1349
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE constexpr T round_down(T a, U b) {
1350
+ using UnsignedT = typename internal::make_unsigned<T>::type;
1351
+ using UnsignedU = typename internal::make_unsigned<U>::type;
1352
+ EIGEN_STATIC_ASSERT((NumTraits<T>::IsInteger), THIS FUNCTION IS FOR INTEGER TYPES)
1353
+ EIGEN_STATIC_ASSERT((NumTraits<U>::IsInteger), THIS FUNCTION IS FOR INTEGER TYPES)
1354
+ // Note: explicitly declaring a and b as non-negative values allows the compiler to use better optimizations
1355
+ const UnsignedT ua = UnsignedT(a);
1356
+ const UnsignedU ub = UnsignedU(b);
1357
+ return ub * (ua / ub);
1358
+ }
1004
1359
 
1005
1360
  /** Log base 2 for 32 bits positive integers.
1006
- * Conveniently returns 0 for x==0. */
1007
- inline int log2(int x)
1008
- {
1009
- eigen_assert(x>=0);
1361
+ * Conveniently returns 0 for x==0. */
1362
+ constexpr int log2(int x) {
1010
1363
  unsigned int v(x);
1011
- static const int table[32] = { 0, 9, 1, 10, 13, 21, 2, 29, 11, 14, 16, 18, 22, 25, 3, 30, 8, 12, 20, 28, 15, 17, 24, 7, 19, 27, 23, 6, 26, 5, 4, 31 };
1364
+ constexpr int table[32] = {0, 9, 1, 10, 13, 21, 2, 29, 11, 14, 16, 18, 22, 25, 3, 30,
1365
+ 8, 12, 20, 28, 15, 17, 24, 7, 19, 27, 23, 6, 26, 5, 4, 31};
1012
1366
  v |= v >> 1;
1013
1367
  v |= v >> 2;
1014
1368
  v |= v >> 4;
@@ -1018,362 +1372,661 @@ inline int log2(int x)
1018
1372
  }
1019
1373
 
1020
1374
  /** \returns the square root of \a x.
1021
- *
1022
- * It is essentially equivalent to
1023
- * \code using std::sqrt; return sqrt(x); \endcode
1024
- * but slightly faster for float/double and some compilers (e.g., gcc), thanks to
1025
- * specializations when SSE is enabled.
1026
- *
1027
- * It's usage is justified in performance critical functions, like norm/normalize.
1028
- */
1029
- template<typename T>
1030
- EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1031
- T sqrt(const T &x)
1032
- {
1033
- EIGEN_USING_STD_MATH(sqrt);
1034
- return sqrt(x);
1375
+ *
1376
+ * It is essentially equivalent to
1377
+ * \code using std::sqrt; return sqrt(x); \endcode
1378
+ * but slightly faster for float/double and some compilers (e.g., gcc), thanks to
1379
+ * specializations when SSE is enabled.
1380
+ *
1381
+ * It's usage is justified in performance critical functions, like norm/normalize.
1382
+ */
1383
+ template <typename Scalar>
1384
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE EIGEN_MATHFUNC_RETVAL(sqrt, Scalar) sqrt(const Scalar& x) {
1385
+ return EIGEN_MATHFUNC_IMPL(sqrt, Scalar)::run(x);
1386
+ }
1387
+
1388
+ // Boolean specialization, avoids implicit float to bool conversion (-Wimplicit-conversion-floating-point-to-bool).
1389
+ template <>
1390
+ EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_DEVICE_FUNC bool sqrt<bool>(const bool& x) {
1391
+ return x;
1392
+ }
1393
+
1394
+ #if defined(SYCL_DEVICE_ONLY)
1395
+ SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(sqrt, sqrt)
1396
+ #endif
1397
+
1398
+ /** \returns the cube root of \a x. **/
1399
+ template <typename T>
1400
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE std::enable_if_t<!NumTraits<T>::IsComplex, T> cbrt(const T& x) {
1401
+ EIGEN_USING_STD(cbrt);
1402
+ return static_cast<T>(cbrt(x));
1403
+ }
1404
+
1405
+ template <typename T>
1406
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE std::enable_if_t<NumTraits<T>::IsComplex, T> cbrt(const T& x) {
1407
+ EIGEN_USING_STD(pow);
1408
+ return pow(x, typename NumTraits<T>::Real(1.0 / 3.0));
1409
+ }
1410
+
1411
+ /** \returns the reciprocal square root of \a x. **/
1412
+ template <typename T>
1413
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T rsqrt(const T& x) {
1414
+ return internal::rsqrt_impl<T>::run(x);
1035
1415
  }
1036
1416
 
1037
- template<typename T>
1038
- EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1039
- T log(const T &x) {
1040
- EIGEN_USING_STD_MATH(log);
1041
- return log(x);
1417
+ template <typename T>
1418
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T log(const T& x) {
1419
+ return internal::log_impl<T>::run(x);
1042
1420
  }
1043
1421
 
1044
- #ifdef __CUDACC__
1045
- template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1046
- float log(const float &x) { return ::logf(x); }
1422
+ #if defined(SYCL_DEVICE_ONLY)
1423
+ SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(log, log)
1424
+ #endif
1425
+
1426
+ #if defined(EIGEN_GPUCC)
1427
+ template <>
1428
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE float log(const float& x) {
1429
+ return ::logf(x);
1430
+ }
1047
1431
 
1048
- template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1049
- double log(const double &x) { return ::log(x); }
1432
+ template <>
1433
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE double log(const double& x) {
1434
+ return ::log(x);
1435
+ }
1050
1436
  #endif
1051
1437
 
1052
- template<typename T>
1053
- EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1054
- typename internal::enable_if<NumTraits<T>::IsSigned || NumTraits<T>::IsComplex,typename NumTraits<T>::Real>::type
1055
- abs(const T &x) {
1056
- EIGEN_USING_STD_MATH(abs);
1438
+ template <typename T>
1439
+ EIGEN_DEVICE_FUNC
1440
+ EIGEN_ALWAYS_INLINE std::enable_if_t<NumTraits<T>::IsSigned || NumTraits<T>::IsComplex, typename NumTraits<T>::Real>
1441
+ abs(const T& x) {
1442
+ EIGEN_USING_STD(abs);
1057
1443
  return abs(x);
1058
1444
  }
1059
1445
 
1060
- template<typename T>
1061
- EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1062
- typename internal::enable_if<!(NumTraits<T>::IsSigned || NumTraits<T>::IsComplex),typename NumTraits<T>::Real>::type
1063
- abs(const T &x) {
1446
+ template <typename T>
1447
+ EIGEN_DEVICE_FUNC
1448
+ EIGEN_ALWAYS_INLINE std::enable_if_t<!(NumTraits<T>::IsSigned || NumTraits<T>::IsComplex), typename NumTraits<T>::Real>
1449
+ abs(const T& x) {
1064
1450
  return x;
1065
1451
  }
1066
1452
 
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__)
1453
+ #if defined(SYCL_DEVICE_ONLY)
1454
+ SYCL_SPECIALIZE_INTEGER_TYPES_UNARY(abs, abs)
1455
+ SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(abs, fabs)
1456
+ #endif
1071
1457
 
1072
- #ifdef __CUDACC__
1073
- template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1074
- float abs(const float &x) { return ::fabsf(x); }
1458
+ #if defined(EIGEN_GPUCC)
1459
+ template <>
1460
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE float abs(const float& x) {
1461
+ return ::fabsf(x);
1462
+ }
1075
1463
 
1076
- template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1077
- double abs(const double &x) { return ::fabs(x); }
1464
+ template <>
1465
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE double abs(const double& x) {
1466
+ return ::fabs(x);
1467
+ }
1078
1468
 
1079
- template <> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1080
- float abs(const std::complex<float>& x) {
1469
+ template <>
1470
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE float abs(const std::complex<float>& x) {
1081
1471
  return ::hypotf(x.real(), x.imag());
1082
1472
  }
1083
1473
 
1084
- template <> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1085
- double abs(const std::complex<double>& x) {
1474
+ template <>
1475
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE double abs(const std::complex<double>& x) {
1086
1476
  return ::hypot(x.real(), x.imag());
1087
1477
  }
1088
1478
  #endif
1089
1479
 
1090
- template<typename T>
1091
- EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1092
- T exp(const T &x) {
1093
- EIGEN_USING_STD_MATH(exp);
1480
+ template <typename Scalar, bool IsInteger = NumTraits<Scalar>::IsInteger, bool IsSigned = NumTraits<Scalar>::IsSigned>
1481
+ struct signbit_impl;
1482
+ template <typename Scalar>
1483
+ struct signbit_impl<Scalar, false, true> {
1484
+ static constexpr size_t Size = sizeof(Scalar);
1485
+ static constexpr size_t Shift = (CHAR_BIT * Size) - 1;
1486
+ using intSize_t = typename get_integer_by_size<Size>::signed_type;
1487
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE static Scalar run(const Scalar& x) {
1488
+ intSize_t a = bit_cast<intSize_t, Scalar>(x);
1489
+ a = a >> Shift;
1490
+ Scalar result = bit_cast<Scalar, intSize_t>(a);
1491
+ return result;
1492
+ }
1493
+ };
1494
+ template <typename Scalar>
1495
+ struct signbit_impl<Scalar, true, true> {
1496
+ static constexpr size_t Size = sizeof(Scalar);
1497
+ static constexpr size_t Shift = (CHAR_BIT * Size) - 1;
1498
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE static constexpr Scalar run(const Scalar& x) { return x >> Shift; }
1499
+ };
1500
+ template <typename Scalar>
1501
+ struct signbit_impl<Scalar, true, false> {
1502
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE static constexpr Scalar run(const Scalar&) { return Scalar(0); }
1503
+ };
1504
+ template <typename Scalar>
1505
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE static constexpr Scalar signbit(const Scalar& x) {
1506
+ return signbit_impl<Scalar>::run(x);
1507
+ }
1508
+
1509
+ template <typename T>
1510
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T exp(const T& x) {
1511
+ EIGEN_USING_STD(exp);
1094
1512
  return exp(x);
1095
1513
  }
1096
1514
 
1097
- #ifdef __CUDACC__
1098
- template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1099
- float exp(const float &x) { return ::expf(x); }
1515
+ // MSVC screws up some edge-cases for std::exp(complex).
1516
+ #ifdef EIGEN_COMP_MSVC
1517
+ template <typename RealScalar>
1518
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE std::complex<RealScalar> exp(const std::complex<RealScalar>& x) {
1519
+ EIGEN_USING_STD(exp);
1520
+ // If z is (x,±∞) (for any finite x), the result is (NaN,NaN) and FE_INVALID is raised.
1521
+ // If z is (x,NaN) (for any finite x), the result is (NaN,NaN) and FE_INVALID may be raised.
1522
+ if ((isfinite)(real_ref(x)) && !(isfinite)(imag_ref(x))) {
1523
+ return std::complex<RealScalar>(NumTraits<RealScalar>::quiet_NaN(), NumTraits<RealScalar>::quiet_NaN());
1524
+ }
1525
+ // If z is (+∞,±∞), the result is (±∞,NaN) and FE_INVALID is raised (the sign of the real part is unspecified)
1526
+ // If z is (+∞,NaN), the result is (±∞,NaN) (the sign of the real part is unspecified)
1527
+ if ((real_ref(x) == NumTraits<RealScalar>::infinity() && !(isfinite)(imag_ref(x)))) {
1528
+ return std::complex<RealScalar>(NumTraits<RealScalar>::infinity(), NumTraits<RealScalar>::quiet_NaN());
1529
+ }
1530
+ return exp(x);
1531
+ }
1532
+ #endif
1533
+
1534
+ #if defined(SYCL_DEVICE_ONLY)
1535
+ SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(exp, exp)
1536
+ #endif
1537
+
1538
+ #if defined(EIGEN_GPUCC)
1539
+ template <>
1540
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE float exp(const float& x) {
1541
+ return ::expf(x);
1542
+ }
1543
+
1544
+ template <>
1545
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE double exp(const double& x) {
1546
+ return ::exp(x);
1547
+ }
1548
+
1549
+ template <>
1550
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE std::complex<float> exp(const std::complex<float>& x) {
1551
+ float com = ::expf(x.real());
1552
+ float res_real = com * ::cosf(x.imag());
1553
+ float res_imag = com * ::sinf(x.imag());
1554
+ return std::complex<float>(res_real, res_imag);
1555
+ }
1556
+
1557
+ template <>
1558
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE std::complex<double> exp(const std::complex<double>& x) {
1559
+ double com = ::exp(x.real());
1560
+ double res_real = com * ::cos(x.imag());
1561
+ double res_imag = com * ::sin(x.imag());
1562
+ return std::complex<double>(res_real, res_imag);
1563
+ }
1564
+ #endif
1565
+
1566
+ template <typename T>
1567
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T exp2(const T& x) {
1568
+ EIGEN_USING_STD(exp2);
1569
+ return exp2(x);
1570
+ }
1571
+
1572
+ // MSVC screws up some edge-cases for std::exp2(complex).
1573
+ #ifdef EIGEN_COMP_MSVC
1574
+ template <typename RealScalar>
1575
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE std::complex<RealScalar> exp2(const std::complex<RealScalar>& x) {
1576
+ EIGEN_USING_STD(exp);
1577
+ // If z is (x,±∞) (for any finite x), the result is (NaN,NaN) and FE_INVALID is raised.
1578
+ // If z is (x,NaN) (for any finite x), the result is (NaN,NaN) and FE_INVALID may be raised.
1579
+ if ((isfinite)(real_ref(x)) && !(isfinite)(imag_ref(x))) {
1580
+ return std::complex<RealScalar>(NumTraits<RealScalar>::quiet_NaN(), NumTraits<RealScalar>::quiet_NaN());
1581
+ }
1582
+ // If z is (+∞,±∞), the result is (±∞,NaN) and FE_INVALID is raised (the sign of the real part is unspecified)
1583
+ // If z is (+∞,NaN), the result is (±∞,NaN) (the sign of the real part is unspecified)
1584
+ if ((real_ref(x) == NumTraits<RealScalar>::infinity() && !(isfinite)(imag_ref(x)))) {
1585
+ return std::complex<RealScalar>(NumTraits<RealScalar>::infinity(), NumTraits<RealScalar>::quiet_NaN());
1586
+ }
1587
+ return exp2(x);
1588
+ }
1589
+ #endif
1590
+
1591
+ #if defined(SYCL_DEVICE_ONLY)
1592
+ SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(exp2, exp2)
1593
+ #endif
1100
1594
 
1101
- template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1102
- double exp(const double &x) { return ::exp(x); }
1595
+ #if defined(EIGEN_GPUCC)
1596
+ template <>
1597
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE float exp2(const float& x) {
1598
+ return ::exp2f(x);
1599
+ }
1600
+
1601
+ template <>
1602
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE double exp2(const double& x) {
1603
+ return ::exp2(x);
1604
+ }
1605
+
1606
+ template <>
1607
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE std::complex<float> exp2(const std::complex<float>& x) {
1608
+ float com = ::exp2f(x.real());
1609
+ float res_real = com * ::cosf(static_cast<float>(EIGEN_LN2) * x.imag());
1610
+ float res_imag = com * ::sinf(static_cast<float>(EIGEN_LN2) * x.imag());
1611
+ return std::complex<float>(res_real, res_imag);
1612
+ }
1613
+
1614
+ template <>
1615
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE std::complex<double> exp2(const std::complex<double>& x) {
1616
+ double com = ::exp2(x.real());
1617
+ double res_real = com * ::cos(static_cast<double>(EIGEN_LN2) * x.imag());
1618
+ double res_imag = com * ::sin(static_cast<double>(EIGEN_LN2) * x.imag());
1619
+ return std::complex<double>(res_real, res_imag);
1620
+ }
1103
1621
  #endif
1104
1622
 
1105
- template<typename T>
1106
- EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1107
- T cos(const T &x) {
1108
- EIGEN_USING_STD_MATH(cos);
1623
+ template <typename Scalar>
1624
+ EIGEN_DEVICE_FUNC inline EIGEN_MATHFUNC_RETVAL(expm1, Scalar) expm1(const Scalar& x) {
1625
+ return EIGEN_MATHFUNC_IMPL(expm1, Scalar)::run(x);
1626
+ }
1627
+
1628
+ #if defined(SYCL_DEVICE_ONLY)
1629
+ SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(expm1, expm1)
1630
+ #endif
1631
+
1632
+ #if defined(EIGEN_GPUCC)
1633
+ template <>
1634
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE float expm1(const float& x) {
1635
+ return ::expm1f(x);
1636
+ }
1637
+
1638
+ template <>
1639
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE double expm1(const double& x) {
1640
+ return ::expm1(x);
1641
+ }
1642
+ #endif
1643
+
1644
+ template <typename T>
1645
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T cos(const T& x) {
1646
+ EIGEN_USING_STD(cos);
1109
1647
  return cos(x);
1110
1648
  }
1111
1649
 
1112
- #ifdef __CUDACC__
1113
- template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1114
- float cos(const float &x) { return ::cosf(x); }
1650
+ #if defined(SYCL_DEVICE_ONLY)
1651
+ SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(cos, cos)
1652
+ #endif
1653
+
1654
+ #if defined(EIGEN_GPUCC)
1655
+ template <>
1656
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE float cos(const float& x) {
1657
+ return ::cosf(x);
1658
+ }
1115
1659
 
1116
- template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1117
- double cos(const double &x) { return ::cos(x); }
1660
+ template <>
1661
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE double cos(const double& x) {
1662
+ return ::cos(x);
1663
+ }
1118
1664
  #endif
1119
1665
 
1120
- template<typename T>
1121
- EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1122
- T sin(const T &x) {
1123
- EIGEN_USING_STD_MATH(sin);
1666
+ template <typename T>
1667
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T sin(const T& x) {
1668
+ EIGEN_USING_STD(sin);
1124
1669
  return sin(x);
1125
1670
  }
1126
1671
 
1127
- #ifdef __CUDACC__
1128
- template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1129
- float sin(const float &x) { return ::sinf(x); }
1672
+ #if defined(SYCL_DEVICE_ONLY)
1673
+ SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(sin, sin)
1674
+ #endif
1675
+
1676
+ #if defined(EIGEN_GPUCC)
1677
+ template <>
1678
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE float sin(const float& x) {
1679
+ return ::sinf(x);
1680
+ }
1130
1681
 
1131
- template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1132
- double sin(const double &x) { return ::sin(x); }
1682
+ template <>
1683
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE double sin(const double& x) {
1684
+ return ::sin(x);
1685
+ }
1133
1686
  #endif
1134
1687
 
1135
- template<typename T>
1136
- EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1137
- T tan(const T &x) {
1138
- EIGEN_USING_STD_MATH(tan);
1688
+ template <typename T>
1689
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T tan(const T& x) {
1690
+ EIGEN_USING_STD(tan);
1139
1691
  return tan(x);
1140
1692
  }
1141
1693
 
1142
- #ifdef __CUDACC__
1143
- template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1144
- float tan(const float &x) { return ::tanf(x); }
1694
+ #if defined(SYCL_DEVICE_ONLY)
1695
+ SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(tan, tan)
1696
+ #endif
1697
+
1698
+ #if defined(EIGEN_GPUCC)
1699
+ template <>
1700
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE float tan(const float& x) {
1701
+ return ::tanf(x);
1702
+ }
1145
1703
 
1146
- template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1147
- double tan(const double &x) { return ::tan(x); }
1704
+ template <>
1705
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE double tan(const double& x) {
1706
+ return ::tan(x);
1707
+ }
1148
1708
  #endif
1149
1709
 
1150
- template<typename T>
1151
- EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1152
- T acos(const T &x) {
1153
- EIGEN_USING_STD_MATH(acos);
1710
+ template <typename T>
1711
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T acos(const T& x) {
1712
+ EIGEN_USING_STD(acos);
1154
1713
  return acos(x);
1155
1714
  }
1156
1715
 
1157
- #ifdef __CUDACC__
1158
- template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1159
- float acos(const float &x) { return ::acosf(x); }
1716
+ template <typename T>
1717
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T acosh(const T& x) {
1718
+ EIGEN_USING_STD(acosh);
1719
+ return static_cast<T>(acosh(x));
1720
+ }
1721
+
1722
+ #if defined(SYCL_DEVICE_ONLY)
1723
+ SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(acos, acos)
1724
+ SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(acosh, acosh)
1725
+ #endif
1726
+
1727
+ #if defined(EIGEN_GPUCC)
1728
+ template <>
1729
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE float acos(const float& x) {
1730
+ return ::acosf(x);
1731
+ }
1160
1732
 
1161
- template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1162
- double acos(const double &x) { return ::acos(x); }
1733
+ template <>
1734
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE double acos(const double& x) {
1735
+ return ::acos(x);
1736
+ }
1163
1737
  #endif
1164
1738
 
1165
- template<typename T>
1166
- EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1167
- T asin(const T &x) {
1168
- EIGEN_USING_STD_MATH(asin);
1739
+ template <typename T>
1740
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T asin(const T& x) {
1741
+ EIGEN_USING_STD(asin);
1169
1742
  return asin(x);
1170
1743
  }
1171
1744
 
1172
- #ifdef __CUDACC__
1173
- template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1174
- float asin(const float &x) { return ::asinf(x); }
1745
+ template <typename T>
1746
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T asinh(const T& x) {
1747
+ EIGEN_USING_STD(asinh);
1748
+ return static_cast<T>(asinh(x));
1749
+ }
1175
1750
 
1176
- template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1177
- double asin(const double &x) { return ::asin(x); }
1751
+ #if defined(SYCL_DEVICE_ONLY)
1752
+ SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(asin, asin)
1753
+ SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(asinh, asinh)
1178
1754
  #endif
1179
1755
 
1180
- template<typename T>
1181
- EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1182
- T atan(const T &x) {
1183
- EIGEN_USING_STD_MATH(atan);
1184
- return atan(x);
1756
+ #if defined(EIGEN_GPUCC)
1757
+ template <>
1758
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE float asin(const float& x) {
1759
+ return ::asinf(x);
1185
1760
  }
1186
1761
 
1187
- #ifdef __CUDACC__
1188
- template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1189
- float atan(const float &x) { return ::atanf(x); }
1762
+ template <>
1763
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE double asin(const double& x) {
1764
+ return ::asin(x);
1765
+ }
1766
+ #endif
1190
1767
 
1191
- template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1192
- double atan(const double &x) { return ::atan(x); }
1768
+ template <typename T>
1769
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T atan(const T& x) {
1770
+ EIGEN_USING_STD(atan);
1771
+ return static_cast<T>(atan(x));
1772
+ }
1773
+
1774
+ template <typename T, std::enable_if_t<!NumTraits<T>::IsComplex, int> = 0>
1775
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T atan2(const T& y, const T& x) {
1776
+ EIGEN_USING_STD(atan2);
1777
+ return static_cast<T>(atan2(y, x));
1778
+ }
1779
+
1780
+ template <typename T>
1781
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T atanh(const T& x) {
1782
+ EIGEN_USING_STD(atanh);
1783
+ return static_cast<T>(atanh(x));
1784
+ }
1785
+
1786
+ #if defined(SYCL_DEVICE_ONLY)
1787
+ SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(atan, atan)
1788
+ SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(atanh, atanh)
1193
1789
  #endif
1194
1790
 
1791
+ #if defined(EIGEN_GPUCC)
1792
+ template <>
1793
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE float atan(const float& x) {
1794
+ return ::atanf(x);
1795
+ }
1195
1796
 
1196
- template<typename T>
1197
- EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1198
- T cosh(const T &x) {
1199
- EIGEN_USING_STD_MATH(cosh);
1200
- return cosh(x);
1797
+ template <>
1798
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE double atan(const double& x) {
1799
+ return ::atan(x);
1201
1800
  }
1801
+ #endif
1202
1802
 
1203
- #ifdef __CUDACC__
1204
- template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1205
- float cosh(const float &x) { return ::coshf(x); }
1803
+ template <typename T>
1804
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T cosh(const T& x) {
1805
+ EIGEN_USING_STD(cosh);
1806
+ return static_cast<T>(cosh(x));
1807
+ }
1808
+
1809
+ #if defined(SYCL_DEVICE_ONLY)
1810
+ SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(cosh, cosh)
1811
+ #endif
1812
+
1813
+ #if defined(EIGEN_GPUCC)
1814
+ template <>
1815
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE float cosh(const float& x) {
1816
+ return ::coshf(x);
1817
+ }
1206
1818
 
1207
- template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1208
- double cosh(const double &x) { return ::cosh(x); }
1819
+ template <>
1820
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE double cosh(const double& x) {
1821
+ return ::cosh(x);
1822
+ }
1209
1823
  #endif
1210
1824
 
1211
- template<typename T>
1212
- EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1213
- T sinh(const T &x) {
1214
- EIGEN_USING_STD_MATH(sinh);
1215
- return sinh(x);
1825
+ template <typename T>
1826
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T sinh(const T& x) {
1827
+ EIGEN_USING_STD(sinh);
1828
+ return static_cast<T>(sinh(x));
1216
1829
  }
1217
1830
 
1218
- #ifdef __CUDACC__
1219
- template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1220
- float sinh(const float &x) { return ::sinhf(x); }
1831
+ #if defined(SYCL_DEVICE_ONLY)
1832
+ SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(sinh, sinh)
1833
+ #endif
1834
+
1835
+ #if defined(EIGEN_GPUCC)
1836
+ template <>
1837
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE float sinh(const float& x) {
1838
+ return ::sinhf(x);
1839
+ }
1221
1840
 
1222
- template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1223
- double sinh(const double &x) { return ::sinh(x); }
1841
+ template <>
1842
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE double sinh(const double& x) {
1843
+ return ::sinh(x);
1844
+ }
1224
1845
  #endif
1225
1846
 
1226
- template<typename T>
1227
- EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1228
- T tanh(const T &x) {
1229
- EIGEN_USING_STD_MATH(tanh);
1847
+ template <typename T>
1848
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T tanh(const T& x) {
1849
+ EIGEN_USING_STD(tanh);
1230
1850
  return tanh(x);
1231
1851
  }
1232
1852
 
1233
- #if (!defined(__CUDACC__)) && EIGEN_FAST_MATH
1234
- EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1235
- float tanh(float x) { return internal::generic_fast_tanh_float(x); }
1853
+ #if (!defined(EIGEN_GPUCC)) && EIGEN_FAST_MATH && !defined(SYCL_DEVICE_ONLY)
1854
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE float tanh(float x) { return internal::ptanh_float(x); }
1855
+ #endif
1856
+
1857
+ #if defined(SYCL_DEVICE_ONLY)
1858
+ SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(tanh, tanh)
1236
1859
  #endif
1237
1860
 
1238
- #ifdef __CUDACC__
1239
- template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1240
- float tanh(const float &x) { return ::tanhf(x); }
1861
+ #if defined(EIGEN_GPUCC)
1862
+ template <>
1863
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE float tanh(const float& x) {
1864
+ return ::tanhf(x);
1865
+ }
1241
1866
 
1242
- template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1243
- double tanh(const double &x) { return ::tanh(x); }
1867
+ template <>
1868
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE double tanh(const double& x) {
1869
+ return ::tanh(x);
1870
+ }
1244
1871
  #endif
1245
1872
 
1246
1873
  template <typename T>
1247
- EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1248
- T fmod(const T& a, const T& b) {
1249
- EIGEN_USING_STD_MATH(fmod);
1874
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T fmod(const T& a, const T& b) {
1875
+ EIGEN_USING_STD(fmod);
1250
1876
  return fmod(a, b);
1251
1877
  }
1252
1878
 
1253
- #ifdef __CUDACC__
1879
+ #if defined(SYCL_DEVICE_ONLY)
1880
+ SYCL_SPECIALIZE_FLOATING_TYPES_BINARY(fmod, fmod)
1881
+ #endif
1882
+
1883
+ #if defined(EIGEN_GPUCC)
1254
1884
  template <>
1255
- EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1256
- float fmod(const float& a, const float& b) {
1885
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE float fmod(const float& a, const float& b) {
1257
1886
  return ::fmodf(a, b);
1258
1887
  }
1259
1888
 
1260
1889
  template <>
1261
- EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1262
- double fmod(const double& a, const double& b) {
1890
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE double fmod(const double& a, const double& b) {
1263
1891
  return ::fmod(a, b);
1264
1892
  }
1265
1893
  #endif
1266
1894
 
1267
- } // end namespace numext
1895
+ #if defined(SYCL_DEVICE_ONLY)
1896
+ #undef SYCL_SPECIALIZE_SIGNED_INTEGER_TYPES_BINARY
1897
+ #undef SYCL_SPECIALIZE_SIGNED_INTEGER_TYPES_UNARY
1898
+ #undef SYCL_SPECIALIZE_UNSIGNED_INTEGER_TYPES_BINARY
1899
+ #undef SYCL_SPECIALIZE_UNSIGNED_INTEGER_TYPES_UNARY
1900
+ #undef SYCL_SPECIALIZE_INTEGER_TYPES_BINARY
1901
+ #undef SYCL_SPECIALIZE_UNSIGNED_INTEGER_TYPES_UNARY
1902
+ #undef SYCL_SPECIALIZE_FLOATING_TYPES_BINARY
1903
+ #undef SYCL_SPECIALIZE_FLOATING_TYPES_UNARY
1904
+ #undef SYCL_SPECIALIZE_FLOATING_TYPES_UNARY_FUNC_RET_TYPE
1905
+ #undef SYCL_SPECIALIZE_GEN_UNARY_FUNC
1906
+ #undef SYCL_SPECIALIZE_UNARY_FUNC
1907
+ #undef SYCL_SPECIALIZE_GEN1_BINARY_FUNC
1908
+ #undef SYCL_SPECIALIZE_GEN2_BINARY_FUNC
1909
+ #undef SYCL_SPECIALIZE_BINARY_FUNC
1910
+ #endif
1911
+
1912
+ template <typename Scalar, typename Enable = std::enable_if_t<std::is_integral<Scalar>::value>>
1913
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar logical_shift_left(const Scalar& a, int n) {
1914
+ return a << n;
1915
+ }
1916
+
1917
+ template <typename Scalar, typename Enable = std::enable_if_t<std::is_integral<Scalar>::value>>
1918
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar logical_shift_right(const Scalar& a, int n) {
1919
+ using UnsignedScalar = typename numext::get_integer_by_size<sizeof(Scalar)>::unsigned_type;
1920
+ return bit_cast<Scalar, UnsignedScalar>(bit_cast<UnsignedScalar, Scalar>(a) >> n);
1921
+ }
1922
+
1923
+ template <typename Scalar, typename Enable = std::enable_if_t<std::is_integral<Scalar>::value>>
1924
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar arithmetic_shift_right(const Scalar& a, int n) {
1925
+ using SignedScalar = typename numext::get_integer_by_size<sizeof(Scalar)>::signed_type;
1926
+ return bit_cast<Scalar, SignedScalar>(bit_cast<SignedScalar, Scalar>(a) >> n);
1927
+ }
1928
+
1929
+ template <typename Scalar>
1930
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar fma(const Scalar& x, const Scalar& y, const Scalar& z) {
1931
+ return internal::fma_impl<Scalar>::run(x, y, z);
1932
+ }
1933
+
1934
+ // Multiply-add.
1935
+ template <typename Scalar>
1936
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar madd(const Scalar& x, const Scalar& y, const Scalar& z) {
1937
+ return internal::madd_impl<Scalar>::run(x, y, z);
1938
+ }
1939
+
1940
+ } // end namespace numext
1268
1941
 
1269
1942
  namespace internal {
1270
1943
 
1271
- template<typename T>
1272
- EIGEN_DEVICE_FUNC bool isfinite_impl(const std::complex<T>& x)
1273
- {
1944
+ template <typename T>
1945
+ EIGEN_DEVICE_FUNC bool isfinite_impl(const std::complex<T>& x) {
1274
1946
  return (numext::isfinite)(numext::real(x)) && (numext::isfinite)(numext::imag(x));
1275
1947
  }
1276
1948
 
1277
- template<typename T>
1278
- EIGEN_DEVICE_FUNC bool isnan_impl(const std::complex<T>& x)
1279
- {
1949
+ template <typename T>
1950
+ EIGEN_DEVICE_FUNC bool isnan_impl(const std::complex<T>& x) {
1280
1951
  return (numext::isnan)(numext::real(x)) || (numext::isnan)(numext::imag(x));
1281
1952
  }
1282
1953
 
1283
- template<typename T>
1284
- EIGEN_DEVICE_FUNC bool isinf_impl(const std::complex<T>& x)
1285
- {
1954
+ template <typename T>
1955
+ EIGEN_DEVICE_FUNC bool isinf_impl(const std::complex<T>& x) {
1286
1956
  return ((numext::isinf)(numext::real(x)) || (numext::isinf)(numext::imag(x))) && (!(numext::isnan)(x));
1287
1957
  }
1288
1958
 
1289
1959
  /****************************************************************************
1290
- * Implementation of fuzzy comparisons *
1291
- ****************************************************************************/
1960
+ * Implementation of fuzzy comparisons *
1961
+ ****************************************************************************/
1292
1962
 
1293
- template<typename Scalar,
1294
- bool IsComplex,
1295
- bool IsInteger>
1963
+ template <typename Scalar, bool IsComplex, bool IsInteger>
1296
1964
  struct scalar_fuzzy_default_impl {};
1297
1965
 
1298
- template<typename Scalar>
1299
- struct scalar_fuzzy_default_impl<Scalar, false, false>
1300
- {
1966
+ template <typename Scalar>
1967
+ struct scalar_fuzzy_default_impl<Scalar, false, false> {
1301
1968
  typedef typename NumTraits<Scalar>::Real RealScalar;
1302
- template<typename OtherScalar> EIGEN_DEVICE_FUNC
1303
- static inline bool isMuchSmallerThan(const Scalar& x, const OtherScalar& y, const RealScalar& prec)
1304
- {
1969
+ template <typename OtherScalar>
1970
+ EIGEN_DEVICE_FUNC static inline bool isMuchSmallerThan(const Scalar& x, const OtherScalar& y,
1971
+ const RealScalar& prec) {
1305
1972
  return numext::abs(x) <= numext::abs(y) * prec;
1306
1973
  }
1307
- EIGEN_DEVICE_FUNC
1308
- static inline bool isApprox(const Scalar& x, const Scalar& y, const RealScalar& prec)
1309
- {
1974
+ EIGEN_DEVICE_FUNC static inline bool isApprox(const Scalar& x, const Scalar& y, const RealScalar& prec) {
1310
1975
  return numext::abs(x - y) <= numext::mini(numext::abs(x), numext::abs(y)) * prec;
1311
1976
  }
1312
- EIGEN_DEVICE_FUNC
1313
- static inline bool isApproxOrLessThan(const Scalar& x, const Scalar& y, const RealScalar& prec)
1314
- {
1977
+ EIGEN_DEVICE_FUNC static inline bool isApproxOrLessThan(const Scalar& x, const Scalar& y, const RealScalar& prec) {
1315
1978
  return x <= y || isApprox(x, y, prec);
1316
1979
  }
1317
1980
  };
1318
1981
 
1319
- template<typename Scalar>
1320
- struct scalar_fuzzy_default_impl<Scalar, false, true>
1321
- {
1982
+ template <typename Scalar>
1983
+ struct scalar_fuzzy_default_impl<Scalar, false, true> {
1322
1984
  typedef typename NumTraits<Scalar>::Real RealScalar;
1323
- template<typename OtherScalar> EIGEN_DEVICE_FUNC
1324
- static inline bool isMuchSmallerThan(const Scalar& x, const Scalar&, const RealScalar&)
1325
- {
1985
+ template <typename OtherScalar>
1986
+ EIGEN_DEVICE_FUNC static inline bool isMuchSmallerThan(const Scalar& x, const Scalar&, const RealScalar&) {
1326
1987
  return x == Scalar(0);
1327
1988
  }
1328
- EIGEN_DEVICE_FUNC
1329
- static inline bool isApprox(const Scalar& x, const Scalar& y, const RealScalar&)
1330
- {
1331
- return x == y;
1332
- }
1333
- EIGEN_DEVICE_FUNC
1334
- static inline bool isApproxOrLessThan(const Scalar& x, const Scalar& y, const RealScalar&)
1335
- {
1989
+ EIGEN_DEVICE_FUNC static inline bool isApprox(const Scalar& x, const Scalar& y, const RealScalar&) { return x == y; }
1990
+ EIGEN_DEVICE_FUNC static inline bool isApproxOrLessThan(const Scalar& x, const Scalar& y, const RealScalar&) {
1336
1991
  return x <= y;
1337
1992
  }
1338
1993
  };
1339
1994
 
1340
- template<typename Scalar>
1341
- struct scalar_fuzzy_default_impl<Scalar, true, false>
1342
- {
1995
+ template <typename Scalar>
1996
+ struct scalar_fuzzy_default_impl<Scalar, true, false> {
1343
1997
  typedef typename NumTraits<Scalar>::Real RealScalar;
1344
- template<typename OtherScalar> EIGEN_DEVICE_FUNC
1345
- static inline bool isMuchSmallerThan(const Scalar& x, const OtherScalar& y, const RealScalar& prec)
1346
- {
1998
+ template <typename OtherScalar>
1999
+ EIGEN_DEVICE_FUNC static inline bool isMuchSmallerThan(const Scalar& x, const OtherScalar& y,
2000
+ const RealScalar& prec) {
1347
2001
  return numext::abs2(x) <= numext::abs2(y) * prec * prec;
1348
2002
  }
1349
- EIGEN_DEVICE_FUNC
1350
- static inline bool isApprox(const Scalar& x, const Scalar& y, const RealScalar& prec)
1351
- {
2003
+ EIGEN_DEVICE_FUNC static inline bool isApprox(const Scalar& x, const Scalar& y, const RealScalar& prec) {
1352
2004
  return numext::abs2(x - y) <= numext::mini(numext::abs2(x), numext::abs2(y)) * prec * prec;
1353
2005
  }
1354
2006
  };
1355
2007
 
1356
- template<typename Scalar>
1357
- struct scalar_fuzzy_impl : scalar_fuzzy_default_impl<Scalar, NumTraits<Scalar>::IsComplex, NumTraits<Scalar>::IsInteger> {};
2008
+ template <typename Scalar>
2009
+ struct scalar_fuzzy_impl
2010
+ : scalar_fuzzy_default_impl<Scalar, NumTraits<Scalar>::IsComplex, NumTraits<Scalar>::IsInteger> {};
1358
2011
 
1359
- template<typename Scalar, typename OtherScalar> EIGEN_DEVICE_FUNC
1360
- inline bool isMuchSmallerThan(const Scalar& x, const OtherScalar& y,
1361
- const typename NumTraits<Scalar>::Real &precision = NumTraits<Scalar>::dummy_precision())
1362
- {
2012
+ template <typename Scalar, typename OtherScalar>
2013
+ EIGEN_DEVICE_FUNC inline bool isMuchSmallerThan(
2014
+ const Scalar& x, const OtherScalar& y,
2015
+ const typename NumTraits<Scalar>::Real& precision = NumTraits<Scalar>::dummy_precision()) {
1363
2016
  return scalar_fuzzy_impl<Scalar>::template isMuchSmallerThan<OtherScalar>(x, y, precision);
1364
2017
  }
1365
2018
 
1366
- template<typename Scalar> EIGEN_DEVICE_FUNC
1367
- inline bool isApprox(const Scalar& x, const Scalar& y,
1368
- const typename NumTraits<Scalar>::Real &precision = NumTraits<Scalar>::dummy_precision())
1369
- {
2019
+ template <typename Scalar>
2020
+ EIGEN_DEVICE_FUNC inline bool isApprox(
2021
+ const Scalar& x, const Scalar& y,
2022
+ const typename NumTraits<Scalar>::Real& precision = NumTraits<Scalar>::dummy_precision()) {
1370
2023
  return scalar_fuzzy_impl<Scalar>::isApprox(x, y, precision);
1371
2024
  }
1372
2025
 
1373
- template<typename Scalar> EIGEN_DEVICE_FUNC
1374
- inline bool isApproxOrLessThan(const Scalar& x, const Scalar& y,
1375
- const typename NumTraits<Scalar>::Real &precision = NumTraits<Scalar>::dummy_precision())
1376
- {
2026
+ template <typename Scalar>
2027
+ EIGEN_DEVICE_FUNC inline bool isApproxOrLessThan(
2028
+ const Scalar& x, const Scalar& y,
2029
+ const typename NumTraits<Scalar>::Real& precision = NumTraits<Scalar>::dummy_precision()) {
1377
2030
  return scalar_fuzzy_impl<Scalar>::isApproxOrLessThan(x, y, precision);
1378
2031
  }
1379
2032
 
@@ -1381,41 +2034,70 @@ inline bool isApproxOrLessThan(const Scalar& x, const Scalar& y,
1381
2034
  *** The special case of the bool type ***
1382
2035
  ******************************************/
1383
2036
 
1384
- template<> struct random_impl<bool>
1385
- {
1386
- static inline bool run()
1387
- {
1388
- return random<int>(0,1)==0 ? false : true;
1389
- }
1390
- };
1391
-
1392
- template<> struct scalar_fuzzy_impl<bool>
1393
- {
2037
+ template <>
2038
+ struct scalar_fuzzy_impl<bool> {
1394
2039
  typedef bool RealScalar;
1395
-
1396
- template<typename OtherScalar> EIGEN_DEVICE_FUNC
1397
- static inline bool isMuchSmallerThan(const bool& x, const bool&, const bool&)
1398
- {
2040
+
2041
+ template <typename OtherScalar>
2042
+ EIGEN_DEVICE_FUNC static inline bool isMuchSmallerThan(const bool& x, const bool&, const bool&) {
1399
2043
  return !x;
1400
2044
  }
1401
-
1402
- EIGEN_DEVICE_FUNC
1403
- static inline bool isApprox(bool x, bool y, bool)
1404
- {
1405
- return x == y;
1406
- }
1407
2045
 
1408
- EIGEN_DEVICE_FUNC
1409
- static inline bool isApproxOrLessThan(const bool& x, const bool& y, const bool&)
1410
- {
2046
+ EIGEN_DEVICE_FUNC static inline bool isApprox(bool x, bool y, bool) { return x == y; }
2047
+
2048
+ EIGEN_DEVICE_FUNC static inline bool isApproxOrLessThan(const bool& x, const bool& y, const bool&) {
1411
2049
  return (!x) || y;
1412
2050
  }
1413
-
1414
2051
  };
1415
2052
 
1416
-
1417
- } // end namespace internal
2053
+ } // end namespace internal
2054
+
2055
+ // Default implementations that rely on other numext implementations
2056
+ namespace internal {
2057
+
2058
+ // Specialization for complex types that are not supported by std::expm1.
2059
+ template <typename RealScalar>
2060
+ struct expm1_impl<std::complex<RealScalar>> {
2061
+ EIGEN_STATIC_ASSERT_NON_INTEGER(RealScalar)
2062
+
2063
+ EIGEN_DEVICE_FUNC static inline std::complex<RealScalar> run(const std::complex<RealScalar>& x) {
2064
+ RealScalar xr = x.real();
2065
+ RealScalar xi = x.imag();
2066
+ // expm1(z) = exp(z) - 1
2067
+ // = exp(x + i * y) - 1
2068
+ // = exp(x) * (cos(y) + i * sin(y)) - 1
2069
+ // = exp(x) * cos(y) - 1 + i * exp(x) * sin(y)
2070
+ // Imag(expm1(z)) = exp(x) * sin(y)
2071
+ // Real(expm1(z)) = exp(x) * cos(y) - 1
2072
+ // = exp(x) * cos(y) - 1.
2073
+ // = expm1(x) + exp(x) * (cos(y) - 1)
2074
+ // = expm1(x) + exp(x) * (2 * sin(y / 2) ** 2)
2075
+ RealScalar erm1 = numext::expm1<RealScalar>(xr);
2076
+ RealScalar er = erm1 + RealScalar(1.);
2077
+ RealScalar sin2 = numext::sin(xi / RealScalar(2.));
2078
+ sin2 = sin2 * sin2;
2079
+ RealScalar s = numext::sin(xi);
2080
+ RealScalar real_part = erm1 - RealScalar(2.) * er * sin2;
2081
+ return std::complex<RealScalar>(real_part, er * s);
2082
+ }
2083
+ };
2084
+
2085
+ template <typename T>
2086
+ struct rsqrt_impl {
2087
+ EIGEN_DEVICE_FUNC static EIGEN_ALWAYS_INLINE T run(const T& x) { return T(1) / numext::sqrt(x); }
2088
+ };
2089
+
2090
+ #if defined(EIGEN_GPU_COMPILE_PHASE)
2091
+ template <typename T>
2092
+ struct conj_impl<std::complex<T>, true> {
2093
+ EIGEN_DEVICE_FUNC static inline std::complex<T> run(const std::complex<T>& x) {
2094
+ return std::complex<T>(numext::real(x), -numext::imag(x));
2095
+ }
2096
+ };
2097
+ #endif
2098
+
2099
+ } // end namespace internal
1418
2100
 
1419
- } // end namespace Eigen
2101
+ } // end namespace Eigen
1420
2102
 
1421
- #endif // EIGEN_MATHFUNCTIONS_H
2103
+ #endif // EIGEN_MATHFUNCTIONS_H