@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,2791 @@
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 headerfilettmathparser
41
+ #define headerfilettmathparser
42
+
43
+ /*!
44
+ \file ttmathparser.h
45
+ \brief A mathematical parser
46
+ */
47
+
48
+ #include <cstdio>
49
+ #include <vector>
50
+ #include <map>
51
+ #include <set>
52
+
53
+ #include "ttmath.h"
54
+ #include "ttmathobjects.h"
55
+ #include "ttmathmisc.h"
56
+
57
+
58
+
59
+ namespace ttmath
60
+ {
61
+
62
+ /*!
63
+ \brief Mathematical parser
64
+
65
+ let x will be an input string meaning an expression for converting:
66
+
67
+ x = [+|-]Value[operator[+|-]Value][operator[+|-]Value]...
68
+ where:
69
+ an operator can be:
70
+ ^ (pow) (the heighest priority)
71
+
72
+ * (mul) (or multiplication without an operator -- short mul)
73
+ / (div) (* and / have the same priority)
74
+
75
+ + (add)
76
+ - (sub) (+ and - have the same priority)
77
+
78
+ < (lower than)
79
+ > (greater than)
80
+ <= (lower or equal than)
81
+ >= (greater or equal than)
82
+ == (equal)
83
+ != (not equal) (all above logical operators have the same priority)
84
+
85
+ && (logical and)
86
+
87
+ || (logical or) (the lowest priority)
88
+
89
+ short mul:
90
+ if the second Value (Var below) is either a variable or function there might not be
91
+ an operator between them, e.g.
92
+ "[+|-]Value Var" is treated as "[+|-]Value * Var" and the multiplication
93
+ has the same priority as a normal multiplication:
94
+ 4x = 4 * x
95
+ 2^3m = (2^3)* m
96
+ 6h^3 = 6 * (h^3)
97
+ 2sin(pi) = 2 * sin(pi)
98
+ etc.
99
+
100
+ Value can be:
101
+ constant e.g. 100, can be preceded by operators for changing the base (radix): [#|&]
102
+ # - hex
103
+ & - bin
104
+ sample: #10 = 16
105
+ &10 = 2
106
+ variable e.g. pi
107
+ another expression between brackets e.g (x)
108
+ function e.g. sin(x)
109
+
110
+ for example a correct input string can be:
111
+ "1"
112
+ "2.1234"
113
+ "2,1234" (they are the same, by default we can either use a comma or a dot)
114
+ "1 + 2"
115
+ "(1 + 2) * 3"
116
+ "pi"
117
+ "sin(pi)"
118
+ "(1+2)*(2+3)"
119
+ "log(2;1234)" there's a semicolon here (not a comma), we use it in functions
120
+ for separating parameters
121
+ "1 < 2" (the result will be: 1)
122
+ "4 < 3" (the result will be: 0)
123
+ "2+x" (of course if the variable 'x' is defined)
124
+ "4x+10"
125
+ "#20+10" = 32 + 10 = 42
126
+ "10 ^ -&101" = 10 ^ -5 = 0.00001
127
+ "8 * -&10" = 8 * -2 = -16
128
+ etc.
129
+
130
+ we can also use a semicolon for separating any 'x' input strings
131
+ for example:
132
+ "1+2;4+5"
133
+ the result will be on the stack as follows:
134
+ stack[0].value=3
135
+ stack[1].value=9
136
+ */
137
+ template<class ValueType>
138
+ class Parser
139
+ {
140
+ protected:
141
+
142
+ /*!
143
+ there are 5 mathematical operators as follows (with their standard priorities):
144
+ add (+)
145
+ sub (-)
146
+ mul (*)
147
+ div (/)
148
+ pow (^)
149
+ and 'shortmul' used when there is no any operators between
150
+ a first parameter and a variable or function
151
+ (the 'shortmul' has the same priority as the normal multiplication )
152
+ */
153
+ class MatOperator
154
+ {
155
+ public:
156
+
157
+ enum Type
158
+ {
159
+ none,add,sub,mul,div,pow,lt,gt,let,get,eq,neq,lor,land,shortmul,assign
160
+ };
161
+
162
+ enum Assoc
163
+ {
164
+ right, // right-associative
165
+ non_right // associative or left-associative
166
+ };
167
+
168
+ Type GetType() const { return type; }
169
+ int GetPriority() const { return priority; }
170
+ Assoc GetAssoc() const { return assoc; }
171
+
172
+ void SetType(Type t)
173
+ {
174
+ type = t;
175
+ assoc = non_right;
176
+
177
+ switch( type )
178
+ {
179
+ case assign:
180
+ priority = 3;
181
+ assoc = right;
182
+ break;
183
+
184
+ case lor:
185
+ priority = 4;
186
+ break;
187
+
188
+ case land:
189
+ priority = 5;
190
+ break;
191
+
192
+ case eq:
193
+ case neq:
194
+ case lt:
195
+ case gt:
196
+ case let:
197
+ case get:
198
+ priority = 7;
199
+ break;
200
+
201
+ case add:
202
+ case sub:
203
+ priority = 10;
204
+ break;
205
+
206
+ case mul:
207
+ case shortmul:
208
+ case div:
209
+ priority = 12;
210
+ break;
211
+
212
+ case pow:
213
+ priority = 14;
214
+ assoc = right;
215
+ break;
216
+
217
+ case none:
218
+ priority = 0;
219
+ assoc = non_right;
220
+ break;
221
+
222
+ default:
223
+ Error( err_internal_error );
224
+ break;
225
+ }
226
+ }
227
+
228
+ MatOperator(): type(none), priority(0), assoc(non_right)
229
+ {
230
+ }
231
+
232
+ private:
233
+
234
+ Type type;
235
+ int priority;
236
+ Assoc assoc;
237
+ }; // end of MatOperator class
238
+
239
+
240
+
241
+ public:
242
+
243
+
244
+
245
+ /*!
246
+ Objects of type 'Item' we are keeping on our stack
247
+ */
248
+ struct Item
249
+ {
250
+ enum Type
251
+ {
252
+ none, numerical_value, mat_operator, first_bracket,
253
+ last_bracket, variable, semicolon
254
+ };
255
+
256
+ // The kind of type which we're keeping
257
+ Type type;
258
+
259
+ // if type == numerical_value
260
+ ValueType value;
261
+
262
+ // if type == mat_operator
263
+ MatOperator moperator;
264
+
265
+ /*
266
+ if type == first_bracket
267
+
268
+ if 'function' is set to true it means that the first recognized bracket
269
+ was the bracket from function in other words we must call a function when
270
+ we'll find the 'last' bracket
271
+ */
272
+ bool function;
273
+
274
+ // if type == first_bracket and if function is true
275
+ // or if type == variable
276
+ std::string function_name;
277
+
278
+ /*
279
+ the sign of value
280
+
281
+ it can be for type==numerical_value or type==first_bracket
282
+ when it's true it means e.g. that value is equal -value
283
+ */
284
+ bool sign;
285
+
286
+ Item()
287
+ {
288
+ Clear();
289
+ }
290
+
291
+ void Clear()
292
+ {
293
+ type = none;
294
+ value.SetNan();
295
+ moperator.SetType(MatOperator::none);
296
+ function = false;
297
+ function_name.clear();
298
+ sign = false;
299
+ }
300
+
301
+ }; // end of Item struct
302
+
303
+
304
+ /*!
305
+ stack on which we're keeping the Items
306
+
307
+ at the end of parsing we'll have the result here
308
+ the result don't have to be one value, it can be
309
+ more than one if we have used a semicolon in the global space
310
+ e.g. such input string "1+2;3+4" will generate a result:
311
+ stack[0].value=3
312
+ stack[1].value=7
313
+
314
+ you should check if the stack is not empty, because if there was
315
+ a syntax error in the input string then we do not have any results
316
+ on the stack
317
+ */
318
+ std::vector<Item> stack;
319
+
320
+
321
+ protected:
322
+
323
+
324
+ /*!
325
+ size of the stack when we're starting parsing of the string
326
+
327
+ if it's to small while parsing the stack will be automatically resized
328
+ */
329
+ const int default_stack_size;
330
+
331
+
332
+
333
+ /*!
334
+ index of an object in our stack
335
+ it's pointing on the place behind the last element
336
+ for example at the beginning of parsing its value is zero
337
+ */
338
+ unsigned int stack_index;
339
+
340
+
341
+ /*!
342
+ code of the last error
343
+ */
344
+ ErrorCode error;
345
+
346
+
347
+ /*!
348
+ pointer to the currently reading char
349
+ when an error has occured it may be used to count the index of the wrong character
350
+ */
351
+ const char * pstring;
352
+
353
+
354
+ /*!
355
+ the base (radix) of the mathematic system (for example it may be '10')
356
+ */
357
+ int base;
358
+
359
+
360
+ /*!
361
+ the unit of angles used in: sin,cos,tan,cot,asin,acos,atan,acot
362
+ 0 - deg
363
+ 1 - rad (default)
364
+ 2 - grad
365
+ */
366
+ int deg_rad_grad;
367
+
368
+
369
+
370
+ /*!
371
+ a pointer to an object which tell us whether we should stop calculating or not
372
+ */
373
+ const volatile StopCalculating * pstop_calculating;
374
+
375
+
376
+
377
+ /*!
378
+ a pointer to the user-defined variables' table
379
+ */
380
+ const Objects * puser_variables;
381
+
382
+ /*!
383
+ a pointer to the user-defined functions' table
384
+ */
385
+ const Objects * puser_functions;
386
+
387
+
388
+ typedef std::map<std::string, ValueType> FunctionLocalVariables;
389
+
390
+ /*!
391
+ a pointer to the local variables of a function
392
+ */
393
+ const FunctionLocalVariables * pfunction_local_variables;
394
+
395
+
396
+ /*!
397
+ a temporary set using during parsing user defined variables
398
+ */
399
+ std::set<std::string> visited_variables;
400
+
401
+
402
+ /*!
403
+ a temporary set using during parsing user defined functions
404
+ */
405
+ std::set<std::string> visited_functions;
406
+
407
+
408
+
409
+
410
+ /*!
411
+ pfunction is the type of pointer to a mathematic function
412
+
413
+ these mathematic functions are private members of this class,
414
+ they are the wrappers for standard mathematics function
415
+
416
+ 'pstack' is the pointer to the first argument on our stack
417
+ 'amount_of_arg' tell us how many argument there are in our stack
418
+ 'result' is the reference for result of function
419
+ */
420
+ typedef void (Parser<ValueType>::*pfunction)(unsigned int pstack, int amount_of_arg, ValueType & result);
421
+
422
+
423
+ /*!
424
+ pfunction is the type of pointer to a method which returns value of variable
425
+ */
426
+ typedef void (ValueType::*pfunction_var)();
427
+
428
+
429
+ /*!
430
+ table of mathematic functions
431
+
432
+ this map consists of:
433
+ std::string - function's name
434
+ pfunction - pointer to specific function
435
+ */
436
+ typedef std::map<std::string, pfunction> FunctionsTable;
437
+ FunctionsTable functions_table;
438
+
439
+
440
+ /*!
441
+ table of mathematic operators
442
+
443
+ this map consists of:
444
+ std::string - operators's name
445
+ MatOperator::Type - type of the operator
446
+ */
447
+ typedef std::map<std::string, typename MatOperator::Type> OperatorsTable;
448
+ OperatorsTable operators_table;
449
+
450
+
451
+ /*!
452
+ table of mathematic variables
453
+
454
+ this map consists of:
455
+ std::string - variable's name
456
+ pfunction_var - pointer to specific function which returns value of variable
457
+ */
458
+ typedef std::map<std::string, pfunction_var> VariablesTable;
459
+ VariablesTable variables_table;
460
+
461
+
462
+ /*!
463
+ some coefficients used when calculating the gamma (or factorial) function
464
+ */
465
+ CGamma<ValueType> cgamma;
466
+
467
+
468
+ /*!
469
+ temporary object for a whole string when Parse(std::wstring) is used
470
+ */
471
+ std::string wide_to_ansi;
472
+
473
+
474
+ /*!
475
+ group character (used when parsing)
476
+ default zero (not used)
477
+ */
478
+ int group;
479
+
480
+
481
+ /*!
482
+ characters used as a comma
483
+ default: '.' and ','
484
+ comma2 can be zero (it means it is not used)
485
+ */
486
+ int comma, comma2;
487
+
488
+
489
+ /*!
490
+ an additional character used as a separator between function parameters
491
+ (semicolon is used always)
492
+ */
493
+ int param_sep;
494
+
495
+
496
+ /*!
497
+ true if something was calculated (at least one mathematical operator was used or a function or a variable)
498
+ */
499
+ bool calculated;
500
+
501
+
502
+
503
+ /*!
504
+ we're using this method for reporting an error
505
+ */
506
+ static void Error(ErrorCode code)
507
+ {
508
+ throw code;
509
+ }
510
+
511
+
512
+ /*!
513
+ this method skips the white character from the string
514
+
515
+ it's moving the 'pstring' to the first no-white character
516
+ */
517
+ void SkipWhiteCharacters()
518
+ {
519
+ while( (*pstring==' ' ) || (*pstring=='\t') )
520
+ ++pstring;
521
+ }
522
+
523
+
524
+
525
+ /*!
526
+ make sure there is a space for a new item at position stack_index
527
+ */
528
+ virtual void EnsurePlaceOnStack()
529
+ {
530
+ if( stack_index >= stack.size() )
531
+ {
532
+ stack.push_back(Item());
533
+ }
534
+ }
535
+
536
+
537
+ /*!
538
+ add a new item (numerical value) to the stack
539
+ */
540
+ void AddToStack(ValueType & value)
541
+ {
542
+ EnsurePlaceOnStack();
543
+
544
+ stack[stack_index].Clear();
545
+ stack[stack_index].type = Item::numerical_value;
546
+ stack[stack_index].value = value;
547
+ stack_index += 1;
548
+ }
549
+
550
+
551
+ /*!
552
+ add a new item to the stack
553
+ */
554
+ void AddToStack(typename Item::Type type, bool is_sign)
555
+ {
556
+ EnsurePlaceOnStack();
557
+
558
+ stack[stack_index].Clear();
559
+ stack[stack_index].type = type;
560
+ stack[stack_index].function = false;
561
+ stack[stack_index].sign = is_sign;
562
+ stack_index += 1;
563
+ }
564
+
565
+
566
+ /*!
567
+ add a new item (math operator) to the stack
568
+ */
569
+ void AddToStack(typename MatOperator::Type mat_operator_type)
570
+ {
571
+ EnsurePlaceOnStack();
572
+
573
+ stack[stack_index].Clear();
574
+ stack[stack_index].type = Item::mat_operator;
575
+ stack[stack_index].moperator.SetType(mat_operator_type);
576
+ stack_index += 1;
577
+ }
578
+
579
+
580
+ /*!
581
+ add a new item (function or variable) to the stack
582
+
583
+ if is_function is true then we add a function name
584
+ when false then we add a variable (such a case is only when an assigment operator = is used e.g. a = 10)
585
+ */
586
+ void AddToStack(typename Item::Type type, const std::string & name, bool is_function, bool is_sign)
587
+ {
588
+ EnsurePlaceOnStack();
589
+
590
+ stack[stack_index].Clear();
591
+ stack[stack_index].type = type;
592
+ stack[stack_index].function_name = name;
593
+ stack[stack_index].function = is_function;
594
+ stack[stack_index].sign = is_sign;
595
+ stack_index += 1;
596
+ }
597
+
598
+
599
+
600
+ /*!
601
+ an auxiliary method for RecurrenceParsingVariablesOrFunction(...)
602
+ */
603
+ void RecurrenceParsingVariablesOrFunction_CheckStopCondition(bool variable, const std::string & name)
604
+ {
605
+ if( variable )
606
+ {
607
+ if( visited_variables.find(name) != visited_variables.end() )
608
+ Error( err_variable_loop );
609
+ }
610
+ else
611
+ {
612
+ if( visited_functions.find(name) != visited_functions.end() )
613
+ Error( err_functions_loop );
614
+ }
615
+ }
616
+
617
+
618
+ /*!
619
+ an auxiliary method for RecurrenceParsingVariablesOrFunction(...)
620
+ */
621
+ void RecurrenceParsingVariablesOrFunction_AddName(bool variable, const std::string & name)
622
+ {
623
+ if( variable )
624
+ visited_variables.insert( name );
625
+ else
626
+ visited_functions.insert( name );
627
+ }
628
+
629
+
630
+ /*!
631
+ an auxiliary method for RecurrenceParsingVariablesOrFunction(...)
632
+ */
633
+ void RecurrenceParsingVariablesOrFunction_DeleteName(bool variable, const std::string & name)
634
+ {
635
+ if( variable )
636
+ visited_variables.erase( name );
637
+ else
638
+ visited_functions.erase( name );
639
+ }
640
+
641
+
642
+ /*!
643
+ this method returns the value of a variable or function
644
+ by creating a new instance of the mathematical parser
645
+ and making the standard parsing algorithm on the given string
646
+
647
+ this method is used only during parsing user defined variables or functions
648
+
649
+ (there can be a recurrence here therefore we're using 'visited_variables'
650
+ and 'visited_functions' sets to make a stop condition)
651
+ */
652
+ ValueType RecurrenceParsingVariablesOrFunction(bool variable, const std::string & name, const char * new_string,
653
+ FunctionLocalVariables * local_variables = 0)
654
+ {
655
+ RecurrenceParsingVariablesOrFunction_CheckStopCondition(variable, name);
656
+ RecurrenceParsingVariablesOrFunction_AddName(variable, name);
657
+
658
+ Parser<ValueType> NewParser(*this);
659
+ ErrorCode err;
660
+
661
+ NewParser.pfunction_local_variables = local_variables;
662
+
663
+ try
664
+ {
665
+ err = NewParser.Parse(new_string);
666
+ }
667
+ catch(...)
668
+ {
669
+ RecurrenceParsingVariablesOrFunction_DeleteName(variable, name);
670
+
671
+ throw;
672
+ }
673
+
674
+ RecurrenceParsingVariablesOrFunction_DeleteName(variable, name);
675
+
676
+ if( err != err_ok )
677
+ Error( err );
678
+
679
+ if( NewParser.stack.size() != 1 )
680
+ Error( err_must_be_only_one_value );
681
+
682
+ if( NewParser.stack[0].type != Item::numerical_value )
683
+ // I think there shouldn't be this error here
684
+ Error( err_incorrect_value );
685
+
686
+ return NewParser.stack[0].value;
687
+ }
688
+
689
+
690
+ public:
691
+
692
+
693
+ /*!
694
+ this method returns the user-defined value of a variable
695
+ */
696
+ bool GetValueOfUserDefinedVariable(const std::string & variable_name,ValueType & result)
697
+ {
698
+ if( !puser_variables )
699
+ return false;
700
+
701
+ const char * string_value;
702
+
703
+ if( puser_variables->GetValue(variable_name, &string_value) != err_ok )
704
+ return false;
705
+
706
+ result = RecurrenceParsingVariablesOrFunction(true, variable_name, string_value);
707
+ calculated = true;
708
+
709
+ return true;
710
+ }
711
+
712
+
713
+ /*!
714
+ this method returns the value of a local variable of a function
715
+ */
716
+ bool GetValueOfFunctionLocalVariable(const std::string & variable_name, ValueType & result)
717
+ {
718
+ if( !pfunction_local_variables )
719
+ return false;
720
+
721
+ typename FunctionLocalVariables::const_iterator i = pfunction_local_variables->find(variable_name);
722
+
723
+ if( i == pfunction_local_variables->end() )
724
+ return false;
725
+
726
+ result = i->second;
727
+
728
+ return true;
729
+ }
730
+
731
+
732
+ /*!
733
+ this method returns the value of a variable from variables' table
734
+
735
+ we make an object of type ValueType then call a method which
736
+ sets the correct value in it and finally we'll return the object
737
+ */
738
+ virtual ValueType GetValueOfVariable(const std::string & variable_name)
739
+ {
740
+ ValueType result;
741
+
742
+ if( GetValueOfFunctionLocalVariable(variable_name, result) )
743
+ return result;
744
+
745
+ if( GetValueOfUserDefinedVariable(variable_name, result) )
746
+ return result;
747
+
748
+
749
+ typename std::map<std::string, pfunction_var>::iterator i =
750
+ variables_table.find(variable_name);
751
+
752
+ if( i == variables_table.end() )
753
+ Error( err_unknown_variable );
754
+
755
+ (result.*(i->second))();
756
+ calculated = true;
757
+
758
+ return result;
759
+ }
760
+
761
+
762
+ protected:
763
+
764
+ /*!
765
+ wrappers for mathematic functions
766
+
767
+ 'index' is pointing on the first argument on the stack, the second argument has 'index+1' and so on
768
+ 'result' will be the result of the function
769
+
770
+ (we're using exceptions here for example when function gets an improper argument)
771
+ */
772
+
773
+
774
+ /*!
775
+ used by: sin,cos,tan,cot
776
+ */
777
+ ValueType ConvertAngleToRad(const ValueType & input)
778
+ {
779
+ if( deg_rad_grad == 1 ) // rad
780
+ return input;
781
+
782
+ ValueType result;
783
+ ErrorCode err;
784
+
785
+ if( deg_rad_grad == 0 ) // deg
786
+ result = ttmath::DegToRad(input, &err);
787
+ else // grad
788
+ result = ttmath::GradToRad(input, &err);
789
+
790
+ if( err != err_ok )
791
+ Error( err );
792
+
793
+ return result;
794
+ }
795
+
796
+
797
+ /*!
798
+ used by: asin,acos,atan,acot
799
+ */
800
+ ValueType ConvertRadToAngle(const ValueType & input)
801
+ {
802
+ if( deg_rad_grad == 1 ) // rad
803
+ return input;
804
+
805
+ ValueType result;
806
+ ErrorCode err;
807
+
808
+ if( deg_rad_grad == 0 ) // deg
809
+ result = ttmath::RadToDeg(input, &err);
810
+ else // grad
811
+ result = ttmath::RadToGrad(input, &err);
812
+
813
+ if( err != err_ok )
814
+ Error( err );
815
+
816
+ return result;
817
+ }
818
+
819
+
820
+ void Gamma(unsigned int index, int amount_of_args, ValueType & result)
821
+ {
822
+ if( amount_of_args != 1 )
823
+ Error( err_improper_amount_of_arguments );
824
+
825
+ ErrorCode err;
826
+
827
+ result = ttmath::Gamma(stack[index].value, cgamma, &err, pstop_calculating);
828
+
829
+ if(err != err_ok)
830
+ Error( err );
831
+ }
832
+
833
+
834
+ /*!
835
+ factorial
836
+ result = 1 * 2 * 3 * 4 * .... * x
837
+ */
838
+ void Factorial(unsigned int index, int amount_of_args, ValueType & result)
839
+ {
840
+ if( amount_of_args != 1 )
841
+ Error( err_improper_amount_of_arguments );
842
+
843
+ ErrorCode err;
844
+
845
+ result = ttmath::Factorial(stack[index].value, cgamma, &err, pstop_calculating);
846
+
847
+ if(err != err_ok)
848
+ Error( err );
849
+ }
850
+
851
+
852
+ void Abs(unsigned int index, int amount_of_args, ValueType & result)
853
+ {
854
+ if( amount_of_args != 1 )
855
+ Error( err_improper_amount_of_arguments );
856
+
857
+ result = ttmath::Abs(stack[index].value);
858
+ }
859
+
860
+ void Sin(unsigned int index, int amount_of_args, ValueType & result)
861
+ {
862
+ if( amount_of_args != 1 )
863
+ Error( err_improper_amount_of_arguments );
864
+
865
+ ErrorCode err;
866
+ result = ttmath::Sin( ConvertAngleToRad(stack[index].value), &err );
867
+
868
+ if(err != err_ok)
869
+ Error( err );
870
+ }
871
+
872
+ void Cos(unsigned int index, int amount_of_args, ValueType & result)
873
+ {
874
+ if( amount_of_args != 1 )
875
+ Error( err_improper_amount_of_arguments );
876
+
877
+ ErrorCode err;
878
+ result = ttmath::Cos( ConvertAngleToRad(stack[index].value), &err );
879
+
880
+ if(err != err_ok)
881
+ Error( err );
882
+ }
883
+
884
+ void Tan(unsigned int index, int amount_of_args, ValueType & result)
885
+ {
886
+ if( amount_of_args != 1 )
887
+ Error( err_improper_amount_of_arguments );
888
+
889
+ ErrorCode err;
890
+ result = ttmath::Tan(ConvertAngleToRad(stack[index].value), &err);
891
+
892
+ if(err != err_ok)
893
+ Error( err );
894
+ }
895
+
896
+ void Cot(unsigned int index, int amount_of_args, ValueType & result)
897
+ {
898
+ if( amount_of_args != 1 )
899
+ Error( err_improper_amount_of_arguments );
900
+
901
+ ErrorCode err;
902
+ result = ttmath::Cot(ConvertAngleToRad(stack[index].value), &err);
903
+
904
+ if(err != err_ok)
905
+ Error( err );
906
+ }
907
+
908
+ void Int(unsigned int index, int amount_of_args, ValueType & result)
909
+ {
910
+ if( amount_of_args != 1 )
911
+ Error( err_improper_amount_of_arguments );
912
+
913
+ result = ttmath::SkipFraction(stack[index].value);
914
+ }
915
+
916
+
917
+ void Round(unsigned int index, int amount_of_args, ValueType & result)
918
+ {
919
+ if( amount_of_args != 1 )
920
+ Error( err_improper_amount_of_arguments );
921
+
922
+ result = stack[index].value;
923
+
924
+ if( result.Round() )
925
+ Error( err_overflow );
926
+ }
927
+
928
+
929
+ void Ln(unsigned int index, int amount_of_args, ValueType & result)
930
+ {
931
+ if( amount_of_args != 1 )
932
+ Error( err_improper_amount_of_arguments );
933
+
934
+ ErrorCode err;
935
+ result = ttmath::Ln(stack[index].value, &err);
936
+
937
+ if(err != err_ok)
938
+ Error( err );
939
+ }
940
+
941
+ void Log(unsigned int index, int amount_of_args, ValueType & result)
942
+ {
943
+ if( amount_of_args != 2 )
944
+ Error( err_improper_amount_of_arguments );
945
+
946
+ ErrorCode err;
947
+ result = ttmath::Log(stack[index].value, stack[index+1].value, &err);
948
+
949
+ if(err != err_ok)
950
+ Error( err );
951
+ }
952
+
953
+ void Exp(unsigned int index, int amount_of_args, ValueType & result)
954
+ {
955
+ if( amount_of_args != 1 )
956
+ Error( err_improper_amount_of_arguments );
957
+
958
+ ErrorCode err;
959
+ result = ttmath::Exp(stack[index].value, &err);
960
+
961
+ if(err != err_ok)
962
+ Error( err );
963
+ }
964
+
965
+
966
+ void Max(unsigned int index, int amount_of_args, ValueType & result)
967
+ {
968
+ if( amount_of_args == 0 )
969
+ {
970
+ result.SetMax();
971
+
972
+ return;
973
+ }
974
+
975
+ result = stack[index].value;
976
+
977
+ for(int i=1 ; i < amount_of_args ; ++i)
978
+ {
979
+ if( result < stack[index + i].value )
980
+ result = stack[index + i].value;
981
+ }
982
+ }
983
+
984
+
985
+ void Min(unsigned int index, int amount_of_args, ValueType & result)
986
+ {
987
+ if( amount_of_args == 0 )
988
+ {
989
+ result.SetMin();
990
+
991
+ return;
992
+ }
993
+
994
+ result = stack[index].value;
995
+
996
+ for(int i=1 ; i<amount_of_args ; ++i)
997
+ {
998
+ if( result > stack[index + i].value )
999
+ result = stack[index + i].value;
1000
+ }
1001
+ }
1002
+
1003
+
1004
+ void ASin(unsigned int index, int amount_of_args, ValueType & result)
1005
+ {
1006
+ if( amount_of_args != 1 )
1007
+ Error( err_improper_amount_of_arguments );
1008
+
1009
+ ErrorCode err;
1010
+ ValueType temp = ttmath::ASin(stack[index].value, &err);
1011
+
1012
+ if(err != err_ok)
1013
+ Error( err );
1014
+
1015
+ result = ConvertRadToAngle(temp);
1016
+ }
1017
+
1018
+
1019
+ void ACos(unsigned int index, int amount_of_args, ValueType & result)
1020
+ {
1021
+ if( amount_of_args != 1 )
1022
+ Error( err_improper_amount_of_arguments );
1023
+
1024
+ ErrorCode err;
1025
+ ValueType temp = ttmath::ACos(stack[index].value, &err);
1026
+
1027
+ if(err != err_ok)
1028
+ Error( err );
1029
+
1030
+ result = ConvertRadToAngle(temp);
1031
+ }
1032
+
1033
+
1034
+ void ATan(unsigned int index, int amount_of_args, ValueType & result)
1035
+ {
1036
+ if( amount_of_args != 1 )
1037
+ Error( err_improper_amount_of_arguments );
1038
+
1039
+ result = ConvertRadToAngle(ttmath::ATan(stack[index].value));
1040
+ }
1041
+
1042
+
1043
+ void ACot(unsigned int index, int amount_of_args, ValueType & result)
1044
+ {
1045
+ if( amount_of_args != 1 )
1046
+ Error( err_improper_amount_of_arguments );
1047
+
1048
+ result = ConvertRadToAngle(ttmath::ACot(stack[index].value));
1049
+ }
1050
+
1051
+
1052
+ void Sgn(unsigned int index, int amount_of_args, ValueType & result)
1053
+ {
1054
+ if( amount_of_args != 1 )
1055
+ Error( err_improper_amount_of_arguments );
1056
+
1057
+ result = ttmath::Sgn(stack[index].value);
1058
+ }
1059
+
1060
+
1061
+ void Mod(unsigned int index, int amount_of_args, ValueType & result)
1062
+ {
1063
+ if( amount_of_args != 2 )
1064
+ Error( err_improper_amount_of_arguments );
1065
+
1066
+ if( stack[index+1].value.IsZero() )
1067
+ Error( err_improper_argument );
1068
+
1069
+ result = stack[index].value;
1070
+ uint c = result.Mod(stack[index+1].value);
1071
+
1072
+ if( c )
1073
+ Error( err_overflow );
1074
+ }
1075
+
1076
+
1077
+ void If(unsigned int index, int amount_of_args, ValueType & result)
1078
+ {
1079
+ if( amount_of_args != 3 )
1080
+ Error( err_improper_amount_of_arguments );
1081
+
1082
+
1083
+ if( !stack[index].value.IsZero() )
1084
+ result = stack[index+1].value;
1085
+ else
1086
+ result = stack[index+2].value;
1087
+ }
1088
+
1089
+
1090
+ void Or(unsigned int index, int amount_of_args, ValueType & result)
1091
+ {
1092
+ if( amount_of_args < 2 )
1093
+ Error( err_improper_amount_of_arguments );
1094
+
1095
+ for(int i=0 ; i < amount_of_args ; ++i)
1096
+ {
1097
+ if( !stack[index+i].value.IsZero() )
1098
+ {
1099
+ result.SetOne();
1100
+ return;
1101
+ }
1102
+ }
1103
+
1104
+ result.SetZero();
1105
+ }
1106
+
1107
+
1108
+ void And(unsigned int index, int amount_of_args, ValueType & result)
1109
+ {
1110
+ if( amount_of_args < 2 )
1111
+ Error( err_improper_amount_of_arguments );
1112
+
1113
+ for(int i=0 ; i<amount_of_args ; ++i)
1114
+ {
1115
+ if( stack[index+i].value.IsZero() )
1116
+ {
1117
+ result.SetZero();
1118
+ return;
1119
+ }
1120
+ }
1121
+
1122
+ result.SetOne();
1123
+ }
1124
+
1125
+
1126
+ void Not(unsigned int index, int amount_of_args, ValueType & result)
1127
+ {
1128
+ if( amount_of_args != 1 )
1129
+ Error( err_improper_amount_of_arguments );
1130
+
1131
+
1132
+ if( stack[index].value.IsZero() )
1133
+ result.SetOne();
1134
+ else
1135
+ result.SetZero();
1136
+ }
1137
+
1138
+
1139
+ void DegToRad(unsigned int index, int amount_of_args, ValueType & result)
1140
+ {
1141
+ ErrorCode err = err_ok;
1142
+
1143
+ if( amount_of_args == 1 )
1144
+ {
1145
+ result = ttmath::DegToRad(stack[index].value, &err);
1146
+ }
1147
+ else
1148
+ if( amount_of_args == 3 )
1149
+ {
1150
+ result = ttmath::DegToRad( stack[index].value, stack[index+1].value,
1151
+ stack[index+2].value, &err);
1152
+ }
1153
+ else
1154
+ Error( err_improper_amount_of_arguments );
1155
+
1156
+
1157
+ if( err != err_ok )
1158
+ Error( err );
1159
+ }
1160
+
1161
+
1162
+ void RadToDeg(unsigned int index, int amount_of_args, ValueType & result)
1163
+ {
1164
+ ErrorCode err;
1165
+
1166
+ if( amount_of_args != 1 )
1167
+ Error( err_improper_amount_of_arguments );
1168
+
1169
+ result = ttmath::RadToDeg(stack[index].value, &err);
1170
+
1171
+ if( err != err_ok )
1172
+ Error( err );
1173
+ }
1174
+
1175
+
1176
+ void DegToDeg(unsigned int index, int amount_of_args, ValueType & result)
1177
+ {
1178
+ if( amount_of_args != 3 )
1179
+ Error( err_improper_amount_of_arguments );
1180
+
1181
+ ErrorCode err;
1182
+ result = ttmath::DegToDeg( stack[index].value, stack[index+1].value,
1183
+ stack[index+2].value, &err);
1184
+
1185
+ if( err != err_ok )
1186
+ Error( err );
1187
+ }
1188
+
1189
+
1190
+ void GradToRad(unsigned int index, int amount_of_args, ValueType & result)
1191
+ {
1192
+ ErrorCode err;
1193
+
1194
+ if( amount_of_args != 1 )
1195
+ Error( err_improper_amount_of_arguments );
1196
+
1197
+ result = ttmath::GradToRad(stack[index].value, &err);
1198
+
1199
+ if( err != err_ok )
1200
+ Error( err );
1201
+ }
1202
+
1203
+
1204
+ void RadToGrad(unsigned int index, int amount_of_args, ValueType & result)
1205
+ {
1206
+ ErrorCode err;
1207
+
1208
+ if( amount_of_args != 1 )
1209
+ Error( err_improper_amount_of_arguments );
1210
+
1211
+ result = ttmath::RadToGrad(stack[index].value, &err);
1212
+
1213
+ if( err != err_ok )
1214
+ Error( err );
1215
+ }
1216
+
1217
+
1218
+ void DegToGrad(unsigned int index, int amount_of_args, ValueType & result)
1219
+ {
1220
+ ErrorCode err = err_ok;
1221
+
1222
+ if( amount_of_args == 1 )
1223
+ {
1224
+ result = ttmath::DegToGrad(stack[index].value, &err);
1225
+ }
1226
+ else
1227
+ if( amount_of_args == 3 )
1228
+ {
1229
+ result = ttmath::DegToGrad( stack[index].value, stack[index+1].value,
1230
+ stack[index+2].value, &err);
1231
+ }
1232
+ else
1233
+ Error( err_improper_amount_of_arguments );
1234
+
1235
+
1236
+ if( err != err_ok )
1237
+ Error( err );
1238
+ }
1239
+
1240
+
1241
+ void GradToDeg(unsigned int index, int amount_of_args, ValueType & result)
1242
+ {
1243
+ ErrorCode err;
1244
+
1245
+ if( amount_of_args != 1 )
1246
+ Error( err_improper_amount_of_arguments );
1247
+
1248
+ result = ttmath::GradToDeg(stack[index].value, &err);
1249
+
1250
+ if( err != err_ok )
1251
+ Error( err );
1252
+ }
1253
+
1254
+
1255
+ void Ceil(unsigned int index, int amount_of_args, ValueType & result)
1256
+ {
1257
+ if( amount_of_args != 1 )
1258
+ Error( err_improper_amount_of_arguments );
1259
+
1260
+ ErrorCode err;
1261
+ result = ttmath::Ceil(stack[index].value, &err);
1262
+
1263
+ if( err != err_ok )
1264
+ Error( err );
1265
+ }
1266
+
1267
+
1268
+ void Floor(unsigned int index, int amount_of_args, ValueType & result)
1269
+ {
1270
+ if( amount_of_args != 1 )
1271
+ Error( err_improper_amount_of_arguments );
1272
+
1273
+ ErrorCode err;
1274
+ result = ttmath::Floor(stack[index].value, &err);
1275
+
1276
+ if( err != err_ok )
1277
+ Error( err );
1278
+ }
1279
+
1280
+ void Sqrt(unsigned int index, int amount_of_args, ValueType & result)
1281
+ {
1282
+ if( amount_of_args != 1 )
1283
+ Error( err_improper_amount_of_arguments );
1284
+
1285
+ ErrorCode err;
1286
+ result = ttmath::Sqrt(stack[index].value, &err);
1287
+
1288
+ if( err != err_ok )
1289
+ Error( err );
1290
+ }
1291
+
1292
+
1293
+ void Sinh(unsigned int index, int amount_of_args, ValueType & result)
1294
+ {
1295
+ if( amount_of_args != 1 )
1296
+ Error( err_improper_amount_of_arguments );
1297
+
1298
+ ErrorCode err;
1299
+ result = ttmath::Sinh(stack[index].value, &err);
1300
+
1301
+ if( err != err_ok )
1302
+ Error( err );
1303
+ }
1304
+
1305
+
1306
+ void Cosh(unsigned int index, int amount_of_args, ValueType & result)
1307
+ {
1308
+ if( amount_of_args != 1 )
1309
+ Error( err_improper_amount_of_arguments );
1310
+
1311
+ ErrorCode err;
1312
+ result = ttmath::Cosh(stack[index].value, &err);
1313
+
1314
+ if( err != err_ok )
1315
+ Error( err );
1316
+ }
1317
+
1318
+
1319
+ void Tanh(unsigned int index, int amount_of_args, ValueType & result)
1320
+ {
1321
+ if( amount_of_args != 1 )
1322
+ Error( err_improper_amount_of_arguments );
1323
+
1324
+ ErrorCode err;
1325
+ result = ttmath::Tanh(stack[index].value, &err);
1326
+
1327
+ if( err != err_ok )
1328
+ Error( err );
1329
+ }
1330
+
1331
+
1332
+ void Coth(unsigned int index, int amount_of_args, ValueType & result)
1333
+ {
1334
+ if( amount_of_args != 1 )
1335
+ Error( err_improper_amount_of_arguments );
1336
+
1337
+ ErrorCode err;
1338
+ result = ttmath::Coth(stack[index].value, &err);
1339
+
1340
+ if( err != err_ok )
1341
+ Error( err );
1342
+ }
1343
+
1344
+
1345
+ void Root(unsigned int index, int amount_of_args, ValueType & result)
1346
+ {
1347
+ if( amount_of_args != 2 )
1348
+ Error( err_improper_amount_of_arguments );
1349
+
1350
+ ErrorCode err;
1351
+ result = ttmath::Root(stack[index].value, stack[index+1].value, &err);
1352
+
1353
+ if( err != err_ok )
1354
+ Error( err );
1355
+ }
1356
+
1357
+
1358
+
1359
+ void ASinh(unsigned int index, int amount_of_args, ValueType & result)
1360
+ {
1361
+ if( amount_of_args != 1 )
1362
+ Error( err_improper_amount_of_arguments );
1363
+
1364
+ ErrorCode err;
1365
+ result = ttmath::ASinh(stack[index].value, &err);
1366
+
1367
+ if( err != err_ok )
1368
+ Error( err );
1369
+ }
1370
+
1371
+
1372
+ void ACosh(unsigned int index, int amount_of_args, ValueType & result)
1373
+ {
1374
+ if( amount_of_args != 1 )
1375
+ Error( err_improper_amount_of_arguments );
1376
+
1377
+ ErrorCode err;
1378
+ result = ttmath::ACosh(stack[index].value, &err);
1379
+
1380
+ if( err != err_ok )
1381
+ Error( err );
1382
+ }
1383
+
1384
+
1385
+ void ATanh(unsigned int index, int amount_of_args, ValueType & result)
1386
+ {
1387
+ if( amount_of_args != 1 )
1388
+ Error( err_improper_amount_of_arguments );
1389
+
1390
+ ErrorCode err;
1391
+ result = ttmath::ATanh(stack[index].value, &err);
1392
+
1393
+ if( err != err_ok )
1394
+ Error( err );
1395
+ }
1396
+
1397
+
1398
+ void ACoth(unsigned int index, int amount_of_args, ValueType & result)
1399
+ {
1400
+ if( amount_of_args != 1 )
1401
+ Error( err_improper_amount_of_arguments );
1402
+
1403
+ ErrorCode err;
1404
+ result = ttmath::ACoth(stack[index].value, &err);
1405
+
1406
+ if( err != err_ok )
1407
+ Error( err );
1408
+ }
1409
+
1410
+
1411
+ void BitAnd(unsigned int index, int amount_of_args, ValueType & result)
1412
+ {
1413
+ if( amount_of_args != 2 )
1414
+ Error( err_improper_amount_of_arguments );
1415
+
1416
+ uint err;
1417
+ result = stack[index].value;
1418
+ err = result.BitAnd(stack[index+1].value);
1419
+
1420
+ switch(err)
1421
+ {
1422
+ case 1:
1423
+ Error( err_overflow );
1424
+ break;
1425
+ case 2:
1426
+ Error( err_improper_argument );
1427
+ break;
1428
+ }
1429
+ }
1430
+
1431
+ void BitOr(unsigned int index, int amount_of_args, ValueType & result)
1432
+ {
1433
+ if( amount_of_args != 2 )
1434
+ Error( err_improper_amount_of_arguments );
1435
+
1436
+ uint err;
1437
+ result = stack[index].value;
1438
+ err = result.BitOr(stack[index+1].value);
1439
+
1440
+ switch(err)
1441
+ {
1442
+ case 1:
1443
+ Error( err_overflow );
1444
+ break;
1445
+ case 2:
1446
+ Error( err_improper_argument );
1447
+ break;
1448
+ }
1449
+ }
1450
+
1451
+
1452
+ void BitXor(unsigned int index, int amount_of_args, ValueType & result)
1453
+ {
1454
+ if( amount_of_args != 2 )
1455
+ Error( err_improper_amount_of_arguments );
1456
+
1457
+ uint err;
1458
+ result = stack[index].value;
1459
+ err = result.BitXor(stack[index+1].value);
1460
+
1461
+ switch(err)
1462
+ {
1463
+ case 1:
1464
+ Error( err_overflow );
1465
+ break;
1466
+ case 2:
1467
+ Error( err_improper_argument );
1468
+ break;
1469
+ }
1470
+ }
1471
+
1472
+
1473
+ void Sum(unsigned int index, int amount_of_args, ValueType & result)
1474
+ {
1475
+ if( amount_of_args == 0 )
1476
+ Error( err_improper_amount_of_arguments );
1477
+
1478
+ result = stack[index].value;
1479
+
1480
+ for(int i=1 ; i < amount_of_args ; ++i )
1481
+ if( result.Add( stack[ index + i ].value ) )
1482
+ Error( err_overflow );
1483
+ }
1484
+
1485
+ void Avg(unsigned int index, int amount_of_args, ValueType & result)
1486
+ {
1487
+ if( amount_of_args == 0 )
1488
+ Error( err_improper_amount_of_arguments );
1489
+
1490
+ result = stack[index].value;
1491
+
1492
+ for(int i=1 ; i < amount_of_args ; ++i )
1493
+ if( result.Add( stack[ index + i ].value ) )
1494
+ Error( err_overflow );
1495
+
1496
+ if( result.Div( amount_of_args ) )
1497
+ Error( err_overflow );
1498
+ }
1499
+
1500
+
1501
+ void Frac(unsigned int index, int amount_of_args, ValueType & result)
1502
+ {
1503
+ if( amount_of_args != 1 )
1504
+ Error( err_improper_amount_of_arguments );
1505
+
1506
+ result = stack[index].value;
1507
+ result.RemainFraction();
1508
+ }
1509
+
1510
+
1511
+
1512
+
1513
+ /*!
1514
+ we use such a method because 'wvsprintf' is not everywhere defined
1515
+ */
1516
+ void Sprintf(char * buffer, int par)
1517
+ {
1518
+ char buf[30]; // char, not wchar_t
1519
+ int i;
1520
+
1521
+ #ifdef _MSC_VER
1522
+ #pragma warning( disable: 4996 )
1523
+ //warning C4996: 'sprintf': This function or variable may be unsafe.
1524
+ #endif
1525
+
1526
+ snprintf(buf, sizeof(buf), "%d", par);
1527
+ for(i=0 ; buf[i] != 0 ; ++i)
1528
+ buffer[i] = buf[i];
1529
+
1530
+ buffer[i] = 0;
1531
+
1532
+ #ifdef _MSC_VER
1533
+ #pragma warning( default: 4996 )
1534
+ #endif
1535
+ }
1536
+
1537
+
1538
+
1539
+
1540
+ /*!
1541
+ this method returns the value from a user-defined function
1542
+
1543
+ (look at the description in 'CallFunction(...)')
1544
+ */
1545
+ bool GetValueOfUserDefinedFunction(const std::string & function_name, int amount_of_args, unsigned int index)
1546
+ {
1547
+ if( !puser_functions )
1548
+ return false;
1549
+
1550
+ const char * string_value;
1551
+ int param;
1552
+
1553
+ if( puser_functions->GetValueAndParam(function_name, &string_value, &param) != err_ok )
1554
+ return false;
1555
+
1556
+ if( param != amount_of_args )
1557
+ Error( err_improper_amount_of_arguments );
1558
+
1559
+
1560
+ FunctionLocalVariables local_variables;
1561
+
1562
+ if( amount_of_args > 0 )
1563
+ {
1564
+ char buffer[30];
1565
+
1566
+ // x = x1
1567
+ buffer[0] = 'x';
1568
+ buffer[1] = 0;
1569
+ local_variables.insert( std::make_pair(buffer, stack[index].value) );
1570
+
1571
+ for(int i=0 ; i<amount_of_args ; ++i)
1572
+ {
1573
+ buffer[0] = 'x';
1574
+ Sprintf(buffer+1, i+1);
1575
+ local_variables.insert( std::make_pair(buffer, stack[index + i].value) );
1576
+ }
1577
+ }
1578
+
1579
+ stack[index-1].value = RecurrenceParsingVariablesOrFunction(false, function_name, string_value, &local_variables);
1580
+ calculated = true;
1581
+
1582
+ return true;
1583
+ }
1584
+
1585
+
1586
+ /*
1587
+ we're calling a specific function
1588
+
1589
+ function_name - name of the function
1590
+ amount_of_args - how many arguments there are on our stack
1591
+ (function must check whether this is a correct value or not)
1592
+ index - index of the first argument on the stack (index is greater than zero)
1593
+ if there are no arguments on the stack then 'index' is pointing to
1594
+ a non existend element (after the first bracket)
1595
+
1596
+ result will be stored in 'stack[index-1].value'
1597
+ (we don't have to set the correct type of this element, it'll be set later)
1598
+ */
1599
+ virtual void CallFunction(const std::string & function_name, int amount_of_args, unsigned int index)
1600
+ {
1601
+ if( GetValueOfUserDefinedFunction(function_name, amount_of_args, index) )
1602
+ return;
1603
+
1604
+ typename FunctionsTable::iterator i = functions_table.find( function_name );
1605
+
1606
+ if( i == functions_table.end() )
1607
+ Error( err_unknown_function );
1608
+
1609
+ /*
1610
+ calling the specify function
1611
+ */
1612
+ (this->*(i->second))(index, amount_of_args, stack[index-1].value);
1613
+ calculated = true;
1614
+ }
1615
+
1616
+
1617
+
1618
+
1619
+
1620
+ /*!
1621
+ inserting a function to the functions' table
1622
+
1623
+ function_name - name of the function
1624
+ pf - pointer to the function (to the wrapper)
1625
+ */
1626
+ void InsertFunctionToTable(const char * function_name, pfunction pf)
1627
+ {
1628
+ std::string str;
1629
+ Misc::AssignString(str, function_name);
1630
+
1631
+ functions_table.insert( std::make_pair(str, pf) );
1632
+ }
1633
+
1634
+
1635
+
1636
+ /*!
1637
+ inserting a function to the variables' table
1638
+ (this function returns value of variable)
1639
+
1640
+ variable_name - name of the function
1641
+ pf - pointer to the function
1642
+ */
1643
+ void InsertVariableToTable(const char * variable_name, pfunction_var pf)
1644
+ {
1645
+ std::string str;
1646
+ Misc::AssignString(str, variable_name);
1647
+
1648
+ variables_table.insert( std::make_pair(str, pf) );
1649
+ }
1650
+
1651
+
1652
+ /*!
1653
+ this method creates the table of functions
1654
+ */
1655
+ void CreateFunctionsTable()
1656
+ {
1657
+ InsertFunctionToTable("gamma", &Parser<ValueType>::Gamma);
1658
+ InsertFunctionToTable("factorial", &Parser<ValueType>::Factorial);
1659
+ InsertFunctionToTable("abs", &Parser<ValueType>::Abs);
1660
+ InsertFunctionToTable("sin", &Parser<ValueType>::Sin);
1661
+ InsertFunctionToTable("cos", &Parser<ValueType>::Cos);
1662
+ InsertFunctionToTable("tan", &Parser<ValueType>::Tan);
1663
+ InsertFunctionToTable("tg", &Parser<ValueType>::Tan);
1664
+ InsertFunctionToTable("cot", &Parser<ValueType>::Cot);
1665
+ InsertFunctionToTable("ctg", &Parser<ValueType>::Cot);
1666
+ InsertFunctionToTable("int", &Parser<ValueType>::Int);
1667
+ InsertFunctionToTable("round", &Parser<ValueType>::Round);
1668
+ InsertFunctionToTable("ln", &Parser<ValueType>::Ln);
1669
+ InsertFunctionToTable("log", &Parser<ValueType>::Log);
1670
+ InsertFunctionToTable("exp", &Parser<ValueType>::Exp);
1671
+ InsertFunctionToTable("max", &Parser<ValueType>::Max);
1672
+ InsertFunctionToTable("min", &Parser<ValueType>::Min);
1673
+ InsertFunctionToTable("asin", &Parser<ValueType>::ASin);
1674
+ InsertFunctionToTable("acos", &Parser<ValueType>::ACos);
1675
+ InsertFunctionToTable("atan", &Parser<ValueType>::ATan);
1676
+ InsertFunctionToTable("atg", &Parser<ValueType>::ATan);
1677
+ InsertFunctionToTable("acot", &Parser<ValueType>::ACot);
1678
+ InsertFunctionToTable("actg", &Parser<ValueType>::ACot);
1679
+ InsertFunctionToTable("sgn", &Parser<ValueType>::Sgn);
1680
+ InsertFunctionToTable("mod", &Parser<ValueType>::Mod);
1681
+ InsertFunctionToTable("if", &Parser<ValueType>::If);
1682
+ InsertFunctionToTable("or", &Parser<ValueType>::Or);
1683
+ InsertFunctionToTable("and", &Parser<ValueType>::And);
1684
+ InsertFunctionToTable("not", &Parser<ValueType>::Not);
1685
+ InsertFunctionToTable("degtorad", &Parser<ValueType>::DegToRad);
1686
+ InsertFunctionToTable("radtodeg", &Parser<ValueType>::RadToDeg);
1687
+ InsertFunctionToTable("degtodeg", &Parser<ValueType>::DegToDeg);
1688
+ InsertFunctionToTable("gradtorad", &Parser<ValueType>::GradToRad);
1689
+ InsertFunctionToTable("radtograd", &Parser<ValueType>::RadToGrad);
1690
+ InsertFunctionToTable("degtograd", &Parser<ValueType>::DegToGrad);
1691
+ InsertFunctionToTable("gradtodeg", &Parser<ValueType>::GradToDeg);
1692
+ InsertFunctionToTable("ceil", &Parser<ValueType>::Ceil);
1693
+ InsertFunctionToTable("floor", &Parser<ValueType>::Floor);
1694
+ InsertFunctionToTable("sqrt", &Parser<ValueType>::Sqrt);
1695
+ InsertFunctionToTable("sinh", &Parser<ValueType>::Sinh);
1696
+ InsertFunctionToTable("cosh", &Parser<ValueType>::Cosh);
1697
+ InsertFunctionToTable("tanh", &Parser<ValueType>::Tanh);
1698
+ InsertFunctionToTable("tgh", &Parser<ValueType>::Tanh);
1699
+ InsertFunctionToTable("coth", &Parser<ValueType>::Coth);
1700
+ InsertFunctionToTable("ctgh", &Parser<ValueType>::Coth);
1701
+ InsertFunctionToTable("root", &Parser<ValueType>::Root);
1702
+ InsertFunctionToTable("asinh", &Parser<ValueType>::ASinh);
1703
+ InsertFunctionToTable("acosh", &Parser<ValueType>::ACosh);
1704
+ InsertFunctionToTable("atanh", &Parser<ValueType>::ATanh);
1705
+ InsertFunctionToTable("atgh", &Parser<ValueType>::ATanh);
1706
+ InsertFunctionToTable("acoth", &Parser<ValueType>::ACoth);
1707
+ InsertFunctionToTable("actgh", &Parser<ValueType>::ACoth);
1708
+ InsertFunctionToTable("bitand", &Parser<ValueType>::BitAnd);
1709
+ InsertFunctionToTable("bitor", &Parser<ValueType>::BitOr);
1710
+ InsertFunctionToTable("bitxor", &Parser<ValueType>::BitXor);
1711
+ InsertFunctionToTable("band", &Parser<ValueType>::BitAnd);
1712
+ InsertFunctionToTable("bor", &Parser<ValueType>::BitOr);
1713
+ InsertFunctionToTable("bxor", &Parser<ValueType>::BitXor);
1714
+ InsertFunctionToTable("sum", &Parser<ValueType>::Sum);
1715
+ InsertFunctionToTable("avg", &Parser<ValueType>::Avg);
1716
+ InsertFunctionToTable("frac", &Parser<ValueType>::Frac);
1717
+ }
1718
+
1719
+
1720
+ /*!
1721
+ this method creates the table of variables
1722
+ */
1723
+ void CreateVariablesTable()
1724
+ {
1725
+ InsertVariableToTable("pi", &ValueType::SetPi);
1726
+ InsertVariableToTable("e", &ValueType::SetE);
1727
+ }
1728
+
1729
+
1730
+ /*!
1731
+ converting from a big letter to a small one
1732
+ */
1733
+ int ToLowerCase(int c)
1734
+ {
1735
+ if( c>='A' && c<='Z' )
1736
+ return c - 'A' + 'a';
1737
+
1738
+ return c;
1739
+ }
1740
+
1741
+
1742
+
1743
+
1744
+ /*!
1745
+ return true if c is a valid function or variable name character
1746
+ */
1747
+ virtual bool IsValidNameCharacter(int c)
1748
+ {
1749
+ return( (c>='a' && c<='z') ||
1750
+ (c>='A' && c<='Z') ||
1751
+ (c>='0' && c<='9') ||
1752
+ c=='_' );
1753
+ }
1754
+
1755
+
1756
+ /*!
1757
+ this method read the name of a variable or a function
1758
+ 'result' will be the name of a variable or a function
1759
+ */
1760
+ virtual void ReadName(std::string & result)
1761
+ {
1762
+ result.erase();
1763
+
1764
+ while( IsValidNameCharacter(*pstring) )
1765
+ {
1766
+ result += *pstring;
1767
+ pstring += 1;
1768
+ }
1769
+ }
1770
+
1771
+
1772
+
1773
+ /*!
1774
+ we're reading the name of a variable or a function
1775
+ if is there a function we'll return 'true'
1776
+ also we return true when we read the name of a variable with an assignment operator
1777
+ */
1778
+ virtual bool ReadVariableOrFunction(bool was_sign, bool was_minus_sign)
1779
+ {
1780
+ std::string name;
1781
+ bool read_next_token = false;
1782
+
1783
+ ReadName(name);
1784
+ SkipWhiteCharacters();
1785
+
1786
+ if( *pstring == '(' )
1787
+ {
1788
+ /*
1789
+ if there's a character '(' that means this name is a name of a function
1790
+ */
1791
+ ++pstring;
1792
+ AddToStack(Item::first_bracket, name, true, was_minus_sign);
1793
+ read_next_token = true;
1794
+ }
1795
+ else
1796
+ if( *pstring == '=' && *(pstring+1) != '=' )
1797
+ {
1798
+ /*
1799
+ if there's a character '=' that means this name is a name of a variable with an assigment operator
1800
+ */
1801
+ ++pstring;
1802
+
1803
+ if( !was_sign )
1804
+ {
1805
+ AddToStack(Item::variable, name, false, false);
1806
+ AddToStack(MatOperator::assign);
1807
+ read_next_token = true;
1808
+ }
1809
+ else
1810
+ {
1811
+ // something like: '-a = 10' or '+a = 10'
1812
+ Error( err_assignment_requires_variable );
1813
+ }
1814
+ }
1815
+ else
1816
+ {
1817
+ /*
1818
+ we've read the name of a variable and we're getting its value now
1819
+ */
1820
+ ValueType value = GetValueOfVariable(name);
1821
+
1822
+ if( was_minus_sign )
1823
+ value.ChangeSign();
1824
+
1825
+ AddToStack(value);
1826
+ }
1827
+
1828
+ return read_next_token;
1829
+ }
1830
+
1831
+
1832
+
1833
+
1834
+
1835
+
1836
+ /*!
1837
+ we're reading a numerical value directly from the string
1838
+ */
1839
+ virtual void ReadValue(int reading_base, bool change_sign)
1840
+ {
1841
+ const char * after_value_string;
1842
+ bool value_read;
1843
+ Conv conv;
1844
+
1845
+ conv.base = reading_base;
1846
+ conv.comma = comma;
1847
+ conv.comma2 = comma2;
1848
+ conv.group = group;
1849
+
1850
+ ValueType value;
1851
+ uint carry = value.FromString(pstring, conv, &after_value_string, &value_read);
1852
+ pstring = after_value_string;
1853
+
1854
+ if( carry )
1855
+ Error( err_overflow );
1856
+
1857
+ if( !value_read )
1858
+ Error( err_unknown_character );
1859
+
1860
+ if( change_sign )
1861
+ {
1862
+ value.ChangeSign();
1863
+ }
1864
+
1865
+ AddToStack(value);
1866
+ }
1867
+
1868
+
1869
+ /*!
1870
+ this method returns true if 'character' is a proper first digit for the value (or a comma -- can be first too)
1871
+ */
1872
+ virtual bool ValueStarts(int character, int character_base)
1873
+ {
1874
+ if( character == comma )
1875
+ return true;
1876
+
1877
+ if( comma2!=0 && character==comma2 )
1878
+ return true;
1879
+
1880
+ if( Misc::CharToDigit(character, character_base) != -1 )
1881
+ return true;
1882
+
1883
+ return false;
1884
+ }
1885
+
1886
+
1887
+ virtual void CheckSignBeforeExpression(bool & was_sign, bool & was_minus_sign)
1888
+ {
1889
+ was_sign = false;
1890
+ was_minus_sign = false;
1891
+
1892
+ SkipWhiteCharacters();
1893
+
1894
+ if( *pstring == '-' )
1895
+ {
1896
+ was_sign = true;
1897
+ was_minus_sign = true;
1898
+ ++pstring;
1899
+ }
1900
+
1901
+ if( *pstring == '+' )
1902
+ {
1903
+ was_sign = true;
1904
+ ++pstring;
1905
+ }
1906
+ }
1907
+
1908
+
1909
+
1910
+ virtual bool ReadToken()
1911
+ {
1912
+ bool was_sign, was_minus_sign;
1913
+ bool read_next_token = false;
1914
+
1915
+ CheckSignBeforeExpression(was_sign, was_minus_sign);
1916
+ SkipWhiteCharacters();
1917
+
1918
+ int character = ToLowerCase( *pstring );
1919
+
1920
+ if( character == 0 )
1921
+ {
1922
+ if( was_sign )
1923
+ {
1924
+ Error( err_unexpected_end ); // at the end of the string a character like '-' or '+' has left
1925
+ }
1926
+ }
1927
+ else
1928
+ if( character == '(' )
1929
+ {
1930
+ AddToStack(Item::first_bracket, was_minus_sign); // we've got a normal bracket (not a function)
1931
+ ++pstring;
1932
+ read_next_token = true;
1933
+ }
1934
+ else
1935
+ if( character == '#' )
1936
+ {
1937
+ ++pstring;
1938
+
1939
+ // after '#' character must be directly value (we do not allow '-' or '+' or white characters)
1940
+ if( ValueStarts(*pstring, 16) )
1941
+ ReadValue(16, was_minus_sign);
1942
+ else
1943
+ Error( err_unknown_character );
1944
+ }
1945
+ else
1946
+ if( character == '&' )
1947
+ {
1948
+ ++pstring;
1949
+
1950
+ // after '&' character must be directly value (we do not allow '-' or '+' or white characters)
1951
+ if( ValueStarts(*pstring, 2) )
1952
+ ReadValue(2, was_minus_sign);
1953
+ else
1954
+ Error( err_unknown_character );
1955
+ }
1956
+ else
1957
+ if( ValueStarts(character, base) )
1958
+ {
1959
+ ReadValue(base, was_minus_sign);
1960
+ }
1961
+ else
1962
+ if( character>='a' && character<='z' )
1963
+ {
1964
+ read_next_token = ReadVariableOrFunction(was_sign, was_minus_sign);
1965
+ }
1966
+ else
1967
+ {
1968
+ Error( err_unknown_character );
1969
+ }
1970
+
1971
+ return read_next_token;
1972
+ }
1973
+
1974
+
1975
+ /*!
1976
+ we're reading the item
1977
+
1978
+ return values:
1979
+ 0 - all ok, the item is successfully read
1980
+ 1 - the end of the string (the item is not read)
1981
+ 2 - the final bracket ')'
1982
+ */
1983
+ virtual void ReadTokens()
1984
+ {
1985
+ bool continue_reading;
1986
+
1987
+ do
1988
+ {
1989
+ continue_reading = false;
1990
+ SkipWhiteCharacters();
1991
+
1992
+ if( *pstring )
1993
+ continue_reading = ReadToken();
1994
+
1995
+ } while( continue_reading );
1996
+ }
1997
+
1998
+
1999
+ void InsertOperatorToTable(const char * name, typename MatOperator::Type type)
2000
+ {
2001
+ operators_table.insert( std::make_pair(std::string(name), type) );
2002
+ }
2003
+
2004
+
2005
+ /*!
2006
+ this method creates the table of operators
2007
+ */
2008
+ void CreateMathematicalOperatorsTable()
2009
+ {
2010
+ InsertOperatorToTable("||", MatOperator::lor);
2011
+ InsertOperatorToTable("&&", MatOperator::land);
2012
+ InsertOperatorToTable("!=", MatOperator::neq);
2013
+ InsertOperatorToTable("==", MatOperator::eq);
2014
+ InsertOperatorToTable(">=", MatOperator::get);
2015
+ InsertOperatorToTable("<=", MatOperator::let);
2016
+ InsertOperatorToTable(">", MatOperator::gt);
2017
+ InsertOperatorToTable("<", MatOperator::lt);
2018
+ InsertOperatorToTable("-", MatOperator::sub);
2019
+ InsertOperatorToTable("+", MatOperator::add);
2020
+ InsertOperatorToTable("/", MatOperator::div);
2021
+ InsertOperatorToTable("*", MatOperator::mul);
2022
+ InsertOperatorToTable("^", MatOperator::pow);
2023
+ InsertOperatorToTable("=", MatOperator::assign);
2024
+ }
2025
+
2026
+
2027
+ /*!
2028
+ returns true if 'short_str' is the substring of long_str
2029
+
2030
+ e.g.
2031
+ true when short_str="te" and long_str="test"
2032
+ */
2033
+ virtual bool IsSubstring(const std::string & short_str, const std::string & long_str)
2034
+ {
2035
+ if( short_str.length() > long_str.length() )
2036
+ return false;
2037
+
2038
+ for(typename std::string::size_type i=0 ; i<short_str.length() ; ++i)
2039
+ if( short_str[i] != long_str[i] )
2040
+ return false;
2041
+
2042
+ return true;
2043
+ }
2044
+
2045
+
2046
+ /*!
2047
+ this method reads a mathematical (or logical) operator
2048
+ */
2049
+ void ReadMathematicalOperator()
2050
+ {
2051
+ std::string oper;
2052
+ typename OperatorsTable::iterator iter_old, iter_new;
2053
+
2054
+ iter_old = operators_table.end();
2055
+
2056
+ for( ; true ; ++pstring )
2057
+ {
2058
+ oper += *pstring;
2059
+ iter_new = operators_table.lower_bound(oper);
2060
+
2061
+ if( iter_new == operators_table.end() || !IsSubstring(oper, iter_new->first) )
2062
+ {
2063
+ oper.erase(oper.begin() + oper.size() - 1); // we've got minimum one element
2064
+
2065
+ if( iter_old != operators_table.end() && iter_old->first == oper )
2066
+ {
2067
+ AddToStack(iter_old->second);
2068
+ break;
2069
+ }
2070
+
2071
+ Error( err_unknown_operator );
2072
+ }
2073
+
2074
+ iter_old = iter_new;
2075
+ }
2076
+ }
2077
+
2078
+
2079
+ /*!
2080
+ this method makes a calculation for the percentage operator
2081
+ e.g.
2082
+ 1000-50% = 1000-(1000*0,5) = 500
2083
+ */
2084
+ void OperatorPercentage()
2085
+ {
2086
+ if( stack_index < 3 ||
2087
+ stack[stack_index-1].type != Item::numerical_value ||
2088
+ stack[stack_index-2].type != Item::mat_operator ||
2089
+ stack[stack_index-3].type != Item::numerical_value )
2090
+ {
2091
+ Error( err_percent_from );
2092
+ }
2093
+ else
2094
+ {
2095
+ uint c = 0;
2096
+ c += stack[stack_index-1].value.Div(100);
2097
+ c += stack[stack_index-1].value.Mul(stack[stack_index-3].value);
2098
+
2099
+ if( c )
2100
+ {
2101
+ Error( err_overflow );
2102
+ }
2103
+ }
2104
+ }
2105
+
2106
+
2107
+ /*!
2108
+ this method reads a mathematic operators
2109
+ or the final bracket or the semicolon operator
2110
+
2111
+ return values:
2112
+ true - if next operator should be read
2113
+ */
2114
+ virtual bool ReadOperator()
2115
+ {
2116
+ bool read_next_operator = false;
2117
+
2118
+ if( *pstring == '%' )
2119
+ {
2120
+ OperatorPercentage();
2121
+ ++pstring;
2122
+ SkipWhiteCharacters();
2123
+ // now we can read another operator
2124
+ // we do not return read_next_operator=true here because
2125
+ // we dont want such an expression to be correct: 20-10+20%% (two percentage operators next to each other)
2126
+ // you must use brackets to calculate it: 20-(10+20%)%
2127
+ }
2128
+
2129
+ if( *pstring == 0 )
2130
+ {
2131
+ // the string is finished (after reading % operator)
2132
+ }
2133
+ else
2134
+ if( *pstring == ')' )
2135
+ {
2136
+ ++pstring;
2137
+ RollingUpFinalBracket();
2138
+ read_next_operator = true;
2139
+ }
2140
+ else
2141
+ if( *pstring == ';' || (param_sep!=0 && *pstring==param_sep) )
2142
+ {
2143
+ RollUPStack();
2144
+ ++pstring;
2145
+ }
2146
+ else
2147
+ if( (*pstring>='a' && *pstring<='z') || (*pstring>='A' && *pstring<='Z') )
2148
+ {
2149
+ // short mul (without any operators)
2150
+ // short mul is available only if the next item is a variable or a function
2151
+ AddToStack(MatOperator::shortmul);
2152
+ }
2153
+ else
2154
+ {
2155
+ ReadMathematicalOperator();
2156
+ }
2157
+
2158
+ return read_next_operator;
2159
+ }
2160
+
2161
+
2162
+
2163
+ /*!
2164
+ this method is reading a operator and if it's a final bracket
2165
+ it's calling RollingUpFinalBracket() and reading an operator again
2166
+ */
2167
+ virtual void ReadOperators()
2168
+ {
2169
+ bool continue_reading;
2170
+
2171
+ do
2172
+ {
2173
+ continue_reading = false;
2174
+ SkipWhiteCharacters();
2175
+
2176
+ if( *pstring )
2177
+ continue_reading = ReadOperator();
2178
+ }
2179
+ while( continue_reading );
2180
+ }
2181
+
2182
+
2183
+
2184
+
2185
+ /*!
2186
+ this method is making the standard mathematic operation like '-' '+' '*' '/' and '^'
2187
+
2188
+ the operation is made between 'value1' and 'value2'
2189
+ the result of this operation is stored in the 'value1'
2190
+ */
2191
+ virtual void MakeStandardMathematicOperation(Item & item1, typename MatOperator::Type mat_operator, const Item & item2)
2192
+ {
2193
+ uint res;
2194
+
2195
+ calculated = true;
2196
+ ValueType & value1 = item1.value;
2197
+ const ValueType & value2 = item2.value;
2198
+
2199
+ switch( mat_operator )
2200
+ {
2201
+ case MatOperator::land:
2202
+ (!value1.IsZero() && !value2.IsZero()) ? value1.SetOne() : value1.SetZero();
2203
+ break;
2204
+
2205
+ case MatOperator::lor:
2206
+ (!value1.IsZero() || !value2.IsZero()) ? value1.SetOne() : value1.SetZero();
2207
+ break;
2208
+
2209
+ case MatOperator::eq:
2210
+ (value1 == value2) ? value1.SetOne() : value1.SetZero();
2211
+ break;
2212
+
2213
+ case MatOperator::neq:
2214
+ (value1 != value2) ? value1.SetOne() : value1.SetZero();
2215
+ break;
2216
+
2217
+ case MatOperator::lt:
2218
+ (value1 < value2) ? value1.SetOne() : value1.SetZero();
2219
+ break;
2220
+
2221
+ case MatOperator::gt:
2222
+ (value1 > value2) ? value1.SetOne() : value1.SetZero();
2223
+ break;
2224
+
2225
+ case MatOperator::let:
2226
+ (value1 <= value2) ? value1.SetOne() : value1.SetZero();
2227
+ break;
2228
+
2229
+ case MatOperator::get:
2230
+ (value1 >= value2) ? value1.SetOne() : value1.SetZero();
2231
+ break;
2232
+
2233
+ case MatOperator::sub:
2234
+ if( value1.Sub(value2) ) Error( err_overflow );
2235
+ break;
2236
+
2237
+ case MatOperator::add:
2238
+ if( value1.Add(value2) ) Error( err_overflow );
2239
+ break;
2240
+
2241
+ case MatOperator::mul:
2242
+ case MatOperator::shortmul:
2243
+ if( value1.Mul(value2) ) Error( err_overflow );
2244
+ break;
2245
+
2246
+ case MatOperator::div:
2247
+ if( value2.IsZero() ) Error( err_division_by_zero );
2248
+ if( value1.Div(value2) ) Error( err_overflow );
2249
+ break;
2250
+
2251
+ case MatOperator::pow:
2252
+ res = value1.Pow( value2 );
2253
+
2254
+ if( res == 1 ) Error( err_overflow );
2255
+ else
2256
+ if( res == 2 ) Error( err_improper_argument );
2257
+
2258
+ break;
2259
+
2260
+ default:
2261
+ /*
2262
+ on the stack left an unknown operator but we had to recognize its before
2263
+ that means there's an error in our algorithm
2264
+ */
2265
+ Error( err_internal_error );
2266
+ }
2267
+ }
2268
+
2269
+
2270
+
2271
+
2272
+ /*!
2273
+ this method is trying to roll the stack up with the operator's priority
2274
+
2275
+ for example if there are:
2276
+ "1 - 2 +"
2277
+ we can subtract "1-2" and the result store on the place where is '1' and copy the last
2278
+ operator '+', that means there'll be '-1+' on our stack
2279
+
2280
+ but if there are:
2281
+ "1 - 2 *"
2282
+ we can't roll the stack up because the operator '*' has greater priority than '-'
2283
+ */
2284
+ void RollUpStackWithOperatorsPriority()
2285
+ {
2286
+ while( stack_index>=4 &&
2287
+ (stack[stack_index-4].type == Item::numerical_value || stack[stack_index-4].type == Item::variable) &&
2288
+ stack[stack_index-3].type == Item::mat_operator &&
2289
+ stack[stack_index-2].type == Item::numerical_value &&
2290
+ stack[stack_index-1].type == Item::mat_operator &&
2291
+ (
2292
+ (
2293
+ // the first operator has greater priority
2294
+ stack[stack_index-3].moperator.GetPriority() > stack[stack_index-1].moperator.GetPriority()
2295
+ ) ||
2296
+ (
2297
+ // or both operators have the same priority and the first operator is not right associative
2298
+ stack[stack_index-3].moperator.GetPriority() == stack[stack_index-1].moperator.GetPriority() &&
2299
+ stack[stack_index-3].moperator.GetAssoc() == MatOperator::non_right
2300
+ )
2301
+ )
2302
+ )
2303
+ {
2304
+ MakeStandardMathematicOperation(stack[stack_index-4],
2305
+ stack[stack_index-3].moperator.GetType(),
2306
+ stack[stack_index-2]);
2307
+
2308
+
2309
+ /*
2310
+ copying the last operator and setting the stack pointer to the correct value
2311
+ */
2312
+ stack[stack_index-3] = stack[stack_index-1];
2313
+ stack_index -= 2;
2314
+ }
2315
+ }
2316
+
2317
+
2318
+ /*!
2319
+ this method is trying to roll the stack up without testing any operators
2320
+
2321
+ for example if there are:
2322
+ "1 - 2"
2323
+ there'll be "-1" on our stack
2324
+ */
2325
+ void RollUPStack()
2326
+ {
2327
+ while( stack_index >= 3 &&
2328
+ (stack[stack_index-3].type == Item::numerical_value || stack[stack_index-3].type == Item::variable) &&
2329
+ stack[stack_index-2].type == Item::mat_operator &&
2330
+ stack[stack_index-1].type == Item::numerical_value )
2331
+ {
2332
+ MakeStandardMathematicOperation( stack[stack_index-3],
2333
+ stack[stack_index-2].moperator.GetType(),
2334
+ stack[stack_index-1] );
2335
+
2336
+ stack_index -= 2;
2337
+ }
2338
+ }
2339
+
2340
+
2341
+
2342
+ /*!
2343
+ this method calculate how many parameters there are on the stack
2344
+ and the index of the first parameter
2345
+
2346
+ if there are no parameters on the stack this method returns
2347
+ 'size' equals zero and 'index' pointing after the first bracket
2348
+ (on non-existend element)
2349
+ */
2350
+ void HowManyParameters(unsigned int & size, unsigned int & index)
2351
+ {
2352
+ size = 0;
2353
+ index = stack_index;
2354
+
2355
+ for( ; index > 0 && stack[index-1].type != Item::first_bracket ; --index )
2356
+ {
2357
+ if( stack[index-1].type != Item::numerical_value )
2358
+ {
2359
+ /*
2360
+ this element must be 'numerical_value', if not that means
2361
+ there's an error in our algorithm
2362
+ */
2363
+ Error( err_internal_error );
2364
+ }
2365
+
2366
+ ++size;
2367
+ }
2368
+
2369
+ if( index<1 || stack[index-1].type != Item::first_bracket )
2370
+ {
2371
+ /*
2372
+ we haven't put a first bracket on the stack
2373
+ */
2374
+ Error( err_unexpected_final_bracket );
2375
+ }
2376
+ }
2377
+
2378
+
2379
+ /*!
2380
+ this method is being called when the final bracket ')' is being found
2381
+
2382
+ this method's rolling the stack up, counting how many parameters there are
2383
+ on the stack and if there was a function it's calling the function
2384
+ */
2385
+ void RollingUpFinalBracket()
2386
+ {
2387
+ unsigned int amount_of_parameters;
2388
+ unsigned int index;
2389
+
2390
+
2391
+ if( stack_index<1 ||
2392
+ (stack[stack_index-1].type != Item::numerical_value &&
2393
+ stack[stack_index-1].type != Item::first_bracket)
2394
+ )
2395
+ {
2396
+ Error( err_unexpected_final_bracket );
2397
+ return;
2398
+ }
2399
+
2400
+ RollUPStack();
2401
+ HowManyParameters(amount_of_parameters, index);
2402
+
2403
+ // 'index' will be greater than zero
2404
+ // 'amount_of_parameters' can be zero
2405
+
2406
+ if( amount_of_parameters==0 && !stack[index-1].function )
2407
+ Error( err_unexpected_final_bracket );
2408
+
2409
+
2410
+ bool was_sign = stack[index-1].sign;
2411
+
2412
+
2413
+ if( stack[index-1].function )
2414
+ {
2415
+ // the result of a function will be on 'stack[index-1]'
2416
+ // and then at the end we'll set the correct type (numerical value) of this element
2417
+ CallFunction(stack[index-1].function_name, amount_of_parameters, index);
2418
+ }
2419
+ else
2420
+ {
2421
+ /*
2422
+ there was a normal bracket (not a funcion)
2423
+ */
2424
+ if( amount_of_parameters != 1 )
2425
+ Error( err_unexpected_semicolon_operator );
2426
+
2427
+
2428
+ /*
2429
+ in the place where is the bracket we put the result
2430
+ */
2431
+ stack[index-1] = stack[index];
2432
+ }
2433
+
2434
+
2435
+ /*
2436
+ if there was a '-' character before the first bracket
2437
+ we change the sign of the expression
2438
+ */
2439
+ stack[index-1].sign = false;
2440
+
2441
+ if( was_sign )
2442
+ stack[index-1].value.ChangeSign();
2443
+
2444
+ stack[index-1].type = Item::numerical_value;
2445
+
2446
+
2447
+ /*
2448
+ the pointer of the stack will be pointing on the next (non-existing now) element
2449
+ */
2450
+ stack_index = index;
2451
+ }
2452
+
2453
+
2454
+
2455
+
2456
+
2457
+ /*!
2458
+ we check wheter there are only numerical value's on the stack
2459
+ */
2460
+ virtual void CheckStackIntegrity()
2461
+ {
2462
+ for(unsigned int i=0 ; i<stack_index; ++i)
2463
+ {
2464
+ if( stack[i].type != Item::numerical_value )
2465
+ {
2466
+ /*
2467
+ on the stack we must only have 'numerical_value'
2468
+ if there is something another that means
2469
+ we probably didn't close any of the 'first' brackets
2470
+ */
2471
+ Error( err_stack_not_clear );
2472
+ }
2473
+ }
2474
+ }
2475
+
2476
+
2477
+
2478
+ /*!
2479
+ the main loop of parsing
2480
+ */
2481
+ virtual void Parse()
2482
+ {
2483
+ while( *pstring )
2484
+ {
2485
+ const char * old_pstring = pstring;
2486
+
2487
+ if( pstop_calculating && pstop_calculating->WasStopSignal() )
2488
+ Error( err_interrupt );
2489
+
2490
+ ReadTokens();
2491
+ ReadOperators();
2492
+ RollUpStackWithOperatorsPriority();
2493
+
2494
+ if( old_pstring == pstring )
2495
+ Error( err_internal_error ); // pstring should be incremented in ReadTokens() or ReadOperators()
2496
+ }
2497
+
2498
+ if( stack_index == 0 )
2499
+ Error( err_nothing_has_read );
2500
+
2501
+ RollUPStack();
2502
+ CheckStackIntegrity();
2503
+ }
2504
+
2505
+
2506
+
2507
+ /*!
2508
+ this method is called at the end of the parsing process
2509
+ */
2510
+ void NormalizeStack()
2511
+ {
2512
+ if( error!=err_ok || stack_index==0 )
2513
+ {
2514
+ stack.clear();
2515
+ return;
2516
+ }
2517
+
2518
+ /*
2519
+ 'stack_index' tell us how many elements there are on the stack,
2520
+ we must resize the stack now because 'stack_index' is using only for parsing
2521
+ and stack has more (or equal) elements than value of 'stack_index'
2522
+ */
2523
+ stack.resize( stack_index );
2524
+ }
2525
+
2526
+
2527
+ public:
2528
+
2529
+
2530
+ /*!
2531
+ the default constructor
2532
+ */
2533
+ Parser(): default_stack_size(100)
2534
+ {
2535
+ pstop_calculating = 0;
2536
+ puser_variables = 0;
2537
+ puser_functions = 0;
2538
+ pfunction_local_variables = 0;
2539
+ base = 10;
2540
+ deg_rad_grad = 1;
2541
+ error = err_ok;
2542
+ group = 0;
2543
+ comma = '.';
2544
+ comma2 = ',';
2545
+ param_sep = 0;
2546
+
2547
+ CreateFunctionsTable();
2548
+ CreateVariablesTable();
2549
+ CreateMathematicalOperatorsTable();
2550
+ }
2551
+
2552
+
2553
+ /*!
2554
+ the assignment operator
2555
+ */
2556
+ Parser<ValueType> & operator=(const Parser<ValueType> & p)
2557
+ {
2558
+ pstop_calculating = p.pstop_calculating;
2559
+ puser_variables = p.puser_variables;
2560
+ puser_functions = p.puser_functions;
2561
+ pfunction_local_variables = 0;
2562
+ base = p.base;
2563
+ deg_rad_grad = p.deg_rad_grad;
2564
+ error = p.error;
2565
+ group = p.group;
2566
+ comma = p.comma;
2567
+ comma2 = p.comma2;
2568
+ param_sep = p.param_sep;
2569
+
2570
+ /*
2571
+ we don't have to call 'CreateFunctionsTable()' etc.
2572
+ we can only copy these tables
2573
+ */
2574
+ functions_table = p.functions_table;
2575
+ variables_table = p.variables_table;
2576
+ operators_table = p.operators_table;
2577
+
2578
+ visited_variables = p.visited_variables;
2579
+ visited_functions = p.visited_functions;
2580
+
2581
+ return *this;
2582
+ }
2583
+
2584
+
2585
+ /*!
2586
+ dctor
2587
+ */
2588
+ virtual ~Parser()
2589
+ {
2590
+ }
2591
+
2592
+
2593
+
2594
+ /*!
2595
+ the copying constructor
2596
+ */
2597
+ Parser(const Parser<ValueType> & p): default_stack_size(p.default_stack_size)
2598
+ {
2599
+ operator=(p);
2600
+ }
2601
+
2602
+
2603
+ /*!
2604
+ the new base of mathematic system
2605
+ default is 10
2606
+ */
2607
+ void SetBase(int b)
2608
+ {
2609
+ if( b>=2 && b<=16 )
2610
+ base = b;
2611
+ }
2612
+
2613
+
2614
+ /*!
2615
+ the unit of angles used in: sin,cos,tan,cot,asin,acos,atan,acot
2616
+ 0 - deg
2617
+ 1 - rad (default)
2618
+ 2 - grad
2619
+ */
2620
+ void SetDegRadGrad(int angle)
2621
+ {
2622
+ if( angle >= 0 && angle <= 2 )
2623
+ deg_rad_grad = angle;
2624
+ }
2625
+
2626
+ /*!
2627
+ this method sets a pointer to the object which tell us whether we should stop
2628
+ calculations
2629
+ */
2630
+ void SetStopObject(const volatile StopCalculating * ps)
2631
+ {
2632
+ pstop_calculating = ps;
2633
+ }
2634
+
2635
+
2636
+ /*!
2637
+ this method sets the new table of user-defined variables
2638
+ if you don't want any other variables just put zero value into the 'puser_variables' variable
2639
+
2640
+ (you can have only one table at the same time)
2641
+ */
2642
+ void SetVariables(const Objects * pv)
2643
+ {
2644
+ puser_variables = pv;
2645
+ }
2646
+
2647
+
2648
+ /*!
2649
+ this method sets the new table of user-defined functions
2650
+ if you don't want any other functions just put zero value into the 'puser_functions' variable
2651
+
2652
+ (you can have only one table at the same time)
2653
+ */
2654
+ void SetFunctions(const Objects * pf)
2655
+ {
2656
+ puser_functions = pf;
2657
+ }
2658
+
2659
+
2660
+ /*!
2661
+ setting the group character
2662
+ default zero (not used)
2663
+ */
2664
+ void SetGroup(int g)
2665
+ {
2666
+ group = g;
2667
+ }
2668
+
2669
+
2670
+ /*!
2671
+ setting the main comma operator and the additional comma operator
2672
+ the additional operator can be zero (which means it is not used)
2673
+ default are: '.' and ','
2674
+ */
2675
+ void SetComma(int c, int c2 = 0)
2676
+ {
2677
+ comma = c;
2678
+ comma2 = c2;
2679
+ }
2680
+
2681
+
2682
+ /*!
2683
+ setting an additional character which is used as a parameters separator
2684
+ the main parameters separator is a semicolon (is used always)
2685
+
2686
+ this character is used also as a global separator
2687
+ */
2688
+ void SetParamSep(int s)
2689
+ {
2690
+ param_sep = s;
2691
+ }
2692
+
2693
+
2694
+ /*!
2695
+ the main method using for parsing string
2696
+ */
2697
+ ErrorCode Parse(const char * str)
2698
+ {
2699
+ stack_index = 0;
2700
+ pstring = str;
2701
+ error = err_ok;
2702
+ calculated = false;
2703
+
2704
+ try
2705
+ {
2706
+ stack.resize(default_stack_size);
2707
+ Parse();
2708
+ }
2709
+ catch(ErrorCode c)
2710
+ {
2711
+ error = c;
2712
+ calculated = false;
2713
+ }
2714
+
2715
+ NormalizeStack();
2716
+
2717
+ return error;
2718
+ }
2719
+
2720
+
2721
+ /*!
2722
+ the main method using for parsing string
2723
+ */
2724
+ ErrorCode Parse(const std::string & str)
2725
+ {
2726
+ return Parse(str.c_str());
2727
+ }
2728
+
2729
+
2730
+ #ifndef TTMATH_DONT_USE_WCHAR
2731
+
2732
+ /*!
2733
+ the main method using for parsing string
2734
+ */
2735
+ ErrorCode Parse(const wchar_t * str)
2736
+ {
2737
+ Misc::AssignString(wide_to_ansi, str);
2738
+
2739
+ return Parse(wide_to_ansi.c_str());
2740
+
2741
+ // !! wide_to_ansi clearing can be added here
2742
+ }
2743
+
2744
+
2745
+ /*!
2746
+ the main method using for parsing string
2747
+ */
2748
+ ErrorCode Parse(const std::wstring & str)
2749
+ {
2750
+ return Parse(str.c_str());
2751
+ }
2752
+
2753
+ #endif
2754
+
2755
+
2756
+ /*!
2757
+ this method returns true is something was calculated
2758
+ (at least one mathematical operator was used or a function or variable)
2759
+ e.g. true if the string to Parse() looked like this:
2760
+ "1+1"
2761
+ "2*3"
2762
+ "sin(5)"
2763
+
2764
+ if the string was e.g. "678" the result is false
2765
+ */
2766
+ bool Calculated()
2767
+ {
2768
+ return calculated;
2769
+ }
2770
+
2771
+
2772
+ /*!
2773
+ initializing coefficients used when calculating the gamma (or factorial) function
2774
+ this speed up the next calculations
2775
+ you don't have to call this method explicitly
2776
+ these coefficients will be calculated when needed
2777
+ */
2778
+ void InitCGamma()
2779
+ {
2780
+ cgamma.InitAll();
2781
+ }
2782
+
2783
+
2784
+ };
2785
+
2786
+
2787
+
2788
+ } // namespace
2789
+
2790
+
2791
+ #endif