tomoto 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (420) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +3 -0
  3. data/LICENSE.txt +22 -0
  4. data/README.md +123 -0
  5. data/ext/tomoto/ext.cpp +245 -0
  6. data/ext/tomoto/extconf.rb +28 -0
  7. data/lib/tomoto.rb +12 -0
  8. data/lib/tomoto/ct.rb +11 -0
  9. data/lib/tomoto/hdp.rb +11 -0
  10. data/lib/tomoto/lda.rb +67 -0
  11. data/lib/tomoto/version.rb +3 -0
  12. data/vendor/EigenRand/EigenRand/Core.h +1139 -0
  13. data/vendor/EigenRand/EigenRand/Dists/Basic.h +111 -0
  14. data/vendor/EigenRand/EigenRand/Dists/Discrete.h +877 -0
  15. data/vendor/EigenRand/EigenRand/Dists/GammaPoisson.h +108 -0
  16. data/vendor/EigenRand/EigenRand/Dists/NormalExp.h +626 -0
  17. data/vendor/EigenRand/EigenRand/EigenRand +19 -0
  18. data/vendor/EigenRand/EigenRand/Macro.h +24 -0
  19. data/vendor/EigenRand/EigenRand/MorePacketMath.h +978 -0
  20. data/vendor/EigenRand/EigenRand/PacketFilter.h +286 -0
  21. data/vendor/EigenRand/EigenRand/PacketRandomEngine.h +624 -0
  22. data/vendor/EigenRand/EigenRand/RandUtils.h +413 -0
  23. data/vendor/EigenRand/EigenRand/doc.h +220 -0
  24. data/vendor/EigenRand/LICENSE +21 -0
  25. data/vendor/EigenRand/README.md +288 -0
  26. data/vendor/eigen/COPYING.BSD +26 -0
  27. data/vendor/eigen/COPYING.GPL +674 -0
  28. data/vendor/eigen/COPYING.LGPL +502 -0
  29. data/vendor/eigen/COPYING.MINPACK +52 -0
  30. data/vendor/eigen/COPYING.MPL2 +373 -0
  31. data/vendor/eigen/COPYING.README +18 -0
  32. data/vendor/eigen/Eigen/CMakeLists.txt +19 -0
  33. data/vendor/eigen/Eigen/Cholesky +46 -0
  34. data/vendor/eigen/Eigen/CholmodSupport +48 -0
  35. data/vendor/eigen/Eigen/Core +537 -0
  36. data/vendor/eigen/Eigen/Dense +7 -0
  37. data/vendor/eigen/Eigen/Eigen +2 -0
  38. data/vendor/eigen/Eigen/Eigenvalues +61 -0
  39. data/vendor/eigen/Eigen/Geometry +62 -0
  40. data/vendor/eigen/Eigen/Householder +30 -0
  41. data/vendor/eigen/Eigen/IterativeLinearSolvers +48 -0
  42. data/vendor/eigen/Eigen/Jacobi +33 -0
  43. data/vendor/eigen/Eigen/LU +50 -0
  44. data/vendor/eigen/Eigen/MetisSupport +35 -0
  45. data/vendor/eigen/Eigen/OrderingMethods +73 -0
  46. data/vendor/eigen/Eigen/PaStiXSupport +48 -0
  47. data/vendor/eigen/Eigen/PardisoSupport +35 -0
  48. data/vendor/eigen/Eigen/QR +51 -0
  49. data/vendor/eigen/Eigen/QtAlignedMalloc +40 -0
  50. data/vendor/eigen/Eigen/SPQRSupport +34 -0
  51. data/vendor/eigen/Eigen/SVD +51 -0
  52. data/vendor/eigen/Eigen/Sparse +36 -0
  53. data/vendor/eigen/Eigen/SparseCholesky +45 -0
  54. data/vendor/eigen/Eigen/SparseCore +69 -0
  55. data/vendor/eigen/Eigen/SparseLU +46 -0
  56. data/vendor/eigen/Eigen/SparseQR +37 -0
  57. data/vendor/eigen/Eigen/StdDeque +27 -0
  58. data/vendor/eigen/Eigen/StdList +26 -0
  59. data/vendor/eigen/Eigen/StdVector +27 -0
  60. data/vendor/eigen/Eigen/SuperLUSupport +64 -0
  61. data/vendor/eigen/Eigen/UmfPackSupport +40 -0
  62. data/vendor/eigen/Eigen/src/Cholesky/LDLT.h +673 -0
  63. data/vendor/eigen/Eigen/src/Cholesky/LLT.h +542 -0
  64. data/vendor/eigen/Eigen/src/Cholesky/LLT_LAPACKE.h +99 -0
  65. data/vendor/eigen/Eigen/src/CholmodSupport/CholmodSupport.h +639 -0
  66. data/vendor/eigen/Eigen/src/Core/Array.h +329 -0
  67. data/vendor/eigen/Eigen/src/Core/ArrayBase.h +226 -0
  68. data/vendor/eigen/Eigen/src/Core/ArrayWrapper.h +209 -0
  69. data/vendor/eigen/Eigen/src/Core/Assign.h +90 -0
  70. data/vendor/eigen/Eigen/src/Core/AssignEvaluator.h +935 -0
  71. data/vendor/eigen/Eigen/src/Core/Assign_MKL.h +178 -0
  72. data/vendor/eigen/Eigen/src/Core/BandMatrix.h +353 -0
  73. data/vendor/eigen/Eigen/src/Core/Block.h +452 -0
  74. data/vendor/eigen/Eigen/src/Core/BooleanRedux.h +164 -0
  75. data/vendor/eigen/Eigen/src/Core/CommaInitializer.h +160 -0
  76. data/vendor/eigen/Eigen/src/Core/ConditionEstimator.h +175 -0
  77. data/vendor/eigen/Eigen/src/Core/CoreEvaluators.h +1688 -0
  78. data/vendor/eigen/Eigen/src/Core/CoreIterators.h +127 -0
  79. data/vendor/eigen/Eigen/src/Core/CwiseBinaryOp.h +184 -0
  80. data/vendor/eigen/Eigen/src/Core/CwiseNullaryOp.h +866 -0
  81. data/vendor/eigen/Eigen/src/Core/CwiseTernaryOp.h +197 -0
  82. data/vendor/eigen/Eigen/src/Core/CwiseUnaryOp.h +103 -0
  83. data/vendor/eigen/Eigen/src/Core/CwiseUnaryView.h +128 -0
  84. data/vendor/eigen/Eigen/src/Core/DenseBase.h +611 -0
  85. data/vendor/eigen/Eigen/src/Core/DenseCoeffsBase.h +681 -0
  86. data/vendor/eigen/Eigen/src/Core/DenseStorage.h +570 -0
  87. data/vendor/eigen/Eigen/src/Core/Diagonal.h +260 -0
  88. data/vendor/eigen/Eigen/src/Core/DiagonalMatrix.h +343 -0
  89. data/vendor/eigen/Eigen/src/Core/DiagonalProduct.h +28 -0
  90. data/vendor/eigen/Eigen/src/Core/Dot.h +318 -0
  91. data/vendor/eigen/Eigen/src/Core/EigenBase.h +159 -0
  92. data/vendor/eigen/Eigen/src/Core/ForceAlignedAccess.h +146 -0
  93. data/vendor/eigen/Eigen/src/Core/Fuzzy.h +155 -0
  94. data/vendor/eigen/Eigen/src/Core/GeneralProduct.h +455 -0
  95. data/vendor/eigen/Eigen/src/Core/GenericPacketMath.h +593 -0
  96. data/vendor/eigen/Eigen/src/Core/GlobalFunctions.h +187 -0
  97. data/vendor/eigen/Eigen/src/Core/IO.h +225 -0
  98. data/vendor/eigen/Eigen/src/Core/Inverse.h +118 -0
  99. data/vendor/eigen/Eigen/src/Core/Map.h +171 -0
  100. data/vendor/eigen/Eigen/src/Core/MapBase.h +303 -0
  101. data/vendor/eigen/Eigen/src/Core/MathFunctions.h +1415 -0
  102. data/vendor/eigen/Eigen/src/Core/MathFunctionsImpl.h +101 -0
  103. data/vendor/eigen/Eigen/src/Core/Matrix.h +459 -0
  104. data/vendor/eigen/Eigen/src/Core/MatrixBase.h +529 -0
  105. data/vendor/eigen/Eigen/src/Core/NestByValue.h +110 -0
  106. data/vendor/eigen/Eigen/src/Core/NoAlias.h +108 -0
  107. data/vendor/eigen/Eigen/src/Core/NumTraits.h +248 -0
  108. data/vendor/eigen/Eigen/src/Core/PermutationMatrix.h +633 -0
  109. data/vendor/eigen/Eigen/src/Core/PlainObjectBase.h +1035 -0
  110. data/vendor/eigen/Eigen/src/Core/Product.h +186 -0
  111. data/vendor/eigen/Eigen/src/Core/ProductEvaluators.h +1112 -0
  112. data/vendor/eigen/Eigen/src/Core/Random.h +182 -0
  113. data/vendor/eigen/Eigen/src/Core/Redux.h +505 -0
  114. data/vendor/eigen/Eigen/src/Core/Ref.h +283 -0
  115. data/vendor/eigen/Eigen/src/Core/Replicate.h +142 -0
  116. data/vendor/eigen/Eigen/src/Core/ReturnByValue.h +117 -0
  117. data/vendor/eigen/Eigen/src/Core/Reverse.h +211 -0
  118. data/vendor/eigen/Eigen/src/Core/Select.h +162 -0
  119. data/vendor/eigen/Eigen/src/Core/SelfAdjointView.h +352 -0
  120. data/vendor/eigen/Eigen/src/Core/SelfCwiseBinaryOp.h +47 -0
  121. data/vendor/eigen/Eigen/src/Core/Solve.h +188 -0
  122. data/vendor/eigen/Eigen/src/Core/SolveTriangular.h +235 -0
  123. data/vendor/eigen/Eigen/src/Core/SolverBase.h +130 -0
  124. data/vendor/eigen/Eigen/src/Core/StableNorm.h +221 -0
  125. data/vendor/eigen/Eigen/src/Core/Stride.h +111 -0
  126. data/vendor/eigen/Eigen/src/Core/Swap.h +67 -0
  127. data/vendor/eigen/Eigen/src/Core/Transpose.h +403 -0
  128. data/vendor/eigen/Eigen/src/Core/Transpositions.h +407 -0
  129. data/vendor/eigen/Eigen/src/Core/TriangularMatrix.h +983 -0
  130. data/vendor/eigen/Eigen/src/Core/VectorBlock.h +96 -0
  131. data/vendor/eigen/Eigen/src/Core/VectorwiseOp.h +695 -0
  132. data/vendor/eigen/Eigen/src/Core/Visitor.h +273 -0
  133. data/vendor/eigen/Eigen/src/Core/arch/AVX/Complex.h +451 -0
  134. data/vendor/eigen/Eigen/src/Core/arch/AVX/MathFunctions.h +439 -0
  135. data/vendor/eigen/Eigen/src/Core/arch/AVX/PacketMath.h +637 -0
  136. data/vendor/eigen/Eigen/src/Core/arch/AVX/TypeCasting.h +51 -0
  137. data/vendor/eigen/Eigen/src/Core/arch/AVX512/MathFunctions.h +391 -0
  138. data/vendor/eigen/Eigen/src/Core/arch/AVX512/PacketMath.h +1316 -0
  139. data/vendor/eigen/Eigen/src/Core/arch/AltiVec/Complex.h +430 -0
  140. data/vendor/eigen/Eigen/src/Core/arch/AltiVec/MathFunctions.h +322 -0
  141. data/vendor/eigen/Eigen/src/Core/arch/AltiVec/PacketMath.h +1061 -0
  142. data/vendor/eigen/Eigen/src/Core/arch/CUDA/Complex.h +103 -0
  143. data/vendor/eigen/Eigen/src/Core/arch/CUDA/Half.h +674 -0
  144. data/vendor/eigen/Eigen/src/Core/arch/CUDA/MathFunctions.h +91 -0
  145. data/vendor/eigen/Eigen/src/Core/arch/CUDA/PacketMath.h +333 -0
  146. data/vendor/eigen/Eigen/src/Core/arch/CUDA/PacketMathHalf.h +1124 -0
  147. data/vendor/eigen/Eigen/src/Core/arch/CUDA/TypeCasting.h +212 -0
  148. data/vendor/eigen/Eigen/src/Core/arch/Default/ConjHelper.h +29 -0
  149. data/vendor/eigen/Eigen/src/Core/arch/Default/Settings.h +49 -0
  150. data/vendor/eigen/Eigen/src/Core/arch/NEON/Complex.h +490 -0
  151. data/vendor/eigen/Eigen/src/Core/arch/NEON/MathFunctions.h +91 -0
  152. data/vendor/eigen/Eigen/src/Core/arch/NEON/PacketMath.h +760 -0
  153. data/vendor/eigen/Eigen/src/Core/arch/SSE/Complex.h +471 -0
  154. data/vendor/eigen/Eigen/src/Core/arch/SSE/MathFunctions.h +562 -0
  155. data/vendor/eigen/Eigen/src/Core/arch/SSE/PacketMath.h +895 -0
  156. data/vendor/eigen/Eigen/src/Core/arch/SSE/TypeCasting.h +77 -0
  157. data/vendor/eigen/Eigen/src/Core/arch/ZVector/Complex.h +397 -0
  158. data/vendor/eigen/Eigen/src/Core/arch/ZVector/MathFunctions.h +137 -0
  159. data/vendor/eigen/Eigen/src/Core/arch/ZVector/PacketMath.h +945 -0
  160. data/vendor/eigen/Eigen/src/Core/functors/AssignmentFunctors.h +168 -0
  161. data/vendor/eigen/Eigen/src/Core/functors/BinaryFunctors.h +475 -0
  162. data/vendor/eigen/Eigen/src/Core/functors/NullaryFunctors.h +188 -0
  163. data/vendor/eigen/Eigen/src/Core/functors/StlFunctors.h +136 -0
  164. data/vendor/eigen/Eigen/src/Core/functors/TernaryFunctors.h +25 -0
  165. data/vendor/eigen/Eigen/src/Core/functors/UnaryFunctors.h +792 -0
  166. data/vendor/eigen/Eigen/src/Core/products/GeneralBlockPanelKernel.h +2156 -0
  167. data/vendor/eigen/Eigen/src/Core/products/GeneralMatrixMatrix.h +492 -0
  168. data/vendor/eigen/Eigen/src/Core/products/GeneralMatrixMatrixTriangular.h +311 -0
  169. data/vendor/eigen/Eigen/src/Core/products/GeneralMatrixMatrixTriangular_BLAS.h +145 -0
  170. data/vendor/eigen/Eigen/src/Core/products/GeneralMatrixMatrix_BLAS.h +122 -0
  171. data/vendor/eigen/Eigen/src/Core/products/GeneralMatrixVector.h +619 -0
  172. data/vendor/eigen/Eigen/src/Core/products/GeneralMatrixVector_BLAS.h +136 -0
  173. data/vendor/eigen/Eigen/src/Core/products/Parallelizer.h +163 -0
  174. data/vendor/eigen/Eigen/src/Core/products/SelfadjointMatrixMatrix.h +521 -0
  175. data/vendor/eigen/Eigen/src/Core/products/SelfadjointMatrixMatrix_BLAS.h +287 -0
  176. data/vendor/eigen/Eigen/src/Core/products/SelfadjointMatrixVector.h +260 -0
  177. data/vendor/eigen/Eigen/src/Core/products/SelfadjointMatrixVector_BLAS.h +118 -0
  178. data/vendor/eigen/Eigen/src/Core/products/SelfadjointProduct.h +133 -0
  179. data/vendor/eigen/Eigen/src/Core/products/SelfadjointRank2Update.h +93 -0
  180. data/vendor/eigen/Eigen/src/Core/products/TriangularMatrixMatrix.h +466 -0
  181. data/vendor/eigen/Eigen/src/Core/products/TriangularMatrixMatrix_BLAS.h +315 -0
  182. data/vendor/eigen/Eigen/src/Core/products/TriangularMatrixVector.h +350 -0
  183. data/vendor/eigen/Eigen/src/Core/products/TriangularMatrixVector_BLAS.h +255 -0
  184. data/vendor/eigen/Eigen/src/Core/products/TriangularSolverMatrix.h +335 -0
  185. data/vendor/eigen/Eigen/src/Core/products/TriangularSolverMatrix_BLAS.h +163 -0
  186. data/vendor/eigen/Eigen/src/Core/products/TriangularSolverVector.h +145 -0
  187. data/vendor/eigen/Eigen/src/Core/util/BlasUtil.h +398 -0
  188. data/vendor/eigen/Eigen/src/Core/util/Constants.h +547 -0
  189. data/vendor/eigen/Eigen/src/Core/util/DisableStupidWarnings.h +83 -0
  190. data/vendor/eigen/Eigen/src/Core/util/ForwardDeclarations.h +302 -0
  191. data/vendor/eigen/Eigen/src/Core/util/MKL_support.h +130 -0
  192. data/vendor/eigen/Eigen/src/Core/util/Macros.h +1001 -0
  193. data/vendor/eigen/Eigen/src/Core/util/Memory.h +993 -0
  194. data/vendor/eigen/Eigen/src/Core/util/Meta.h +534 -0
  195. data/vendor/eigen/Eigen/src/Core/util/NonMPL2.h +3 -0
  196. data/vendor/eigen/Eigen/src/Core/util/ReenableStupidWarnings.h +27 -0
  197. data/vendor/eigen/Eigen/src/Core/util/StaticAssert.h +218 -0
  198. data/vendor/eigen/Eigen/src/Core/util/XprHelper.h +821 -0
  199. data/vendor/eigen/Eigen/src/Eigenvalues/ComplexEigenSolver.h +346 -0
  200. data/vendor/eigen/Eigen/src/Eigenvalues/ComplexSchur.h +459 -0
  201. data/vendor/eigen/Eigen/src/Eigenvalues/ComplexSchur_LAPACKE.h +91 -0
  202. data/vendor/eigen/Eigen/src/Eigenvalues/EigenSolver.h +622 -0
  203. data/vendor/eigen/Eigen/src/Eigenvalues/GeneralizedEigenSolver.h +418 -0
  204. data/vendor/eigen/Eigen/src/Eigenvalues/GeneralizedSelfAdjointEigenSolver.h +226 -0
  205. data/vendor/eigen/Eigen/src/Eigenvalues/HessenbergDecomposition.h +374 -0
  206. data/vendor/eigen/Eigen/src/Eigenvalues/MatrixBaseEigenvalues.h +158 -0
  207. data/vendor/eigen/Eigen/src/Eigenvalues/RealQZ.h +654 -0
  208. data/vendor/eigen/Eigen/src/Eigenvalues/RealSchur.h +546 -0
  209. data/vendor/eigen/Eigen/src/Eigenvalues/RealSchur_LAPACKE.h +77 -0
  210. data/vendor/eigen/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h +870 -0
  211. data/vendor/eigen/Eigen/src/Eigenvalues/SelfAdjointEigenSolver_LAPACKE.h +87 -0
  212. data/vendor/eigen/Eigen/src/Eigenvalues/Tridiagonalization.h +556 -0
  213. data/vendor/eigen/Eigen/src/Geometry/AlignedBox.h +392 -0
  214. data/vendor/eigen/Eigen/src/Geometry/AngleAxis.h +247 -0
  215. data/vendor/eigen/Eigen/src/Geometry/EulerAngles.h +114 -0
  216. data/vendor/eigen/Eigen/src/Geometry/Homogeneous.h +497 -0
  217. data/vendor/eigen/Eigen/src/Geometry/Hyperplane.h +282 -0
  218. data/vendor/eigen/Eigen/src/Geometry/OrthoMethods.h +234 -0
  219. data/vendor/eigen/Eigen/src/Geometry/ParametrizedLine.h +195 -0
  220. data/vendor/eigen/Eigen/src/Geometry/Quaternion.h +814 -0
  221. data/vendor/eigen/Eigen/src/Geometry/Rotation2D.h +199 -0
  222. data/vendor/eigen/Eigen/src/Geometry/RotationBase.h +206 -0
  223. data/vendor/eigen/Eigen/src/Geometry/Scaling.h +170 -0
  224. data/vendor/eigen/Eigen/src/Geometry/Transform.h +1542 -0
  225. data/vendor/eigen/Eigen/src/Geometry/Translation.h +208 -0
  226. data/vendor/eigen/Eigen/src/Geometry/Umeyama.h +166 -0
  227. data/vendor/eigen/Eigen/src/Geometry/arch/Geometry_SSE.h +161 -0
  228. data/vendor/eigen/Eigen/src/Householder/BlockHouseholder.h +103 -0
  229. data/vendor/eigen/Eigen/src/Householder/Householder.h +172 -0
  230. data/vendor/eigen/Eigen/src/Householder/HouseholderSequence.h +470 -0
  231. data/vendor/eigen/Eigen/src/IterativeLinearSolvers/BasicPreconditioners.h +226 -0
  232. data/vendor/eigen/Eigen/src/IterativeLinearSolvers/BiCGSTAB.h +228 -0
  233. data/vendor/eigen/Eigen/src/IterativeLinearSolvers/ConjugateGradient.h +246 -0
  234. data/vendor/eigen/Eigen/src/IterativeLinearSolvers/IncompleteCholesky.h +400 -0
  235. data/vendor/eigen/Eigen/src/IterativeLinearSolvers/IncompleteLUT.h +462 -0
  236. data/vendor/eigen/Eigen/src/IterativeLinearSolvers/IterativeSolverBase.h +394 -0
  237. data/vendor/eigen/Eigen/src/IterativeLinearSolvers/LeastSquareConjugateGradient.h +216 -0
  238. data/vendor/eigen/Eigen/src/IterativeLinearSolvers/SolveWithGuess.h +115 -0
  239. data/vendor/eigen/Eigen/src/Jacobi/Jacobi.h +462 -0
  240. data/vendor/eigen/Eigen/src/LU/Determinant.h +101 -0
  241. data/vendor/eigen/Eigen/src/LU/FullPivLU.h +891 -0
  242. data/vendor/eigen/Eigen/src/LU/InverseImpl.h +415 -0
  243. data/vendor/eigen/Eigen/src/LU/PartialPivLU.h +611 -0
  244. data/vendor/eigen/Eigen/src/LU/PartialPivLU_LAPACKE.h +83 -0
  245. data/vendor/eigen/Eigen/src/LU/arch/Inverse_SSE.h +338 -0
  246. data/vendor/eigen/Eigen/src/MetisSupport/MetisSupport.h +137 -0
  247. data/vendor/eigen/Eigen/src/OrderingMethods/Amd.h +445 -0
  248. data/vendor/eigen/Eigen/src/OrderingMethods/Eigen_Colamd.h +1843 -0
  249. data/vendor/eigen/Eigen/src/OrderingMethods/Ordering.h +157 -0
  250. data/vendor/eigen/Eigen/src/PaStiXSupport/PaStiXSupport.h +678 -0
  251. data/vendor/eigen/Eigen/src/PardisoSupport/PardisoSupport.h +543 -0
  252. data/vendor/eigen/Eigen/src/QR/ColPivHouseholderQR.h +653 -0
  253. data/vendor/eigen/Eigen/src/QR/ColPivHouseholderQR_LAPACKE.h +97 -0
  254. data/vendor/eigen/Eigen/src/QR/CompleteOrthogonalDecomposition.h +562 -0
  255. data/vendor/eigen/Eigen/src/QR/FullPivHouseholderQR.h +676 -0
  256. data/vendor/eigen/Eigen/src/QR/HouseholderQR.h +409 -0
  257. data/vendor/eigen/Eigen/src/QR/HouseholderQR_LAPACKE.h +68 -0
  258. data/vendor/eigen/Eigen/src/SPQRSupport/SuiteSparseQRSupport.h +313 -0
  259. data/vendor/eigen/Eigen/src/SVD/BDCSVD.h +1246 -0
  260. data/vendor/eigen/Eigen/src/SVD/JacobiSVD.h +804 -0
  261. data/vendor/eigen/Eigen/src/SVD/JacobiSVD_LAPACKE.h +91 -0
  262. data/vendor/eigen/Eigen/src/SVD/SVDBase.h +315 -0
  263. data/vendor/eigen/Eigen/src/SVD/UpperBidiagonalization.h +414 -0
  264. data/vendor/eigen/Eigen/src/SparseCholesky/SimplicialCholesky.h +689 -0
  265. data/vendor/eigen/Eigen/src/SparseCholesky/SimplicialCholesky_impl.h +199 -0
  266. data/vendor/eigen/Eigen/src/SparseCore/AmbiVector.h +377 -0
  267. data/vendor/eigen/Eigen/src/SparseCore/CompressedStorage.h +258 -0
  268. data/vendor/eigen/Eigen/src/SparseCore/ConservativeSparseSparseProduct.h +352 -0
  269. data/vendor/eigen/Eigen/src/SparseCore/MappedSparseMatrix.h +67 -0
  270. data/vendor/eigen/Eigen/src/SparseCore/SparseAssign.h +216 -0
  271. data/vendor/eigen/Eigen/src/SparseCore/SparseBlock.h +603 -0
  272. data/vendor/eigen/Eigen/src/SparseCore/SparseColEtree.h +206 -0
  273. data/vendor/eigen/Eigen/src/SparseCore/SparseCompressedBase.h +341 -0
  274. data/vendor/eigen/Eigen/src/SparseCore/SparseCwiseBinaryOp.h +726 -0
  275. data/vendor/eigen/Eigen/src/SparseCore/SparseCwiseUnaryOp.h +148 -0
  276. data/vendor/eigen/Eigen/src/SparseCore/SparseDenseProduct.h +320 -0
  277. data/vendor/eigen/Eigen/src/SparseCore/SparseDiagonalProduct.h +138 -0
  278. data/vendor/eigen/Eigen/src/SparseCore/SparseDot.h +98 -0
  279. data/vendor/eigen/Eigen/src/SparseCore/SparseFuzzy.h +29 -0
  280. data/vendor/eigen/Eigen/src/SparseCore/SparseMap.h +305 -0
  281. data/vendor/eigen/Eigen/src/SparseCore/SparseMatrix.h +1403 -0
  282. data/vendor/eigen/Eigen/src/SparseCore/SparseMatrixBase.h +405 -0
  283. data/vendor/eigen/Eigen/src/SparseCore/SparsePermutation.h +178 -0
  284. data/vendor/eigen/Eigen/src/SparseCore/SparseProduct.h +169 -0
  285. data/vendor/eigen/Eigen/src/SparseCore/SparseRedux.h +49 -0
  286. data/vendor/eigen/Eigen/src/SparseCore/SparseRef.h +397 -0
  287. data/vendor/eigen/Eigen/src/SparseCore/SparseSelfAdjointView.h +656 -0
  288. data/vendor/eigen/Eigen/src/SparseCore/SparseSolverBase.h +124 -0
  289. data/vendor/eigen/Eigen/src/SparseCore/SparseSparseProductWithPruning.h +198 -0
  290. data/vendor/eigen/Eigen/src/SparseCore/SparseTranspose.h +92 -0
  291. data/vendor/eigen/Eigen/src/SparseCore/SparseTriangularView.h +189 -0
  292. data/vendor/eigen/Eigen/src/SparseCore/SparseUtil.h +178 -0
  293. data/vendor/eigen/Eigen/src/SparseCore/SparseVector.h +478 -0
  294. data/vendor/eigen/Eigen/src/SparseCore/SparseView.h +253 -0
  295. data/vendor/eigen/Eigen/src/SparseCore/TriangularSolver.h +315 -0
  296. data/vendor/eigen/Eigen/src/SparseLU/SparseLU.h +773 -0
  297. data/vendor/eigen/Eigen/src/SparseLU/SparseLUImpl.h +66 -0
  298. data/vendor/eigen/Eigen/src/SparseLU/SparseLU_Memory.h +226 -0
  299. data/vendor/eigen/Eigen/src/SparseLU/SparseLU_Structs.h +110 -0
  300. data/vendor/eigen/Eigen/src/SparseLU/SparseLU_SupernodalMatrix.h +301 -0
  301. data/vendor/eigen/Eigen/src/SparseLU/SparseLU_Utils.h +80 -0
  302. data/vendor/eigen/Eigen/src/SparseLU/SparseLU_column_bmod.h +181 -0
  303. data/vendor/eigen/Eigen/src/SparseLU/SparseLU_column_dfs.h +179 -0
  304. data/vendor/eigen/Eigen/src/SparseLU/SparseLU_copy_to_ucol.h +107 -0
  305. data/vendor/eigen/Eigen/src/SparseLU/SparseLU_gemm_kernel.h +280 -0
  306. data/vendor/eigen/Eigen/src/SparseLU/SparseLU_heap_relax_snode.h +126 -0
  307. data/vendor/eigen/Eigen/src/SparseLU/SparseLU_kernel_bmod.h +130 -0
  308. data/vendor/eigen/Eigen/src/SparseLU/SparseLU_panel_bmod.h +223 -0
  309. data/vendor/eigen/Eigen/src/SparseLU/SparseLU_panel_dfs.h +258 -0
  310. data/vendor/eigen/Eigen/src/SparseLU/SparseLU_pivotL.h +137 -0
  311. data/vendor/eigen/Eigen/src/SparseLU/SparseLU_pruneL.h +136 -0
  312. data/vendor/eigen/Eigen/src/SparseLU/SparseLU_relax_snode.h +83 -0
  313. data/vendor/eigen/Eigen/src/SparseQR/SparseQR.h +745 -0
  314. data/vendor/eigen/Eigen/src/StlSupport/StdDeque.h +126 -0
  315. data/vendor/eigen/Eigen/src/StlSupport/StdList.h +106 -0
  316. data/vendor/eigen/Eigen/src/StlSupport/StdVector.h +131 -0
  317. data/vendor/eigen/Eigen/src/StlSupport/details.h +84 -0
  318. data/vendor/eigen/Eigen/src/SuperLUSupport/SuperLUSupport.h +1027 -0
  319. data/vendor/eigen/Eigen/src/UmfPackSupport/UmfPackSupport.h +506 -0
  320. data/vendor/eigen/Eigen/src/misc/Image.h +82 -0
  321. data/vendor/eigen/Eigen/src/misc/Kernel.h +79 -0
  322. data/vendor/eigen/Eigen/src/misc/RealSvd2x2.h +55 -0
  323. data/vendor/eigen/Eigen/src/misc/blas.h +440 -0
  324. data/vendor/eigen/Eigen/src/misc/lapack.h +152 -0
  325. data/vendor/eigen/Eigen/src/misc/lapacke.h +16291 -0
  326. data/vendor/eigen/Eigen/src/misc/lapacke_mangling.h +17 -0
  327. data/vendor/eigen/Eigen/src/plugins/ArrayCwiseBinaryOps.h +332 -0
  328. data/vendor/eigen/Eigen/src/plugins/ArrayCwiseUnaryOps.h +552 -0
  329. data/vendor/eigen/Eigen/src/plugins/BlockMethods.h +1058 -0
  330. data/vendor/eigen/Eigen/src/plugins/CommonCwiseBinaryOps.h +115 -0
  331. data/vendor/eigen/Eigen/src/plugins/CommonCwiseUnaryOps.h +163 -0
  332. data/vendor/eigen/Eigen/src/plugins/MatrixCwiseBinaryOps.h +152 -0
  333. data/vendor/eigen/Eigen/src/plugins/MatrixCwiseUnaryOps.h +85 -0
  334. data/vendor/eigen/README.md +3 -0
  335. data/vendor/eigen/bench/README.txt +55 -0
  336. data/vendor/eigen/bench/btl/COPYING +340 -0
  337. data/vendor/eigen/bench/btl/README +154 -0
  338. data/vendor/eigen/bench/tensors/README +21 -0
  339. data/vendor/eigen/blas/README.txt +6 -0
  340. data/vendor/eigen/demos/mandelbrot/README +10 -0
  341. data/vendor/eigen/demos/mix_eigen_and_c/README +9 -0
  342. data/vendor/eigen/demos/opengl/README +13 -0
  343. data/vendor/eigen/unsupported/Eigen/CXX11/src/Tensor/README.md +1760 -0
  344. data/vendor/eigen/unsupported/README.txt +50 -0
  345. data/vendor/tomotopy/LICENSE +21 -0
  346. data/vendor/tomotopy/README.kr.rst +375 -0
  347. data/vendor/tomotopy/README.rst +382 -0
  348. data/vendor/tomotopy/src/Labeling/FoRelevance.cpp +362 -0
  349. data/vendor/tomotopy/src/Labeling/FoRelevance.h +88 -0
  350. data/vendor/tomotopy/src/Labeling/Labeler.h +50 -0
  351. data/vendor/tomotopy/src/TopicModel/CT.h +37 -0
  352. data/vendor/tomotopy/src/TopicModel/CTModel.cpp +13 -0
  353. data/vendor/tomotopy/src/TopicModel/CTModel.hpp +293 -0
  354. data/vendor/tomotopy/src/TopicModel/DMR.h +51 -0
  355. data/vendor/tomotopy/src/TopicModel/DMRModel.cpp +13 -0
  356. data/vendor/tomotopy/src/TopicModel/DMRModel.hpp +374 -0
  357. data/vendor/tomotopy/src/TopicModel/DT.h +65 -0
  358. data/vendor/tomotopy/src/TopicModel/DTM.h +22 -0
  359. data/vendor/tomotopy/src/TopicModel/DTModel.cpp +15 -0
  360. data/vendor/tomotopy/src/TopicModel/DTModel.hpp +572 -0
  361. data/vendor/tomotopy/src/TopicModel/GDMR.h +37 -0
  362. data/vendor/tomotopy/src/TopicModel/GDMRModel.cpp +14 -0
  363. data/vendor/tomotopy/src/TopicModel/GDMRModel.hpp +485 -0
  364. data/vendor/tomotopy/src/TopicModel/HDP.h +74 -0
  365. data/vendor/tomotopy/src/TopicModel/HDPModel.cpp +13 -0
  366. data/vendor/tomotopy/src/TopicModel/HDPModel.hpp +592 -0
  367. data/vendor/tomotopy/src/TopicModel/HLDA.h +40 -0
  368. data/vendor/tomotopy/src/TopicModel/HLDAModel.cpp +13 -0
  369. data/vendor/tomotopy/src/TopicModel/HLDAModel.hpp +681 -0
  370. data/vendor/tomotopy/src/TopicModel/HPA.h +27 -0
  371. data/vendor/tomotopy/src/TopicModel/HPAModel.cpp +21 -0
  372. data/vendor/tomotopy/src/TopicModel/HPAModel.hpp +588 -0
  373. data/vendor/tomotopy/src/TopicModel/LDA.h +144 -0
  374. data/vendor/tomotopy/src/TopicModel/LDACVB0Model.hpp +442 -0
  375. data/vendor/tomotopy/src/TopicModel/LDAModel.cpp +13 -0
  376. data/vendor/tomotopy/src/TopicModel/LDAModel.hpp +1058 -0
  377. data/vendor/tomotopy/src/TopicModel/LLDA.h +45 -0
  378. data/vendor/tomotopy/src/TopicModel/LLDAModel.cpp +13 -0
  379. data/vendor/tomotopy/src/TopicModel/LLDAModel.hpp +203 -0
  380. data/vendor/tomotopy/src/TopicModel/MGLDA.h +63 -0
  381. data/vendor/tomotopy/src/TopicModel/MGLDAModel.cpp +17 -0
  382. data/vendor/tomotopy/src/TopicModel/MGLDAModel.hpp +558 -0
  383. data/vendor/tomotopy/src/TopicModel/PA.h +43 -0
  384. data/vendor/tomotopy/src/TopicModel/PAModel.cpp +13 -0
  385. data/vendor/tomotopy/src/TopicModel/PAModel.hpp +467 -0
  386. data/vendor/tomotopy/src/TopicModel/PLDA.h +17 -0
  387. data/vendor/tomotopy/src/TopicModel/PLDAModel.cpp +13 -0
  388. data/vendor/tomotopy/src/TopicModel/PLDAModel.hpp +214 -0
  389. data/vendor/tomotopy/src/TopicModel/SLDA.h +54 -0
  390. data/vendor/tomotopy/src/TopicModel/SLDAModel.cpp +17 -0
  391. data/vendor/tomotopy/src/TopicModel/SLDAModel.hpp +456 -0
  392. data/vendor/tomotopy/src/TopicModel/TopicModel.hpp +692 -0
  393. data/vendor/tomotopy/src/Utils/AliasMethod.hpp +169 -0
  394. data/vendor/tomotopy/src/Utils/Dictionary.h +80 -0
  395. data/vendor/tomotopy/src/Utils/EigenAddonOps.hpp +181 -0
  396. data/vendor/tomotopy/src/Utils/LBFGS.h +202 -0
  397. data/vendor/tomotopy/src/Utils/LBFGS/LineSearchBacktracking.h +120 -0
  398. data/vendor/tomotopy/src/Utils/LBFGS/LineSearchBracketing.h +122 -0
  399. data/vendor/tomotopy/src/Utils/LBFGS/Param.h +213 -0
  400. data/vendor/tomotopy/src/Utils/LUT.hpp +82 -0
  401. data/vendor/tomotopy/src/Utils/MultiNormalDistribution.hpp +69 -0
  402. data/vendor/tomotopy/src/Utils/PolyaGamma.hpp +200 -0
  403. data/vendor/tomotopy/src/Utils/PolyaGammaHybrid.hpp +672 -0
  404. data/vendor/tomotopy/src/Utils/ThreadPool.hpp +150 -0
  405. data/vendor/tomotopy/src/Utils/Trie.hpp +220 -0
  406. data/vendor/tomotopy/src/Utils/TruncMultiNormal.hpp +94 -0
  407. data/vendor/tomotopy/src/Utils/Utils.hpp +337 -0
  408. data/vendor/tomotopy/src/Utils/avx_gamma.h +46 -0
  409. data/vendor/tomotopy/src/Utils/avx_mathfun.h +736 -0
  410. data/vendor/tomotopy/src/Utils/exception.h +28 -0
  411. data/vendor/tomotopy/src/Utils/math.h +281 -0
  412. data/vendor/tomotopy/src/Utils/rtnorm.hpp +2690 -0
  413. data/vendor/tomotopy/src/Utils/sample.hpp +192 -0
  414. data/vendor/tomotopy/src/Utils/serializer.hpp +695 -0
  415. data/vendor/tomotopy/src/Utils/slp.hpp +131 -0
  416. data/vendor/tomotopy/src/Utils/sse_gamma.h +48 -0
  417. data/vendor/tomotopy/src/Utils/sse_mathfun.h +710 -0
  418. data/vendor/tomotopy/src/Utils/text.hpp +49 -0
  419. data/vendor/tomotopy/src/Utils/tvector.hpp +543 -0
  420. metadata +531 -0
