@ladybugmem/icebug 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (624) hide show
  1. package/README.md +14 -0
  2. package/binding.gyp +54 -0
  3. package/build/Release/.deps/Release/icebug.node.d +1 -0
  4. package/build/Release/.deps/Release/obj.target/icebug/src/addon.o.d +291 -0
  5. package/build/Release/icebug.node +0 -0
  6. package/build/Release/obj.target/icebug/src/addon.o +0 -0
  7. package/lib/index.d.ts +361 -0
  8. package/lib/index.js +102 -0
  9. package/package.json +42 -0
  10. package/src/addon.cpp +1253 -0
  11. package/vendor/include/networkit/GlobalState.hpp +86 -0
  12. package/vendor/include/networkit/Globals.hpp +41 -0
  13. package/vendor/include/networkit/algebraic/AlgebraicGlobals.hpp +27 -0
  14. package/vendor/include/networkit/algebraic/CSRGeneralMatrix.hpp +1292 -0
  15. package/vendor/include/networkit/algebraic/CSRMatrix.hpp +11 -0
  16. package/vendor/include/networkit/algebraic/DenseMatrix.hpp +537 -0
  17. package/vendor/include/networkit/algebraic/DynamicMatrix.hpp +514 -0
  18. package/vendor/include/networkit/algebraic/GraphBLAS.hpp +323 -0
  19. package/vendor/include/networkit/algebraic/MatrixTools.hpp +156 -0
  20. package/vendor/include/networkit/algebraic/Semirings.hpp +171 -0
  21. package/vendor/include/networkit/algebraic/SparseAccumulator.hpp +111 -0
  22. package/vendor/include/networkit/algebraic/Vector.hpp +371 -0
  23. package/vendor/include/networkit/algebraic/algorithms/AlgebraicBFS.hpp +72 -0
  24. package/vendor/include/networkit/algebraic/algorithms/AlgebraicBellmanFord.hpp +88 -0
  25. package/vendor/include/networkit/algebraic/algorithms/AlgebraicMatchingCoarsening.hpp +96 -0
  26. package/vendor/include/networkit/algebraic/algorithms/AlgebraicPageRank.hpp +145 -0
  27. package/vendor/include/networkit/algebraic/algorithms/AlgebraicSpanningEdgeCentrality.hpp +122 -0
  28. package/vendor/include/networkit/algebraic/algorithms/AlgebraicTriangleCounting.hpp +76 -0
  29. package/vendor/include/networkit/auxiliary/AlignedAllocator.hpp +113 -0
  30. package/vendor/include/networkit/auxiliary/ArrayTools.hpp +85 -0
  31. package/vendor/include/networkit/auxiliary/BloomFilter.hpp +70 -0
  32. package/vendor/include/networkit/auxiliary/BucketPQ.hpp +142 -0
  33. package/vendor/include/networkit/auxiliary/Enforce.hpp +117 -0
  34. package/vendor/include/networkit/auxiliary/FunctionTraits.hpp +74 -0
  35. package/vendor/include/networkit/auxiliary/HashUtils.hpp +28 -0
  36. package/vendor/include/networkit/auxiliary/IncrementalUniformRandomSelector.hpp +52 -0
  37. package/vendor/include/networkit/auxiliary/Log.hpp +119 -0
  38. package/vendor/include/networkit/auxiliary/MissingMath.hpp +48 -0
  39. package/vendor/include/networkit/auxiliary/Multiprecision.hpp +17 -0
  40. package/vendor/include/networkit/auxiliary/NumberParsing.hpp +307 -0
  41. package/vendor/include/networkit/auxiliary/NumericTools.hpp +57 -0
  42. package/vendor/include/networkit/auxiliary/Parallel.hpp +56 -0
  43. package/vendor/include/networkit/auxiliary/Parallelism.hpp +33 -0
  44. package/vendor/include/networkit/auxiliary/PrioQueue.hpp +252 -0
  45. package/vendor/include/networkit/auxiliary/Random.hpp +122 -0
  46. package/vendor/include/networkit/auxiliary/SetIntersector.hpp +72 -0
  47. package/vendor/include/networkit/auxiliary/SignalHandling.hpp +39 -0
  48. package/vendor/include/networkit/auxiliary/SortedList.hpp +128 -0
  49. package/vendor/include/networkit/auxiliary/SparseVector.hpp +215 -0
  50. package/vendor/include/networkit/auxiliary/SpinLock.hpp +23 -0
  51. package/vendor/include/networkit/auxiliary/StringBuilder.hpp +322 -0
  52. package/vendor/include/networkit/auxiliary/StringTools.hpp +76 -0
  53. package/vendor/include/networkit/auxiliary/TemplateUtils.hpp +76 -0
  54. package/vendor/include/networkit/auxiliary/Timer.hpp +145 -0
  55. package/vendor/include/networkit/auxiliary/VectorComparator.hpp +32 -0
  56. package/vendor/include/networkit/base/Algorithm.hpp +41 -0
  57. package/vendor/include/networkit/base/DynAlgorithm.hpp +31 -0
  58. package/vendor/include/networkit/centrality/ApproxBetweenness.hpp +62 -0
  59. package/vendor/include/networkit/centrality/ApproxCloseness.hpp +136 -0
  60. package/vendor/include/networkit/centrality/ApproxElectricalCloseness.hpp +156 -0
  61. package/vendor/include/networkit/centrality/ApproxGroupBetweenness.hpp +124 -0
  62. package/vendor/include/networkit/centrality/ApproxSpanningEdge.hpp +84 -0
  63. package/vendor/include/networkit/centrality/Betweenness.hpp +47 -0
  64. package/vendor/include/networkit/centrality/Centrality.hpp +98 -0
  65. package/vendor/include/networkit/centrality/Closeness.hpp +107 -0
  66. package/vendor/include/networkit/centrality/ComplexPaths.hpp +113 -0
  67. package/vendor/include/networkit/centrality/CoreDecomposition.hpp +161 -0
  68. package/vendor/include/networkit/centrality/DegreeCentrality.hpp +55 -0
  69. package/vendor/include/networkit/centrality/DynApproxBetweenness.hpp +95 -0
  70. package/vendor/include/networkit/centrality/DynBetweenness.hpp +99 -0
  71. package/vendor/include/networkit/centrality/DynBetweennessOneNode.hpp +98 -0
  72. package/vendor/include/networkit/centrality/DynKatzCentrality.hpp +115 -0
  73. package/vendor/include/networkit/centrality/DynTopHarmonicCloseness.hpp +223 -0
  74. package/vendor/include/networkit/centrality/EigenvectorCentrality.hpp +41 -0
  75. package/vendor/include/networkit/centrality/EstimateBetweenness.hpp +51 -0
  76. package/vendor/include/networkit/centrality/ForestCentrality.hpp +112 -0
  77. package/vendor/include/networkit/centrality/GedWalk.hpp +225 -0
  78. package/vendor/include/networkit/centrality/GroupCloseness.hpp +115 -0
  79. package/vendor/include/networkit/centrality/GroupClosenessGrowShrink.hpp +78 -0
  80. package/vendor/include/networkit/centrality/GroupClosenessLocalSearch.hpp +77 -0
  81. package/vendor/include/networkit/centrality/GroupClosenessLocalSwaps.hpp +106 -0
  82. package/vendor/include/networkit/centrality/GroupDegree.hpp +155 -0
  83. package/vendor/include/networkit/centrality/GroupHarmonicCloseness.hpp +83 -0
  84. package/vendor/include/networkit/centrality/HarmonicCloseness.hpp +48 -0
  85. package/vendor/include/networkit/centrality/KPathCentrality.hpp +52 -0
  86. package/vendor/include/networkit/centrality/KadabraBetweenness.hpp +242 -0
  87. package/vendor/include/networkit/centrality/KatzCentrality.hpp +62 -0
  88. package/vendor/include/networkit/centrality/LaplacianCentrality.hpp +44 -0
  89. package/vendor/include/networkit/centrality/LocalClusteringCoefficient.hpp +60 -0
  90. package/vendor/include/networkit/centrality/LocalPartitionCoverage.hpp +43 -0
  91. package/vendor/include/networkit/centrality/LocalSquareClusteringCoefficient.hpp +42 -0
  92. package/vendor/include/networkit/centrality/PageRank.hpp +101 -0
  93. package/vendor/include/networkit/centrality/PermanenceCentrality.hpp +48 -0
  94. package/vendor/include/networkit/centrality/Sfigality.hpp +45 -0
  95. package/vendor/include/networkit/centrality/SpanningEdgeCentrality.hpp +86 -0
  96. package/vendor/include/networkit/centrality/TopCloseness.hpp +136 -0
  97. package/vendor/include/networkit/centrality/TopHarmonicCloseness.hpp +151 -0
  98. package/vendor/include/networkit/clique/MaximalCliques.hpp +83 -0
  99. package/vendor/include/networkit/coarsening/ClusteringProjector.hpp +59 -0
  100. package/vendor/include/networkit/coarsening/CoarsenedGraphView.hpp +156 -0
  101. package/vendor/include/networkit/coarsening/GraphCoarsening.hpp +57 -0
  102. package/vendor/include/networkit/coarsening/MatchingCoarsening.hpp +43 -0
  103. package/vendor/include/networkit/coarsening/ParallelPartitionCoarsening.hpp +33 -0
  104. package/vendor/include/networkit/coarsening/ParallelPartitionCoarseningView.hpp +62 -0
  105. package/vendor/include/networkit/community/AdjustedRandMeasure.hpp +31 -0
  106. package/vendor/include/networkit/community/ClusteringGenerator.hpp +75 -0
  107. package/vendor/include/networkit/community/CommunityDetectionAlgorithm.hpp +58 -0
  108. package/vendor/include/networkit/community/Conductance.hpp +32 -0
  109. package/vendor/include/networkit/community/CoverF1Similarity.hpp +53 -0
  110. package/vendor/include/networkit/community/CoverHubDominance.hpp +38 -0
  111. package/vendor/include/networkit/community/Coverage.hpp +25 -0
  112. package/vendor/include/networkit/community/CutClustering.hpp +62 -0
  113. package/vendor/include/networkit/community/DissimilarityMeasure.hpp +31 -0
  114. package/vendor/include/networkit/community/DynamicNMIDistance.hpp +44 -0
  115. package/vendor/include/networkit/community/EdgeCut.hpp +24 -0
  116. package/vendor/include/networkit/community/GraphClusteringTools.hpp +103 -0
  117. package/vendor/include/networkit/community/GraphStructuralRandMeasure.hpp +28 -0
  118. package/vendor/include/networkit/community/HubDominance.hpp +46 -0
  119. package/vendor/include/networkit/community/IntrapartitionDensity.hpp +44 -0
  120. package/vendor/include/networkit/community/IsolatedInterpartitionConductance.hpp +40 -0
  121. package/vendor/include/networkit/community/IsolatedInterpartitionExpansion.hpp +40 -0
  122. package/vendor/include/networkit/community/JaccardMeasure.hpp +25 -0
  123. package/vendor/include/networkit/community/LFM.hpp +49 -0
  124. package/vendor/include/networkit/community/LPDegreeOrdered.hpp +48 -0
  125. package/vendor/include/networkit/community/LocalCommunityEvaluation.hpp +100 -0
  126. package/vendor/include/networkit/community/LocalCoverEvaluation.hpp +31 -0
  127. package/vendor/include/networkit/community/LocalPartitionEvaluation.hpp +31 -0
  128. package/vendor/include/networkit/community/LouvainMapEquation.hpp +135 -0
  129. package/vendor/include/networkit/community/Modularity.hpp +54 -0
  130. package/vendor/include/networkit/community/NMIDistance.hpp +28 -0
  131. package/vendor/include/networkit/community/NodeStructuralRandMeasure.hpp +27 -0
  132. package/vendor/include/networkit/community/OverlappingCommunityDetectionAlgorithm.hpp +51 -0
  133. package/vendor/include/networkit/community/OverlappingNMIDistance.hpp +175 -0
  134. package/vendor/include/networkit/community/PLM.hpp +89 -0
  135. package/vendor/include/networkit/community/PLP.hpp +83 -0
  136. package/vendor/include/networkit/community/ParallelAgglomerativeClusterer.hpp +37 -0
  137. package/vendor/include/networkit/community/ParallelLeiden.hpp +96 -0
  138. package/vendor/include/networkit/community/ParallelLeidenView.hpp +138 -0
  139. package/vendor/include/networkit/community/PartitionFragmentation.hpp +30 -0
  140. package/vendor/include/networkit/community/PartitionHubDominance.hpp +37 -0
  141. package/vendor/include/networkit/community/PartitionIntersection.hpp +25 -0
  142. package/vendor/include/networkit/community/QualityMeasure.hpp +27 -0
  143. package/vendor/include/networkit/community/SampledGraphStructuralRandMeasure.hpp +40 -0
  144. package/vendor/include/networkit/community/SampledNodeStructuralRandMeasure.hpp +40 -0
  145. package/vendor/include/networkit/community/StablePartitionNodes.hpp +48 -0
  146. package/vendor/include/networkit/components/BiconnectedComponents.hpp +116 -0
  147. package/vendor/include/networkit/components/ComponentDecomposition.hpp +72 -0
  148. package/vendor/include/networkit/components/ConnectedComponents.hpp +55 -0
  149. package/vendor/include/networkit/components/DynConnectedComponents.hpp +71 -0
  150. package/vendor/include/networkit/components/DynWeaklyConnectedComponents.hpp +73 -0
  151. package/vendor/include/networkit/components/ParallelConnectedComponents.hpp +44 -0
  152. package/vendor/include/networkit/components/RandomSpanningForest.hpp +36 -0
  153. package/vendor/include/networkit/components/StronglyConnectedComponents.hpp +50 -0
  154. package/vendor/include/networkit/components/WeaklyConnectedComponents.hpp +59 -0
  155. package/vendor/include/networkit/correlation/Assortativity.hpp +64 -0
  156. package/vendor/include/networkit/distance/APSP.hpp +70 -0
  157. package/vendor/include/networkit/distance/AStar.hpp +68 -0
  158. package/vendor/include/networkit/distance/AStarGeneral.hpp +110 -0
  159. package/vendor/include/networkit/distance/AdamicAdarDistance.hpp +52 -0
  160. package/vendor/include/networkit/distance/AffectedNodes.hpp +130 -0
  161. package/vendor/include/networkit/distance/AlgebraicDistance.hpp +63 -0
  162. package/vendor/include/networkit/distance/BFS.hpp +43 -0
  163. package/vendor/include/networkit/distance/BidirectionalBFS.hpp +51 -0
  164. package/vendor/include/networkit/distance/BidirectionalDijkstra.hpp +69 -0
  165. package/vendor/include/networkit/distance/CommuteTimeDistance.hpp +89 -0
  166. package/vendor/include/networkit/distance/Diameter.hpp +97 -0
  167. package/vendor/include/networkit/distance/Dijkstra.hpp +50 -0
  168. package/vendor/include/networkit/distance/DynAPSP.hpp +67 -0
  169. package/vendor/include/networkit/distance/DynBFS.hpp +56 -0
  170. package/vendor/include/networkit/distance/DynDijkstra.hpp +57 -0
  171. package/vendor/include/networkit/distance/DynPrunedLandmarkLabeling.hpp +67 -0
  172. package/vendor/include/networkit/distance/DynSSSP.hpp +87 -0
  173. package/vendor/include/networkit/distance/Eccentricity.hpp +32 -0
  174. package/vendor/include/networkit/distance/EffectiveDiameter.hpp +47 -0
  175. package/vendor/include/networkit/distance/EffectiveDiameterApproximation.hpp +57 -0
  176. package/vendor/include/networkit/distance/FloydWarshall.hpp +93 -0
  177. package/vendor/include/networkit/distance/GraphDistance.hpp +49 -0
  178. package/vendor/include/networkit/distance/HopPlotApproximation.hpp +62 -0
  179. package/vendor/include/networkit/distance/IncompleteDijkstra.hpp +66 -0
  180. package/vendor/include/networkit/distance/IncompleteSSSP.hpp +41 -0
  181. package/vendor/include/networkit/distance/JaccardDistance.hpp +57 -0
  182. package/vendor/include/networkit/distance/MultiTargetBFS.hpp +32 -0
  183. package/vendor/include/networkit/distance/MultiTargetDijkstra.hpp +40 -0
  184. package/vendor/include/networkit/distance/NeighborhoodFunction.hpp +47 -0
  185. package/vendor/include/networkit/distance/NeighborhoodFunctionApproximation.hpp +56 -0
  186. package/vendor/include/networkit/distance/NeighborhoodFunctionHeuristic.hpp +56 -0
  187. package/vendor/include/networkit/distance/NodeDistance.hpp +54 -0
  188. package/vendor/include/networkit/distance/PrunedLandmarkLabeling.hpp +76 -0
  189. package/vendor/include/networkit/distance/ReverseBFS.hpp +46 -0
  190. package/vendor/include/networkit/distance/SPSP.hpp +143 -0
  191. package/vendor/include/networkit/distance/SSSP.hpp +216 -0
  192. package/vendor/include/networkit/distance/STSP.hpp +193 -0
  193. package/vendor/include/networkit/distance/Volume.hpp +66 -0
  194. package/vendor/include/networkit/dynamics/DGSStreamParser.hpp +40 -0
  195. package/vendor/include/networkit/dynamics/DGSWriter.hpp +30 -0
  196. package/vendor/include/networkit/dynamics/GraphDifference.hpp +110 -0
  197. package/vendor/include/networkit/dynamics/GraphEvent.hpp +55 -0
  198. package/vendor/include/networkit/dynamics/GraphEventHandler.hpp +39 -0
  199. package/vendor/include/networkit/dynamics/GraphEventProxy.hpp +55 -0
  200. package/vendor/include/networkit/dynamics/GraphUpdater.hpp +38 -0
  201. package/vendor/include/networkit/edgescores/ChibaNishizekiQuadrangleEdgeScore.hpp +26 -0
  202. package/vendor/include/networkit/edgescores/ChibaNishizekiTriangleEdgeScore.hpp +33 -0
  203. package/vendor/include/networkit/edgescores/EdgeScore.hpp +50 -0
  204. package/vendor/include/networkit/edgescores/EdgeScoreAsWeight.hpp +33 -0
  205. package/vendor/include/networkit/edgescores/EdgeScoreBlender.hpp +33 -0
  206. package/vendor/include/networkit/edgescores/EdgeScoreLinearizer.hpp +32 -0
  207. package/vendor/include/networkit/edgescores/EdgeScoreNormalizer.hpp +35 -0
  208. package/vendor/include/networkit/edgescores/GeometricMeanScore.hpp +29 -0
  209. package/vendor/include/networkit/edgescores/PrefixJaccardScore.hpp +23 -0
  210. package/vendor/include/networkit/edgescores/TriangleEdgeScore.hpp +39 -0
  211. package/vendor/include/networkit/embedding/Node2Vec.hpp +83 -0
  212. package/vendor/include/networkit/flow/EdmondsKarp.hpp +112 -0
  213. package/vendor/include/networkit/generators/BarabasiAlbertGenerator.hpp +87 -0
  214. package/vendor/include/networkit/generators/ChungLuGenerator.hpp +46 -0
  215. package/vendor/include/networkit/generators/ChungLuGeneratorAlamEtAl.hpp +63 -0
  216. package/vendor/include/networkit/generators/ClusteredRandomGraphGenerator.hpp +56 -0
  217. package/vendor/include/networkit/generators/ConfigurationModel.hpp +36 -0
  218. package/vendor/include/networkit/generators/DorogovtsevMendesGenerator.hpp +33 -0
  219. package/vendor/include/networkit/generators/DynamicBarabasiAlbertGenerator.hpp +33 -0
  220. package/vendor/include/networkit/generators/DynamicDGSParser.hpp +51 -0
  221. package/vendor/include/networkit/generators/DynamicDorogovtsevMendesGenerator.hpp +34 -0
  222. package/vendor/include/networkit/generators/DynamicForestFireGenerator.hpp +55 -0
  223. package/vendor/include/networkit/generators/DynamicGraphGenerator.hpp +40 -0
  224. package/vendor/include/networkit/generators/DynamicGraphSource.hpp +79 -0
  225. package/vendor/include/networkit/generators/DynamicHyperbolicGenerator.hpp +143 -0
  226. package/vendor/include/networkit/generators/DynamicPathGenerator.hpp +26 -0
  227. package/vendor/include/networkit/generators/DynamicPubWebGenerator.hpp +54 -0
  228. package/vendor/include/networkit/generators/EdgeSwitchingMarkovChainGenerator.hpp +65 -0
  229. package/vendor/include/networkit/generators/ErdosRenyiEnumerator.hpp +318 -0
  230. package/vendor/include/networkit/generators/ErdosRenyiGenerator.hpp +56 -0
  231. package/vendor/include/networkit/generators/HavelHakimiGenerator.hpp +48 -0
  232. package/vendor/include/networkit/generators/HyperbolicGenerator.hpp +236 -0
  233. package/vendor/include/networkit/generators/LFRGenerator.hpp +175 -0
  234. package/vendor/include/networkit/generators/MocnikGenerator.hpp +147 -0
  235. package/vendor/include/networkit/generators/MocnikGeneratorBasic.hpp +58 -0
  236. package/vendor/include/networkit/generators/PowerlawDegreeSequence.hpp +128 -0
  237. package/vendor/include/networkit/generators/PubWebGenerator.hpp +94 -0
  238. package/vendor/include/networkit/generators/RegularRingLatticeGenerator.hpp +37 -0
  239. package/vendor/include/networkit/generators/RmatGenerator.hpp +67 -0
  240. package/vendor/include/networkit/generators/StaticDegreeSequenceGenerator.hpp +42 -0
  241. package/vendor/include/networkit/generators/StaticGraphGenerator.hpp +30 -0
  242. package/vendor/include/networkit/generators/StochasticBlockmodel.hpp +41 -0
  243. package/vendor/include/networkit/generators/WattsStrogatzGenerator.hpp +43 -0
  244. package/vendor/include/networkit/generators/quadtree/QuadNode.hpp +857 -0
  245. package/vendor/include/networkit/generators/quadtree/QuadNodeCartesianEuclid.hpp +587 -0
  246. package/vendor/include/networkit/generators/quadtree/QuadNodePolarEuclid.hpp +726 -0
  247. package/vendor/include/networkit/generators/quadtree/Quadtree.hpp +232 -0
  248. package/vendor/include/networkit/generators/quadtree/QuadtreeCartesianEuclid.hpp +149 -0
  249. package/vendor/include/networkit/generators/quadtree/QuadtreePolarEuclid.hpp +143 -0
  250. package/vendor/include/networkit/geometric/HyperbolicSpace.hpp +248 -0
  251. package/vendor/include/networkit/geometric/Point2DWithIndex.hpp +145 -0
  252. package/vendor/include/networkit/global/ClusteringCoefficient.hpp +42 -0
  253. package/vendor/include/networkit/global/GlobalClusteringCoefficient.hpp +24 -0
  254. package/vendor/include/networkit/graph/Attributes.hpp +568 -0
  255. package/vendor/include/networkit/graph/BFS.hpp +111 -0
  256. package/vendor/include/networkit/graph/DFS.hpp +71 -0
  257. package/vendor/include/networkit/graph/Dijkstra.hpp +83 -0
  258. package/vendor/include/networkit/graph/EdgeIterators.hpp +171 -0
  259. package/vendor/include/networkit/graph/Graph.hpp +2083 -0
  260. package/vendor/include/networkit/graph/GraphBuilder.hpp +289 -0
  261. package/vendor/include/networkit/graph/GraphR.hpp +133 -0
  262. package/vendor/include/networkit/graph/GraphTools.hpp +589 -0
  263. package/vendor/include/networkit/graph/GraphW.hpp +1236 -0
  264. package/vendor/include/networkit/graph/KruskalMSF.hpp +50 -0
  265. package/vendor/include/networkit/graph/NeighborIterators.hpp +163 -0
  266. package/vendor/include/networkit/graph/NodeIterators.hpp +127 -0
  267. package/vendor/include/networkit/graph/PrimMSF.hpp +66 -0
  268. package/vendor/include/networkit/graph/RandomMaximumSpanningForest.hpp +133 -0
  269. package/vendor/include/networkit/graph/SpanningForest.hpp +41 -0
  270. package/vendor/include/networkit/graph/TopologicalSort.hpp +87 -0
  271. package/vendor/include/networkit/graph/UnionMaximumSpanningForest.hpp +126 -0
  272. package/vendor/include/networkit/graph/test/GraphBuilderBenchmark.hpp +68 -0
  273. package/vendor/include/networkit/independentset/IndependentSetFinder.hpp +44 -0
  274. package/vendor/include/networkit/independentset/Luby.hpp +27 -0
  275. package/vendor/include/networkit/io/BinaryEdgeListPartitionReader.hpp +45 -0
  276. package/vendor/include/networkit/io/BinaryEdgeListPartitionWriter.hpp +47 -0
  277. package/vendor/include/networkit/io/BinaryPartitionReader.hpp +41 -0
  278. package/vendor/include/networkit/io/BinaryPartitionWriter.hpp +44 -0
  279. package/vendor/include/networkit/io/CoverReader.hpp +27 -0
  280. package/vendor/include/networkit/io/CoverWriter.hpp +21 -0
  281. package/vendor/include/networkit/io/DGSReader.hpp +39 -0
  282. package/vendor/include/networkit/io/DibapGraphReader.hpp +43 -0
  283. package/vendor/include/networkit/io/DotGraphWriter.hpp +39 -0
  284. package/vendor/include/networkit/io/DotPartitionWriter.hpp +23 -0
  285. package/vendor/include/networkit/io/DynamicGraphReader.hpp +29 -0
  286. package/vendor/include/networkit/io/EdgeListCoverReader.hpp +35 -0
  287. package/vendor/include/networkit/io/EdgeListPartitionReader.hpp +43 -0
  288. package/vendor/include/networkit/io/EdgeListReader.hpp +61 -0
  289. package/vendor/include/networkit/io/EdgeListWriter.hpp +48 -0
  290. package/vendor/include/networkit/io/GMLGraphReader.hpp +33 -0
  291. package/vendor/include/networkit/io/GMLGraphWriter.hpp +33 -0
  292. package/vendor/include/networkit/io/GraphIO.hpp +52 -0
  293. package/vendor/include/networkit/io/GraphReader.hpp +40 -0
  294. package/vendor/include/networkit/io/GraphToolBinaryReader.hpp +71 -0
  295. package/vendor/include/networkit/io/GraphToolBinaryWriter.hpp +61 -0
  296. package/vendor/include/networkit/io/GraphWriter.hpp +27 -0
  297. package/vendor/include/networkit/io/KONECTGraphReader.hpp +44 -0
  298. package/vendor/include/networkit/io/LineFileReader.hpp +42 -0
  299. package/vendor/include/networkit/io/METISGraphReader.hpp +36 -0
  300. package/vendor/include/networkit/io/METISGraphWriter.hpp +29 -0
  301. package/vendor/include/networkit/io/METISParser.hpp +63 -0
  302. package/vendor/include/networkit/io/MTXGraphReader.hpp +31 -0
  303. package/vendor/include/networkit/io/MTXParser.hpp +87 -0
  304. package/vendor/include/networkit/io/MatrixMarketReader.hpp +33 -0
  305. package/vendor/include/networkit/io/MatrixReader.hpp +33 -0
  306. package/vendor/include/networkit/io/MemoryMappedFile.hpp +80 -0
  307. package/vendor/include/networkit/io/NetworkitBinaryGraph.hpp +144 -0
  308. package/vendor/include/networkit/io/NetworkitBinaryReader.hpp +50 -0
  309. package/vendor/include/networkit/io/NetworkitBinaryWriter.hpp +71 -0
  310. package/vendor/include/networkit/io/PartitionReader.hpp +34 -0
  311. package/vendor/include/networkit/io/PartitionWriter.hpp +31 -0
  312. package/vendor/include/networkit/io/RBGraphReader.hpp +37 -0
  313. package/vendor/include/networkit/io/RBMatrixReader.hpp +49 -0
  314. package/vendor/include/networkit/io/RasterReader.hpp +40 -0
  315. package/vendor/include/networkit/io/SNAPEdgeListPartitionReader.hpp +28 -0
  316. package/vendor/include/networkit/io/SNAPGraphReader.hpp +53 -0
  317. package/vendor/include/networkit/io/SNAPGraphWriter.hpp +53 -0
  318. package/vendor/include/networkit/io/ThrillGraphBinaryReader.hpp +44 -0
  319. package/vendor/include/networkit/io/ThrillGraphBinaryWriter.hpp +27 -0
  320. package/vendor/include/networkit/layout/LayoutAlgorithm.hpp +39 -0
  321. package/vendor/include/networkit/linkprediction/AdamicAdarIndex.hpp +37 -0
  322. package/vendor/include/networkit/linkprediction/AdjustedRandIndex.hpp +36 -0
  323. package/vendor/include/networkit/linkprediction/AlgebraicDistanceIndex.hpp +70 -0
  324. package/vendor/include/networkit/linkprediction/CommonNeighborsIndex.hpp +39 -0
  325. package/vendor/include/networkit/linkprediction/EvaluationMetric.hpp +135 -0
  326. package/vendor/include/networkit/linkprediction/JaccardIndex.hpp +44 -0
  327. package/vendor/include/networkit/linkprediction/KatzIndex.hpp +84 -0
  328. package/vendor/include/networkit/linkprediction/LinkPredictor.hpp +98 -0
  329. package/vendor/include/networkit/linkprediction/LinkThresholder.hpp +56 -0
  330. package/vendor/include/networkit/linkprediction/MissingLinksFinder.hpp +60 -0
  331. package/vendor/include/networkit/linkprediction/NeighborhoodDistanceIndex.hpp +42 -0
  332. package/vendor/include/networkit/linkprediction/NeighborhoodUtility.hpp +54 -0
  333. package/vendor/include/networkit/linkprediction/NeighborsMeasureIndex.hpp +48 -0
  334. package/vendor/include/networkit/linkprediction/PrecisionRecallMetric.hpp +40 -0
  335. package/vendor/include/networkit/linkprediction/PredictionsSorter.hpp +66 -0
  336. package/vendor/include/networkit/linkprediction/PreferentialAttachmentIndex.hpp +37 -0
  337. package/vendor/include/networkit/linkprediction/ROCMetric.hpp +39 -0
  338. package/vendor/include/networkit/linkprediction/RandomLinkSampler.hpp +47 -0
  339. package/vendor/include/networkit/linkprediction/ResourceAllocationIndex.hpp +38 -0
  340. package/vendor/include/networkit/linkprediction/SameCommunityIndex.hpp +50 -0
  341. package/vendor/include/networkit/linkprediction/TotalNeighborsIndex.hpp +39 -0
  342. package/vendor/include/networkit/linkprediction/UDegreeIndex.hpp +35 -0
  343. package/vendor/include/networkit/linkprediction/VDegreeIndex.hpp +35 -0
  344. package/vendor/include/networkit/matching/BMatcher.hpp +52 -0
  345. package/vendor/include/networkit/matching/BMatching.hpp +115 -0
  346. package/vendor/include/networkit/matching/BSuitorMatcher.hpp +170 -0
  347. package/vendor/include/networkit/matching/DynamicBSuitorMatcher.hpp +78 -0
  348. package/vendor/include/networkit/matching/LocalMaxMatcher.hpp +35 -0
  349. package/vendor/include/networkit/matching/Matcher.hpp +55 -0
  350. package/vendor/include/networkit/matching/Matching.hpp +111 -0
  351. package/vendor/include/networkit/matching/PathGrowingMatcher.hpp +46 -0
  352. package/vendor/include/networkit/matching/SuitorMatcher.hpp +62 -0
  353. package/vendor/include/networkit/numerics/ConjugateGradient.hpp +163 -0
  354. package/vendor/include/networkit/numerics/GaussSeidelRelaxation.hpp +99 -0
  355. package/vendor/include/networkit/numerics/LAMG/LAMGSettings.hpp +70 -0
  356. package/vendor/include/networkit/numerics/LAMG/Lamg.hpp +460 -0
  357. package/vendor/include/networkit/numerics/LAMG/Level/EliminationStage.hpp +47 -0
  358. package/vendor/include/networkit/numerics/LAMG/Level/Level.hpp +56 -0
  359. package/vendor/include/networkit/numerics/LAMG/Level/LevelAggregation.hpp +52 -0
  360. package/vendor/include/networkit/numerics/LAMG/Level/LevelElimination.hpp +133 -0
  361. package/vendor/include/networkit/numerics/LAMG/Level/LevelFinest.hpp +28 -0
  362. package/vendor/include/networkit/numerics/LAMG/LevelHierarchy.hpp +165 -0
  363. package/vendor/include/networkit/numerics/LAMG/MultiLevelSetup.hpp +1090 -0
  364. package/vendor/include/networkit/numerics/LAMG/SolverLamg.hpp +316 -0
  365. package/vendor/include/networkit/numerics/LinearSolver.hpp +151 -0
  366. package/vendor/include/networkit/numerics/Preconditioner/DiagonalPreconditioner.hpp +61 -0
  367. package/vendor/include/networkit/numerics/Preconditioner/IdentityPreconditioner.hpp +36 -0
  368. package/vendor/include/networkit/numerics/Smoother.hpp +37 -0
  369. package/vendor/include/networkit/overlap/HashingOverlapper.hpp +28 -0
  370. package/vendor/include/networkit/overlap/Overlapper.hpp +27 -0
  371. package/vendor/include/networkit/planarity/LeftRightPlanarityCheck.hpp +113 -0
  372. package/vendor/include/networkit/randomization/Curveball.hpp +49 -0
  373. package/vendor/include/networkit/randomization/CurveballGlobalTradeGenerator.hpp +39 -0
  374. package/vendor/include/networkit/randomization/CurveballUniformTradeGenerator.hpp +39 -0
  375. package/vendor/include/networkit/randomization/DegreePreservingShuffle.hpp +82 -0
  376. package/vendor/include/networkit/randomization/EdgeSwitching.hpp +157 -0
  377. package/vendor/include/networkit/randomization/GlobalCurveball.hpp +69 -0
  378. package/vendor/include/networkit/randomization/GlobalTradeSequence.hpp +303 -0
  379. package/vendor/include/networkit/reachability/AllSimplePaths.hpp +122 -0
  380. package/vendor/include/networkit/reachability/ReachableNodes.hpp +83 -0
  381. package/vendor/include/networkit/scd/ApproximatePageRank.hpp +51 -0
  382. package/vendor/include/networkit/scd/CliqueDetect.hpp +55 -0
  383. package/vendor/include/networkit/scd/CombinedSCD.hpp +51 -0
  384. package/vendor/include/networkit/scd/GCE.hpp +42 -0
  385. package/vendor/include/networkit/scd/LFMLocal.hpp +54 -0
  386. package/vendor/include/networkit/scd/LocalT.hpp +40 -0
  387. package/vendor/include/networkit/scd/LocalTightnessExpansion.hpp +46 -0
  388. package/vendor/include/networkit/scd/PageRankNibble.hpp +55 -0
  389. package/vendor/include/networkit/scd/RandomBFS.hpp +33 -0
  390. package/vendor/include/networkit/scd/SCDGroundTruthComparison.hpp +121 -0
  391. package/vendor/include/networkit/scd/SelectiveCommunityDetector.hpp +76 -0
  392. package/vendor/include/networkit/scd/SetConductance.hpp +47 -0
  393. package/vendor/include/networkit/scd/TCE.hpp +41 -0
  394. package/vendor/include/networkit/scd/TwoPhaseL.hpp +40 -0
  395. package/vendor/include/networkit/scoring/EdgeScoring.hpp +44 -0
  396. package/vendor/include/networkit/scoring/ModularityScoring.hpp +79 -0
  397. package/vendor/include/networkit/simulation/EpidemicSimulationSEIR.hpp +59 -0
  398. package/vendor/include/networkit/sparsification/ChanceCorrectedTriangleScore.hpp +28 -0
  399. package/vendor/include/networkit/sparsification/ForestFireScore.hpp +34 -0
  400. package/vendor/include/networkit/sparsification/GlobalThresholdFilter.hpp +40 -0
  401. package/vendor/include/networkit/sparsification/LocalDegreeScore.hpp +30 -0
  402. package/vendor/include/networkit/sparsification/LocalFilterScore.hpp +124 -0
  403. package/vendor/include/networkit/sparsification/LocalSimilarityScore.hpp +63 -0
  404. package/vendor/include/networkit/sparsification/MultiscaleScore.hpp +38 -0
  405. package/vendor/include/networkit/sparsification/RandomEdgeScore.hpp +33 -0
  406. package/vendor/include/networkit/sparsification/RandomNodeEdgeScore.hpp +29 -0
  407. package/vendor/include/networkit/sparsification/SCANStructuralSimilarityScore.hpp +23 -0
  408. package/vendor/include/networkit/sparsification/SimmelianOverlapScore.hpp +35 -0
  409. package/vendor/include/networkit/sparsification/SimmelianScore.hpp +92 -0
  410. package/vendor/include/networkit/sparsification/Sparsifiers.hpp +166 -0
  411. package/vendor/include/networkit/structures/Cover.hpp +248 -0
  412. package/vendor/include/networkit/structures/LocalCommunity.hpp +363 -0
  413. package/vendor/include/networkit/structures/Partition.hpp +335 -0
  414. package/vendor/include/networkit/structures/UnionFind.hpp +66 -0
  415. package/vendor/include/networkit/viz/GraphLayoutAlgorithm.hpp +157 -0
  416. package/vendor/include/networkit/viz/MaxentStress.hpp +346 -0
  417. package/vendor/include/networkit/viz/Octree.hpp +428 -0
  418. package/vendor/include/networkit/viz/PivotMDS.hpp +63 -0
  419. package/vendor/include/networkit/viz/Point.hpp +415 -0
  420. package/vendor/include/networkit/viz/PostscriptWriter.hpp +78 -0
  421. package/vendor/include/tlx/algorithm/exclusive_scan.hpp +56 -0
  422. package/vendor/include/tlx/algorithm/is_sorted_cmp.hpp +56 -0
  423. package/vendor/include/tlx/algorithm/merge_advance.hpp +177 -0
  424. package/vendor/include/tlx/algorithm/merge_combine.hpp +76 -0
  425. package/vendor/include/tlx/algorithm/multisequence_partition.hpp +346 -0
  426. package/vendor/include/tlx/algorithm/multisequence_selection.hpp +351 -0
  427. package/vendor/include/tlx/algorithm/multiway_merge.hpp +1385 -0
  428. package/vendor/include/tlx/algorithm/multiway_merge_splitting.hpp +257 -0
  429. package/vendor/include/tlx/algorithm/parallel_multiway_merge.hpp +408 -0
  430. package/vendor/include/tlx/algorithm/random_bipartition_shuffle.hpp +116 -0
  431. package/vendor/include/tlx/algorithm.hpp +36 -0
  432. package/vendor/include/tlx/allocator_base.hpp +100 -0
  433. package/vendor/include/tlx/backtrace.hpp +54 -0
  434. package/vendor/include/tlx/cmdline_parser.hpp +498 -0
  435. package/vendor/include/tlx/container/btree.hpp +3977 -0
  436. package/vendor/include/tlx/container/btree_map.hpp +634 -0
  437. package/vendor/include/tlx/container/btree_multimap.hpp +627 -0
  438. package/vendor/include/tlx/container/btree_multiset.hpp +612 -0
  439. package/vendor/include/tlx/container/btree_set.hpp +612 -0
  440. package/vendor/include/tlx/container/d_ary_addressable_int_heap.hpp +416 -0
  441. package/vendor/include/tlx/container/d_ary_heap.hpp +311 -0
  442. package/vendor/include/tlx/container/loser_tree.hpp +1009 -0
  443. package/vendor/include/tlx/container/lru_cache.hpp +319 -0
  444. package/vendor/include/tlx/container/radix_heap.hpp +735 -0
  445. package/vendor/include/tlx/container/ring_buffer.hpp +428 -0
  446. package/vendor/include/tlx/container/simple_vector.hpp +304 -0
  447. package/vendor/include/tlx/container/splay_tree.hpp +399 -0
  448. package/vendor/include/tlx/container/string_view.hpp +805 -0
  449. package/vendor/include/tlx/container.hpp +40 -0
  450. package/vendor/include/tlx/counting_ptr.hpp +522 -0
  451. package/vendor/include/tlx/define/attribute_always_inline.hpp +34 -0
  452. package/vendor/include/tlx/define/attribute_fallthrough.hpp +36 -0
  453. package/vendor/include/tlx/define/attribute_format_printf.hpp +34 -0
  454. package/vendor/include/tlx/define/attribute_packed.hpp +34 -0
  455. package/vendor/include/tlx/define/attribute_warn_unused_result.hpp +34 -0
  456. package/vendor/include/tlx/define/constexpr.hpp +31 -0
  457. package/vendor/include/tlx/define/deprecated.hpp +39 -0
  458. package/vendor/include/tlx/define/endian.hpp +49 -0
  459. package/vendor/include/tlx/define/likely.hpp +33 -0
  460. package/vendor/include/tlx/define/visibility_hidden.hpp +34 -0
  461. package/vendor/include/tlx/define.hpp +36 -0
  462. package/vendor/include/tlx/delegate.hpp +524 -0
  463. package/vendor/include/tlx/die/core.hpp +311 -0
  464. package/vendor/include/tlx/die.hpp +106 -0
  465. package/vendor/include/tlx/digest/md5.hpp +81 -0
  466. package/vendor/include/tlx/digest/sha1.hpp +81 -0
  467. package/vendor/include/tlx/digest/sha256.hpp +81 -0
  468. package/vendor/include/tlx/digest/sha512.hpp +81 -0
  469. package/vendor/include/tlx/digest.hpp +30 -0
  470. package/vendor/include/tlx/logger/all.hpp +33 -0
  471. package/vendor/include/tlx/logger/array.hpp +43 -0
  472. package/vendor/include/tlx/logger/core.hpp +287 -0
  473. package/vendor/include/tlx/logger/deque.hpp +42 -0
  474. package/vendor/include/tlx/logger/map.hpp +65 -0
  475. package/vendor/include/tlx/logger/set.hpp +60 -0
  476. package/vendor/include/tlx/logger/tuple.hpp +66 -0
  477. package/vendor/include/tlx/logger/unordered_map.hpp +68 -0
  478. package/vendor/include/tlx/logger/unordered_set.hpp +64 -0
  479. package/vendor/include/tlx/logger/wrap_unprintable.hpp +75 -0
  480. package/vendor/include/tlx/logger.hpp +44 -0
  481. package/vendor/include/tlx/math/abs_diff.hpp +35 -0
  482. package/vendor/include/tlx/math/aggregate.hpp +231 -0
  483. package/vendor/include/tlx/math/aggregate_min_max.hpp +116 -0
  484. package/vendor/include/tlx/math/bswap.hpp +148 -0
  485. package/vendor/include/tlx/math/bswap_be.hpp +79 -0
  486. package/vendor/include/tlx/math/bswap_le.hpp +79 -0
  487. package/vendor/include/tlx/math/clz.hpp +174 -0
  488. package/vendor/include/tlx/math/ctz.hpp +174 -0
  489. package/vendor/include/tlx/math/div_ceil.hpp +36 -0
  490. package/vendor/include/tlx/math/ffs.hpp +123 -0
  491. package/vendor/include/tlx/math/integer_log2.hpp +189 -0
  492. package/vendor/include/tlx/math/is_power_of_two.hpp +74 -0
  493. package/vendor/include/tlx/math/polynomial_regression.hpp +243 -0
  494. package/vendor/include/tlx/math/popcount.hpp +173 -0
  495. package/vendor/include/tlx/math/power_to_the.hpp +44 -0
  496. package/vendor/include/tlx/math/rol.hpp +112 -0
  497. package/vendor/include/tlx/math/ror.hpp +112 -0
  498. package/vendor/include/tlx/math/round_to_power_of_two.hpp +121 -0
  499. package/vendor/include/tlx/math/round_up.hpp +36 -0
  500. package/vendor/include/tlx/math/sgn.hpp +38 -0
  501. package/vendor/include/tlx/math.hpp +46 -0
  502. package/vendor/include/tlx/meta/apply_tuple.hpp +55 -0
  503. package/vendor/include/tlx/meta/call_for_range.hpp +78 -0
  504. package/vendor/include/tlx/meta/call_foreach.hpp +60 -0
  505. package/vendor/include/tlx/meta/call_foreach_tuple.hpp +60 -0
  506. package/vendor/include/tlx/meta/call_foreach_tuple_with_index.hpp +61 -0
  507. package/vendor/include/tlx/meta/call_foreach_with_index.hpp +64 -0
  508. package/vendor/include/tlx/meta/enable_if.hpp +37 -0
  509. package/vendor/include/tlx/meta/fold_left.hpp +63 -0
  510. package/vendor/include/tlx/meta/fold_left_tuple.hpp +60 -0
  511. package/vendor/include/tlx/meta/fold_right.hpp +63 -0
  512. package/vendor/include/tlx/meta/fold_right_tuple.hpp +60 -0
  513. package/vendor/include/tlx/meta/function_chain.hpp +197 -0
  514. package/vendor/include/tlx/meta/function_stack.hpp +189 -0
  515. package/vendor/include/tlx/meta/has_member.hpp +80 -0
  516. package/vendor/include/tlx/meta/has_method.hpp +117 -0
  517. package/vendor/include/tlx/meta/index_sequence.hpp +66 -0
  518. package/vendor/include/tlx/meta/is_std_array.hpp +40 -0
  519. package/vendor/include/tlx/meta/is_std_pair.hpp +39 -0
  520. package/vendor/include/tlx/meta/is_std_tuple.hpp +39 -0
  521. package/vendor/include/tlx/meta/is_std_vector.hpp +39 -0
  522. package/vendor/include/tlx/meta/log2.hpp +101 -0
  523. package/vendor/include/tlx/meta/no_operation.hpp +55 -0
  524. package/vendor/include/tlx/meta/static_index.hpp +42 -0
  525. package/vendor/include/tlx/meta/vexpand.hpp +34 -0
  526. package/vendor/include/tlx/meta/vmap_for_range.hpp +84 -0
  527. package/vendor/include/tlx/meta/vmap_foreach.hpp +63 -0
  528. package/vendor/include/tlx/meta/vmap_foreach_tuple.hpp +59 -0
  529. package/vendor/include/tlx/meta/vmap_foreach_tuple_with_index.hpp +62 -0
  530. package/vendor/include/tlx/meta/vmap_foreach_with_index.hpp +70 -0
  531. package/vendor/include/tlx/meta.hpp +55 -0
  532. package/vendor/include/tlx/multi_timer.hpp +148 -0
  533. package/vendor/include/tlx/port/setenv.hpp +31 -0
  534. package/vendor/include/tlx/port.hpp +27 -0
  535. package/vendor/include/tlx/semaphore.hpp +119 -0
  536. package/vendor/include/tlx/simple_vector.hpp +20 -0
  537. package/vendor/include/tlx/siphash.hpp +282 -0
  538. package/vendor/include/tlx/sort/networks/best.hpp +611 -0
  539. package/vendor/include/tlx/sort/networks/bose_nelson.hpp +412 -0
  540. package/vendor/include/tlx/sort/networks/bose_nelson_parameter.hpp +507 -0
  541. package/vendor/include/tlx/sort/networks/cswap.hpp +60 -0
  542. package/vendor/include/tlx/sort/parallel_mergesort.hpp +398 -0
  543. package/vendor/include/tlx/sort/strings/insertion_sort.hpp +232 -0
  544. package/vendor/include/tlx/sort/strings/multikey_quicksort.hpp +185 -0
  545. package/vendor/include/tlx/sort/strings/parallel_sample_sort.hpp +1647 -0
  546. package/vendor/include/tlx/sort/strings/radix_sort.hpp +934 -0
  547. package/vendor/include/tlx/sort/strings/sample_sort_tools.hpp +756 -0
  548. package/vendor/include/tlx/sort/strings/string_ptr.hpp +426 -0
  549. package/vendor/include/tlx/sort/strings/string_set.hpp +800 -0
  550. package/vendor/include/tlx/sort/strings.hpp +329 -0
  551. package/vendor/include/tlx/sort/strings_parallel.hpp +325 -0
  552. package/vendor/include/tlx/sort.hpp +29 -0
  553. package/vendor/include/tlx/stack_allocator.hpp +226 -0
  554. package/vendor/include/tlx/string/appendline.hpp +35 -0
  555. package/vendor/include/tlx/string/base64.hpp +87 -0
  556. package/vendor/include/tlx/string/bitdump.hpp +139 -0
  557. package/vendor/include/tlx/string/compare_icase.hpp +42 -0
  558. package/vendor/include/tlx/string/contains.hpp +36 -0
  559. package/vendor/include/tlx/string/contains_word.hpp +42 -0
  560. package/vendor/include/tlx/string/ends_with.hpp +79 -0
  561. package/vendor/include/tlx/string/equal_icase.hpp +42 -0
  562. package/vendor/include/tlx/string/erase_all.hpp +70 -0
  563. package/vendor/include/tlx/string/escape_html.hpp +34 -0
  564. package/vendor/include/tlx/string/escape_uri.hpp +34 -0
  565. package/vendor/include/tlx/string/expand_environment_variables.hpp +49 -0
  566. package/vendor/include/tlx/string/extract_between.hpp +40 -0
  567. package/vendor/include/tlx/string/format_iec_units.hpp +32 -0
  568. package/vendor/include/tlx/string/format_si_iec_units.hpp +19 -0
  569. package/vendor/include/tlx/string/format_si_units.hpp +32 -0
  570. package/vendor/include/tlx/string/hash_djb2.hpp +87 -0
  571. package/vendor/include/tlx/string/hash_sdbm.hpp +86 -0
  572. package/vendor/include/tlx/string/hexdump.hpp +154 -0
  573. package/vendor/include/tlx/string/index_of.hpp +56 -0
  574. package/vendor/include/tlx/string/join.hpp +65 -0
  575. package/vendor/include/tlx/string/join_generic.hpp +89 -0
  576. package/vendor/include/tlx/string/join_quoted.hpp +46 -0
  577. package/vendor/include/tlx/string/less_icase.hpp +64 -0
  578. package/vendor/include/tlx/string/levenshtein.hpp +193 -0
  579. package/vendor/include/tlx/string/pad.hpp +39 -0
  580. package/vendor/include/tlx/string/parse_si_iec_units.hpp +46 -0
  581. package/vendor/include/tlx/string/parse_uri.hpp +66 -0
  582. package/vendor/include/tlx/string/parse_uri_form_data.hpp +136 -0
  583. package/vendor/include/tlx/string/replace.hpp +141 -0
  584. package/vendor/include/tlx/string/split.hpp +170 -0
  585. package/vendor/include/tlx/string/split_quoted.hpp +49 -0
  586. package/vendor/include/tlx/string/split_view.hpp +218 -0
  587. package/vendor/include/tlx/string/split_words.hpp +53 -0
  588. package/vendor/include/tlx/string/ssprintf.hpp +45 -0
  589. package/vendor/include/tlx/string/ssprintf_generic.hpp +95 -0
  590. package/vendor/include/tlx/string/starts_with.hpp +44 -0
  591. package/vendor/include/tlx/string/to_lower.hpp +47 -0
  592. package/vendor/include/tlx/string/to_upper.hpp +47 -0
  593. package/vendor/include/tlx/string/trim.hpp +298 -0
  594. package/vendor/include/tlx/string/union_words.hpp +33 -0
  595. package/vendor/include/tlx/string/word_wrap.hpp +35 -0
  596. package/vendor/include/tlx/string.hpp +68 -0
  597. package/vendor/include/tlx/thread_barrier_mutex.hpp +109 -0
  598. package/vendor/include/tlx/thread_barrier_spin.hpp +127 -0
  599. package/vendor/include/tlx/thread_pool.hpp +151 -0
  600. package/vendor/include/tlx/timestamp.hpp +23 -0
  601. package/vendor/include/tlx/unused.hpp +28 -0
  602. package/vendor/include/tlx/vector_free.hpp +30 -0
  603. package/vendor/include/tlx/version.hpp +49 -0
  604. package/vendor/include/ttmath/ttmath.h +2881 -0
  605. package/vendor/include/ttmath/ttmathbig.h +6111 -0
  606. package/vendor/include/ttmath/ttmathdec.h +419 -0
  607. package/vendor/include/ttmath/ttmathint.h +1923 -0
  608. package/vendor/include/ttmath/ttmathmisc.h +250 -0
  609. package/vendor/include/ttmath/ttmathobjects.h +812 -0
  610. package/vendor/include/ttmath/ttmathparser.h +2791 -0
  611. package/vendor/include/ttmath/ttmaththreads.h +252 -0
  612. package/vendor/include/ttmath/ttmathtypes.h +707 -0
  613. package/vendor/include/ttmath/ttmathuint.h +4190 -0
  614. package/vendor/include/ttmath/ttmathuint_noasm.h +1038 -0
  615. package/vendor/include/ttmath/ttmathuint_x86.h +1620 -0
  616. package/vendor/include/ttmath/ttmathuint_x86_64.h +1177 -0
  617. package/vendor/lib/cmake/tlx/tlx-config.cmake +51 -0
  618. package/vendor/lib/cmake/tlx/tlx-targets-release.cmake +19 -0
  619. package/vendor/lib/cmake/tlx/tlx-targets.cmake +106 -0
  620. package/vendor/lib/cmake/tlx/tlx-version.cmake +11 -0
  621. package/vendor/lib/libnetworkit.dylib +0 -0
  622. package/vendor/lib/libtlx.a +0 -0
  623. package/vendor/lib/pkgconfig/networkit.pc +11 -0
  624. package/vendor/lib/pkgconfig/tlx.pc +11 -0
