umappp 0.1.2

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 (395) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +25 -0
  3. data/README.md +110 -0
  4. data/ext/umappp/extconf.rb +25 -0
  5. data/ext/umappp/numo.hpp +867 -0
  6. data/ext/umappp/umappp.cpp +225 -0
  7. data/lib/umappp/version.rb +5 -0
  8. data/lib/umappp.rb +41 -0
  9. data/vendor/Eigen/Cholesky +45 -0
  10. data/vendor/Eigen/CholmodSupport +48 -0
  11. data/vendor/Eigen/Core +384 -0
  12. data/vendor/Eigen/Dense +7 -0
  13. data/vendor/Eigen/Eigen +2 -0
  14. data/vendor/Eigen/Eigenvalues +60 -0
  15. data/vendor/Eigen/Geometry +59 -0
  16. data/vendor/Eigen/Householder +29 -0
  17. data/vendor/Eigen/IterativeLinearSolvers +48 -0
  18. data/vendor/Eigen/Jacobi +32 -0
  19. data/vendor/Eigen/KLUSupport +41 -0
  20. data/vendor/Eigen/LU +47 -0
  21. data/vendor/Eigen/MetisSupport +35 -0
  22. data/vendor/Eigen/OrderingMethods +70 -0
  23. data/vendor/Eigen/PaStiXSupport +49 -0
  24. data/vendor/Eigen/PardisoSupport +35 -0
  25. data/vendor/Eigen/QR +50 -0
  26. data/vendor/Eigen/QtAlignedMalloc +39 -0
  27. data/vendor/Eigen/SPQRSupport +34 -0
  28. data/vendor/Eigen/SVD +50 -0
  29. data/vendor/Eigen/Sparse +34 -0
  30. data/vendor/Eigen/SparseCholesky +37 -0
  31. data/vendor/Eigen/SparseCore +69 -0
  32. data/vendor/Eigen/SparseLU +50 -0
  33. data/vendor/Eigen/SparseQR +36 -0
  34. data/vendor/Eigen/StdDeque +27 -0
  35. data/vendor/Eigen/StdList +26 -0
  36. data/vendor/Eigen/StdVector +27 -0
  37. data/vendor/Eigen/SuperLUSupport +64 -0
  38. data/vendor/Eigen/UmfPackSupport +40 -0
  39. data/vendor/Eigen/src/Cholesky/LDLT.h +688 -0
  40. data/vendor/Eigen/src/Cholesky/LLT.h +558 -0
  41. data/vendor/Eigen/src/Cholesky/LLT_LAPACKE.h +99 -0
  42. data/vendor/Eigen/src/CholmodSupport/CholmodSupport.h +682 -0
  43. data/vendor/Eigen/src/Core/ArithmeticSequence.h +413 -0
  44. data/vendor/Eigen/src/Core/Array.h +417 -0
  45. data/vendor/Eigen/src/Core/ArrayBase.h +226 -0
  46. data/vendor/Eigen/src/Core/ArrayWrapper.h +209 -0
  47. data/vendor/Eigen/src/Core/Assign.h +90 -0
  48. data/vendor/Eigen/src/Core/AssignEvaluator.h +1010 -0
  49. data/vendor/Eigen/src/Core/Assign_MKL.h +178 -0
  50. data/vendor/Eigen/src/Core/BandMatrix.h +353 -0
  51. data/vendor/Eigen/src/Core/Block.h +448 -0
  52. data/vendor/Eigen/src/Core/BooleanRedux.h +162 -0
  53. data/vendor/Eigen/src/Core/CommaInitializer.h +164 -0
  54. data/vendor/Eigen/src/Core/ConditionEstimator.h +175 -0
  55. data/vendor/Eigen/src/Core/CoreEvaluators.h +1741 -0
  56. data/vendor/Eigen/src/Core/CoreIterators.h +132 -0
  57. data/vendor/Eigen/src/Core/CwiseBinaryOp.h +183 -0
  58. data/vendor/Eigen/src/Core/CwiseNullaryOp.h +1001 -0
  59. data/vendor/Eigen/src/Core/CwiseTernaryOp.h +197 -0
  60. data/vendor/Eigen/src/Core/CwiseUnaryOp.h +103 -0
  61. data/vendor/Eigen/src/Core/CwiseUnaryView.h +132 -0
  62. data/vendor/Eigen/src/Core/DenseBase.h +701 -0
  63. data/vendor/Eigen/src/Core/DenseCoeffsBase.h +685 -0
  64. data/vendor/Eigen/src/Core/DenseStorage.h +652 -0
  65. data/vendor/Eigen/src/Core/Diagonal.h +258 -0
  66. data/vendor/Eigen/src/Core/DiagonalMatrix.h +391 -0
  67. data/vendor/Eigen/src/Core/DiagonalProduct.h +28 -0
  68. data/vendor/Eigen/src/Core/Dot.h +318 -0
  69. data/vendor/Eigen/src/Core/EigenBase.h +160 -0
  70. data/vendor/Eigen/src/Core/ForceAlignedAccess.h +150 -0
  71. data/vendor/Eigen/src/Core/Fuzzy.h +155 -0
  72. data/vendor/Eigen/src/Core/GeneralProduct.h +465 -0
  73. data/vendor/Eigen/src/Core/GenericPacketMath.h +1040 -0
  74. data/vendor/Eigen/src/Core/GlobalFunctions.h +194 -0
  75. data/vendor/Eigen/src/Core/IO.h +258 -0
  76. data/vendor/Eigen/src/Core/IndexedView.h +237 -0
  77. data/vendor/Eigen/src/Core/Inverse.h +117 -0
  78. data/vendor/Eigen/src/Core/Map.h +171 -0
  79. data/vendor/Eigen/src/Core/MapBase.h +310 -0
  80. data/vendor/Eigen/src/Core/MathFunctions.h +2057 -0
  81. data/vendor/Eigen/src/Core/MathFunctionsImpl.h +200 -0
  82. data/vendor/Eigen/src/Core/Matrix.h +565 -0
  83. data/vendor/Eigen/src/Core/MatrixBase.h +547 -0
  84. data/vendor/Eigen/src/Core/NestByValue.h +85 -0
  85. data/vendor/Eigen/src/Core/NoAlias.h +109 -0
  86. data/vendor/Eigen/src/Core/NumTraits.h +335 -0
  87. data/vendor/Eigen/src/Core/PartialReduxEvaluator.h +232 -0
  88. data/vendor/Eigen/src/Core/PermutationMatrix.h +605 -0
  89. data/vendor/Eigen/src/Core/PlainObjectBase.h +1128 -0
  90. data/vendor/Eigen/src/Core/Product.h +191 -0
  91. data/vendor/Eigen/src/Core/ProductEvaluators.h +1179 -0
  92. data/vendor/Eigen/src/Core/Random.h +218 -0
  93. data/vendor/Eigen/src/Core/Redux.h +515 -0
  94. data/vendor/Eigen/src/Core/Ref.h +381 -0
  95. data/vendor/Eigen/src/Core/Replicate.h +142 -0
  96. data/vendor/Eigen/src/Core/Reshaped.h +454 -0
  97. data/vendor/Eigen/src/Core/ReturnByValue.h +119 -0
  98. data/vendor/Eigen/src/Core/Reverse.h +217 -0
  99. data/vendor/Eigen/src/Core/Select.h +164 -0
  100. data/vendor/Eigen/src/Core/SelfAdjointView.h +365 -0
  101. data/vendor/Eigen/src/Core/SelfCwiseBinaryOp.h +47 -0
  102. data/vendor/Eigen/src/Core/Solve.h +188 -0
  103. data/vendor/Eigen/src/Core/SolveTriangular.h +235 -0
  104. data/vendor/Eigen/src/Core/SolverBase.h +168 -0
  105. data/vendor/Eigen/src/Core/StableNorm.h +251 -0
  106. data/vendor/Eigen/src/Core/StlIterators.h +463 -0
  107. data/vendor/Eigen/src/Core/Stride.h +116 -0
  108. data/vendor/Eigen/src/Core/Swap.h +68 -0
  109. data/vendor/Eigen/src/Core/Transpose.h +464 -0
  110. data/vendor/Eigen/src/Core/Transpositions.h +386 -0
  111. data/vendor/Eigen/src/Core/TriangularMatrix.h +1001 -0
  112. data/vendor/Eigen/src/Core/VectorBlock.h +96 -0
  113. data/vendor/Eigen/src/Core/VectorwiseOp.h +784 -0
  114. data/vendor/Eigen/src/Core/Visitor.h +381 -0
  115. data/vendor/Eigen/src/Core/arch/AVX/Complex.h +372 -0
  116. data/vendor/Eigen/src/Core/arch/AVX/MathFunctions.h +228 -0
  117. data/vendor/Eigen/src/Core/arch/AVX/PacketMath.h +1574 -0
  118. data/vendor/Eigen/src/Core/arch/AVX/TypeCasting.h +115 -0
  119. data/vendor/Eigen/src/Core/arch/AVX512/Complex.h +422 -0
  120. data/vendor/Eigen/src/Core/arch/AVX512/MathFunctions.h +362 -0
  121. data/vendor/Eigen/src/Core/arch/AVX512/PacketMath.h +2303 -0
  122. data/vendor/Eigen/src/Core/arch/AVX512/TypeCasting.h +89 -0
  123. data/vendor/Eigen/src/Core/arch/AltiVec/Complex.h +417 -0
  124. data/vendor/Eigen/src/Core/arch/AltiVec/MathFunctions.h +90 -0
  125. data/vendor/Eigen/src/Core/arch/AltiVec/MatrixProduct.h +2937 -0
  126. data/vendor/Eigen/src/Core/arch/AltiVec/MatrixProductCommon.h +221 -0
  127. data/vendor/Eigen/src/Core/arch/AltiVec/MatrixProductMMA.h +629 -0
  128. data/vendor/Eigen/src/Core/arch/AltiVec/PacketMath.h +2711 -0
  129. data/vendor/Eigen/src/Core/arch/CUDA/Complex.h +258 -0
  130. data/vendor/Eigen/src/Core/arch/Default/BFloat16.h +700 -0
  131. data/vendor/Eigen/src/Core/arch/Default/ConjHelper.h +117 -0
  132. data/vendor/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h +1649 -0
  133. data/vendor/Eigen/src/Core/arch/Default/GenericPacketMathFunctionsFwd.h +110 -0
  134. data/vendor/Eigen/src/Core/arch/Default/Half.h +942 -0
  135. data/vendor/Eigen/src/Core/arch/Default/Settings.h +49 -0
  136. data/vendor/Eigen/src/Core/arch/Default/TypeCasting.h +120 -0
  137. data/vendor/Eigen/src/Core/arch/GPU/MathFunctions.h +103 -0
  138. data/vendor/Eigen/src/Core/arch/GPU/PacketMath.h +1685 -0
  139. data/vendor/Eigen/src/Core/arch/GPU/TypeCasting.h +80 -0
  140. data/vendor/Eigen/src/Core/arch/HIP/hcc/math_constants.h +23 -0
  141. data/vendor/Eigen/src/Core/arch/MSA/Complex.h +648 -0
  142. data/vendor/Eigen/src/Core/arch/MSA/MathFunctions.h +387 -0
  143. data/vendor/Eigen/src/Core/arch/MSA/PacketMath.h +1233 -0
  144. data/vendor/Eigen/src/Core/arch/NEON/Complex.h +584 -0
  145. data/vendor/Eigen/src/Core/arch/NEON/GeneralBlockPanelKernel.h +183 -0
  146. data/vendor/Eigen/src/Core/arch/NEON/MathFunctions.h +75 -0
  147. data/vendor/Eigen/src/Core/arch/NEON/PacketMath.h +4587 -0
  148. data/vendor/Eigen/src/Core/arch/NEON/TypeCasting.h +1419 -0
  149. data/vendor/Eigen/src/Core/arch/SSE/Complex.h +351 -0
  150. data/vendor/Eigen/src/Core/arch/SSE/MathFunctions.h +199 -0
  151. data/vendor/Eigen/src/Core/arch/SSE/PacketMath.h +1505 -0
  152. data/vendor/Eigen/src/Core/arch/SSE/TypeCasting.h +142 -0
  153. data/vendor/Eigen/src/Core/arch/SVE/MathFunctions.h +44 -0
  154. data/vendor/Eigen/src/Core/arch/SVE/PacketMath.h +752 -0
  155. data/vendor/Eigen/src/Core/arch/SVE/TypeCasting.h +49 -0
  156. data/vendor/Eigen/src/Core/arch/SYCL/InteropHeaders.h +232 -0
  157. data/vendor/Eigen/src/Core/arch/SYCL/MathFunctions.h +301 -0
  158. data/vendor/Eigen/src/Core/arch/SYCL/PacketMath.h +670 -0
  159. data/vendor/Eigen/src/Core/arch/SYCL/SyclMemoryModel.h +694 -0
  160. data/vendor/Eigen/src/Core/arch/SYCL/TypeCasting.h +85 -0
  161. data/vendor/Eigen/src/Core/arch/ZVector/Complex.h +426 -0
  162. data/vendor/Eigen/src/Core/arch/ZVector/MathFunctions.h +233 -0
  163. data/vendor/Eigen/src/Core/arch/ZVector/PacketMath.h +1060 -0
  164. data/vendor/Eigen/src/Core/functors/AssignmentFunctors.h +177 -0
  165. data/vendor/Eigen/src/Core/functors/BinaryFunctors.h +541 -0
  166. data/vendor/Eigen/src/Core/functors/NullaryFunctors.h +189 -0
  167. data/vendor/Eigen/src/Core/functors/StlFunctors.h +166 -0
  168. data/vendor/Eigen/src/Core/functors/TernaryFunctors.h +25 -0
  169. data/vendor/Eigen/src/Core/functors/UnaryFunctors.h +1131 -0
  170. data/vendor/Eigen/src/Core/products/GeneralBlockPanelKernel.h +2645 -0
  171. data/vendor/Eigen/src/Core/products/GeneralMatrixMatrix.h +517 -0
  172. data/vendor/Eigen/src/Core/products/GeneralMatrixMatrixTriangular.h +317 -0
  173. data/vendor/Eigen/src/Core/products/GeneralMatrixMatrixTriangular_BLAS.h +145 -0
  174. data/vendor/Eigen/src/Core/products/GeneralMatrixMatrix_BLAS.h +124 -0
  175. data/vendor/Eigen/src/Core/products/GeneralMatrixVector.h +518 -0
  176. data/vendor/Eigen/src/Core/products/GeneralMatrixVector_BLAS.h +136 -0
  177. data/vendor/Eigen/src/Core/products/Parallelizer.h +180 -0
  178. data/vendor/Eigen/src/Core/products/SelfadjointMatrixMatrix.h +544 -0
  179. data/vendor/Eigen/src/Core/products/SelfadjointMatrixMatrix_BLAS.h +295 -0
  180. data/vendor/Eigen/src/Core/products/SelfadjointMatrixVector.h +262 -0
  181. data/vendor/Eigen/src/Core/products/SelfadjointMatrixVector_BLAS.h +118 -0
  182. data/vendor/Eigen/src/Core/products/SelfadjointProduct.h +133 -0
  183. data/vendor/Eigen/src/Core/products/SelfadjointRank2Update.h +94 -0
  184. data/vendor/Eigen/src/Core/products/TriangularMatrixMatrix.h +472 -0
  185. data/vendor/Eigen/src/Core/products/TriangularMatrixMatrix_BLAS.h +317 -0
  186. data/vendor/Eigen/src/Core/products/TriangularMatrixVector.h +350 -0
  187. data/vendor/Eigen/src/Core/products/TriangularMatrixVector_BLAS.h +255 -0
  188. data/vendor/Eigen/src/Core/products/TriangularSolverMatrix.h +337 -0
  189. data/vendor/Eigen/src/Core/products/TriangularSolverMatrix_BLAS.h +167 -0
  190. data/vendor/Eigen/src/Core/products/TriangularSolverVector.h +148 -0
  191. data/vendor/Eigen/src/Core/util/BlasUtil.h +583 -0
  192. data/vendor/Eigen/src/Core/util/ConfigureVectorization.h +512 -0
  193. data/vendor/Eigen/src/Core/util/Constants.h +563 -0
  194. data/vendor/Eigen/src/Core/util/DisableStupidWarnings.h +106 -0
  195. data/vendor/Eigen/src/Core/util/ForwardDeclarations.h +322 -0
  196. data/vendor/Eigen/src/Core/util/IndexedViewHelper.h +186 -0
  197. data/vendor/Eigen/src/Core/util/IntegralConstant.h +272 -0
  198. data/vendor/Eigen/src/Core/util/MKL_support.h +137 -0
  199. data/vendor/Eigen/src/Core/util/Macros.h +1464 -0
  200. data/vendor/Eigen/src/Core/util/Memory.h +1163 -0
  201. data/vendor/Eigen/src/Core/util/Meta.h +812 -0
  202. data/vendor/Eigen/src/Core/util/NonMPL2.h +3 -0
  203. data/vendor/Eigen/src/Core/util/ReenableStupidWarnings.h +31 -0
  204. data/vendor/Eigen/src/Core/util/ReshapedHelper.h +51 -0
  205. data/vendor/Eigen/src/Core/util/StaticAssert.h +221 -0
  206. data/vendor/Eigen/src/Core/util/SymbolicIndex.h +293 -0
  207. data/vendor/Eigen/src/Core/util/XprHelper.h +856 -0
  208. data/vendor/Eigen/src/Eigenvalues/ComplexEigenSolver.h +346 -0
  209. data/vendor/Eigen/src/Eigenvalues/ComplexSchur.h +462 -0
  210. data/vendor/Eigen/src/Eigenvalues/ComplexSchur_LAPACKE.h +91 -0
  211. data/vendor/Eigen/src/Eigenvalues/EigenSolver.h +622 -0
  212. data/vendor/Eigen/src/Eigenvalues/GeneralizedEigenSolver.h +418 -0
  213. data/vendor/Eigen/src/Eigenvalues/GeneralizedSelfAdjointEigenSolver.h +226 -0
  214. data/vendor/Eigen/src/Eigenvalues/HessenbergDecomposition.h +374 -0
  215. data/vendor/Eigen/src/Eigenvalues/MatrixBaseEigenvalues.h +158 -0
  216. data/vendor/Eigen/src/Eigenvalues/RealQZ.h +657 -0
  217. data/vendor/Eigen/src/Eigenvalues/RealSchur.h +558 -0
  218. data/vendor/Eigen/src/Eigenvalues/RealSchur_LAPACKE.h +77 -0
  219. data/vendor/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h +904 -0
  220. data/vendor/Eigen/src/Eigenvalues/SelfAdjointEigenSolver_LAPACKE.h +87 -0
  221. data/vendor/Eigen/src/Eigenvalues/Tridiagonalization.h +561 -0
  222. data/vendor/Eigen/src/Geometry/AlignedBox.h +486 -0
  223. data/vendor/Eigen/src/Geometry/AngleAxis.h +247 -0
  224. data/vendor/Eigen/src/Geometry/EulerAngles.h +114 -0
  225. data/vendor/Eigen/src/Geometry/Homogeneous.h +501 -0
  226. data/vendor/Eigen/src/Geometry/Hyperplane.h +282 -0
  227. data/vendor/Eigen/src/Geometry/OrthoMethods.h +235 -0
  228. data/vendor/Eigen/src/Geometry/ParametrizedLine.h +232 -0
  229. data/vendor/Eigen/src/Geometry/Quaternion.h +870 -0
  230. data/vendor/Eigen/src/Geometry/Rotation2D.h +199 -0
  231. data/vendor/Eigen/src/Geometry/RotationBase.h +206 -0
  232. data/vendor/Eigen/src/Geometry/Scaling.h +188 -0
  233. data/vendor/Eigen/src/Geometry/Transform.h +1563 -0
  234. data/vendor/Eigen/src/Geometry/Translation.h +202 -0
  235. data/vendor/Eigen/src/Geometry/Umeyama.h +166 -0
  236. data/vendor/Eigen/src/Geometry/arch/Geometry_SIMD.h +168 -0
  237. data/vendor/Eigen/src/Householder/BlockHouseholder.h +110 -0
  238. data/vendor/Eigen/src/Householder/Householder.h +176 -0
  239. data/vendor/Eigen/src/Householder/HouseholderSequence.h +545 -0
  240. data/vendor/Eigen/src/IterativeLinearSolvers/BasicPreconditioners.h +226 -0
  241. data/vendor/Eigen/src/IterativeLinearSolvers/BiCGSTAB.h +212 -0
  242. data/vendor/Eigen/src/IterativeLinearSolvers/ConjugateGradient.h +229 -0
  243. data/vendor/Eigen/src/IterativeLinearSolvers/IncompleteCholesky.h +394 -0
  244. data/vendor/Eigen/src/IterativeLinearSolvers/IncompleteLUT.h +453 -0
  245. data/vendor/Eigen/src/IterativeLinearSolvers/IterativeSolverBase.h +444 -0
  246. data/vendor/Eigen/src/IterativeLinearSolvers/LeastSquareConjugateGradient.h +198 -0
  247. data/vendor/Eigen/src/IterativeLinearSolvers/SolveWithGuess.h +117 -0
  248. data/vendor/Eigen/src/Jacobi/Jacobi.h +483 -0
  249. data/vendor/Eigen/src/KLUSupport/KLUSupport.h +358 -0
  250. data/vendor/Eigen/src/LU/Determinant.h +117 -0
  251. data/vendor/Eigen/src/LU/FullPivLU.h +877 -0
  252. data/vendor/Eigen/src/LU/InverseImpl.h +432 -0
  253. data/vendor/Eigen/src/LU/PartialPivLU.h +624 -0
  254. data/vendor/Eigen/src/LU/PartialPivLU_LAPACKE.h +83 -0
  255. data/vendor/Eigen/src/LU/arch/InverseSize4.h +351 -0
  256. data/vendor/Eigen/src/MetisSupport/MetisSupport.h +137 -0
  257. data/vendor/Eigen/src/OrderingMethods/Amd.h +435 -0
  258. data/vendor/Eigen/src/OrderingMethods/Eigen_Colamd.h +1863 -0
  259. data/vendor/Eigen/src/OrderingMethods/Ordering.h +153 -0
  260. data/vendor/Eigen/src/PaStiXSupport/PaStiXSupport.h +678 -0
  261. data/vendor/Eigen/src/PardisoSupport/PardisoSupport.h +545 -0
  262. data/vendor/Eigen/src/QR/ColPivHouseholderQR.h +674 -0
  263. data/vendor/Eigen/src/QR/ColPivHouseholderQR_LAPACKE.h +97 -0
  264. data/vendor/Eigen/src/QR/CompleteOrthogonalDecomposition.h +635 -0
  265. data/vendor/Eigen/src/QR/FullPivHouseholderQR.h +713 -0
  266. data/vendor/Eigen/src/QR/HouseholderQR.h +434 -0
  267. data/vendor/Eigen/src/QR/HouseholderQR_LAPACKE.h +68 -0
  268. data/vendor/Eigen/src/SPQRSupport/SuiteSparseQRSupport.h +335 -0
  269. data/vendor/Eigen/src/SVD/BDCSVD.h +1366 -0
  270. data/vendor/Eigen/src/SVD/JacobiSVD.h +812 -0
  271. data/vendor/Eigen/src/SVD/JacobiSVD_LAPACKE.h +91 -0
  272. data/vendor/Eigen/src/SVD/SVDBase.h +376 -0
  273. data/vendor/Eigen/src/SVD/UpperBidiagonalization.h +414 -0
  274. data/vendor/Eigen/src/SparseCholesky/SimplicialCholesky.h +697 -0
  275. data/vendor/Eigen/src/SparseCholesky/SimplicialCholesky_impl.h +174 -0
  276. data/vendor/Eigen/src/SparseCore/AmbiVector.h +378 -0
  277. data/vendor/Eigen/src/SparseCore/CompressedStorage.h +274 -0
  278. data/vendor/Eigen/src/SparseCore/ConservativeSparseSparseProduct.h +352 -0
  279. data/vendor/Eigen/src/SparseCore/MappedSparseMatrix.h +67 -0
  280. data/vendor/Eigen/src/SparseCore/SparseAssign.h +270 -0
  281. data/vendor/Eigen/src/SparseCore/SparseBlock.h +571 -0
  282. data/vendor/Eigen/src/SparseCore/SparseColEtree.h +206 -0
  283. data/vendor/Eigen/src/SparseCore/SparseCompressedBase.h +370 -0
  284. data/vendor/Eigen/src/SparseCore/SparseCwiseBinaryOp.h +722 -0
  285. data/vendor/Eigen/src/SparseCore/SparseCwiseUnaryOp.h +150 -0
  286. data/vendor/Eigen/src/SparseCore/SparseDenseProduct.h +342 -0
  287. data/vendor/Eigen/src/SparseCore/SparseDiagonalProduct.h +138 -0
  288. data/vendor/Eigen/src/SparseCore/SparseDot.h +98 -0
  289. data/vendor/Eigen/src/SparseCore/SparseFuzzy.h +29 -0
  290. data/vendor/Eigen/src/SparseCore/SparseMap.h +305 -0
  291. data/vendor/Eigen/src/SparseCore/SparseMatrix.h +1518 -0
  292. data/vendor/Eigen/src/SparseCore/SparseMatrixBase.h +398 -0
  293. data/vendor/Eigen/src/SparseCore/SparsePermutation.h +178 -0
  294. data/vendor/Eigen/src/SparseCore/SparseProduct.h +181 -0
  295. data/vendor/Eigen/src/SparseCore/SparseRedux.h +49 -0
  296. data/vendor/Eigen/src/SparseCore/SparseRef.h +397 -0
  297. data/vendor/Eigen/src/SparseCore/SparseSelfAdjointView.h +659 -0
  298. data/vendor/Eigen/src/SparseCore/SparseSolverBase.h +124 -0
  299. data/vendor/Eigen/src/SparseCore/SparseSparseProductWithPruning.h +198 -0
  300. data/vendor/Eigen/src/SparseCore/SparseTranspose.h +92 -0
  301. data/vendor/Eigen/src/SparseCore/SparseTriangularView.h +189 -0
  302. data/vendor/Eigen/src/SparseCore/SparseUtil.h +186 -0
  303. data/vendor/Eigen/src/SparseCore/SparseVector.h +478 -0
  304. data/vendor/Eigen/src/SparseCore/SparseView.h +254 -0
  305. data/vendor/Eigen/src/SparseCore/TriangularSolver.h +315 -0
  306. data/vendor/Eigen/src/SparseLU/SparseLU.h +923 -0
  307. data/vendor/Eigen/src/SparseLU/SparseLUImpl.h +66 -0
  308. data/vendor/Eigen/src/SparseLU/SparseLU_Memory.h +226 -0
  309. data/vendor/Eigen/src/SparseLU/SparseLU_Structs.h +110 -0
  310. data/vendor/Eigen/src/SparseLU/SparseLU_SupernodalMatrix.h +375 -0
  311. data/vendor/Eigen/src/SparseLU/SparseLU_Utils.h +80 -0
  312. data/vendor/Eigen/src/SparseLU/SparseLU_column_bmod.h +181 -0
  313. data/vendor/Eigen/src/SparseLU/SparseLU_column_dfs.h +179 -0
  314. data/vendor/Eigen/src/SparseLU/SparseLU_copy_to_ucol.h +107 -0
  315. data/vendor/Eigen/src/SparseLU/SparseLU_gemm_kernel.h +280 -0
  316. data/vendor/Eigen/src/SparseLU/SparseLU_heap_relax_snode.h +126 -0
  317. data/vendor/Eigen/src/SparseLU/SparseLU_kernel_bmod.h +130 -0
  318. data/vendor/Eigen/src/SparseLU/SparseLU_panel_bmod.h +223 -0
  319. data/vendor/Eigen/src/SparseLU/SparseLU_panel_dfs.h +258 -0
  320. data/vendor/Eigen/src/SparseLU/SparseLU_pivotL.h +137 -0
  321. data/vendor/Eigen/src/SparseLU/SparseLU_pruneL.h +136 -0
  322. data/vendor/Eigen/src/SparseLU/SparseLU_relax_snode.h +83 -0
  323. data/vendor/Eigen/src/SparseQR/SparseQR.h +758 -0
  324. data/vendor/Eigen/src/StlSupport/StdDeque.h +116 -0
  325. data/vendor/Eigen/src/StlSupport/StdList.h +106 -0
  326. data/vendor/Eigen/src/StlSupport/StdVector.h +131 -0
  327. data/vendor/Eigen/src/StlSupport/details.h +84 -0
  328. data/vendor/Eigen/src/SuperLUSupport/SuperLUSupport.h +1025 -0
  329. data/vendor/Eigen/src/UmfPackSupport/UmfPackSupport.h +642 -0
  330. data/vendor/Eigen/src/misc/Image.h +82 -0
  331. data/vendor/Eigen/src/misc/Kernel.h +79 -0
  332. data/vendor/Eigen/src/misc/RealSvd2x2.h +55 -0
  333. data/vendor/Eigen/src/misc/blas.h +440 -0
  334. data/vendor/Eigen/src/misc/lapack.h +152 -0
  335. data/vendor/Eigen/src/misc/lapacke.h +16292 -0
  336. data/vendor/Eigen/src/misc/lapacke_mangling.h +17 -0
  337. data/vendor/Eigen/src/plugins/ArrayCwiseBinaryOps.h +358 -0
  338. data/vendor/Eigen/src/plugins/ArrayCwiseUnaryOps.h +696 -0
  339. data/vendor/Eigen/src/plugins/BlockMethods.h +1442 -0
  340. data/vendor/Eigen/src/plugins/CommonCwiseBinaryOps.h +115 -0
  341. data/vendor/Eigen/src/plugins/CommonCwiseUnaryOps.h +177 -0
  342. data/vendor/Eigen/src/plugins/IndexedViewMethods.h +262 -0
  343. data/vendor/Eigen/src/plugins/MatrixCwiseBinaryOps.h +152 -0
  344. data/vendor/Eigen/src/plugins/MatrixCwiseUnaryOps.h +95 -0
  345. data/vendor/Eigen/src/plugins/ReshapedMethods.h +149 -0
  346. data/vendor/aarand/aarand.hpp +114 -0
  347. data/vendor/annoy/annoylib.h +1495 -0
  348. data/vendor/annoy/kissrandom.h +120 -0
  349. data/vendor/annoy/mman.h +242 -0
  350. data/vendor/hnswlib/bruteforce.h +152 -0
  351. data/vendor/hnswlib/hnswalg.h +1192 -0
  352. data/vendor/hnswlib/hnswlib.h +108 -0
  353. data/vendor/hnswlib/space_ip.h +282 -0
  354. data/vendor/hnswlib/space_l2.h +281 -0
  355. data/vendor/hnswlib/visited_list_pool.h +79 -0
  356. data/vendor/irlba/irlba.hpp +575 -0
  357. data/vendor/irlba/lanczos.hpp +212 -0
  358. data/vendor/irlba/parallel.hpp +474 -0
  359. data/vendor/irlba/utils.hpp +224 -0
  360. data/vendor/irlba/wrappers.hpp +228 -0
  361. data/vendor/kmeans/Base.hpp +75 -0
  362. data/vendor/kmeans/Details.hpp +79 -0
  363. data/vendor/kmeans/HartiganWong.hpp +492 -0
  364. data/vendor/kmeans/InitializeKmeansPP.hpp +144 -0
  365. data/vendor/kmeans/InitializeNone.hpp +44 -0
  366. data/vendor/kmeans/InitializePCAPartition.hpp +309 -0
  367. data/vendor/kmeans/InitializeRandom.hpp +91 -0
  368. data/vendor/kmeans/Kmeans.hpp +161 -0
  369. data/vendor/kmeans/Lloyd.hpp +134 -0
  370. data/vendor/kmeans/MiniBatch.hpp +269 -0
  371. data/vendor/kmeans/QuickSearch.hpp +179 -0
  372. data/vendor/kmeans/compute_centroids.hpp +32 -0
  373. data/vendor/kmeans/compute_wcss.hpp +27 -0
  374. data/vendor/kmeans/is_edge_case.hpp +42 -0
  375. data/vendor/kmeans/random.hpp +55 -0
  376. data/vendor/knncolle/Annoy/Annoy.hpp +193 -0
  377. data/vendor/knncolle/BruteForce/BruteForce.hpp +120 -0
  378. data/vendor/knncolle/Hnsw/Hnsw.hpp +225 -0
  379. data/vendor/knncolle/Kmknn/Kmknn.hpp +286 -0
  380. data/vendor/knncolle/VpTree/VpTree.hpp +256 -0
  381. data/vendor/knncolle/knncolle.hpp +34 -0
  382. data/vendor/knncolle/utils/Base.hpp +100 -0
  383. data/vendor/knncolle/utils/NeighborQueue.hpp +94 -0
  384. data/vendor/knncolle/utils/distances.hpp +98 -0
  385. data/vendor/knncolle/utils/find_nearest_neighbors.hpp +112 -0
  386. data/vendor/powerit/PowerIterations.hpp +157 -0
  387. data/vendor/umappp/NeighborList.hpp +37 -0
  388. data/vendor/umappp/Umap.hpp +662 -0
  389. data/vendor/umappp/combine_neighbor_sets.hpp +95 -0
  390. data/vendor/umappp/find_ab.hpp +157 -0
  391. data/vendor/umappp/neighbor_similarities.hpp +136 -0
  392. data/vendor/umappp/optimize_layout.hpp +285 -0
  393. data/vendor/umappp/spectral_init.hpp +181 -0
  394. data/vendor/umappp/umappp.hpp +13 -0
  395. metadata +465 -0
