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