tomoto 0.2.2 → 0.3.0

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