@@ -0,0 +1,662 @@
1
+ #ifndef UMAPPP_UMAP_HPP
2
+ #define UMAPPP_UMAP_HPP
3
+
4
+ #include "NeighborList.hpp"
5
+ #include "combine_neighbor_sets.hpp"
6
+ #include "find_ab.hpp"
7
+ #include "neighbor_similarities.hpp"
8
+ #include "optimize_layout.hpp"
9
+ #include "spectral_init.hpp"
10
+
11
+ #ifndef UMAPPP_CUSTOM_NEIGHBORS
12
+ #include "knncolle/knncolle.hpp"
13
+ #endif
14
+
15
+ #include <random>
16
+ #include <cstdint>
17
+
18
+ /**
19
+ * @file Umap.hpp
20
+ *
21
+ * @brief Run the UMAP algorithm.
22
+ */
23
+
24
+ namespace umappp {
25
+
26
+ /**
27
+ * How should the initial coordinates of the embedding be obtained?
28
+ *
29
+ * - `SPECTRAL`: attempts initialization based on spectral decomposition of the graph Laplacian.
30
+ * If that fails, we fall back to random draws from a normal distribution.
31
+ * - `SPECTRAL_ONLY`: attempts spectral initialization as before,
32
+ * but if that fails, we use the existing values in the supplied embedding array.
33
+ * - `RANDOM`: fills the embedding with random draws from a normal distribution.
34
+ * - `NONE`: uses the existing values in the supplied embedding array.
35
+ */
36
+ enum InitMethod { SPECTRAL, SPECTRAL_ONLY, RANDOM, NONE };
37
+
38
+ /**
39
+ * @cond
40
+ */
41
+ int choose_num_epochs(int num_epochs, size_t size) {
42
+ if (num_epochs < 0) {
43
+ // Choosing the number of epochs. We use a simple formula to decrease
44
+ // the number of epochs with increasing size, with the aim being that
45
+ // the 'extra work' beyond the minimal 200 epochs should be the same
46
+ // regardless of the numbe of observations. Given one calculation per
47
+ // observation per epoch, this amounts to 300 * 10000 calculations at
48
+ // the lower bound, so we simply choose a number of epochs that
49
+ // equalizes the number of calculations for any number of observations.
50
+ if (num_epochs < 0) {
51
+ constexpr int limit = 10000, minimal = 200, maximal = 300;
52
+ if (size <= limit) {
53
+ num_epochs = minimal + maximal;
54
+ } else {
55
+ num_epochs = minimal + static_cast<int>(std::ceil(maximal * limit / static_cast<double>(size)));
56
+ }
57
+ }
58
+ }
59
+ return num_epochs;
60
+ }
61
+ /**
62
+ * @endcond
63
+ */
64
+
65
+ /**
66
+ * @brief Wrapper class to run UMAP.
67
+ *
68
+ * The Uniform Manifold Approximation and Projection (UMAP) algorithm is an efficient dimensionality reduction method based on nearest neighbors.
69
+ * The general idea is to find a low-dimensional embedding that preserves the neighborhood of each observation from the original space;
70
+ * this is achieved by applying attractive forces between each observation and its neighbors while repelling to all other cells.
71
+ * Further theoretical details can be found in the [original UMAP documentation](https://umap-learn.readthedocs.io/en/latest/how_umap_works.html),
72
+ * though this particular implementation is derived from the C++ code in the [**uwot** R package](https://github.com/jlmelville/uwot).
73
+ *
74
+ * @tparam Float Floating-point type.
75
+ * Defaults to `double` to be conservative, but most applications can make do with `float` for some extra speed.
76
+ *
77
+ * @see
78
+ * McInnes L, Healy J and Melville J (2020).
79
+ * UMAP: Uniform Manifold Approximation and Projection for Dimension Reduction.
80
+ * _arXiv_, https://arxiv.org/abs/1802.03426
81
+ */
82
+ template<typename Float = double>
83
+ class Umap {
84
+ public:
85
+ /**
86
+ * @brief Default values for all UMAP parameters.
87
+ */
88
+ struct Defaults {
89
+ /**
90
+ * See `set_local_connectivity()`.
91
+ */
92
+ static constexpr Float local_connectivity = 1.0;
93
+
94
+ /**
95
+ * See `set_bandwidth()`.
96
+ */
97
+ static constexpr Float bandwidth = 1;
98
+
99
+ /**
100
+ * See `set_mix_ratio()`.
101
+ */
102
+ static constexpr Float mix_ratio = 1;
103
+
104
+ /**
105
+ * See `set_spread()`.
106
+ */
107
+ static constexpr Float spread = 1;
108
+
109
+ /**
110
+ * See `set_min_dist()`.
111
+ */
112
+ static constexpr Float min_dist = 0.01;
113
+
114
+ /**
115
+ * See `set_a()`.
116
+ */
117
+ static constexpr Float a = 0;
118
+
119
+ /**
120
+ * See `set_b()`.
121
+ */
122
+ static constexpr Float b = 0;
123
+
124
+ /**
125
+ * See `set_repulsion_strength()`.
126
+ */
127
+ static constexpr Float repulsion_strength = 1;
128
+
129
+ /**
130
+ * See `set_initialize()`.
131
+ */
132
+ static constexpr InitMethod initialize = SPECTRAL;
133
+
134
+ /**
135
+ * See `set_num_epochs()`.
136
+ */
137
+ static constexpr int num_epochs = -1;
138
+
139
+ /**
140
+ * See `set_learning_rate()`.
141
+ */
142
+ static constexpr Float learning_rate = 1;
143
+
144
+ /**
145
+ * See `set_negative_sample_rate()`.
146
+ */
147
+ static constexpr Float negative_sample_rate = 5;
148
+
149
+ /**
150
+ * See `set_num_neighbors()`.
151
+ */
152
+ static constexpr int num_neighbors = 15;
153
+
154
+ /**
155
+ * See `set_seed()`.
156
+ */
157
+ static constexpr uint64_t seed = 1234567890;
158
+
159
+ /**
160
+ * See `set_batch()`.
161
+ */
162
+ static constexpr bool batch = false;
163
+
164
+ /**
165
+ * See `set_num_threads()`.
166
+ */
167
+ static constexpr int num_threads = 1;
168
+ };
169
+
170
+ private:
171
+ InitMethod init = Defaults::initialize;
172
+ int num_neighbors = Defaults::num_neighbors;
173
+ Float local_connectivity = Defaults::local_connectivity;
174
+ Float bandwidth = Defaults::bandwidth;
175
+ Float mix_ratio = Defaults::mix_ratio;
176
+ Float spread = Defaults::spread;
177
+ Float min_dist = Defaults::min_dist;
178
+ int num_epochs = Defaults::num_epochs;
179
+ Float negative_sample_rate = Defaults::negative_sample_rate;
180
+ uint64_t seed = Defaults::seed;
181
+
182
+ struct RuntimeParameters {
183
+ Float a = Defaults::a;
184
+ Float b = Defaults::b;
185
+ Float repulsion_strength = Defaults::repulsion_strength;
186
+ Float learning_rate = Defaults::learning_rate;
187
+ bool batch = Defaults::batch;
188
+ int nthreads = Defaults::num_threads;
189
+ };
190
+
191
+ RuntimeParameters rparams;
192
+
193
+ public:
194
+ /**
195
+ * @param i How to initialize the embedding, see `InitMethod` for more details.
196
+ * Some choices may use the existing coordinates provided to `run()` via the `embedding` argument.
197
+ *
198
+ * @return A reference to this `Umap` object.
199
+ */
200
+ Umap& set_initialize(InitMethod i = Defaults::initialize) {
201
+ init = i;
202
+ return *this;
203
+ }
204
+
205
+ /**
206
+ * @param n Number of neighbors to use to define the fuzzy sets.
207
+ * Larger values improve connectivity and favor preservation of global structure, at the cost of increased computational work.
208
+ * This argument is only used in certain `run()` and `initialize()` methods that perform identification of the nearest neighbors.
209
+ *
210
+ * @return A reference to this `Umap` object.
211
+ */
212
+ Umap& set_num_neighbors(Float n = Defaults::num_neighbors) {
213
+ num_neighbors = n;
214
+ return *this;
215
+ }
216
+
217
+ /**
218
+ * @param l The number of nearest neighbors that are assumed to be always connected, with maximum membership confidence.
219
+ * Larger values increase the connectivity of the embedding and reduce the focus on local structure.
220
+ *
221
+ * @return A reference to this `Umap` object.
222
+ */
223
+ Umap& set_local_connectivity(Float l = Defaults::local_connectivity) {
224
+ local_connectivity = l;
225
+ return *this;
226
+ }
227
+
228
+ /**
229
+ * @param b Effective bandwidth of the kernel when converting the distance to a neighbor into a fuzzy set membership confidence.
230
+ * Larger values reduce the decay in confidence with respect to distance, increasing connectivity and favoring global structure.
231
+ *
232
+ * @return A reference to this `Umap` object.
233
+ */
234
+ Umap& set_bandwidth(Float b = Defaults::bandwidth) {
235
+ bandwidth = b;
236
+ return *this;
237
+ }
238
+
239
+ /**
240
+ * @param m Mixing ratio to use when combining fuzzy sets.
241
+ * This symmetrizes the sets by ensuring that the confidence of $A$ belonging to $B$'s set is the same as the confidence of $B$ belonging to $A$'s set.
242
+ * A mixing ratio of 1 will take the union of confidences, a ratio of 0 will take the intersection, and intermediate values will interpolate between them.
243
+ * Larger values (up to 1) favor connectivity and more global structure.
244
+ *
245
+ * @return A reference to this `Umap` object.
246
+ */
247
+ Umap& set_mix_ratio(Float m = Defaults::mix_ratio) {
248
+ mix_ratio = m;
249
+ return *this;
250
+ }
251
+
252
+ /**
253
+ * @param s Scale of the coordinates of the final low-dimensional embedding.
254
+ *
255
+ * @return A reference to this `Umap` object.
256
+ */
257
+ Umap& set_spread(Float s = Defaults::spread) {
258
+ spread = s;
259
+ return *this;
260
+ }
261
+
262
+ /**
263
+ * @param m Minimum distance between observations in the final low-dimensional embedding.
264
+ * Smaller values will increase local clustering while larger values favors a more even distribution.
265
+ * This is interpreted relative to the spread of points in `set_spread()`.
266
+ *
267
+ * @return A reference to this `Umap` object.
268
+ */
269
+ Umap& set_min_dist(Float m = Defaults::min_dist) {
270
+ min_dist = m;
271
+ return *this;
272
+ }
273
+
274
+ /**
275
+ * @param n Number of epochs for the gradient descent, i.e., optimization iterations.
276
+ *
277
+ * Larger values improve accuracy at the cost of computational work.
278
+ * If the requested number of epochs is negative, a value is automatically chosen based on the size of the dataset:
279
+ *
280
+ * - For datasets with no more than 10000 observations, the number of epochs is set to 500.
281
+ * - For larger datasets, the number of epochs decreases from 500 according to the number of cells beyond 10000, to a lower limit of 200.
282
+ *
283
+ * This choice aims to reduce computational work for very large datasets.
284
+ *
285
+ * @return A reference to this `Umap` object.
286
+ */
287
+ Umap& set_num_epochs(int n = Defaults::num_epochs) {
288
+ num_epochs = n;
289
+ return *this;
290
+ }
291
+
292
+ /**
293
+ * @param n Rate of sampling negative observations to compute repulsive forces.
294
+ * This is interpreted with respect to the number of neighbors with attractive forces, i.e., for each attractive interaction, `n` negative samples are taken for repulsive interactions.
295
+ * Smaller values can improve the speed of convergence but at the cost of stability.
296
+ *
297
+ * @return A reference to this `Umap` object.
298
+ */
299
+ Umap& set_negative_sample_rate(Float n = Defaults::negative_sample_rate) {
300
+ negative_sample_rate = n;
301
+ return *this;
302
+ }
303
+
304
+ /**
305
+ * @param s Seed to use for the Mersenne Twister when sampling negative observations.
306
+ *
307
+ * @return A reference to this `Umap` object.
308
+ */
309
+ Umap& set_seed(uint64_t s = Defaults::seed) {
310
+ seed = s;
311
+ return *this;
312
+ }
313
+
314
+ /**
315
+ * @param a Positive value for the $a$ parameter for the fuzzy set membership strength calculations.
316
+ * Larger values yield a sharper decay in membership strength with increasing distance between observations.
317
+ *
318
+ * If this or `set_b()` is set to zero, a suitable value for this parameter is automatically determined from the values provided to `set_spread()` and `set_min_dist()`.
319
+ *
320
+ * @return A reference to this `Umap` object.
321
+ */
322
+ Umap& set_a(Float a = Defaults::a) {
323
+ rparams.a = a;
324
+ return *this;
325
+ }
326
+
327
+ /**
328
+ * @param b Value in $(0, 1)$ for the $b$ parameter for the fuzzy set membership strength calculations.
329
+ * Larger values yield an earlier decay in membership strength with increasing distance between observations.
330
+ *
331
+ * If this or `set_a()` is set to zero, a suitable value for this parameter is automatically determined from the values provided to `set_spread()` and `set_min_dist()`.
332
+ *
333
+ * @return A reference to this `Umap` object.
334
+ */
335
+ Umap& set_b(Float b = Defaults::b) {
336
+ rparams.b = b;
337
+ return *this;
338
+ }
339
+
340
+ /**
341
+ * @param r Modifier for the repulsive force.
342
+ * Larger values increase repulsion and favor local structure.
343
+ *
344
+ * @return A reference to this `Umap` object.
345
+ */
346
+ Umap& set_repulsion_strength(Float r = Defaults::repulsion_strength) {
347
+ rparams.repulsion_strength = r;
348
+ return *this;
349
+ }
350
+
351
+ /**
352
+ * @param l Initial learning rate used in the gradient descent.
353
+ * Larger values can improve the speed of convergence but at the cost of stability.
354
+ *
355
+ * @return A reference to this `Umap` object.
356
+ */
357
+ Umap& set_learning_rate(Float l = Defaults::learning_rate) {
358
+ rparams.learning_rate = l;
359
+ return *this;
360
+ }
361
+
362
+ /**
363
+ * @param b Whether to optimize in batch mode.
364
+ * Batch mode is required for effective parallelization via OpenMP but may reduce the stability of the gradient descent.
365
+ *
366
+ * Batch mode involves computing forces for all observations and applying them simultaneously.
367
+ * This is in contrast to the default where the location of observation is updated before the forces are computed for the next observation.
368
+ * As each observation's forces are computed independently, batch mode is more amenable to parallelization;
369
+ * however, this comes at the cost of stability as the force calculations for later observations are not aware of updates to the positions of earlier observations.
370
+ *
371
+ * @return A reference to this `Umap` object.
372
+ */
373
+ Umap& set_batch(bool b = Defaults::batch) {
374
+ rparams.batch = b;
375
+ return *this;
376
+ }
377
+
378
+ /**
379
+ * @param n Number of threads to use.
380
+ *
381
+ * @return A reference to this `Umap` object.
382
+ *
383
+ * This setting affects nearest neighbor detection (if an existing list of neighbors is not supplied in `initialize()` or `run()`) and spectral initialization.
384
+ * If `set_batch()` is `true`, multiple threads will also be used during layout optimization.
385
+ *
386
+ * The `UMAPPP_CUSTOM_PARALLEL` macro can be set to a function that specifies a custom parallelization scheme.
387
+ * This function should be a template that accept three arguments:
388
+ *
389
+ * - `njobs`, an integer specifying the number of jobs.
390
+ * - `fun`, a lambda that accepts two arguments, `start` and `end`.
391
+ * - `nthreads`, an integer specifying the number of threads to use.
392
+ *
393
+ * The function should split `[0, njobs)` into any number of contiguous, non-overlapping intervals, and call `fun` on each interval, possibly in different threads.
394
+ * The details of the splitting and evaluation are left to the discretion of the developer defining the macro.
395
+ * The function should only return once all evaluations of `fun` are complete.
396
+ *
397
+ * If `UMAPPP_CUSTOM_PARALLEL` is set, the `IRLBA_CUSTOM_PARALLEL` macro is also set if it is not already defined.
398
+ * This ensures that any custom parallelization scheme is propagated to all of **umappp**'s dependencies.
399
+ * If **irlba** is used outside of **umappp**, some care is required to ensure that the macros are consistently defined throughout the client library/application;
400
+ * otherwise, developers may observe ODR compilation errors.
401
+ */
402
+ Umap& set_num_threads(int n = Defaults::num_threads) {
403
+ rparams.nthreads = n;
404
+ return *this;
405
+ }
406
+
407
+ public:
408
+ /**
409
+ * @brief Status of the UMAP optimization iterations.
410
+ */
411
+ struct Status {
412
+ /**
413
+ * @cond
414
+ */
415
+ Status(EpochData<Float> e, uint64_t seed, RuntimeParameters p) : epochs(std::move(e)), engine(seed), rparams(std::move(p)) {}
416
+
417
+ EpochData<Float> epochs;
418
+ std::mt19937_64 engine;
419
+ RuntimeParameters rparams;
420
+ /**
421
+ * @endcond
422
+ */
423
+
424
+ /**
425
+ * @return Current epoch.
426
+ */
427
+ int epoch() const {
428
+ return epochs.current_epoch;
429
+ }
430
+
431
+ /**
432
+ * @return Total number of epochs.
433
+ * This is equal to the value set by `set_num_epochs()` when the `Status` object is created.
434
+ */
435
+ int num_epochs() const {
436
+ return epochs.total_epochs;
437
+ }
438
+
439
+ /**
440
+ * @return The number of observations in the dataset.
441
+ */
442
+ size_t nobs() const {
443
+ return epochs.head.size();
444
+ }
445
+
446
+ /**
447
+ * @param ndim Number of dimensions of the embedding.
448
+ * @param[in, out] embedding Two-dimensional array where rows are dimensions (`ndim`) and columns are observations.
449
+ * This contains the initial coordinates and is updated to store the final embedding.
450
+ * @param epoch_limit Number of epochs to run to.
451
+ * The actual number of epochs performed is equal to the difference between `epoch_limit` and the current number of epochs in `epoch()`.
452
+ * `epoch_limit` should be not less than `epoch()` and no greater than the maximum number of epochs specified in `Umap::set_num_epochs()`.
453
+ * If zero, defaults to the maximum number of epochs.
454
+ *
455
+ * @return The status of the algorithm and the coordinates in `embedding` are updated to the specified number of epochs.
456
+ */
457
+ void run(int ndim, Float* embedding, int epoch_limit = 0) {
458
+ if (!rparams.batch) {
459
+ optimize_layout(
460
+ ndim,
461
+ embedding,
462
+ epochs,
463
+ rparams.a,
464
+ rparams.b,
465
+ rparams.repulsion_strength,
466
+ rparams.learning_rate,
467
+ engine,
468
+ epoch_limit
469
+ );
470
+ } else {
471
+ optimize_layout_batched(
472
+ ndim,
473
+ embedding,
474
+ epochs,
475
+ rparams.a,
476
+ rparams.b,
477
+ rparams.repulsion_strength,
478
+ rparams.learning_rate,
479
+ [&]() -> auto { return engine(); },
480
+ [](decltype(engine()) s) -> auto { return std::mt19937_64(s); },
481
+ epoch_limit,
482
+ rparams.nthreads
483
+ );
484
+ }
485
+ return;
486
+ }
487
+ };
488
+
489
+ /**
490
+ * @param x Indices and distances to the nearest neighbors for each observation.
491
+ * Note the expectations in the `NeighborList` documentation.
492
+ * @param ndim Number of dimensions of the embedding.
493
+ * @param[in, out] embedding Two-dimensional array to store the embedding,
494
+ * where rows are dimensions (`ndim`) and columns are observations (`x.size()`).
495
+ *
496
+ * @return A `Status` object containing the initial state of the UMAP algorithm, to be used in `run()`.
497
+ * If `set_initialize()` is `NONE` or if spectral initialization fails with `SPECTRAL_ONLY`, `embedding` should contain the initial coordinates and will not be altered;
498
+ * otherwise, it is filled with initial coordinates.
499
+ */
500
+ Status initialize(NeighborList<Float> x, int ndim, Float* embedding) const {
501
+ neighbor_similarities(x, local_connectivity, bandwidth);
502
+ combine_neighbor_sets(x, mix_ratio);
503
+
504
+ // Choosing the manner of initialization.
505
+ if (init == SPECTRAL || init == SPECTRAL_ONLY) {
506
+ bool attempt = spectral_init(x, ndim, embedding, rparams.nthreads);
507
+ if (!attempt && init == SPECTRAL) {
508
+ random_init(x.size(), ndim, embedding);
509
+ }
510
+ } else if (init == RANDOM) {
511
+ random_init(x.size(), ndim, embedding);
512
+ }
513
+
514
+ // Finding a good a/b pair.
515
+ auto pcopy = rparams;
516
+ if (pcopy.a <= 0 || pcopy.b <= 0) {
517
+ auto found = find_ab(spread, min_dist);
518
+ pcopy.a = found.first;
519
+ pcopy.b = found.second;
520
+ }
521
+
522
+ int num_epochs_to_do = choose_num_epochs(num_epochs, x.size());
523
+
524
+ return Status(
525
+ similarities_to_epochs(x, num_epochs_to_do, negative_sample_rate),
526
+ seed,
527
+ std::move(pcopy)
528
+ );
529
+ }
530
+
531
+ public:
532
+ /**
533
+ * @tparam Algorithm `knncolle::Base` subclass implementing a nearest neighbor search algorithm.
534
+ *
535
+ * @param searcher Pointer to a `knncolle::Base` subclass with a `find_nearest_neighbors()` method.
536
+ * @param ndim Number of dimensions of the embedding.
537
+ * @param[out] embedding Two-dimensional array to store the embedding,
538
+ * where rows are dimensions (`ndim`) and columns are observations (`searcher->nobs()`).
539
+ *
540
+ * @return A `Status` object containing the initial state of the UMAP algorithm, to be used in `run()`.
541
+ * If `set_initialize()` is true, `embedding` is filled with initial coordinates derived from the fuzzy set graph;
542
+ * otherwise it is ignored.
543
+ */
544
+ template<class Algorithm>
545
+ Status initialize(const Algorithm* searcher, int ndim, Float* embedding) {
546
+ const size_t N = searcher->nobs();
547
+ NeighborList<Float> output(N);
548
+
549
+ #ifndef UMAPPP_CUSTOM_PARALLEL
550
+ #pragma omp parallel for num_threads(rparams.nthreads)
551
+ for (size_t i = 0; i < N; ++i) {
552
+ #else
553
+ UMAPPP_CUSTOM_PARALLEL(N, [&](size_t first, size_t last) -> void {
554
+ for (size_t i = first; i < last; ++i) {
555
+ #endif
556
+
557
+ output[i] = searcher->find_nearest_neighbors(i, num_neighbors);
558
+
559
+ #ifndef UMAPPP_CUSTOM_PARALLEL
560
+ }
561
+ #else
562
+ }
563
+ }, rparams.nthreads);
564
+ #endif
565
+
566
+ return initialize(std::move(output), ndim, embedding);
567
+ }
568
+
569
+ #ifndef UMAPPP_CUSTOM_NEIGHBORS
570
+ /**
571
+ * @tparam Input Floating point type for the input data.
572
+ *
573
+ * @param ndim_in Number of dimensions.
574
+ * @param nobs Number of observations.
575
+ * @param[in] input Pointer to a 2D array containing the input high-dimensional data, with number of rows and columns equal to `ndim_in` and `nobs`, respectively.
576
+ * The array is treated as column-major where each row corresponds to a dimension and each column corresponds to an observation.
577
+ * @param ndim_out Number of dimensions of the embedding.
578
+ * @param[out] embedding Two-dimensional array to store the embedding,
579
+ * where rows are dimensions (`ndim`) and columns are observations (`searcher->nobs()`).
580
+ *
581
+ * @return A `Status` object containing various pre-computed structures required for the epochs in `run()`.
582
+ * If `set_initialize()` is `NONE` or if spectral initialization fails with `SPECTRAL_ONLY`, `embedding` should contain the initial coordinates and will not be altered;
583
+ * otherwise, it is filled with initial coordinates.
584
+ *
585
+ * This differs from the other `initialize()` methods in that it will internally compute the nearest neighbors for each observation.
586
+ * It will use vantage point trees for the search - see the other `initialize()` methods to specify a custom search algorithm.
587
+ */
588
+ template<typename Input = Float>
589
+ Status initialize(int ndim_in, size_t nobs, const Input* input, int ndim_out, Float* embedding) {
590
+ knncolle::VpTreeEuclidean<> searcher(ndim_in, nobs, input);
591
+ return initialize(&searcher, ndim_out, embedding);
592
+ }
593
+ #endif
594
+
595
+ public:
596
+ /**
597
+ * @tparam Algorithm `knncolle::Base` subclass implementing a nearest neighbor search algorithm.
598
+ *
599
+ * @param searcher Pointer to a `knncolle::Base` subclass with a `find_nearest_neighbors()` method.
600
+ * @param ndim Number of dimensions of the embedding.
601
+ * @param[in, out] embedding Two-dimensional array where rows are dimensions (`ndim`) and columns are observations (`searcher->nobs()`).
602
+ * This is filled with the final embedding on output.
603
+ * If `set_initialize()` is false, this is assumed to contain the initial coordinates on input.
604
+ * @param epoch_limit Number of epochs to run - see `Status::run()`.
605
+ *
606
+ * @return The status of the algorithm is returned after running up to `epoch_limit`; this can be used for further iterations by invoking `Status::run()`.
607
+ * `embedding` is updated with the embedding at the specified epoch limit.
608
+ */
609
+ template<class Algorithm>
610
+ Status run(const Algorithm* searcher, int ndim, Float* embedding, int epoch_limit = 0) {
611
+ auto status = initialize(searcher, ndim, embedding);
612
+ status.run(ndim, embedding, epoch_limit);
613
+ return status;
614
+ }
615
+
616
+ /**
617
+ * @param x Indices and distances to the nearest neighbors for each observation.
618
+ * Note the expectations in the `NeighborList` documentation.
619
+ * @param ndim Number of dimensions of the embedding.
620
+ * @param[in, out] embedding Two-dimensional array where rows are dimensions (`ndim`) and columns are observations.
621
+ * This is filled with the final embedding on output.
622
+ * If `set_initialize()` is `NONE` or if spectral initialization fails with `SPECTRAL_ONLY`, `embedding` is assumed to contain the initial coordinates on input.
623
+ * @param epoch_limit Number of epochs to run - see `Status::run()`.
624
+ *
625
+ * @return The status of the algorithm is returned after running up to `epoch_limit`; this can be used for further iterations by invoking `Status::run()`.
626
+ * `embedding` is updated with the embedding at the specified epoch limit.
627
+ */
628
+ Status run(NeighborList<Float> x, int ndim, Float* embedding, int epoch_limit = 0) const {
629
+ auto status = initialize(std::move(x), ndim, embedding);
630
+ status.run(ndim, embedding, epoch_limit);
631
+ return status;
632
+ }
633
+
634
+ #ifndef UMAPPP_CUSTOM_NEIGHBORS
635
+ /**
636
+ * @tparam Input Floating point type for the input data.
637
+ *
638
+ * @param ndim_in Number of dimensions.
639
+ * @param nobs Number of observations.
640
+ * @param[in] input Pointer to a 2D array containing the input high-dimensional data, with number of rows and columns equal to `ndim_in` and `nobs`, respectively.
641
+ * The array is treated as column-major where each row corresponds to a dimension and each column corresponds to an observation.
642
+ * @param ndim_out Number of dimensions of the embedding.
643
+ * @param[in, out] embedding Two-dimensional array where rows are dimensions (`ndim`) and columns are observations (`searcher->nobs()`).
644
+ * This is filled with the final embedding on output.
645
+ * If `set_initialize()` is `NONE` or if spectral initialization fails with `SPECTRAL_ONLY`, `embedding` is assumed to contain the initial coordinates on input.
646
+ * @param epoch_limit Number of epochs to run - see `Status::run()`.
647
+ *
648
+ * @return The status of the algorithm is returned after running up to `epoch_limit`; this can be used for further iterations by invoking `Status::run()`.
649
+ * `embedding` is updated with the embedding at the specified epoch limit.
650
+ */
651
+ template<typename Input = Float>
652
+ Status run(int ndim_in, size_t nobs, const Input* input, int ndim_out, Float* embedding, int epoch_limit = 0) {
653
+ auto status = initialize(ndim_in, nobs, input, ndim_out, embedding);
654
+ status.run(ndim_out, embedding, epoch_limit);
655
+ return status;
656
+ }
657
+ #endif
658
+ };
659
+
660
+ }
661
+
662
+ #endif