@@ -0,0 +1,103 @@
1
+ // This file is part of Eigen, a lightweight C++ template library
2
+ // for linear algebra.
3
+ //
4
+ // Copyright (C) 2014 Benoit Steiner <benoit.steiner.goog@gmail.com>
5
+ //
6
+ // This Source Code Form is subject to the terms of the Mozilla
7
+ // Public License v. 2.0. If a copy of the MPL was not distributed
8
+ // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9
+
10
+ #ifndef EIGEN_COMPLEX_CUDA_H
11
+ #define EIGEN_COMPLEX_CUDA_H
12
+
13
+ // clang-format off
14
+
15
+ namespace Eigen {
16
+
17
+ namespace internal {
18
+
19
+ #if defined(__CUDACC__) && defined(EIGEN_USE_GPU)
20
+
21
+ // Many std::complex methods such as operator+, operator-, operator* and
22
+ // operator/ are not constexpr. Due to this, clang does not treat them as device
23
+ // functions and thus Eigen functors making use of these operators fail to
24
+ // compile. Here, we manually specialize these functors for complex types when
25
+ // building for CUDA to avoid non-constexpr methods.
26
+
27
+ // Sum
28
+ template<typename T> struct scalar_sum_op<const std::complex<T>, const std::complex<T> > : binary_op_base<const std::complex<T>, const std::complex<T> > {
29
+ typedef typename std::complex<T> result_type;
30
+
31
+ EIGEN_EMPTY_STRUCT_CTOR(scalar_sum_op)
32
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE std::complex<T> operator() (const std::complex<T>& a, const std::complex<T>& b) const {
33
+ return std::complex<T>(numext::real(a) + numext::real(b),
34
+ numext::imag(a) + numext::imag(b));
35
+ }
36
+ };
37
+
38
+ template<typename T> struct scalar_sum_op<std::complex<T>, std::complex<T> > : scalar_sum_op<const std::complex<T>, const std::complex<T> > {};
39
+
40
+
41
+ // Difference
42
+ template<typename T> struct scalar_difference_op<const std::complex<T>, const std::complex<T> > : binary_op_base<const std::complex<T>, const std::complex<T> > {
43
+ typedef typename std::complex<T> result_type;
44
+
45
+ EIGEN_EMPTY_STRUCT_CTOR(scalar_difference_op)
46
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE std::complex<T> operator() (const std::complex<T>& a, const std::complex<T>& b) const {
47
+ return std::complex<T>(numext::real(a) - numext::real(b),
48
+ numext::imag(a) - numext::imag(b));
49
+ }
50
+ };
51
+
52
+ template<typename T> struct scalar_difference_op<std::complex<T>, std::complex<T> > : scalar_difference_op<const std::complex<T>, const std::complex<T> > {};
53
+
54
+
55
+ // Product
56
+ template<typename T> struct scalar_product_op<const std::complex<T>, const std::complex<T> > : binary_op_base<const std::complex<T>, const std::complex<T> > {
57
+ enum {
58
+ Vectorizable = packet_traits<std::complex<T>>::HasMul
59
+ };
60
+ typedef typename std::complex<T> result_type;
61
+
62
+ EIGEN_EMPTY_STRUCT_CTOR(scalar_product_op)
63
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE std::complex<T> operator() (const std::complex<T>& a, const std::complex<T>& b) const {
64
+ const T a_real = numext::real(a);
65
+ const T a_imag = numext::imag(a);
66
+ const T b_real = numext::real(b);
67
+ const T b_imag = numext::imag(b);
68
+ return std::complex<T>(a_real * b_real - a_imag * b_imag,
69
+ a_real * b_imag + a_imag * b_real);
70
+ }
71
+ };
72
+
73
+ template<typename T> struct scalar_product_op<std::complex<T>, std::complex<T> > : scalar_product_op<const std::complex<T>, const std::complex<T> > {};
74
+
75
+
76
+ // Quotient
77
+ template<typename T> struct scalar_quotient_op<const std::complex<T>, const std::complex<T> > : binary_op_base<const std::complex<T>, const std::complex<T> > {
78
+ enum {
79
+ Vectorizable = packet_traits<std::complex<T>>::HasDiv
80
+ };
81
+ typedef typename std::complex<T> result_type;
82
+
83
+ EIGEN_EMPTY_STRUCT_CTOR(scalar_quotient_op)
84
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE std::complex<T> operator() (const std::complex<T>& a, const std::complex<T>& b) const {
85
+ const T a_real = numext::real(a);
86
+ const T a_imag = numext::imag(a);
87
+ const T b_real = numext::real(b);
88
+ const T b_imag = numext::imag(b);
89
+ const T norm = T(1) / (b_real * b_real + b_imag * b_imag);
90
+ return std::complex<T>((a_real * b_real + a_imag * b_imag) * norm,
91
+ (a_imag * b_real - a_real * b_imag) * norm);
92
+ }
93
+ };
94
+
95
+ template<typename T> struct scalar_quotient_op<std::complex<T>, std::complex<T> > : scalar_quotient_op<const std::complex<T>, const std::complex<T> > {};
96
+
97
+ #endif
98
+
99
+ } // end namespace internal
100
+
101
+ } // end namespace Eigen
102
+
103
+ #endif // EIGEN_COMPLEX_CUDA_H
@@ -0,0 +1,674 @@
1
+ // This file is part of Eigen, a lightweight C++ template library
2
+ // for linear algebra.
3
+ //
4
+ // This Source Code Form is subject to the terms of the Mozilla
5
+ // Public License v. 2.0. If a copy of the MPL was not distributed
6
+ // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
7
+ //
8
+ // The conversion routines are Copyright (c) Fabian Giesen, 2016.
9
+ // The original license follows:
10
+ //
11
+ // Copyright (c) Fabian Giesen, 2016
12
+ // All rights reserved.
13
+ // Redistribution and use in source and binary forms, with or without
14
+ // modification, are permitted.
15
+ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16
+ // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17
+ // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18
+ // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19
+ // HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20
+ // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21
+ // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22
+ // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23
+ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
+ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25
+ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
+
27
+
28
+ // Standard 16-bit float type, mostly useful for GPUs. Defines a new
29
+ // type Eigen::half (inheriting from CUDA's __half struct) with
30
+ // operator overloads such that it behaves basically as an arithmetic
31
+ // type. It will be quite slow on CPUs (so it is recommended to stay
32
+ // in float32_bits for CPUs, except for simple parameter conversions, I/O
33
+ // to disk and the likes), but fast on GPUs.
34
+
35
+
36
+ #ifndef EIGEN_HALF_CUDA_H
37
+ #define EIGEN_HALF_CUDA_H
38
+
39
+ #if __cplusplus > 199711L
40
+ #define EIGEN_EXPLICIT_CAST(tgt_type) explicit operator tgt_type()
41
+ #else
42
+ #define EIGEN_EXPLICIT_CAST(tgt_type) operator tgt_type()
43
+ #endif
44
+
45
+
46
+ namespace Eigen {
47
+
48
+ struct half;
49
+
50
+ namespace half_impl {
51
+
52
+ #if !defined(EIGEN_HAS_CUDA_FP16)
53
+ // Make our own __half_raw definition that is similar to CUDA's.
54
+ struct __half_raw {
55
+ EIGEN_DEVICE_FUNC __half_raw() : x(0) {}
56
+ explicit EIGEN_DEVICE_FUNC __half_raw(unsigned short raw) : x(raw) {}
57
+ unsigned short x;
58
+ };
59
+ #elif defined(EIGEN_CUDACC_VER) && EIGEN_CUDACC_VER < 90000
60
+ // In CUDA < 9.0, __half is the equivalent of CUDA 9's __half_raw
61
+ typedef __half __half_raw;
62
+ #endif
63
+
64
+ EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC __half_raw raw_uint16_to_half(unsigned short x);
65
+ EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC __half_raw float_to_half_rtne(float ff);
66
+ EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC float half_to_float(__half_raw h);
67
+
68
+ struct half_base : public __half_raw {
69
+ EIGEN_DEVICE_FUNC half_base() {}
70
+ EIGEN_DEVICE_FUNC half_base(const half_base& h) : __half_raw(h) {}
71
+ EIGEN_DEVICE_FUNC half_base(const __half_raw& h) : __half_raw(h) {}
72
+ #if defined(EIGEN_HAS_CUDA_FP16) && defined(EIGEN_CUDACC_VER) && EIGEN_CUDACC_VER >= 90000
73
+ EIGEN_DEVICE_FUNC half_base(const __half& h) : __half_raw(*(__half_raw*)&h) {}
74
+ #endif
75
+ };
76
+
77
+ } // namespace half_impl
78
+
79
+ // Class definition.
80
+ struct half : public half_impl::half_base {
81
+ #if !defined(EIGEN_HAS_CUDA_FP16) || (defined(EIGEN_CUDACC_VER) && EIGEN_CUDACC_VER < 90000)
82
+ typedef half_impl::__half_raw __half_raw;
83
+ #endif
84
+
85
+ EIGEN_DEVICE_FUNC half() {}
86
+
87
+ EIGEN_DEVICE_FUNC half(const __half_raw& h) : half_impl::half_base(h) {}
88
+ EIGEN_DEVICE_FUNC half(const half& h) : half_impl::half_base(h) {}
89
+ #if defined(EIGEN_HAS_CUDA_FP16) && defined(EIGEN_CUDACC_VER) && EIGEN_CUDACC_VER >= 90000
90
+ EIGEN_DEVICE_FUNC half(const __half& h) : half_impl::half_base(h) {}
91
+ #endif
92
+
93
+ explicit EIGEN_DEVICE_FUNC half(bool b)
94
+ : half_impl::half_base(half_impl::raw_uint16_to_half(b ? 0x3c00 : 0)) {}
95
+ template<class T>
96
+ explicit EIGEN_DEVICE_FUNC half(const T& val)
97
+ : half_impl::half_base(half_impl::float_to_half_rtne(static_cast<float>(val))) {}
98
+ explicit EIGEN_DEVICE_FUNC half(float f)
99
+ : half_impl::half_base(half_impl::float_to_half_rtne(f)) {}
100
+
101
+ EIGEN_DEVICE_FUNC EIGEN_EXPLICIT_CAST(bool) const {
102
+ // +0.0 and -0.0 become false, everything else becomes true.
103
+ return (x & 0x7fff) != 0;
104
+ }
105
+ EIGEN_DEVICE_FUNC EIGEN_EXPLICIT_CAST(signed char) const {
106
+ return static_cast<signed char>(half_impl::half_to_float(*this));
107
+ }
108
+ EIGEN_DEVICE_FUNC EIGEN_EXPLICIT_CAST(unsigned char) const {
109
+ return static_cast<unsigned char>(half_impl::half_to_float(*this));
110
+ }
111
+ EIGEN_DEVICE_FUNC EIGEN_EXPLICIT_CAST(short) const {
112
+ return static_cast<short>(half_impl::half_to_float(*this));
113
+ }
114
+ EIGEN_DEVICE_FUNC EIGEN_EXPLICIT_CAST(unsigned short) const {
115
+ return static_cast<unsigned short>(half_impl::half_to_float(*this));
116
+ }
117
+ EIGEN_DEVICE_FUNC EIGEN_EXPLICIT_CAST(int) const {
118
+ return static_cast<int>(half_impl::half_to_float(*this));
119
+ }
120
+ EIGEN_DEVICE_FUNC EIGEN_EXPLICIT_CAST(unsigned int) const {
121
+ return static_cast<unsigned int>(half_impl::half_to_float(*this));
122
+ }
123
+ EIGEN_DEVICE_FUNC EIGEN_EXPLICIT_CAST(long) const {
124
+ return static_cast<long>(half_impl::half_to_float(*this));
125
+ }
126
+ EIGEN_DEVICE_FUNC EIGEN_EXPLICIT_CAST(unsigned long) const {
127
+ return static_cast<unsigned long>(half_impl::half_to_float(*this));
128
+ }
129
+ EIGEN_DEVICE_FUNC EIGEN_EXPLICIT_CAST(long long) const {
130
+ return static_cast<long long>(half_impl::half_to_float(*this));
131
+ }
132
+ EIGEN_DEVICE_FUNC EIGEN_EXPLICIT_CAST(unsigned long long) const {
133
+ return static_cast<unsigned long long>(half_to_float(*this));
134
+ }
135
+ EIGEN_DEVICE_FUNC EIGEN_EXPLICIT_CAST(float) const {
136
+ return half_impl::half_to_float(*this);
137
+ }
138
+ EIGEN_DEVICE_FUNC EIGEN_EXPLICIT_CAST(double) const {
139
+ return static_cast<double>(half_impl::half_to_float(*this));
140
+ }
141
+
142
+ EIGEN_DEVICE_FUNC half& operator=(const half& other) {
143
+ x = other.x;
144
+ return *this;
145
+ }
146
+ };
147
+
148
+ } // end namespace Eigen
149
+
150
+ namespace std {
151
+ template<>
152
+ struct numeric_limits<Eigen::half> {
153
+ static const bool is_specialized = true;
154
+ static const bool is_signed = true;
155
+ static const bool is_integer = false;
156
+ static const bool is_exact = false;
157
+ static const bool has_infinity = true;
158
+ static const bool has_quiet_NaN = true;
159
+ static const bool has_signaling_NaN = true;
160
+ static const float_denorm_style has_denorm = denorm_present;
161
+ static const bool has_denorm_loss = false;
162
+ static const std::float_round_style round_style = std::round_to_nearest;
163
+ static const bool is_iec559 = false;
164
+ static const bool is_bounded = false;
165
+ static const bool is_modulo = false;
166
+ static const int digits = 11;
167
+ static const int digits10 = 3; // according to http://half.sourceforge.net/structstd_1_1numeric__limits_3_01half__float_1_1half_01_4.html
168
+ static const int max_digits10 = 5; // according to http://half.sourceforge.net/structstd_1_1numeric__limits_3_01half__float_1_1half_01_4.html
169
+ static const int radix = 2;
170
+ static const int min_exponent = -13;
171
+ static const int min_exponent10 = -4;
172
+ static const int max_exponent = 16;
173
+ static const int max_exponent10 = 4;
174
+ static const bool traps = true;
175
+ static const bool tinyness_before = false;
176
+
177
+ static Eigen::half (min)() { return Eigen::half_impl::raw_uint16_to_half(0x400); }
178
+ static Eigen::half lowest() { return Eigen::half_impl::raw_uint16_to_half(0xfbff); }
179
+ static Eigen::half (max)() { return Eigen::half_impl::raw_uint16_to_half(0x7bff); }
180
+ static Eigen::half epsilon() { return Eigen::half_impl::raw_uint16_to_half(0x0800); }
181
+ static Eigen::half round_error() { return Eigen::half(0.5); }
182
+ static Eigen::half infinity() { return Eigen::half_impl::raw_uint16_to_half(0x7c00); }
183
+ static Eigen::half quiet_NaN() { return Eigen::half_impl::raw_uint16_to_half(0x7e00); }
184
+ static Eigen::half signaling_NaN() { return Eigen::half_impl::raw_uint16_to_half(0x7e00); }
185
+ static Eigen::half denorm_min() { return Eigen::half_impl::raw_uint16_to_half(0x1); }
186
+ };
187
+
188
+ // If std::numeric_limits<T> is specialized, should also specialize
189
+ // std::numeric_limits<const T>, std::numeric_limits<volatile T>, and
190
+ // std::numeric_limits<const volatile T>
191
+ // https://stackoverflow.com/a/16519653/
192
+ template<>
193
+ struct numeric_limits<const Eigen::half> : numeric_limits<Eigen::half> {};
194
+ template<>
195
+ struct numeric_limits<volatile Eigen::half> : numeric_limits<Eigen::half> {};
196
+ template<>
197
+ struct numeric_limits<const volatile Eigen::half> : numeric_limits<Eigen::half> {};
198
+ } // end namespace std
199
+
200
+ namespace Eigen {
201
+
202
+ namespace half_impl {
203
+
204
+ #if defined(EIGEN_HAS_CUDA_FP16) && defined(EIGEN_CUDA_ARCH) && EIGEN_CUDA_ARCH >= 530
205
+
206
+ // Intrinsics for native fp16 support. Note that on current hardware,
207
+ // these are no faster than float32_bits arithmetic (you need to use the half2
208
+ // versions to get the ALU speed increased), but you do save the
209
+ // conversion steps back and forth.
210
+
211
+ EIGEN_STRONG_INLINE __device__ half operator + (const half& a, const half& b) {
212
+ return __hadd(a, b);
213
+ }
214
+ EIGEN_STRONG_INLINE __device__ half operator * (const half& a, const half& b) {
215
+ return __hmul(a, b);
216
+ }
217
+ EIGEN_STRONG_INLINE __device__ half operator - (const half& a, const half& b) {
218
+ return __hsub(a, b);
219
+ }
220
+ EIGEN_STRONG_INLINE __device__ half operator / (const half& a, const half& b) {
221
+ float num = __half2float(a);
222
+ float denom = __half2float(b);
223
+ return __float2half(num / denom);
224
+ }
225
+ EIGEN_STRONG_INLINE __device__ half operator - (const half& a) {
226
+ return __hneg(a);
227
+ }
228
+ EIGEN_STRONG_INLINE __device__ half& operator += (half& a, const half& b) {
229
+ a = a + b;
230
+ return a;
231
+ }
232
+ EIGEN_STRONG_INLINE __device__ half& operator *= (half& a, const half& b) {
233
+ a = a * b;
234
+ return a;
235
+ }
236
+ EIGEN_STRONG_INLINE __device__ half& operator -= (half& a, const half& b) {
237
+ a = a - b;
238
+ return a;
239
+ }
240
+ EIGEN_STRONG_INLINE __device__ half& operator /= (half& a, const half& b) {
241
+ a = a / b;
242
+ return a;
243
+ }
244
+ EIGEN_STRONG_INLINE __device__ bool operator == (const half& a, const half& b) {
245
+ return __heq(a, b);
246
+ }
247
+ EIGEN_STRONG_INLINE __device__ bool operator != (const half& a, const half& b) {
248
+ return __hne(a, b);
249
+ }
250
+ EIGEN_STRONG_INLINE __device__ bool operator < (const half& a, const half& b) {
251
+ return __hlt(a, b);
252
+ }
253
+ EIGEN_STRONG_INLINE __device__ bool operator <= (const half& a, const half& b) {
254
+ return __hle(a, b);
255
+ }
256
+ EIGEN_STRONG_INLINE __device__ bool operator > (const half& a, const half& b) {
257
+ return __hgt(a, b);
258
+ }
259
+ EIGEN_STRONG_INLINE __device__ bool operator >= (const half& a, const half& b) {
260
+ return __hge(a, b);
261
+ }
262
+
263
+ #else // Emulate support for half floats
264
+
265
+ // Definitions for CPUs and older CUDA, mostly working through conversion
266
+ // to/from float32_bits.
267
+
268
+ EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half operator + (const half& a, const half& b) {
269
+ return half(float(a) + float(b));
270
+ }
271
+ EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half operator * (const half& a, const half& b) {
272
+ return half(float(a) * float(b));
273
+ }
274
+ EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half operator - (const half& a, const half& b) {
275
+ return half(float(a) - float(b));
276
+ }
277
+ EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half operator / (const half& a, const half& b) {
278
+ return half(float(a) / float(b));
279
+ }
280
+ EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half operator - (const half& a) {
281
+ half result;
282
+ result.x = a.x ^ 0x8000;
283
+ return result;
284
+ }
285
+ EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half& operator += (half& a, const half& b) {
286
+ a = half(float(a) + float(b));
287
+ return a;
288
+ }
289
+ EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half& operator *= (half& a, const half& b) {
290
+ a = half(float(a) * float(b));
291
+ return a;
292
+ }
293
+ EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half& operator -= (half& a, const half& b) {
294
+ a = half(float(a) - float(b));
295
+ return a;
296
+ }
297
+ EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half& operator /= (half& a, const half& b) {
298
+ a = half(float(a) / float(b));
299
+ return a;
300
+ }
301
+ EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool operator == (const half& a, const half& b) {
302
+ return numext::equal_strict(float(a),float(b));
303
+ }
304
+ EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool operator != (const half& a, const half& b) {
305
+ return numext::not_equal_strict(float(a), float(b));
306
+ }
307
+ EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool operator < (const half& a, const half& b) {
308
+ return float(a) < float(b);
309
+ }
310
+ EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool operator <= (const half& a, const half& b) {
311
+ return float(a) <= float(b);
312
+ }
313
+ EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool operator > (const half& a, const half& b) {
314
+ return float(a) > float(b);
315
+ }
316
+ EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool operator >= (const half& a, const half& b) {
317
+ return float(a) >= float(b);
318
+ }
319
+
320
+ #endif // Emulate support for half floats
321
+
322
+ // Division by an index. Do it in full float precision to avoid accuracy
323
+ // issues in converting the denominator to half.
324
+ EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half operator / (const half& a, Index b) {
325
+ return half(static_cast<float>(a) / static_cast<float>(b));
326
+ }
327
+
328
+ // Conversion routines, including fallbacks for the host or older CUDA.
329
+ // Note that newer Intel CPUs (Haswell or newer) have vectorized versions of
330
+ // these in hardware. If we need more performance on older/other CPUs, they are
331
+ // also possible to vectorize directly.
332
+
333
+ EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC __half_raw raw_uint16_to_half(unsigned short x) {
334
+ __half_raw h;
335
+ h.x = x;
336
+ return h;
337
+ }
338
+
339
+ union float32_bits {
340
+ unsigned int u;
341
+ float f;
342
+ };
343
+
344
+ EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC __half_raw float_to_half_rtne(float ff) {
345
+ #if defined(EIGEN_HAS_CUDA_FP16) && defined(EIGEN_CUDA_ARCH) && EIGEN_CUDA_ARCH >= 300
346
+ __half tmp_ff = __float2half(ff);
347
+ return *(__half_raw*)&tmp_ff;
348
+
349
+ #elif defined(EIGEN_HAS_FP16_C)
350
+ __half_raw h;
351
+ h.x = _cvtss_sh(ff, 0);
352
+ return h;
353
+
354
+ #else
355
+ float32_bits f; f.f = ff;
356
+
357
+ const float32_bits f32infty = { 255 << 23 };
358
+ const float32_bits f16max = { (127 + 16) << 23 };
359
+ const float32_bits denorm_magic = { ((127 - 15) + (23 - 10) + 1) << 23 };
360
+ unsigned int sign_mask = 0x80000000u;
361
+ __half_raw o;
362
+ o.x = static_cast<unsigned short>(0x0u);
363
+
364
+ unsigned int sign = f.u & sign_mask;
365
+ f.u ^= sign;
366
+
367
+ // NOTE all the integer compares in this function can be safely
368
+ // compiled into signed compares since all operands are below
369
+ // 0x80000000. Important if you want fast straight SSE2 code
370
+ // (since there's no unsigned PCMPGTD).
371
+
372
+ if (f.u >= f16max.u) { // result is Inf or NaN (all exponent bits set)
373
+ o.x = (f.u > f32infty.u) ? 0x7e00 : 0x7c00; // NaN->qNaN and Inf->Inf
374
+ } else { // (De)normalized number or zero
375
+ if (f.u < (113 << 23)) { // resulting FP16 is subnormal or zero
376
+ // use a magic value to align our 10 mantissa bits at the bottom of
377
+ // the float. as long as FP addition is round-to-nearest-even this
378
+ // just works.
379
+ f.f += denorm_magic.f;
380
+
381
+ // and one integer subtract of the bias later, we have our final float!
382
+ o.x = static_cast<unsigned short>(f.u - denorm_magic.u);
383
+ } else {
384
+ unsigned int mant_odd = (f.u >> 13) & 1; // resulting mantissa is odd
385
+
386
+ // update exponent, rounding bias part 1
387
+ f.u += ((unsigned int)(15 - 127) << 23) + 0xfff;
388
+ // rounding bias part 2
389
+ f.u += mant_odd;
390
+ // take the bits!
391
+ o.x = static_cast<unsigned short>(f.u >> 13);
392
+ }
393
+ }
394
+
395
+ o.x |= static_cast<unsigned short>(sign >> 16);
396
+ return o;
397
+ #endif
398
+ }
399
+
400
+ EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC float half_to_float(__half_raw h) {
401
+ #if defined(EIGEN_HAS_CUDA_FP16) && defined(EIGEN_CUDA_ARCH) && EIGEN_CUDA_ARCH >= 300
402
+ return __half2float(h);
403
+
404
+ #elif defined(EIGEN_HAS_FP16_C)
405
+ return _cvtsh_ss(h.x);
406
+
407
+ #else
408
+ const float32_bits magic = { 113 << 23 };
409
+ const unsigned int shifted_exp = 0x7c00 << 13; // exponent mask after shift
410
+ float32_bits o;
411
+
412
+ o.u = (h.x & 0x7fff) << 13; // exponent/mantissa bits
413
+ unsigned int exp = shifted_exp & o.u; // just the exponent
414
+ o.u += (127 - 15) << 23; // exponent adjust
415
+
416
+ // handle exponent special cases
417
+ if (exp == shifted_exp) { // Inf/NaN?
418
+ o.u += (128 - 16) << 23; // extra exp adjust
419
+ } else if (exp == 0) { // Zero/Denormal?
420
+ o.u += 1 << 23; // extra exp adjust
421
+ o.f -= magic.f; // renormalize
422
+ }
423
+
424
+ o.u |= (h.x & 0x8000) << 16; // sign bit
425
+ return o.f;
426
+ #endif
427
+ }
428
+
429
+ // --- standard functions ---
430
+
431
+ EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool (isinf)(const half& a) {
432
+ return (a.x & 0x7fff) == 0x7c00;
433
+ }
434
+ EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool (isnan)(const half& a) {
435
+ #if defined(EIGEN_HAS_CUDA_FP16) && defined(EIGEN_CUDA_ARCH) && EIGEN_CUDA_ARCH >= 530
436
+ return __hisnan(a);
437
+ #else
438
+ return (a.x & 0x7fff) > 0x7c00;
439
+ #endif
440
+ }
441
+ EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool (isfinite)(const half& a) {
442
+ return !(isinf EIGEN_NOT_A_MACRO (a)) && !(isnan EIGEN_NOT_A_MACRO (a));
443
+ }
444
+
445
+ EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half abs(const half& a) {
446
+ half result;
447
+ result.x = a.x & 0x7FFF;
448
+ return result;
449
+ }
450
+ EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half exp(const half& a) {
451
+ #if EIGEN_CUDACC_VER >= 80000 && defined EIGEN_CUDA_ARCH && EIGEN_CUDA_ARCH >= 530
452
+ return half(hexp(a));
453
+ #else
454
+ return half(::expf(float(a)));
455
+ #endif
456
+ }
457
+ EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half log(const half& a) {
458
+ #if defined(EIGEN_HAS_CUDA_FP16) && EIGEN_CUDACC_VER >= 80000 && defined(EIGEN_CUDA_ARCH) && EIGEN_CUDA_ARCH >= 530
459
+ return half(::hlog(a));
460
+ #else
461
+ return half(::logf(float(a)));
462
+ #endif
463
+ }
464
+ EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half log1p(const half& a) {
465
+ return half(numext::log1p(float(a)));
466
+ }
467
+ EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half log10(const half& a) {
468
+ return half(::log10f(float(a)));
469
+ }
470
+ EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half sqrt(const half& a) {
471
+ #if EIGEN_CUDACC_VER >= 80000 && defined EIGEN_CUDA_ARCH && EIGEN_CUDA_ARCH >= 530
472
+ return half(hsqrt(a));
473
+ #else
474
+ return half(::sqrtf(float(a)));
475
+ #endif
476
+ }
477
+ EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half pow(const half& a, const half& b) {
478
+ return half(::powf(float(a), float(b)));
479
+ }
480
+ EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half sin(const half& a) {
481
+ return half(::sinf(float(a)));
482
+ }
483
+ EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half cos(const half& a) {
484
+ return half(::cosf(float(a)));
485
+ }
486
+ EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half tan(const half& a) {
487
+ return half(::tanf(float(a)));
488
+ }
489
+ EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half tanh(const half& a) {
490
+ return half(::tanhf(float(a)));
491
+ }
492
+ EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half floor(const half& a) {
493
+ #if EIGEN_CUDACC_VER >= 80000 && defined EIGEN_CUDA_ARCH && EIGEN_CUDA_ARCH >= 300
494
+ return half(hfloor(a));
495
+ #else
496
+ return half(::floorf(float(a)));
497
+ #endif
498
+ }
499
+ EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half ceil(const half& a) {
500
+ #if EIGEN_CUDACC_VER >= 80000 && defined EIGEN_CUDA_ARCH && EIGEN_CUDA_ARCH >= 300
501
+ return half(hceil(a));
502
+ #else
503
+ return half(::ceilf(float(a)));
504
+ #endif
505
+ }
506
+
507
+ EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half (min)(const half& a, const half& b) {
508
+ #if defined(EIGEN_HAS_CUDA_FP16) && defined(EIGEN_CUDA_ARCH) && EIGEN_CUDA_ARCH >= 530
509
+ return __hlt(b, a) ? b : a;
510
+ #else
511
+ const float f1 = static_cast<float>(a);
512
+ const float f2 = static_cast<float>(b);
513
+ return f2 < f1 ? b : a;
514
+ #endif
515
+ }
516
+ EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half (max)(const half& a, const half& b) {
517
+ #if defined(EIGEN_HAS_CUDA_FP16) && defined(EIGEN_CUDA_ARCH) && EIGEN_CUDA_ARCH >= 530
518
+ return __hlt(a, b) ? b : a;
519
+ #else
520
+ const float f1 = static_cast<float>(a);
521
+ const float f2 = static_cast<float>(b);
522
+ return f1 < f2 ? b : a;
523
+ #endif
524
+ }
525
+
526
+ EIGEN_ALWAYS_INLINE std::ostream& operator << (std::ostream& os, const half& v) {
527
+ os << static_cast<float>(v);
528
+ return os;
529
+ }
530
+
531
+ } // end namespace half_impl
532
+
533
+ // import Eigen::half_impl::half into Eigen namespace
534
+ // using half_impl::half;
535
+
536
+ namespace internal {
537
+
538
+ template<>
539
+ struct random_default_impl<half, false, false>
540
+ {
541
+ static inline half run(const half& x, const half& y)
542
+ {
543
+ return x + (y-x) * half(float(std::rand()) / float(RAND_MAX));
544
+ }
545
+ static inline half run()
546
+ {
547
+ return run(half(-1.f), half(1.f));
548
+ }
549
+ };
550
+
551
+ template<> struct is_arithmetic<half> { enum { value = true }; };
552
+
553
+ } // end namespace internal
554
+
555
+ template<> struct NumTraits<Eigen::half>
556
+ : GenericNumTraits<Eigen::half>
557
+ {
558
+ enum {
559
+ IsSigned = true,
560
+ IsInteger = false,
561
+ IsComplex = false,
562
+ RequireInitialization = false
563
+ };
564
+
565
+ EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE Eigen::half epsilon() {
566
+ return half_impl::raw_uint16_to_half(0x0800);
567
+ }
568
+ EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE Eigen::half dummy_precision() { return Eigen::half(1e-2f); }
569
+ EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE Eigen::half highest() {
570
+ return half_impl::raw_uint16_to_half(0x7bff);
571
+ }
572
+ EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE Eigen::half lowest() {
573
+ return half_impl::raw_uint16_to_half(0xfbff);
574
+ }
575
+ EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE Eigen::half infinity() {
576
+ return half_impl::raw_uint16_to_half(0x7c00);
577
+ }
578
+ EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE Eigen::half quiet_NaN() {
579
+ return half_impl::raw_uint16_to_half(0x7c01);
580
+ }
581
+ };
582
+
583
+ } // end namespace Eigen
584
+
585
+ // C-like standard mathematical functions and trancendentals.
586
+ EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Eigen::half fabsh(const Eigen::half& a) {
587
+ Eigen::half result;
588
+ result.x = a.x & 0x7FFF;
589
+ return result;
590
+ }
591
+ EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Eigen::half exph(const Eigen::half& a) {
592
+ return Eigen::half(::expf(float(a)));
593
+ }
594
+ EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Eigen::half logh(const Eigen::half& a) {
595
+ #if EIGEN_CUDACC_VER >= 80000 && defined(EIGEN_CUDA_ARCH) && EIGEN_CUDA_ARCH >= 530
596
+ return Eigen::half(::hlog(a));
597
+ #else
598
+ return Eigen::half(::logf(float(a)));
599
+ #endif
600
+ }
601
+ EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Eigen::half sqrth(const Eigen::half& a) {
602
+ return Eigen::half(::sqrtf(float(a)));
603
+ }
604
+ EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Eigen::half powh(const Eigen::half& a, const Eigen::half& b) {
605
+ return Eigen::half(::powf(float(a), float(b)));
606
+ }
607
+ EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Eigen::half floorh(const Eigen::half& a) {
608
+ return Eigen::half(::floorf(float(a)));
609
+ }
610
+ EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Eigen::half ceilh(const Eigen::half& a) {
611
+ return Eigen::half(::ceilf(float(a)));
612
+ }
613
+
614
+ namespace std {
615
+
616
+ #if __cplusplus > 199711L
617
+ template <>
618
+ struct hash<Eigen::half> {
619
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE std::size_t operator()(const Eigen::half& a) const {
620
+ return static_cast<std::size_t>(a.x);
621
+ }
622
+ };
623
+ #endif
624
+
625
+ } // end namespace std
626
+
627
+
628
+ // Add the missing shfl_xor intrinsic
629
+ #if defined(EIGEN_CUDA_ARCH) && EIGEN_CUDA_ARCH >= 300
630
+ __device__ EIGEN_STRONG_INLINE Eigen::half __shfl_xor(Eigen::half var, int laneMask, int width=warpSize) {
631
+ #if EIGEN_CUDACC_VER < 90000
632
+ return static_cast<Eigen::half>(__shfl_xor(static_cast<float>(var), laneMask, width));
633
+ #else
634
+ return static_cast<Eigen::half>(__shfl_xor_sync(0xFFFFFFFF, static_cast<float>(var), laneMask, width));
635
+ #endif
636
+ }
637
+ #endif
638
+
639
+ // ldg() has an overload for __half_raw, but we also need one for Eigen::half.
640
+ #if defined(EIGEN_CUDA_ARCH) && EIGEN_CUDA_ARCH >= 350
641
+ EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Eigen::half __ldg(const Eigen::half* ptr) {
642
+ return Eigen::half_impl::raw_uint16_to_half(
643
+ __ldg(reinterpret_cast<const unsigned short*>(ptr)));
644
+ }
645
+ #endif
646
+
647
+
648
+ #if defined(EIGEN_CUDA_ARCH)
649
+ namespace Eigen {
650
+ namespace numext {
651
+
652
+ template<>
653
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
654
+ bool (isnan)(const Eigen::half& h) {
655
+ return (half_impl::isnan)(h);
656
+ }
657
+
658
+ template<>
659
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
660
+ bool (isinf)(const Eigen::half& h) {
661
+ return (half_impl::isinf)(h);
662
+ }
663
+
664
+ template<>
665
+ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
666
+ bool (isfinite)(const Eigen::half& h) {
667
+ return (half_impl::isfinite)(h);
668
+ }
669
+
670
+ } // namespace Eigen
671
+ } // namespace numext
672
+ #endif
673
+
674
+ #endif // EIGEN_HALF_CUDA_H