@@ -0,0 +1,2881 @@
1
+ /*
2
+ * This file is a part of TTMath Bignum Library
3
+ * and is distributed under the 3-Clause BSD Licence.
4
+ * Author: Tomasz Sowa <t.sowa@ttmath.org>
5
+ */
6
+
7
+ /*
8
+ * Copyright (c) 2006-2017, Tomasz Sowa
9
+ * All rights reserved.
10
+ *
11
+ * Redistribution and use in source and binary forms, with or without
12
+ * modification, are permitted provided that the following conditions are met:
13
+ *
14
+ * * Redistributions of source code must retain the above copyright notice,
15
+ * this list of conditions and the following disclaimer.
16
+ *
17
+ * * Redistributions in binary form must reproduce the above copyright
18
+ * notice, this list of conditions and the following disclaimer in the
19
+ * documentation and/or other materials provided with the distribution.
20
+ *
21
+ * * Neither the name Tomasz Sowa nor the names of contributors to this
22
+ * project may be used to endorse or promote products derived
23
+ * from this software without specific prior written permission.
24
+ *
25
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
29
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
35
+ * THE POSSIBILITY OF SUCH DAMAGE.
36
+ */
37
+
38
+
39
+
40
+ #ifndef headerfilettmathmathtt
41
+ #define headerfilettmathmathtt
42
+
43
+ /*!
44
+ \file ttmath.h
45
+ \brief Mathematics functions.
46
+ */
47
+
48
+ #ifdef _MSC_VER
49
+ //warning C4127: conditional expression is constant
50
+ #pragma warning( disable: 4127 )
51
+ //warning C4702: unreachable code
52
+ #pragma warning( disable: 4702 )
53
+ //warning C4800: forcing value to bool 'true' or 'false' (performance warning)
54
+ #pragma warning( disable: 4800 )
55
+ #endif
56
+
57
+
58
+ #include "ttmathbig.h"
59
+ #include "ttmathobjects.h"
60
+
61
+
62
+ namespace ttmath
63
+ {
64
+ /*
65
+ *
66
+ * functions defined here are used only with Big<> types
67
+ *
68
+ *
69
+ */
70
+
71
+
72
+ /*
73
+ *
74
+ * functions for rounding
75
+ *
76
+ *
77
+ */
78
+
79
+
80
+ /*!
81
+ this function skips the fraction from x
82
+
83
+ samples
84
+ - 2.2 = 2
85
+ - 2.7 = 2
86
+ - -2.2 = 2
87
+ - -2.7 = 2
88
+ */
89
+ template<class ValueType>
90
+ ValueType SkipFraction(const ValueType & x)
91
+ {
92
+ ValueType result( x );
93
+ result.SkipFraction();
94
+
95
+ return result;
96
+ }
97
+
98
+
99
+ /*!
100
+ this function rounds to the nearest integer value
101
+
102
+ samples
103
+ - 2.2 = 2
104
+ - 2.7 = 3
105
+ - -2.2 = -2
106
+ - -2.7 = -3
107
+ */
108
+ template<class ValueType>
109
+ ValueType Round(const ValueType & x, ErrorCode * err = 0)
110
+ {
111
+ if( x.IsNan() )
112
+ {
113
+ if( err )
114
+ *err = err_improper_argument;
115
+
116
+ return x; // NaN
117
+ }
118
+
119
+ ValueType result( x );
120
+ uint c = result.Round();
121
+
122
+ if( err )
123
+ *err = c ? err_overflow : err_ok;
124
+
125
+ return result;
126
+ }
127
+
128
+
129
+
130
+ /*!
131
+ this function returns a value representing the smallest integer
132
+ that is greater than or equal to x
133
+
134
+ - Ceil(-3.7) = -3
135
+ - Ceil(-3.1) = -3
136
+ - Ceil(-3.0) = -3
137
+ - Ceil(4.0) = 4
138
+ - Ceil(4.2) = 5
139
+ - Ceil(4.8) = 5
140
+ */
141
+ template<class ValueType>
142
+ ValueType Ceil(const ValueType & x, ErrorCode * err = 0)
143
+ {
144
+ if( x.IsNan() )
145
+ {
146
+ if( err )
147
+ *err = err_improper_argument;
148
+
149
+ return x; // NaN
150
+ }
151
+
152
+ ValueType result(x);
153
+ uint c = 0;
154
+
155
+ result.SkipFraction();
156
+
157
+ if( result != x )
158
+ {
159
+ // x is with fraction
160
+ // if x is negative we don't have to do anything
161
+ if( !x.IsSign() )
162
+ {
163
+ ValueType one;
164
+ one.SetOne();
165
+
166
+ c += result.Add(one);
167
+ }
168
+ }
169
+
170
+ if( err )
171
+ *err = c ? err_overflow : err_ok;
172
+
173
+ return result;
174
+ }
175
+
176
+
177
+ /*!
178
+ this function returns a value representing the largest integer
179
+ that is less than or equal to x
180
+
181
+ - Floor(-3.6) = -4
182
+ - Floor(-3.1) = -4
183
+ - Floor(-3) = -3
184
+ - Floor(2) = 2
185
+ - Floor(2.3) = 2
186
+ - Floor(2.8) = 2
187
+ */
188
+ template<class ValueType>
189
+ ValueType Floor(const ValueType & x, ErrorCode * err = 0)
190
+ {
191
+ if( x.IsNan() )
192
+ {
193
+ if( err )
194
+ *err = err_improper_argument;
195
+
196
+ return x; // NaN
197
+ }
198
+
199
+ ValueType result(x);
200
+ uint c = 0;
201
+
202
+ result.SkipFraction();
203
+
204
+ if( result != x )
205
+ {
206
+ // x is with fraction
207
+ // if x is positive we don't have to do anything
208
+ if( x.IsSign() )
209
+ {
210
+ ValueType one;
211
+ one.SetOne();
212
+
213
+ c += result.Sub(one);
214
+ }
215
+ }
216
+
217
+ if( err )
218
+ *err = c ? err_overflow : err_ok;
219
+
220
+ return result;
221
+ }
222
+
223
+
224
+
225
+ /*
226
+ *
227
+ * logarithms and the exponent
228
+ *
229
+ *
230
+ */
231
+
232
+
233
+ /*!
234
+ this function calculates the natural logarithm (logarithm with the base 'e')
235
+ */
236
+ template<class ValueType>
237
+ ValueType Ln(const ValueType & x, ErrorCode * err = 0)
238
+ {
239
+ if( x.IsNan() )
240
+ {
241
+ if( err )
242
+ *err = err_improper_argument;
243
+
244
+ return x; // NaN
245
+ }
246
+
247
+ ValueType result;
248
+ uint state = result.Ln(x);
249
+
250
+ if( err )
251
+ {
252
+ switch( state )
253
+ {
254
+ case 0:
255
+ *err = err_ok;
256
+ break;
257
+ case 1:
258
+ *err = err_overflow;
259
+ break;
260
+ case 2:
261
+ *err = err_improper_argument;
262
+ break;
263
+ default:
264
+ *err = err_internal_error;
265
+ break;
266
+ }
267
+ }
268
+
269
+
270
+ return result;
271
+ }
272
+
273
+
274
+ /*!
275
+ this function calculates the logarithm
276
+ */
277
+ template<class ValueType>
278
+ ValueType Log(const ValueType & x, const ValueType & base, ErrorCode * err = 0)
279
+ {
280
+ if( x.IsNan() )
281
+ {
282
+ if( err ) *err = err_improper_argument;
283
+ return x;
284
+ }
285
+
286
+ if( base.IsNan() )
287
+ {
288
+ if( err ) *err = err_improper_argument;
289
+ return base;
290
+ }
291
+
292
+ ValueType result;
293
+ uint state = result.Log(x, base);
294
+
295
+ if( err )
296
+ {
297
+ switch( state )
298
+ {
299
+ case 0:
300
+ *err = err_ok;
301
+ break;
302
+ case 1:
303
+ *err = err_overflow;
304
+ break;
305
+ case 2:
306
+ case 3:
307
+ *err = err_improper_argument;
308
+ break;
309
+ default:
310
+ *err = err_internal_error;
311
+ break;
312
+ }
313
+ }
314
+
315
+ return result;
316
+ }
317
+
318
+
319
+ /*!
320
+ this function calculates the expression e^x
321
+ */
322
+ template<class ValueType>
323
+ ValueType Exp(const ValueType & x, ErrorCode * err = 0)
324
+ {
325
+ if( x.IsNan() )
326
+ {
327
+ if( err )
328
+ *err = err_improper_argument;
329
+
330
+ return x; // NaN
331
+ }
332
+
333
+ ValueType result;
334
+ uint c = result.Exp(x);
335
+
336
+ if( err )
337
+ *err = c ? err_overflow : err_ok;
338
+
339
+ return result;
340
+ }
341
+
342
+
343
+ /*!
344
+ *
345
+ * trigonometric functions
346
+ *
347
+ */
348
+
349
+
350
+ /*
351
+ this namespace consists of auxiliary functions
352
+ (something like 'private' in a class)
353
+
354
+ this is excluded from doxygen documentation
355
+ (option EXCLUDE_SYMBOLS in doxygen.cfg)
356
+ */
357
+ namespace auxiliaryfunctions
358
+ {
359
+
360
+ /*!
361
+ an auxiliary function for calculating the Sine
362
+ (you don't have to call this function)
363
+ */
364
+ template<class ValueType>
365
+ uint PrepareSin(ValueType & x, bool & change_sign)
366
+ {
367
+ ValueType temp;
368
+
369
+ change_sign = false;
370
+
371
+ if( x.IsSign() )
372
+ {
373
+ // we're using the formula 'sin(-x) = -sin(x)'
374
+ change_sign = !change_sign;
375
+ x.ChangeSign();
376
+ }
377
+
378
+ // we're reducing the period 2*PI
379
+ // (for big values there'll always be zero)
380
+ temp.Set2Pi();
381
+
382
+ if( x.Mod(temp) )
383
+ return 1;
384
+
385
+
386
+ // we're setting 'x' as being in the range of <0, 0.5PI>
387
+
388
+ temp.SetPi();
389
+
390
+ if( x > temp )
391
+ {
392
+ // x is in (pi, 2*pi>
393
+ x.Sub( temp );
394
+ change_sign = !change_sign;
395
+ }
396
+
397
+ temp.Set05Pi();
398
+
399
+ if( x > temp )
400
+ {
401
+ // x is in (0.5pi, pi>
402
+ x.Sub( temp );
403
+ x = temp - x;
404
+ }
405
+
406
+ return 0;
407
+ }
408
+
409
+
410
+ /*!
411
+ an auxiliary function for calculating the Sine
412
+ (you don't have to call this function)
413
+
414
+ it returns Sin(x) where 'x' is from <0, PI/2>
415
+ we're calculating the Sin with using Taylor series in zero or PI/2
416
+ (depending on which point of these two points is nearer to the 'x')
417
+
418
+ Taylor series:
419
+ sin(x) = sin(a) + cos(a)*(x-a)/(1!)
420
+ - sin(a)*((x-a)^2)/(2!) - cos(a)*((x-a)^3)/(3!)
421
+ + sin(a)*((x-a)^4)/(4!) + ...
422
+
423
+ when a=0 it'll be:
424
+ sin(x) = (x)/(1!) - (x^3)/(3!) + (x^5)/(5!) - (x^7)/(7!) + (x^9)/(9!) ...
425
+
426
+ and when a=PI/2:
427
+ sin(x) = 1 - ((x-PI/2)^2)/(2!) + ((x-PI/2)^4)/(4!) - ((x-PI/2)^6)/(6!) ...
428
+ */
429
+ template<class ValueType>
430
+ ValueType Sin0pi05(const ValueType & x)
431
+ {
432
+ ValueType result;
433
+ ValueType numerator, denominator;
434
+ ValueType d_numerator, d_denominator;
435
+ ValueType one, temp, old_result;
436
+
437
+ // temp = pi/4
438
+ temp.Set05Pi();
439
+ temp.exponent.SubOne();
440
+
441
+ one.SetOne();
442
+
443
+ if( x < temp )
444
+ {
445
+ // we're using the Taylor series with a=0
446
+ result = x;
447
+ numerator = x;
448
+ denominator = one;
449
+
450
+ // d_numerator = x^2
451
+ d_numerator = x;
452
+ d_numerator.Mul(x);
453
+
454
+ d_denominator = 2;
455
+ }
456
+ else
457
+ {
458
+ // we're using the Taylor series with a=PI/2
459
+ result = one;
460
+ numerator = one;
461
+ denominator = one;
462
+
463
+ // d_numerator = (x-pi/2)^2
464
+ ValueType pi05;
465
+ pi05.Set05Pi();
466
+
467
+ temp = x;
468
+ temp.Sub( pi05 );
469
+ d_numerator = temp;
470
+ d_numerator.Mul( temp );
471
+
472
+ d_denominator = one;
473
+ }
474
+
475
+ uint c = 0;
476
+ bool addition = false;
477
+
478
+ old_result = result;
479
+ for(uint i=1 ; i<=TTMATH_ARITHMETIC_MAX_LOOP ; ++i)
480
+ {
481
+ // we're starting from a second part of the formula
482
+ c += numerator. Mul( d_numerator );
483
+ c += denominator. Mul( d_denominator );
484
+ c += d_denominator.Add( one );
485
+ c += denominator. Mul( d_denominator );
486
+ c += d_denominator.Add( one );
487
+ temp = numerator;
488
+ c += temp.Div(denominator);
489
+
490
+ if( c )
491
+ // Sin is from <-1,1> and cannot make an overflow
492
+ // but the carry can be from the Taylor series
493
+ // (then we only break our calculations)
494
+ break;
495
+
496
+ if( addition )
497
+ result.Add( temp );
498
+ else
499
+ result.Sub( temp );
500
+
501
+
502
+ addition = !addition;
503
+
504
+ // we're testing whether the result has changed after adding
505
+ // the next part of the Taylor formula, if not we end the loop
506
+ // (it means 'x' is zero or 'x' is PI/2 or this part of the formula
507
+ // is too small)
508
+ if( result == old_result )
509
+ break;
510
+
511
+ old_result = result;
512
+ }
513
+
514
+ return result;
515
+ }
516
+
517
+ } // namespace auxiliaryfunctions
518
+
519
+
520
+
521
+ /*!
522
+ this function calculates the Sine
523
+ */
524
+ template<class ValueType>
525
+ ValueType Sin(ValueType x, ErrorCode * err = 0)
526
+ {
527
+ using namespace auxiliaryfunctions;
528
+
529
+ ValueType one, result;
530
+ bool change_sign;
531
+
532
+ if( x.IsNan() )
533
+ {
534
+ if( err )
535
+ *err = err_improper_argument;
536
+
537
+ return x;
538
+ }
539
+
540
+ if( err )
541
+ *err = err_ok;
542
+
543
+ if( PrepareSin( x, change_sign ) )
544
+ {
545
+ // x is too big, we cannnot reduce the 2*PI period
546
+ // prior to version 0.8.5 the result was zero
547
+
548
+ // result has NaN flag set by default
549
+
550
+ if( err )
551
+ *err = err_overflow; // maybe another error code? err_improper_argument?
552
+
553
+ return result; // NaN is set by default
554
+ }
555
+
556
+ result = Sin0pi05( x );
557
+
558
+ one.SetOne();
559
+
560
+ // after calculations there can be small distortions in the result
561
+ if( result > one )
562
+ result = one;
563
+ else
564
+ if( result.IsSign() )
565
+ // we've calculated the sin from <0, pi/2> and the result
566
+ // should be positive
567
+ result.SetZero();
568
+
569
+ if( change_sign )
570
+ result.ChangeSign();
571
+
572
+ return result;
573
+ }
574
+
575
+
576
+ /*!
577
+ this function calulates the Cosine
578
+ we're using the formula cos(x) = sin(x + PI/2)
579
+ */
580
+ template<class ValueType>
581
+ ValueType Cos(ValueType x, ErrorCode * err = 0)
582
+ {
583
+ if( x.IsNan() )
584
+ {
585
+ if( err )
586
+ *err = err_improper_argument;
587
+
588
+ return x; // NaN
589
+ }
590
+
591
+ ValueType pi05;
592
+ pi05.Set05Pi();
593
+
594
+ uint c = x.Add( pi05 );
595
+
596
+ if( c )
597
+ {
598
+ if( err )
599
+ *err = err_overflow;
600
+
601
+ return ValueType(); // result is undefined (NaN is set by default)
602
+ }
603
+
604
+ return Sin(x, err);
605
+ }
606
+
607
+
608
+ /*!
609
+ this function calulates the Tangent
610
+ we're using the formula tan(x) = sin(x) / cos(x)
611
+
612
+ it takes more time than calculating the Tan directly
613
+ from for example Taylor series but should be a bit preciser
614
+ because Tan receives its values from -infinity to +infinity
615
+ and when we calculate it from any series then we can make
616
+ a greater mistake than calculating 'sin/cos'
617
+ */
618
+ template<class ValueType>
619
+ ValueType Tan(const ValueType & x, ErrorCode * err = 0)
620
+ {
621
+ ValueType result = Cos(x, err);
622
+
623
+ if( err && *err != err_ok )
624
+ return result;
625
+
626
+ if( result.IsZero() )
627
+ {
628
+ if( err )
629
+ *err = err_improper_argument;
630
+
631
+ result.SetNan();
632
+
633
+ return result;
634
+ }
635
+
636
+ return Sin(x, err) / result;
637
+ }
638
+
639
+
640
+ /*!
641
+ this function calulates the Tangent
642
+ look at the description of Tan(...)
643
+
644
+ (the abbreviation of Tangent can be 'tg' as well)
645
+ */
646
+ template<class ValueType>
647
+ ValueType Tg(const ValueType & x, ErrorCode * err = 0)
648
+ {
649
+ return Tan(x, err);
650
+ }
651
+
652
+
653
+ /*!
654
+ this function calulates the Cotangent
655
+ we're using the formula tan(x) = cos(x) / sin(x)
656
+
657
+ (why do we make it in this way?
658
+ look at information in Tan() function)
659
+ */
660
+ template<class ValueType>
661
+ ValueType Cot(const ValueType & x, ErrorCode * err = 0)
662
+ {
663
+ ValueType result = Sin(x, err);
664
+
665
+ if( err && *err != err_ok )
666
+ return result;
667
+
668
+ if( result.IsZero() )
669
+ {
670
+ if( err )
671
+ *err = err_improper_argument;
672
+
673
+ result.SetNan();
674
+
675
+ return result;
676
+ }
677
+
678
+ return Cos(x, err) / result;
679
+ }
680
+
681
+
682
+ /*!
683
+ this function calulates the Cotangent
684
+ look at the description of Cot(...)
685
+
686
+ (the abbreviation of Cotangent can be 'ctg' as well)
687
+ */
688
+ template<class ValueType>
689
+ ValueType Ctg(const ValueType & x, ErrorCode * err = 0)
690
+ {
691
+ return Cot(x, err);
692
+ }
693
+
694
+
695
+ /*
696
+ *
697
+ * inverse trigonometric functions
698
+ *
699
+ *
700
+ */
701
+
702
+ namespace auxiliaryfunctions
703
+ {
704
+
705
+ /*!
706
+ an auxiliary function for calculating the Arc Sine
707
+
708
+ we're calculating asin from the following formula:
709
+ asin(x) = x + (1*x^3)/(2*3) + (1*3*x^5)/(2*4*5) + (1*3*5*x^7)/(2*4*6*7) + ...
710
+ where abs(x) <= 1
711
+
712
+ we're using this formula when x is from <0, 1/2>
713
+ */
714
+ template<class ValueType>
715
+ ValueType ASin_0(const ValueType & x)
716
+ {
717
+ ValueType nominator, denominator, nominator_add, nominator_x, denominator_add, denominator_x;
718
+ ValueType two, result(x), x2(x);
719
+ ValueType nominator_temp, denominator_temp, old_result = result;
720
+ uint c = 0;
721
+
722
+ x2.Mul(x);
723
+ two = 2;
724
+
725
+ nominator.SetOne();
726
+ denominator = two;
727
+ nominator_add = nominator;
728
+ denominator_add = denominator;
729
+ nominator_x = x;
730
+ denominator_x = 3;
731
+
732
+ for(uint i=1 ; i<=TTMATH_ARITHMETIC_MAX_LOOP ; ++i)
733
+ {
734
+ c += nominator_x.Mul(x2);
735
+ nominator_temp = nominator_x;
736
+ c += nominator_temp.Mul(nominator);
737
+ denominator_temp = denominator;
738
+ c += denominator_temp.Mul(denominator_x);
739
+ c += nominator_temp.Div(denominator_temp);
740
+
741
+ // if there is a carry somewhere we only break the calculating
742
+ // the result should be ok -- it's from <-pi/2, pi/2>
743
+ if( c )
744
+ break;
745
+
746
+ result.Add(nominator_temp);
747
+
748
+ if( result == old_result )
749
+ // there's no sense to calculate more
750
+ break;
751
+
752
+ old_result = result;
753
+
754
+
755
+ c += nominator_add.Add(two);
756
+ c += denominator_add.Add(two);
757
+ c += nominator.Mul(nominator_add);
758
+ c += denominator.Mul(denominator_add);
759
+ c += denominator_x.Add(two);
760
+ }
761
+
762
+ return result;
763
+ }
764
+
765
+
766
+
767
+ /*!
768
+ an auxiliary function for calculating the Arc Sine
769
+
770
+ we're calculating asin from the following formula:
771
+ asin(x) = pi/2 - sqrt(2)*sqrt(1-x) * asin_temp
772
+ asin_temp = 1 + (1*(1-x))/((2*3)*(2)) + (1*3*(1-x)^2)/((2*4*5)*(4)) + (1*3*5*(1-x)^3)/((2*4*6*7)*(8)) + ...
773
+
774
+ where abs(x) <= 1
775
+
776
+ we're using this formula when x is from (1/2, 1>
777
+ */
778
+ template<class ValueType>
779
+ ValueType ASin_1(const ValueType & x)
780
+ {
781
+ ValueType nominator, denominator, nominator_add, nominator_x, nominator_x_add, denominator_add, denominator_x;
782
+ ValueType denominator2;
783
+ ValueType one, two, result;
784
+ ValueType nominator_temp, denominator_temp, old_result;
785
+ uint c = 0;
786
+
787
+ two = 2;
788
+
789
+ one.SetOne();
790
+ nominator = one;
791
+ result = one;
792
+ old_result = result;
793
+ denominator = two;
794
+ nominator_add = nominator;
795
+ denominator_add = denominator;
796
+ nominator_x = one;
797
+ nominator_x.Sub(x);
798
+ nominator_x_add = nominator_x;
799
+ denominator_x = 3;
800
+ denominator2 = two;
801
+
802
+
803
+ for(uint i=1 ; i<=TTMATH_ARITHMETIC_MAX_LOOP ; ++i)
804
+ {
805
+ nominator_temp = nominator_x;
806
+ c += nominator_temp.Mul(nominator);
807
+ denominator_temp = denominator;
808
+ c += denominator_temp.Mul(denominator_x);
809
+ c += denominator_temp.Mul(denominator2);
810
+ c += nominator_temp.Div(denominator_temp);
811
+
812
+ // if there is a carry somewhere we only break the calculating
813
+ // the result should be ok -- it's from <-pi/2, pi/2>
814
+ if( c )
815
+ break;
816
+
817
+ result.Add(nominator_temp);
818
+
819
+ if( result == old_result )
820
+ // there's no sense to calculate more
821
+ break;
822
+
823
+ old_result = result;
824
+
825
+ c += nominator_x.Mul(nominator_x_add);
826
+ c += nominator_add.Add(two);
827
+ c += denominator_add.Add(two);
828
+ c += nominator.Mul(nominator_add);
829
+ c += denominator.Mul(denominator_add);
830
+ c += denominator_x.Add(two);
831
+ c += denominator2.Mul(two);
832
+ }
833
+
834
+
835
+ nominator_x_add.exponent.AddOne(); // *2
836
+ one.exponent.SubOne(); // =0.5
837
+ nominator_x_add.Pow(one); // =sqrt(nominator_x_add)
838
+ result.Mul(nominator_x_add);
839
+
840
+ one.Set05Pi();
841
+ one.Sub(result);
842
+
843
+ return one;
844
+ }
845
+
846
+
847
+ } // namespace auxiliaryfunctions
848
+
849
+
850
+ /*!
851
+ this function calculates the Arc Sine
852
+ x is from <-1,1>
853
+ */
854
+ template<class ValueType>
855
+ ValueType ASin(ValueType x, ErrorCode * err = 0)
856
+ {
857
+ using namespace auxiliaryfunctions;
858
+
859
+ ValueType result, one;
860
+ one.SetOne();
861
+ bool change_sign = false;
862
+
863
+ if( x.IsNan() )
864
+ {
865
+ if( err )
866
+ *err = err_improper_argument;
867
+
868
+ return x;
869
+ }
870
+
871
+ if( x.GreaterWithoutSignThan(one) )
872
+ {
873
+ if( err )
874
+ *err = err_improper_argument;
875
+
876
+ result.SetZeroNan();
877
+ return result;
878
+ }
879
+
880
+ if( x.IsSign() )
881
+ {
882
+ change_sign = true;
883
+ x.Abs();
884
+ }
885
+
886
+ one.exponent.SubOne(); // =0.5
887
+
888
+ // asin(-x) = -asin(x)
889
+ if( x.GreaterWithoutSignThan(one) )
890
+ result = ASin_1(x);
891
+ else
892
+ result = ASin_0(x);
893
+
894
+ if( change_sign )
895
+ result.ChangeSign();
896
+
897
+ if( err )
898
+ *err = err_ok;
899
+
900
+ return result;
901
+ }
902
+
903
+
904
+ /*!
905
+ this function calculates the Arc Cosine
906
+
907
+ we're using the formula:
908
+ acos(x) = pi/2 - asin(x)
909
+ */
910
+ template<class ValueType>
911
+ ValueType ACos(const ValueType & x, ErrorCode * err = 0)
912
+ {
913
+ ValueType temp;
914
+
915
+ temp.Set05Pi();
916
+ temp.Sub(ASin(x, err));
917
+
918
+ return temp;
919
+ }
920
+
921
+
922
+
923
+ namespace auxiliaryfunctions
924
+ {
925
+
926
+ /*!
927
+ an auxiliary function for calculating the Arc Tangent
928
+
929
+ arc tan (x) where x is in <0; 0.5)
930
+ (x can be in (-0.5 ; 0.5) too)
931
+
932
+ we're using the Taylor series expanded in zero:
933
+ atan(x) = x - (x^3)/3 + (x^5)/5 - (x^7)/7 + ...
934
+ */
935
+ template<class ValueType>
936
+ ValueType ATan0(const ValueType & x)
937
+ {
938
+ ValueType nominator, denominator, nominator_add, denominator_add, temp;
939
+ ValueType result, old_result;
940
+ bool adding = false;
941
+ uint c = 0;
942
+
943
+ result = x;
944
+ old_result = result;
945
+ nominator = x;
946
+ nominator_add = x;
947
+ nominator_add.Mul(x);
948
+
949
+ denominator.SetOne();
950
+ denominator_add = 2;
951
+
952
+ for(uint i=1 ; i<=TTMATH_ARITHMETIC_MAX_LOOP ; ++i)
953
+ {
954
+ c += nominator.Mul(nominator_add);
955
+ c += denominator.Add(denominator_add);
956
+
957
+ temp = nominator;
958
+ c += temp.Div(denominator);
959
+
960
+ if( c )
961
+ // the result should be ok
962
+ break;
963
+
964
+ if( adding )
965
+ result.Add(temp);
966
+ else
967
+ result.Sub(temp);
968
+
969
+ if( result == old_result )
970
+ // there's no sense to calculate more
971
+ break;
972
+
973
+ old_result = result;
974
+ adding = !adding;
975
+ }
976
+
977
+ return result;
978
+ }
979
+
980
+
981
+ /*!
982
+ an auxiliary function for calculating the Arc Tangent
983
+
984
+ where x is in <0 ; 1>
985
+ */
986
+ template<class ValueType>
987
+ ValueType ATan01(const ValueType & x)
988
+ {
989
+ ValueType half;
990
+ half.Set05();
991
+
992
+ /*
993
+ it would be better if we chose about sqrt(2)-1=0.41... instead of 0.5 here
994
+
995
+ because as you can see below:
996
+ when x = sqrt(2)-1
997
+ abs(x) = abs( (x-1)/(1+x) )
998
+ so when we're calculating values around x
999
+ then they will be better converged to each other
1000
+
1001
+ for example if we have x=0.4999 then during calculating ATan0(0.4999)
1002
+ we have to make about 141 iterations but when we have x=0.5
1003
+ then during calculating ATan0( (x-1)/(1+x) ) we have to make
1004
+ only about 89 iterations (both for Big<3,9>)
1005
+
1006
+ in the future this 0.5 can be changed
1007
+ */
1008
+ if( x.SmallerWithoutSignThan(half) )
1009
+ return ATan0(x);
1010
+
1011
+
1012
+ /*
1013
+ x>=0.5 and x<=1
1014
+ (x can be even smaller than 0.5)
1015
+
1016
+ y = atac(x)
1017
+ x = tan(y)
1018
+
1019
+ tan(y-b) = (tan(y)-tab(b)) / (1+tan(y)*tan(b))
1020
+ y-b = atan( (tan(y)-tab(b)) / (1+tan(y)*tan(b)) )
1021
+ y = b + atan( (x-tab(b)) / (1+x*tan(b)) )
1022
+
1023
+ let b = pi/4
1024
+ tan(b) = tan(pi/4) = 1
1025
+ y = pi/4 + atan( (x-1)/(1+x) )
1026
+
1027
+ so
1028
+ atac(x) = pi/4 + atan( (x-1)/(1+x) )
1029
+ when x->1 (x converges to 1) the (x-1)/(1+x) -> 0
1030
+ and we can use ATan0() function here
1031
+ */
1032
+
1033
+ ValueType n(x),d(x),one,result;
1034
+
1035
+ one.SetOne();
1036
+ n.Sub(one);
1037
+ d.Add(one);
1038
+ n.Div(d);
1039
+
1040
+ result = ATan0(n);
1041
+
1042
+ n.Set05Pi();
1043
+ n.exponent.SubOne(); // =pi/4
1044
+ result.Add(n);
1045
+
1046
+ return result;
1047
+ }
1048
+
1049
+
1050
+ /*!
1051
+ an auxiliary function for calculating the Arc Tangent
1052
+ where x > 1
1053
+
1054
+ we're using the formula:
1055
+ atan(x) = pi/2 - atan(1/x) for x>0
1056
+ */
1057
+ template<class ValueType>
1058
+ ValueType ATanGreaterThanPlusOne(const ValueType & x)
1059
+ {
1060
+ ValueType temp, atan;
1061
+
1062
+ temp.SetOne();
1063
+
1064
+ if( temp.Div(x) )
1065
+ {
1066
+ // if there was a carry here that means x is very big
1067
+ // and atan(1/x) fast converged to 0
1068
+ atan.SetZero();
1069
+ }
1070
+ else
1071
+ atan = ATan01(temp);
1072
+
1073
+ temp.Set05Pi();
1074
+ temp.Sub(atan);
1075
+
1076
+ return temp;
1077
+ }
1078
+
1079
+ } // namespace auxiliaryfunctions
1080
+
1081
+
1082
+ /*!
1083
+ this function calculates the Arc Tangent
1084
+ */
1085
+ template<class ValueType>
1086
+ ValueType ATan(ValueType x)
1087
+ {
1088
+ using namespace auxiliaryfunctions;
1089
+
1090
+ ValueType one, result;
1091
+ one.SetOne();
1092
+ bool change_sign = false;
1093
+
1094
+ if( x.IsNan() )
1095
+ return x;
1096
+
1097
+ // if x is negative we're using the formula:
1098
+ // atan(-x) = -atan(x)
1099
+ if( x.IsSign() )
1100
+ {
1101
+ change_sign = true;
1102
+ x.Abs();
1103
+ }
1104
+
1105
+ if( x.GreaterWithoutSignThan(one) )
1106
+ result = ATanGreaterThanPlusOne(x);
1107
+ else
1108
+ result = ATan01(x);
1109
+
1110
+ if( change_sign )
1111
+ result.ChangeSign();
1112
+
1113
+ return result;
1114
+ }
1115
+
1116
+
1117
+ /*!
1118
+ this function calculates the Arc Tangent
1119
+ look at the description of ATan(...)
1120
+
1121
+ (the abbreviation of Arc Tangent can be 'atg' as well)
1122
+ */
1123
+ template<class ValueType>
1124
+ ValueType ATg(const ValueType & x)
1125
+ {
1126
+ return ATan(x);
1127
+ }
1128
+
1129
+
1130
+ /*!
1131
+ this function calculates the Arc Cotangent
1132
+
1133
+ we're using the formula:
1134
+ actan(x) = pi/2 - atan(x)
1135
+ */
1136
+ template<class ValueType>
1137
+ ValueType ACot(const ValueType & x)
1138
+ {
1139
+ ValueType result;
1140
+
1141
+ result.Set05Pi();
1142
+ result.Sub(ATan(x));
1143
+
1144
+ return result;
1145
+ }
1146
+
1147
+
1148
+ /*!
1149
+ this function calculates the Arc Cotangent
1150
+ look at the description of ACot(...)
1151
+
1152
+ (the abbreviation of Arc Cotangent can be 'actg' as well)
1153
+ */
1154
+ template<class ValueType>
1155
+ ValueType ACtg(const ValueType & x)
1156
+ {
1157
+ return ACot(x);
1158
+ }
1159
+
1160
+
1161
+ /*
1162
+ *
1163
+ * hyperbolic functions
1164
+ *
1165
+ *
1166
+ */
1167
+
1168
+
1169
+ /*!
1170
+ this function calculates the Hyperbolic Sine
1171
+
1172
+ we're using the formula sinh(x)= ( e^x - e^(-x) ) / 2
1173
+ */
1174
+ template<class ValueType>
1175
+ ValueType Sinh(const ValueType & x, ErrorCode * err = 0)
1176
+ {
1177
+ if( x.IsNan() )
1178
+ {
1179
+ if( err )
1180
+ *err = err_improper_argument;
1181
+
1182
+ return x; // NaN
1183
+ }
1184
+
1185
+ ValueType ex, emx;
1186
+ uint c = 0;
1187
+
1188
+ c += ex.Exp(x);
1189
+ c += emx.Exp(-x);
1190
+
1191
+ c += ex.Sub(emx);
1192
+ c += ex.exponent.SubOne();
1193
+
1194
+ if( err )
1195
+ *err = c ? err_overflow : err_ok;
1196
+
1197
+ return ex;
1198
+ }
1199
+
1200
+
1201
+ /*!
1202
+ this function calculates the Hyperbolic Cosine
1203
+
1204
+ we're using the formula cosh(x)= ( e^x + e^(-x) ) / 2
1205
+ */
1206
+ template<class ValueType>
1207
+ ValueType Cosh(const ValueType & x, ErrorCode * err = 0)
1208
+ {
1209
+ if( x.IsNan() )
1210
+ {
1211
+ if( err )
1212
+ *err = err_improper_argument;
1213
+
1214
+ return x; // NaN
1215
+ }
1216
+
1217
+ ValueType ex, emx;
1218
+ uint c = 0;
1219
+
1220
+ c += ex.Exp(x);
1221
+ c += emx.Exp(-x);
1222
+
1223
+ c += ex.Add(emx);
1224
+ c += ex.exponent.SubOne();
1225
+
1226
+ if( err )
1227
+ *err = c ? err_overflow : err_ok;
1228
+
1229
+ return ex;
1230
+ }
1231
+
1232
+
1233
+ /*!
1234
+ this function calculates the Hyperbolic Tangent
1235
+
1236
+ we're using the formula tanh(x)= ( e^x - e^(-x) ) / ( e^x + e^(-x) )
1237
+ */
1238
+ template<class ValueType>
1239
+ ValueType Tanh(const ValueType & x, ErrorCode * err = 0)
1240
+ {
1241
+ if( x.IsNan() )
1242
+ {
1243
+ if( err )
1244
+ *err = err_improper_argument;
1245
+
1246
+ return x; // NaN
1247
+ }
1248
+
1249
+ ValueType ex, emx, nominator, denominator;
1250
+ uint c = 0;
1251
+
1252
+ c += ex.Exp(x);
1253
+ c += emx.Exp(-x);
1254
+
1255
+ nominator = ex;
1256
+ c += nominator.Sub(emx);
1257
+ denominator = ex;
1258
+ c += denominator.Add(emx);
1259
+
1260
+ c += nominator.Div(denominator);
1261
+
1262
+ if( err )
1263
+ *err = c ? err_overflow : err_ok;
1264
+
1265
+ return nominator;
1266
+ }
1267
+
1268
+
1269
+ /*!
1270
+ this function calculates the Hyperbolic Tangent
1271
+ look at the description of Tanh(...)
1272
+
1273
+ (the abbreviation of Hyperbolic Tangent can be 'tgh' as well)
1274
+ */
1275
+ template<class ValueType>
1276
+ ValueType Tgh(const ValueType & x, ErrorCode * err = 0)
1277
+ {
1278
+ return Tanh(x, err);
1279
+ }
1280
+
1281
+ /*!
1282
+ this function calculates the Hyperbolic Cotangent
1283
+
1284
+ we're using the formula coth(x)= ( e^x + e^(-x) ) / ( e^x - e^(-x) )
1285
+ */
1286
+ template<class ValueType>
1287
+ ValueType Coth(const ValueType & x, ErrorCode * err = 0)
1288
+ {
1289
+ if( x.IsNan() )
1290
+ {
1291
+ if( err )
1292
+ *err = err_improper_argument;
1293
+
1294
+ return x; // NaN
1295
+ }
1296
+
1297
+ if( x.IsZero() )
1298
+ {
1299
+ if( err )
1300
+ *err = err_improper_argument;
1301
+
1302
+ return ValueType(); // NaN is set by default
1303
+ }
1304
+
1305
+ ValueType ex, emx, nominator, denominator;
1306
+ uint c = 0;
1307
+
1308
+ c += ex.Exp(x);
1309
+ c += emx.Exp(-x);
1310
+
1311
+ nominator = ex;
1312
+ c += nominator.Add(emx);
1313
+ denominator = ex;
1314
+ c += denominator.Sub(emx);
1315
+
1316
+ c += nominator.Div(denominator);
1317
+
1318
+ if( err )
1319
+ *err = c ? err_overflow : err_ok;
1320
+
1321
+ return nominator;
1322
+ }
1323
+
1324
+
1325
+ /*!
1326
+ this function calculates the Hyperbolic Cotangent
1327
+ look at the description of Coth(...)
1328
+
1329
+ (the abbreviation of Hyperbolic Cotangent can be 'ctgh' as well)
1330
+ */
1331
+ template<class ValueType>
1332
+ ValueType Ctgh(const ValueType & x, ErrorCode * err = 0)
1333
+ {
1334
+ return Coth(x, err);
1335
+ }
1336
+
1337
+
1338
+ /*
1339
+ *
1340
+ * inverse hyperbolic functions
1341
+ *
1342
+ *
1343
+ */
1344
+
1345
+
1346
+ /*!
1347
+ inverse hyperbolic sine
1348
+
1349
+ asinh(x) = ln( x + sqrt(x^2 + 1) )
1350
+ */
1351
+ template<class ValueType>
1352
+ ValueType ASinh(const ValueType & x, ErrorCode * err = 0)
1353
+ {
1354
+ if( x.IsNan() )
1355
+ {
1356
+ if( err )
1357
+ *err = err_improper_argument;
1358
+
1359
+ return x; // NaN
1360
+ }
1361
+
1362
+ ValueType xx(x), one, result;
1363
+ uint c = 0;
1364
+ one.SetOne();
1365
+
1366
+ c += xx.Mul(x);
1367
+ c += xx.Add(one);
1368
+ one.exponent.SubOne(); // one=0.5
1369
+ // xx is >= 1
1370
+ c += xx.PowFrac(one); // xx=sqrt(xx)
1371
+ c += xx.Add(x);
1372
+ c += result.Ln(xx); // xx > 0
1373
+
1374
+ // here can only be a carry
1375
+ if( err )
1376
+ *err = c ? err_overflow : err_ok;
1377
+
1378
+ return result;
1379
+ }
1380
+
1381
+
1382
+ /*!
1383
+ inverse hyperbolic cosine
1384
+
1385
+ acosh(x) = ln( x + sqrt(x^2 - 1) ) x in <1, infinity)
1386
+ */
1387
+ template<class ValueType>
1388
+ ValueType ACosh(const ValueType & x, ErrorCode * err = 0)
1389
+ {
1390
+ if( x.IsNan() )
1391
+ {
1392
+ if( err )
1393
+ *err = err_improper_argument;
1394
+
1395
+ return x; // NaN
1396
+ }
1397
+
1398
+ ValueType xx(x), one, result;
1399
+ uint c = 0;
1400
+ one.SetOne();
1401
+
1402
+ if( x < one )
1403
+ {
1404
+ if( err )
1405
+ *err = err_improper_argument;
1406
+
1407
+ return result; // NaN is set by default
1408
+ }
1409
+
1410
+ c += xx.Mul(x);
1411
+ c += xx.Sub(one);
1412
+ // xx is >= 0
1413
+ // we can't call a PowFrac when the 'x' is zero
1414
+ // if x is 0 the sqrt(0) is 0
1415
+ if( !xx.IsZero() )
1416
+ {
1417
+ one.exponent.SubOne(); // one=0.5
1418
+ c += xx.PowFrac(one); // xx=sqrt(xx)
1419
+ }
1420
+ c += xx.Add(x);
1421
+ c += result.Ln(xx); // xx >= 1
1422
+
1423
+ // here can only be a carry
1424
+ if( err )
1425
+ *err = c ? err_overflow : err_ok;
1426
+
1427
+ return result;
1428
+ }
1429
+
1430
+
1431
+ /*!
1432
+ inverse hyperbolic tangent
1433
+
1434
+ atanh(x) = 0.5 * ln( (1+x) / (1-x) ) x in (-1, 1)
1435
+ */
1436
+ template<class ValueType>
1437
+ ValueType ATanh(const ValueType & x, ErrorCode * err = 0)
1438
+ {
1439
+ if( x.IsNan() )
1440
+ {
1441
+ if( err )
1442
+ *err = err_improper_argument;
1443
+
1444
+ return x; // NaN
1445
+ }
1446
+
1447
+ ValueType nominator(x), denominator, one, result;
1448
+ uint c = 0;
1449
+ one.SetOne();
1450
+
1451
+ if( !x.SmallerWithoutSignThan(one) )
1452
+ {
1453
+ if( err )
1454
+ *err = err_improper_argument;
1455
+
1456
+ return result; // NaN is set by default
1457
+ }
1458
+
1459
+ c += nominator.Add(one);
1460
+ denominator = one;
1461
+ c += denominator.Sub(x);
1462
+ c += nominator.Div(denominator);
1463
+ c += result.Ln(nominator);
1464
+ c += result.exponent.SubOne();
1465
+
1466
+ // here can only be a carry
1467
+ if( err )
1468
+ *err = c ? err_overflow : err_ok;
1469
+
1470
+ return result;
1471
+ }
1472
+
1473
+
1474
+ /*!
1475
+ inverse hyperbolic tantent
1476
+ */
1477
+ template<class ValueType>
1478
+ ValueType ATgh(const ValueType & x, ErrorCode * err = 0)
1479
+ {
1480
+ return ATanh(x, err);
1481
+ }
1482
+
1483
+
1484
+ /*!
1485
+ inverse hyperbolic cotangent
1486
+
1487
+ acoth(x) = 0.5 * ln( (x+1) / (x-1) ) x in (-infinity, -1) or (1, infinity)
1488
+ */
1489
+ template<class ValueType>
1490
+ ValueType ACoth(const ValueType & x, ErrorCode * err = 0)
1491
+ {
1492
+ if( x.IsNan() )
1493
+ {
1494
+ if( err )
1495
+ *err = err_improper_argument;
1496
+
1497
+ return x; // NaN
1498
+ }
1499
+
1500
+ ValueType nominator(x), denominator(x), one, result;
1501
+ uint c = 0;
1502
+ one.SetOne();
1503
+
1504
+ if( !x.GreaterWithoutSignThan(one) )
1505
+ {
1506
+ if( err )
1507
+ *err = err_improper_argument;
1508
+
1509
+ return result; // NaN is set by default
1510
+ }
1511
+
1512
+ c += nominator.Add(one);
1513
+ c += denominator.Sub(one);
1514
+ c += nominator.Div(denominator);
1515
+ c += result.Ln(nominator);
1516
+ c += result.exponent.SubOne();
1517
+
1518
+ // here can only be a carry
1519
+ if( err )
1520
+ *err = c ? err_overflow : err_ok;
1521
+
1522
+ return result;
1523
+ }
1524
+
1525
+
1526
+ /*!
1527
+ inverse hyperbolic cotantent
1528
+ */
1529
+ template<class ValueType>
1530
+ ValueType ACtgh(const ValueType & x, ErrorCode * err = 0)
1531
+ {
1532
+ return ACoth(x, err);
1533
+ }
1534
+
1535
+
1536
+
1537
+
1538
+
1539
+ /*
1540
+ *
1541
+ * functions for converting between degrees, radians and gradians
1542
+ *
1543
+ *
1544
+ */
1545
+
1546
+
1547
+ /*!
1548
+ this function converts degrees to radians
1549
+
1550
+ it returns: x * pi / 180
1551
+ */
1552
+ template<class ValueType>
1553
+ ValueType DegToRad(const ValueType & x, ErrorCode * err = 0)
1554
+ {
1555
+ ValueType result, temp;
1556
+ uint c = 0;
1557
+
1558
+ if( x.IsNan() )
1559
+ {
1560
+ if( err )
1561
+ *err = err_improper_argument;
1562
+
1563
+ return x;
1564
+ }
1565
+
1566
+ result = x;
1567
+
1568
+ // it is better to make division first and then multiplication
1569
+ // the result is more accurate especially when x is: 90,180,270 or 360
1570
+ temp = 180;
1571
+ c += result.Div(temp);
1572
+
1573
+ temp.SetPi();
1574
+ c += result.Mul(temp);
1575
+
1576
+ if( err )
1577
+ *err = c ? err_overflow : err_ok;
1578
+
1579
+ return result;
1580
+ }
1581
+
1582
+
1583
+ /*!
1584
+ this function converts radians to degrees
1585
+
1586
+ it returns: x * 180 / pi
1587
+ */
1588
+ template<class ValueType>
1589
+ ValueType RadToDeg(const ValueType & x, ErrorCode * err = 0)
1590
+ {
1591
+ ValueType result, delimiter;
1592
+ uint c = 0;
1593
+
1594
+ if( x.IsNan() )
1595
+ {
1596
+ if( err )
1597
+ *err = err_improper_argument;
1598
+
1599
+ return x;
1600
+ }
1601
+
1602
+ result = 180;
1603
+ c += result.Mul(x);
1604
+
1605
+ delimiter.SetPi();
1606
+ c += result.Div(delimiter);
1607
+
1608
+ if( err )
1609
+ *err = c ? err_overflow : err_ok;
1610
+
1611
+ return result;
1612
+ }
1613
+
1614
+
1615
+ /*!
1616
+ this function converts degrees in the long format into one value
1617
+
1618
+ long format: (degrees, minutes, seconds)
1619
+ minutes and seconds must be greater than or equal zero
1620
+
1621
+ result:
1622
+ - if d>=0 : result= d + ((s/60)+m)/60
1623
+ - if d<0 : result= d - ((s/60)+m)/60
1624
+
1625
+ ((s/60)+m)/60 = (s+60*m)/3600 (second version is faster because
1626
+ there's only one division)
1627
+
1628
+ samples:
1629
+
1630
+ - DegToDeg(10, 30, 0) = 10.5
1631
+ - DegToDeg(10, 24, 35.6)=10.4098(8)
1632
+ */
1633
+ template<class ValueType>
1634
+ ValueType DegToDeg( const ValueType & d, const ValueType & m, const ValueType & s,
1635
+ ErrorCode * err = 0)
1636
+ {
1637
+ ValueType delimiter, multipler;
1638
+ uint c = 0;
1639
+
1640
+ if( d.IsNan() || m.IsNan() || s.IsNan() || m.IsSign() || s.IsSign() )
1641
+ {
1642
+ if( err )
1643
+ *err = err_improper_argument;
1644
+
1645
+ delimiter.SetZeroNan(); // not needed, only to get rid of GCC warning about an uninitialized variable
1646
+
1647
+ return delimiter;
1648
+ }
1649
+
1650
+ multipler = 60;
1651
+ delimiter = 3600;
1652
+
1653
+ c += multipler.Mul(m);
1654
+ c += multipler.Add(s);
1655
+ c += multipler.Div(delimiter);
1656
+
1657
+ if( d.IsSign() )
1658
+ multipler.ChangeSign();
1659
+
1660
+ c += multipler.Add(d);
1661
+
1662
+ if( err )
1663
+ *err = c ? err_overflow : err_ok;
1664
+
1665
+ return multipler;
1666
+ }
1667
+
1668
+
1669
+ /*!
1670
+ this function converts degrees in the long format to radians
1671
+ */
1672
+ template<class ValueType>
1673
+ ValueType DegToRad( const ValueType & d, const ValueType & m, const ValueType & s,
1674
+ ErrorCode * err = 0)
1675
+ {
1676
+ ValueType temp_deg = DegToDeg(d,m,s,err);
1677
+
1678
+ if( err && *err!=err_ok )
1679
+ return temp_deg;
1680
+
1681
+ return DegToRad(temp_deg, err);
1682
+ }
1683
+
1684
+
1685
+ /*!
1686
+ this function converts gradians to radians
1687
+
1688
+ it returns: x * pi / 200
1689
+ */
1690
+ template<class ValueType>
1691
+ ValueType GradToRad(const ValueType & x, ErrorCode * err = 0)
1692
+ {
1693
+ ValueType result, temp;
1694
+ uint c = 0;
1695
+
1696
+ if( x.IsNan() )
1697
+ {
1698
+ if( err )
1699
+ *err = err_improper_argument;
1700
+
1701
+ return x;
1702
+ }
1703
+
1704
+ result = x;
1705
+
1706
+ // it is better to make division first and then multiplication
1707
+ // the result is more accurate especially when x is: 100,200,300 or 400
1708
+ temp = 200;
1709
+ c += result.Div(temp);
1710
+
1711
+ temp.SetPi();
1712
+ c += result.Mul(temp);
1713
+
1714
+ if( err )
1715
+ *err = c ? err_overflow : err_ok;
1716
+
1717
+ return result;
1718
+ }
1719
+
1720
+
1721
+ /*!
1722
+ this function converts radians to gradians
1723
+
1724
+ it returns: x * 200 / pi
1725
+ */
1726
+ template<class ValueType>
1727
+ ValueType RadToGrad(const ValueType & x, ErrorCode * err = 0)
1728
+ {
1729
+ ValueType result, delimiter;
1730
+ uint c = 0;
1731
+
1732
+ if( x.IsNan() )
1733
+ {
1734
+ if( err )
1735
+ *err = err_improper_argument;
1736
+
1737
+ return x;
1738
+ }
1739
+
1740
+ result = 200;
1741
+ c += result.Mul(x);
1742
+
1743
+ delimiter.SetPi();
1744
+ c += result.Div(delimiter);
1745
+
1746
+ if( err )
1747
+ *err = c ? err_overflow : err_ok;
1748
+
1749
+ return result;
1750
+ }
1751
+
1752
+
1753
+ /*!
1754
+ this function converts degrees to gradians
1755
+
1756
+ it returns: x * 200 / 180
1757
+ */
1758
+ template<class ValueType>
1759
+ ValueType DegToGrad(const ValueType & x, ErrorCode * err = 0)
1760
+ {
1761
+ ValueType result, temp;
1762
+ uint c = 0;
1763
+
1764
+ if( x.IsNan() )
1765
+ {
1766
+ if( err )
1767
+ *err = err_improper_argument;
1768
+
1769
+ return x;
1770
+ }
1771
+
1772
+ result = x;
1773
+
1774
+ temp = 200;
1775
+ c += result.Mul(temp);
1776
+
1777
+ temp = 180;
1778
+ c += result.Div(temp);
1779
+
1780
+ if( err )
1781
+ *err = c ? err_overflow : err_ok;
1782
+
1783
+ return result;
1784
+ }
1785
+
1786
+
1787
+ /*!
1788
+ this function converts degrees in the long format to gradians
1789
+ */
1790
+ template<class ValueType>
1791
+ ValueType DegToGrad( const ValueType & d, const ValueType & m, const ValueType & s,
1792
+ ErrorCode * err = 0)
1793
+ {
1794
+ ValueType temp_deg = DegToDeg(d,m,s,err);
1795
+
1796
+ if( err && *err!=err_ok )
1797
+ return temp_deg;
1798
+
1799
+ return DegToGrad(temp_deg, err);
1800
+ }
1801
+
1802
+
1803
+ /*!
1804
+ this function converts degrees to gradians
1805
+
1806
+ it returns: x * 180 / 200
1807
+ */
1808
+ template<class ValueType>
1809
+ ValueType GradToDeg(const ValueType & x, ErrorCode * err = 0)
1810
+ {
1811
+ ValueType result, temp;
1812
+ uint c = 0;
1813
+
1814
+ if( x.IsNan() )
1815
+ {
1816
+ if( err )
1817
+ *err = err_improper_argument;
1818
+
1819
+ return x;
1820
+ }
1821
+
1822
+ result = x;
1823
+
1824
+ temp = 180;
1825
+ c += result.Mul(temp);
1826
+
1827
+ temp = 200;
1828
+ c += result.Div(temp);
1829
+
1830
+ if( err )
1831
+ *err = c ? err_overflow : err_ok;
1832
+
1833
+ return result;
1834
+ }
1835
+
1836
+
1837
+
1838
+
1839
+ /*
1840
+ *
1841
+ * another functions
1842
+ *
1843
+ *
1844
+ */
1845
+
1846
+
1847
+ /*!
1848
+ this function calculates the square root
1849
+
1850
+ Sqrt(9) = 3
1851
+ */
1852
+ template<class ValueType>
1853
+ ValueType Sqrt(ValueType x, ErrorCode * err = 0)
1854
+ {
1855
+ if( x.IsNan() || x.IsSign() )
1856
+ {
1857
+ if( err )
1858
+ *err = err_improper_argument;
1859
+
1860
+ x.SetNan();
1861
+
1862
+ return x;
1863
+ }
1864
+
1865
+ uint c = x.Sqrt();
1866
+
1867
+ if( err )
1868
+ *err = c ? err_overflow : err_ok;
1869
+
1870
+ return x;
1871
+ }
1872
+
1873
+
1874
+
1875
+ namespace auxiliaryfunctions
1876
+ {
1877
+
1878
+ template<class ValueType>
1879
+ bool RootCheckIndexSign(ValueType & x, const ValueType & index, ErrorCode * err)
1880
+ {
1881
+ if( index.IsSign() )
1882
+ {
1883
+ // index cannot be negative
1884
+ if( err )
1885
+ *err = err_improper_argument;
1886
+
1887
+ x.SetNan();
1888
+
1889
+ return true;
1890
+ }
1891
+
1892
+ return false;
1893
+ }
1894
+
1895
+
1896
+ template<class ValueType>
1897
+ bool RootCheckIndexZero(ValueType & x, const ValueType & index, ErrorCode * err)
1898
+ {
1899
+ if( index.IsZero() )
1900
+ {
1901
+ if( x.IsZero() )
1902
+ {
1903
+ // there isn't root(0;0) - we assume it's not defined
1904
+ if( err )
1905
+ *err = err_improper_argument;
1906
+
1907
+ x.SetNan();
1908
+
1909
+ return true;
1910
+ }
1911
+
1912
+ // root(x;0) is 1 (if x!=0)
1913
+ x.SetOne();
1914
+
1915
+ if( err )
1916
+ *err = err_ok;
1917
+
1918
+ return true;
1919
+ }
1920
+
1921
+ return false;
1922
+ }
1923
+
1924
+
1925
+ template<class ValueType>
1926
+ bool RootCheckIndexOne(const ValueType & index, ErrorCode * err)
1927
+ {
1928
+ ValueType one;
1929
+ one.SetOne();
1930
+
1931
+ if( index == one )
1932
+ {
1933
+ //root(x;1) is x
1934
+ // we do it because if we used the PowFrac function
1935
+ // we would lose the precision
1936
+ if( err )
1937
+ *err = err_ok;
1938
+
1939
+ return true;
1940
+ }
1941
+
1942
+ return false;
1943
+ }
1944
+
1945
+
1946
+ template<class ValueType>
1947
+ bool RootCheckIndexTwo(ValueType & x, const ValueType & index, ErrorCode * err)
1948
+ {
1949
+ if( index == 2 )
1950
+ {
1951
+ x = Sqrt(x, err);
1952
+
1953
+ return true;
1954
+ }
1955
+
1956
+ return false;
1957
+ }
1958
+
1959
+
1960
+ template<class ValueType>
1961
+ bool RootCheckIndexFrac(ValueType & x, const ValueType & index, ErrorCode * err)
1962
+ {
1963
+ if( !index.IsInteger() )
1964
+ {
1965
+ // index must be integer
1966
+ if( err )
1967
+ *err = err_improper_argument;
1968
+
1969
+ x.SetNan();
1970
+
1971
+ return true;
1972
+ }
1973
+
1974
+ return false;
1975
+ }
1976
+
1977
+
1978
+ template<class ValueType>
1979
+ bool RootCheckXZero(ValueType & x, ErrorCode * err)
1980
+ {
1981
+ if( x.IsZero() )
1982
+ {
1983
+ // root(0;index) is zero (if index!=0)
1984
+ // RootCheckIndexZero() must be called beforehand
1985
+ x.SetZero();
1986
+
1987
+ if( err )
1988
+ *err = err_ok;
1989
+
1990
+ return true;
1991
+ }
1992
+
1993
+ return false;
1994
+ }
1995
+
1996
+
1997
+ template<class ValueType>
1998
+ bool RootCheckIndex(ValueType & x, const ValueType & index, ErrorCode * err, bool * change_sign)
1999
+ {
2000
+ *change_sign = false;
2001
+
2002
+ if( index.Mod2() )
2003
+ {
2004
+ // index is odd (1,3,5...)
2005
+ if( x.IsSign() )
2006
+ {
2007
+ *change_sign = true;
2008
+ x.Abs();
2009
+ }
2010
+ }
2011
+ else
2012
+ {
2013
+ // index is even
2014
+ // x cannot be negative
2015
+ if( x.IsSign() )
2016
+ {
2017
+ if( err )
2018
+ *err = err_improper_argument;
2019
+
2020
+ x.SetNan();
2021
+
2022
+ return true;
2023
+ }
2024
+ }
2025
+
2026
+ return false;
2027
+ }
2028
+
2029
+
2030
+ template<class ValueType>
2031
+ uint RootCorrectInteger(ValueType & old_x, ValueType & x, const ValueType & index)
2032
+ {
2033
+ if( !old_x.IsInteger() || x.IsInteger() || !index.exponent.IsSign() )
2034
+ return 0;
2035
+
2036
+ // old_x is integer,
2037
+ // x is not integer,
2038
+ // index is relatively small (index.exponent<0 or index.exponent<=0)
2039
+ // (because we're using a special powering algorithm Big::PowUInt())
2040
+
2041
+ uint c = 0;
2042
+
2043
+ ValueType temp(x);
2044
+ c += temp.Round();
2045
+
2046
+ ValueType temp_round(temp);
2047
+ c += temp.PowUInt(index);
2048
+
2049
+ if( temp == old_x )
2050
+ x = temp_round;
2051
+
2052
+ return (c==0)? 0 : 1;
2053
+ }
2054
+
2055
+
2056
+
2057
+ } // namespace auxiliaryfunctions
2058
+
2059
+
2060
+
2061
+ /*!
2062
+ caltulate the index'th Root of x
2063
+
2064
+ index must be integer and not negative <0;1;2;3....)
2065
+
2066
+ - if index==0 the result is one
2067
+ - if x==0 the result is zero and we assume root(0;0) is not defined
2068
+
2069
+ - if index is even (2;4;6...) the result is x^(1/index) and x>0
2070
+ - if index is odd (1;2;3;...) the result is either
2071
+ - -(abs(x)^(1/index)) if x<0, or
2072
+ - x^(1/index)) if x>0
2073
+
2074
+ - for index==1 the result is equal x
2075
+ */
2076
+ template<class ValueType>
2077
+ ValueType Root(ValueType x, const ValueType & index, ErrorCode * err = 0)
2078
+ {
2079
+ using namespace auxiliaryfunctions;
2080
+
2081
+ if( x.IsNan() || index.IsNan() )
2082
+ {
2083
+ if( err )
2084
+ *err = err_improper_argument;
2085
+
2086
+ x.SetNan();
2087
+
2088
+ return x;
2089
+ }
2090
+
2091
+ if( RootCheckIndexSign(x, index, err) ) return x;
2092
+ if( RootCheckIndexZero(x, index, err) ) return x;
2093
+ if( RootCheckIndexOne ( index, err) ) return x;
2094
+ if( RootCheckIndexTwo (x, index, err) ) return x;
2095
+ if( RootCheckIndexFrac(x, index, err) ) return x;
2096
+ if( RootCheckXZero (x, err) ) return x;
2097
+
2098
+ // index integer and index!=0
2099
+ // x!=0
2100
+
2101
+ ValueType old_x(x);
2102
+ bool change_sign;
2103
+
2104
+ if( RootCheckIndex(x, index, err, &change_sign ) ) return x;
2105
+
2106
+ ValueType temp;
2107
+ uint c = 0;
2108
+
2109
+ // we're using the formula: root(x ; n) = exp( ln(x) / n )
2110
+ c += temp.Ln(x);
2111
+ c += temp.Div(index);
2112
+ c += x.Exp(temp);
2113
+
2114
+ if( change_sign )
2115
+ {
2116
+ // x is different from zero
2117
+ x.SetSign();
2118
+ }
2119
+
2120
+ c += RootCorrectInteger(old_x, x, index);
2121
+
2122
+ if( err )
2123
+ *err = c ? err_overflow : err_ok;
2124
+
2125
+ return x;
2126
+ }
2127
+
2128
+
2129
+
2130
+ /*!
2131
+ absolute value of x
2132
+
2133
+ samples:
2134
+ - -2 = 2
2135
+ - 2 = 2
2136
+ */
2137
+ template<class ValueType>
2138
+ ValueType Abs(const ValueType & x)
2139
+ {
2140
+ ValueType result( x );
2141
+ result.Abs();
2142
+
2143
+ return result;
2144
+ }
2145
+
2146
+
2147
+ /*!
2148
+ it returns the sign of the value
2149
+
2150
+ samples:
2151
+ - -2 = -1
2152
+ - 0 = 0
2153
+ - 10 = 1
2154
+ */
2155
+ template<class ValueType>
2156
+ ValueType Sgn(ValueType x)
2157
+ {
2158
+ x.Sgn();
2159
+
2160
+ return x;
2161
+ }
2162
+
2163
+
2164
+ /*!
2165
+ the remainder from a division
2166
+
2167
+ samples:
2168
+ - mod( 12.6 ; 3) = 0.6 because 12.6 = 3*4 + 0.6
2169
+ - mod(-12.6 ; 3) = -0.6 bacause -12.6 = 3*(-4) + (-0.6)
2170
+ - mod( 12.6 ; -3) = 0.6
2171
+ - mod(-12.6 ; -3) = -0.6
2172
+ */
2173
+ template<class ValueType>
2174
+ ValueType Mod(ValueType a, const ValueType & b, ErrorCode * err = 0)
2175
+ {
2176
+ if( a.IsNan() || b.IsNan() )
2177
+ {
2178
+ if( err )
2179
+ *err = err_improper_argument;
2180
+
2181
+ a.SetNan();
2182
+
2183
+ return a;
2184
+ }
2185
+
2186
+ uint c = a.Mod(b);
2187
+
2188
+ if( err )
2189
+ *err = c ? err_overflow : err_ok;
2190
+
2191
+ return a;
2192
+ }
2193
+
2194
+
2195
+
2196
+ namespace auxiliaryfunctions
2197
+ {
2198
+
2199
+ /*!
2200
+ this function is used to store factorials in a given container
2201
+ 'more' means how many values should be added at the end
2202
+
2203
+ sample:
2204
+
2205
+ std::vector<ValueType> fact;
2206
+ SetFactorialSequence(fact, 3);
2207
+ // now the container has three values: 1 1 2
2208
+
2209
+ SetFactorialSequence(fact, 2);
2210
+ // now the container has five values: 1 1 2 6 24
2211
+ */
2212
+ template<class ValueType>
2213
+ void SetFactorialSequence(std::vector<ValueType> & fact, uint more = 20)
2214
+ {
2215
+ if( more == 0 )
2216
+ more = 1;
2217
+
2218
+ uint start = static_cast<uint>(fact.size());
2219
+ fact.resize(fact.size() + more);
2220
+
2221
+ if( start == 0 )
2222
+ {
2223
+ fact[0] = 1;
2224
+ ++start;
2225
+ }
2226
+
2227
+ for(uint i=start ; i<fact.size() ; ++i)
2228
+ {
2229
+ fact[i] = fact[i-1];
2230
+ fact[i].MulInt(i);
2231
+ }
2232
+ }
2233
+
2234
+
2235
+ /*!
2236
+ an auxiliary function used to calculate Bernoulli numbers
2237
+
2238
+ this function returns a sum:
2239
+
2240
+ sum(m) = sum_{k=0}^{m-1} {2^k * (m k) * B(k)} k in [0, m-1] (m k) means binomial coefficient = (m! / (k! * (m-k)!))
2241
+
2242
+ you should have sufficient factorials in cgamma.fact
2243
+ (cgamma.fact should have at least m items)
2244
+
2245
+ n_ should be equal 2
2246
+ */
2247
+ template<class ValueType>
2248
+ ValueType SetBernoulliNumbersSum(CGamma<ValueType> & cgamma, const ValueType & n_, uint m,
2249
+ const volatile StopCalculating * stop = 0)
2250
+ {
2251
+ ValueType k_, temp, temp2, temp3, sum;
2252
+
2253
+ sum.SetZero();
2254
+
2255
+ for(uint k=0 ; k<m ; ++k) // k<m means k<=m-1
2256
+ {
2257
+ if( stop && (k & 15)==0 ) // means: k % 16 == 0
2258
+ if( stop->WasStopSignal() )
2259
+ return ValueType(); // NaN
2260
+
2261
+ if( k>1 && (k & 1) == 1 ) // for that k the Bernoulli number is zero
2262
+ continue;
2263
+
2264
+ k_ = k;
2265
+
2266
+ temp = n_; // n_ is equal 2
2267
+ temp.Pow(k_);
2268
+ // temp = 2^k
2269
+
2270
+ temp2 = cgamma.fact[m];
2271
+ temp3 = cgamma.fact[k];
2272
+ temp3.Mul(cgamma.fact[m-k]);
2273
+ temp2.Div(temp3);
2274
+ // temp2 = (m k) = m! / ( k! * (m-k)! )
2275
+
2276
+ temp.Mul(temp2);
2277
+ temp.Mul(cgamma.bern[k]);
2278
+
2279
+ sum.Add(temp);
2280
+ // sum += 2^k * (m k) * B(k)
2281
+
2282
+ if( sum.IsNan() )
2283
+ break;
2284
+ }
2285
+
2286
+ return sum;
2287
+ }
2288
+
2289
+
2290
+ /*!
2291
+ an auxiliary function used to calculate Bernoulli numbers
2292
+ start is >= 2
2293
+
2294
+ we use the recurrence formula:
2295
+
2296
+ B(m) = 1 / (2*(1 - 2^m)) * sum(m)
2297
+ where sum(m) is calculated by SetBernoulliNumbersSum()
2298
+ */
2299
+ template<class ValueType>
2300
+ bool SetBernoulliNumbersMore(CGamma<ValueType> & cgamma, uint start, const volatile StopCalculating * stop = 0)
2301
+ {
2302
+ ValueType denominator, temp, temp2, temp3, m_, sum, sum2, n_, k_;
2303
+
2304
+ const uint n = 2;
2305
+ n_ = n;
2306
+
2307
+ // start is >= 2
2308
+ for(uint m=start ; m<cgamma.bern.size() ; ++m)
2309
+ {
2310
+ if( (m & 1) == 1 )
2311
+ {
2312
+ cgamma.bern[m].SetZero();
2313
+ }
2314
+ else
2315
+ {
2316
+ m_ = m;
2317
+
2318
+ temp = n_; // n_ = 2
2319
+ temp.Pow(m_);
2320
+ // temp = 2^m
2321
+
2322
+ denominator.SetOne();
2323
+ denominator.Sub(temp);
2324
+ if( denominator.exponent.AddOne() ) // it means: denominator.MulInt(2)
2325
+ denominator.SetNan();
2326
+
2327
+ // denominator = 2 * (1 - 2^m)
2328
+
2329
+ cgamma.bern[m] = SetBernoulliNumbersSum(cgamma, n_, m, stop);
2330
+
2331
+ if( stop && stop->WasStopSignal() )
2332
+ {
2333
+ cgamma.bern.resize(m); // valid numbers are in [0, m-1]
2334
+ return false;
2335
+ }
2336
+
2337
+ cgamma.bern[m].Div(denominator);
2338
+ }
2339
+ }
2340
+
2341
+ return true;
2342
+ }
2343
+
2344
+
2345
+ /*!
2346
+ this function is used to calculate Bernoulli numbers,
2347
+ returns false if there was a stop signal,
2348
+ 'more' means how many values should be added at the end
2349
+
2350
+ sample:
2351
+
2352
+ typedef Big<1,2> MyBig;
2353
+ CGamma<MyBig> cgamma;
2354
+ SetBernoulliNumbers(cgamma, 3);
2355
+ // now we have three first Bernoulli numbers: 1 -0.5 0.16667
2356
+
2357
+ SetBernoulliNumbers(cgamma, 4);
2358
+ // now we have 7 Bernoulli numbers: 1 -0.5 0.16667 0 -0.0333 0 0.0238
2359
+ */
2360
+ template<class ValueType>
2361
+ bool SetBernoulliNumbers(CGamma<ValueType> & cgamma, uint more = 20, const volatile StopCalculating * stop = 0)
2362
+ {
2363
+ if( more == 0 )
2364
+ more = 1;
2365
+
2366
+ uint start = static_cast<uint>(cgamma.bern.size());
2367
+ cgamma.bern.resize(cgamma.bern.size() + more);
2368
+
2369
+ if( start == 0 )
2370
+ {
2371
+ cgamma.bern[0].SetOne();
2372
+ ++start;
2373
+ }
2374
+
2375
+ if( cgamma.bern.size() == 1 )
2376
+ return true;
2377
+
2378
+ if( start == 1 )
2379
+ {
2380
+ cgamma.bern[1].Set05();
2381
+ cgamma.bern[1].ChangeSign();
2382
+ ++start;
2383
+ }
2384
+
2385
+ // we should have sufficient factorials in cgamma.fact
2386
+ if( cgamma.fact.size() < cgamma.bern.size() )
2387
+ SetFactorialSequence(cgamma.fact, static_cast<uint>(cgamma.bern.size() - cgamma.fact.size()));
2388
+
2389
+
2390
+ return SetBernoulliNumbersMore(cgamma, start, stop);
2391
+ }
2392
+
2393
+
2394
+ /*!
2395
+ an auxiliary function used to calculate the Gamma() function
2396
+
2397
+ we calculate a sum:
2398
+
2399
+ sum(n) = sum_{m=2} { B(m) / ( (m^2 - m) * n^(m-1) ) } = 1/(12*n) - 1/(360*n^3) + 1/(1260*n^5) + ...
2400
+
2401
+ B(m) means a mth Bernoulli number
2402
+ the sum starts from m=2, we calculate as long as the value will not change after adding a next part
2403
+ */
2404
+ template<class ValueType>
2405
+ ValueType GammaFactorialHighSum(const ValueType & n, CGamma<ValueType> & cgamma, ErrorCode & err,
2406
+ const volatile StopCalculating * stop)
2407
+ {
2408
+ ValueType temp, temp2, denominator, sum, oldsum;
2409
+
2410
+ sum.SetZero();
2411
+
2412
+ for(uint m=2 ; m<TTMATH_ARITHMETIC_MAX_LOOP ; m+=2)
2413
+ {
2414
+ if( stop && (m & 3)==0 ) // (m & 3)==0 means: (m % 4)==0
2415
+ if( stop->WasStopSignal() )
2416
+ {
2417
+ err = err_interrupt;
2418
+ return ValueType(); // NaN
2419
+ }
2420
+
2421
+ temp = (m-1);
2422
+ denominator = n;
2423
+ denominator.Pow(temp);
2424
+ // denominator = n ^ (m-1)
2425
+
2426
+ temp = m;
2427
+ temp2 = temp;
2428
+ temp.Mul(temp2);
2429
+ temp.Sub(temp2);
2430
+ // temp = m^2 - m
2431
+
2432
+ denominator.Mul(temp);
2433
+ // denominator = (m^2 - m) * n ^ (m-1)
2434
+
2435
+ if( m >= cgamma.bern.size() )
2436
+ {
2437
+ if( !SetBernoulliNumbers(cgamma, m - cgamma.bern.size() + 1 + 3, stop) ) // 3 more than needed
2438
+ {
2439
+ // there was the stop signal
2440
+ err = err_interrupt;
2441
+ return ValueType(); // NaN
2442
+ }
2443
+ }
2444
+
2445
+ temp = cgamma.bern[m];
2446
+ temp.Div(denominator);
2447
+
2448
+ oldsum = sum;
2449
+ sum.Add(temp);
2450
+
2451
+ if( sum.IsNan() || oldsum==sum )
2452
+ break;
2453
+ }
2454
+
2455
+ return sum;
2456
+ }
2457
+
2458
+
2459
+ /*!
2460
+ an auxiliary function used to calculate the Gamma() function
2461
+
2462
+ we calculate a helper function GammaFactorialHigh() by using Stirling's series:
2463
+
2464
+ n! = (n/e)^n * sqrt(2*pi*n) * exp( sum(n) )
2465
+
2466
+ where n is a real number (not only an integer) and is sufficient large (greater than TTMATH_GAMMA_BOUNDARY)
2467
+ and sum(n) is calculated by GammaFactorialHighSum()
2468
+ */
2469
+ template<class ValueType>
2470
+ ValueType GammaFactorialHigh(const ValueType & n, CGamma<ValueType> & cgamma, ErrorCode & err,
2471
+ const volatile StopCalculating * stop)
2472
+ {
2473
+ ValueType temp, temp2, temp3, denominator, sum;
2474
+
2475
+ temp.Set2Pi();
2476
+ temp.Mul(n);
2477
+ temp2 = Sqrt(temp);
2478
+ // temp2 = sqrt(2*pi*n)
2479
+
2480
+ temp = n;
2481
+ temp3.SetE();
2482
+ temp.Div(temp3);
2483
+ temp.Pow(n);
2484
+ // temp = (n/e)^n
2485
+
2486
+ sum = GammaFactorialHighSum(n, cgamma, err, stop);
2487
+ temp3.Exp(sum);
2488
+ // temp3 = exp(sum)
2489
+
2490
+ temp.Mul(temp2);
2491
+ temp.Mul(temp3);
2492
+
2493
+ return temp;
2494
+ }
2495
+
2496
+
2497
+ /*!
2498
+ an auxiliary function used to calculate the Gamma() function
2499
+
2500
+ Gamma(x) = GammaFactorialHigh(x-1)
2501
+ */
2502
+ template<class ValueType>
2503
+ ValueType GammaPlusHigh(ValueType n, CGamma<ValueType> & cgamma, ErrorCode & err, const volatile StopCalculating * stop)
2504
+ {
2505
+ ValueType one;
2506
+
2507
+ one.SetOne();
2508
+ n.Sub(one);
2509
+
2510
+ return GammaFactorialHigh(n, cgamma, err, stop);
2511
+ }
2512
+
2513
+
2514
+ /*!
2515
+ an auxiliary function used to calculate the Gamma() function
2516
+
2517
+ we use this function when n is integer and a small value (from 0 to TTMATH_GAMMA_BOUNDARY]
2518
+ we use the formula:
2519
+
2520
+ gamma(n) = (n-1)! = 1 * 2 * 3 * ... * (n-1)
2521
+ */
2522
+ template<class ValueType>
2523
+ ValueType GammaPlusLowIntegerInt(uint n, CGamma<ValueType> & cgamma)
2524
+ {
2525
+ TTMATH_ASSERT( n > 0 )
2526
+
2527
+ if( n - 1 < static_cast<uint>(cgamma.fact.size()) )
2528
+ return cgamma.fact[n - 1];
2529
+
2530
+ ValueType res;
2531
+ uint start = 2;
2532
+
2533
+ if( cgamma.fact.size() < 2 )
2534
+ {
2535
+ res.SetOne();
2536
+ }
2537
+ else
2538
+ {
2539
+ start = static_cast<uint>(cgamma.fact.size());
2540
+ res = cgamma.fact[start-1];
2541
+ }
2542
+
2543
+ for(uint i=start ; i<n ; ++i)
2544
+ res.MulInt(i);
2545
+
2546
+ return res;
2547
+ }
2548
+
2549
+
2550
+ /*!
2551
+ an auxiliary function used to calculate the Gamma() function
2552
+
2553
+ we use this function when n is integer and a small value (from 0 to TTMATH_GAMMA_BOUNDARY]
2554
+ */
2555
+ template<class ValueType>
2556
+ ValueType GammaPlusLowInteger(const ValueType & n, CGamma<ValueType> & cgamma)
2557
+ {
2558
+ sint n_;
2559
+
2560
+ n.ToInt(n_);
2561
+
2562
+ return GammaPlusLowIntegerInt(n_, cgamma);
2563
+ }
2564
+
2565
+
2566
+ /*!
2567
+ an auxiliary function used to calculate the Gamma() function
2568
+
2569
+ we use this function when n is a small value (from 0 to TTMATH_GAMMA_BOUNDARY]
2570
+ we use a recurrence formula:
2571
+
2572
+ gamma(z+1) = z * gamma(z)
2573
+ then: gamma(z) = gamma(z+1) / z
2574
+
2575
+ samples:
2576
+ - gamma(3.89) = gamma(2001.89) / ( 3.89 * 4.89 * 5.89 * ... * 1999.89 * 2000.89 )
2577
+ */
2578
+ template<class ValueType>
2579
+ ValueType GammaPlusLow(ValueType n, CGamma<ValueType> & cgamma, ErrorCode & err, const volatile StopCalculating * stop)
2580
+ {
2581
+ ValueType one, denominator, temp, boundary;
2582
+
2583
+ if( n.IsInteger() )
2584
+ return GammaPlusLowInteger(n, cgamma);
2585
+
2586
+ one.SetOne();
2587
+ denominator = n;
2588
+ boundary = TTMATH_GAMMA_BOUNDARY;
2589
+
2590
+ while( n < boundary )
2591
+ {
2592
+ n.Add(one);
2593
+ denominator.Mul(n);
2594
+ }
2595
+
2596
+ n.Add(one);
2597
+
2598
+ // now n is sufficient big
2599
+ temp = GammaPlusHigh(n, cgamma, err, stop);
2600
+ temp.Div(denominator);
2601
+
2602
+ return temp;
2603
+ }
2604
+
2605
+
2606
+ /*!
2607
+ an auxiliary function used to calculate the Gamma() function
2608
+ */
2609
+ template<class ValueType>
2610
+ ValueType GammaPlus(const ValueType & n, CGamma<ValueType> & cgamma, ErrorCode & err, const volatile StopCalculating * stop)
2611
+ {
2612
+ if( n > TTMATH_GAMMA_BOUNDARY )
2613
+ return GammaPlusHigh(n, cgamma, err, stop);
2614
+
2615
+ return GammaPlusLow(n, cgamma, err, stop);
2616
+ }
2617
+
2618
+
2619
+ /*!
2620
+ an auxiliary function used to calculate the Gamma() function
2621
+
2622
+ this function is used when n is negative
2623
+ we use the reflection formula:
2624
+ gamma(1-z) * gamma(z) = pi / sin(pi*z)
2625
+ then: gamma(z) = pi / (sin(pi*z) * gamma(1-z))
2626
+
2627
+ */
2628
+ template<class ValueType>
2629
+ ValueType GammaMinus(const ValueType & n, CGamma<ValueType> & cgamma, ErrorCode & err, const volatile StopCalculating * stop)
2630
+ {
2631
+ ValueType pi, denominator, temp, temp2;
2632
+
2633
+ if( n.IsInteger() )
2634
+ {
2635
+ // gamma function is not defined when n is negative and integer
2636
+ err = err_improper_argument;
2637
+ return temp; // NaN
2638
+ }
2639
+
2640
+ pi.SetPi();
2641
+
2642
+ temp = pi;
2643
+ temp.Mul(n);
2644
+ temp2 = Sin(temp);
2645
+ // temp2 = sin(pi * n)
2646
+
2647
+ temp.SetOne();
2648
+ temp.Sub(n);
2649
+ temp = GammaPlus(temp, cgamma, err, stop);
2650
+ // temp = gamma(1 - n)
2651
+
2652
+ temp.Mul(temp2);
2653
+ pi.Div(temp);
2654
+
2655
+ return pi;
2656
+ }
2657
+
2658
+ } // namespace auxiliaryfunctions
2659
+
2660
+
2661
+
2662
+ /*!
2663
+ this function calculates the Gamma function
2664
+
2665
+ it's multithread safe, you should create a CGamma<> object and use it whenever you call the Gamma()
2666
+ e.g.
2667
+
2668
+ typedef Big<1,2> MyBig;
2669
+ MyBig x=234, y=345.53;
2670
+ CGamma<MyBig> cgamma;
2671
+ std::cout << Gamma(x, cgamma) << std::endl;
2672
+ std::cout << Gamma(y, cgamma) << std::endl;
2673
+
2674
+ in the CGamma<> object the function stores some coefficients (factorials, Bernoulli numbers),
2675
+ and they will be reused in next calls to the function
2676
+
2677
+ each thread should have its own CGamma<> object, and you can use these objects with Factorial() function too
2678
+ */
2679
+ template<class ValueType>
2680
+ ValueType Gamma(const ValueType & n, CGamma<ValueType> & cgamma, ErrorCode * err = 0,
2681
+ const volatile StopCalculating * stop = 0)
2682
+ {
2683
+ using namespace auxiliaryfunctions;
2684
+
2685
+ ValueType result;
2686
+ ErrorCode err_tmp;
2687
+
2688
+ if( n.IsNan() )
2689
+ {
2690
+ if( err )
2691
+ *err = err_improper_argument;
2692
+
2693
+ return n;
2694
+ }
2695
+
2696
+ if( cgamma.history.Get(n, result, err_tmp) )
2697
+ {
2698
+ if( err )
2699
+ *err = err_tmp;
2700
+
2701
+ return result;
2702
+ }
2703
+
2704
+ err_tmp = err_ok;
2705
+
2706
+ if( n.IsSign() )
2707
+ {
2708
+ result = GammaMinus(n, cgamma, err_tmp, stop);
2709
+ }
2710
+ else
2711
+ if( n.IsZero() )
2712
+ {
2713
+ err_tmp = err_improper_argument;
2714
+ result.SetZeroNan();
2715
+ }
2716
+ else
2717
+ {
2718
+ result = GammaPlus(n, cgamma, err_tmp, stop);
2719
+ }
2720
+
2721
+ if( result.IsNan() && err_tmp==err_ok )
2722
+ err_tmp = err_overflow;
2723
+
2724
+ if( err )
2725
+ *err = err_tmp;
2726
+
2727
+ if( stop && !stop->WasStopSignal() )
2728
+ cgamma.history.Add(n, result, err_tmp);
2729
+
2730
+ return result;
2731
+ }
2732
+
2733
+
2734
+ /*!
2735
+ this function calculates the Gamma function
2736
+
2737
+ note: this function should be used only in a single-thread environment
2738
+ */
2739
+ template<class ValueType>
2740
+ ValueType Gamma(const ValueType & n, ErrorCode * err = 0)
2741
+ {
2742
+ // warning: this static object is not thread safe
2743
+ static CGamma<ValueType> cgamma;
2744
+
2745
+ return Gamma(n, cgamma, err);
2746
+ }
2747
+
2748
+
2749
+
2750
+ namespace auxiliaryfunctions
2751
+ {
2752
+
2753
+ /*!
2754
+ an auxiliary function for calculating the factorial function
2755
+
2756
+ we use the formula:
2757
+ x! = gamma(x+1)
2758
+ */
2759
+ template<class ValueType>
2760
+ ValueType Factorial2(ValueType x,
2761
+ CGamma<ValueType> * cgamma = 0,
2762
+ ErrorCode * err = 0,
2763
+ const volatile StopCalculating * stop = 0)
2764
+ {
2765
+ ValueType result, one;
2766
+
2767
+ if( x.IsNan() || x.IsSign() || !x.IsInteger() )
2768
+ {
2769
+ if( err )
2770
+ *err = err_improper_argument;
2771
+
2772
+ x.SetNan();
2773
+
2774
+ return x;
2775
+ }
2776
+
2777
+ one.SetOne();
2778
+ x.Add(one);
2779
+
2780
+ if( cgamma )
2781
+ return Gamma(x, *cgamma, err, stop);
2782
+
2783
+ return Gamma(x, err);
2784
+ }
2785
+
2786
+ } // namespace auxiliaryfunctions
2787
+
2788
+
2789
+
2790
+ /*!
2791
+ the factorial from given 'x'
2792
+ e.g.
2793
+ Factorial(4) = 4! = 1*2*3*4
2794
+
2795
+ it's multithread safe, you should create a CGamma<> object and use it whenever you call the Factorial()
2796
+ e.g.
2797
+
2798
+ typedef Big<1,2> MyBig;
2799
+ MyBig x=234, y=54345;
2800
+ CGamma<MyBig> cgamma;
2801
+ std::cout << Factorial(x, cgamma) << std::endl;
2802
+ std::cout << Factorial(y, cgamma) << std::endl;
2803
+
2804
+ in the CGamma<> object the function stores some coefficients (factorials, Bernoulli numbers),
2805
+ and they will be reused in next calls to the function
2806
+
2807
+ each thread should have its own CGamma<> object, and you can use these objects with Gamma() function too
2808
+ */
2809
+ template<class ValueType>
2810
+ ValueType Factorial(const ValueType & x, CGamma<ValueType> & cgamma, ErrorCode * err = 0,
2811
+ const volatile StopCalculating * stop = 0)
2812
+ {
2813
+ return auxiliaryfunctions::Factorial2(x, &cgamma, err, stop);
2814
+ }
2815
+
2816
+
2817
+ /*!
2818
+ the factorial from given 'x'
2819
+ e.g.
2820
+ Factorial(4) = 4! = 1*2*3*4
2821
+
2822
+ note: this function should be used only in a single-thread environment
2823
+ */
2824
+ template<class ValueType>
2825
+ ValueType Factorial(const ValueType & x, ErrorCode * err = 0)
2826
+ {
2827
+ return auxiliaryfunctions::Factorial2(x, (CGamma<ValueType>*)0, err, 0);
2828
+ }
2829
+
2830
+
2831
+ /*!
2832
+ this method prepares some coefficients: factorials and Bernoulli numbers
2833
+ stored in 'fact' and 'bern' objects
2834
+
2835
+ we're defining the method here because we're using Gamma() function which
2836
+ is not available in ttmathobjects.h
2837
+
2838
+ read the doc info in ttmathobjects.h file where CGamma<> struct is declared
2839
+ */
2840
+ template<class ValueType>
2841
+ void CGamma<ValueType>::InitAll()
2842
+ {
2843
+ ValueType x = TTMATH_GAMMA_BOUNDARY + 1;
2844
+
2845
+ // history.Remove(x) removes only one object
2846
+ // we must be sure that there are not others objects with the key 'x'
2847
+ while( history.Remove(x) )
2848
+ {
2849
+ }
2850
+
2851
+ // the simplest way to initialize is to call the Gamma function with (TTMATH_GAMMA_BOUNDARY + 1)
2852
+ // when x is larger then fewer coefficients we need
2853
+ Gamma(x, *this);
2854
+ }
2855
+
2856
+
2857
+
2858
+ } // namespace
2859
+
2860
+
2861
+ /*!
2862
+ this is for convenience for the user
2863
+ he can only use '#include <ttmath/ttmath.h>'
2864
+ */
2865
+ #include "ttmathparser.h"
2866
+
2867
+ // Dec is not finished yet
2868
+ //#include "ttmathdec.h"
2869
+
2870
+
2871
+
2872
+ #ifdef _MSC_VER
2873
+ //warning C4127: conditional expression is constant
2874
+ #pragma warning( default: 4127 )
2875
+ //warning C4702: unreachable code
2876
+ #pragma warning( default: 4702 )
2877
+ //warning C4800: forcing value to bool 'true' or 'false' (performance warning)
2878
+ #pragma warning( default: 4800 )
2879
+ #endif
2880
+
2881
+ #endif