nerdamer 1.1.13 → 2.0.0-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (387) hide show
  1. package/BREAKING_CHANGES.md +244 -5
  2. package/LICENSE.md +184 -0
  3. package/README.md +232 -318
  4. package/dist/bundle.js +2 -0
  5. package/dist/bundle.js.LICENSE.txt +7 -0
  6. package/dist/parser.js +2 -0
  7. package/dist/parser.js.LICENSE.txt +7 -0
  8. package/docs-data/parser-functions.json +2248 -0
  9. package/index.d.ts +10 -426
  10. package/output/algebra/adapters.d.ts +3 -0
  11. package/output/algebra/adapters.js +11 -0
  12. package/output/algebra/algorithms/arith.d.ts +84 -0
  13. package/output/algebra/algorithms/arith.js +324 -0
  14. package/output/algebra/algorithms/groebnerBase.d.ts +161 -0
  15. package/output/algebra/algorithms/groebnerBase.js +929 -0
  16. package/output/algebra/dispatch.d.ts +1 -0
  17. package/output/algebra/dispatch.js +25 -0
  18. package/output/algebra/factor/factor.d.ts +77 -0
  19. package/output/algebra/factor/factor.js +245 -0
  20. package/output/algebra/gcd/gcd.d.ts +30 -0
  21. package/output/algebra/gcd/gcd.js +95 -0
  22. package/output/algebra/groebner.d.ts +21 -0
  23. package/output/algebra/groebner.js +36 -0
  24. package/output/algebra/partfrac.d.ts +19 -0
  25. package/output/algebra/partfrac.js +365 -0
  26. package/output/algebra/polynomial/ModularSparsePolynomial.d.ts +131 -0
  27. package/output/algebra/polynomial/ModularSparsePolynomial.js +378 -0
  28. package/output/algebra/polynomial/ModularSparsePolynomialFactor.d.ts +40 -0
  29. package/output/algebra/polynomial/ModularSparsePolynomialFactor.js +661 -0
  30. package/output/algebra/polynomial/SparsePolynomialFactor.d.ts +64 -0
  31. package/output/algebra/polynomial/SparsePolynomialFactor.js +492 -0
  32. package/output/algebra/polynomial/SparsePolynomialGcd.d.ts +29 -0
  33. package/output/algebra/polynomial/SparsePolynomialGcd.js +259 -0
  34. package/output/algebra/polynomial/SparsePolynomialMultivariateFactor.d.ts +82 -0
  35. package/output/algebra/polynomial/SparsePolynomialMultivariateFactor.js +604 -0
  36. package/output/algebra/polynomial/modularGcd.d.ts +40 -0
  37. package/output/algebra/polynomial/modularGcd.js +365 -0
  38. package/output/algebra/polynomialize.d.ts +20 -0
  39. package/output/algebra/polynomialize.js +26 -0
  40. package/output/algebra/simplify/complexsimp.d.ts +7 -0
  41. package/output/algebra/simplify/complexsimp.js +24 -0
  42. package/output/algebra/simplify/factorCommon.d.ts +13 -0
  43. package/output/algebra/simplify/factorCommon.js +136 -0
  44. package/output/algebra/simplify/funcsimp.d.ts +26 -0
  45. package/output/algebra/simplify/funcsimp.js +633 -0
  46. package/output/algebra/simplify/invtrigrewrite.d.ts +10 -0
  47. package/output/algebra/simplify/invtrigrewrite.js +96 -0
  48. package/output/algebra/simplify/ratsimp.d.ts +21 -0
  49. package/output/algebra/simplify/ratsimp.js +140 -0
  50. package/output/algebra/simplify/simplify.d.ts +25 -0
  51. package/output/algebra/simplify/simplify.js +237 -0
  52. package/output/algebra/simplify/trigreduce.d.ts +38 -0
  53. package/output/algebra/simplify/trigreduce.js +424 -0
  54. package/output/algebra/simplify/trigrewrite.d.ts +17 -0
  55. package/output/algebra/simplify/trigrewrite.js +156 -0
  56. package/output/algebra/simplify/trigsimp.d.ts +11 -0
  57. package/output/algebra/simplify/trigsimp.js +369 -0
  58. package/output/algebra/simplify/utils.d.ts +32 -0
  59. package/output/algebra/simplify/utils.js +56 -0
  60. package/output/algebra/utils.d.ts +32 -0
  61. package/output/algebra/utils.js +48 -0
  62. package/output/api/advanced.d.ts +8 -0
  63. package/output/api/advanced.js +18 -0
  64. package/output/api/algebra.d.ts +17 -0
  65. package/output/api/algebra.js +35 -0
  66. package/output/api/assumptions.d.ts +4 -0
  67. package/output/api/assumptions.js +11 -0
  68. package/output/api/calculus.d.ts +10 -0
  69. package/output/api/calculus.js +22 -0
  70. package/output/api/core.d.ts +17 -0
  71. package/output/api/core.js +41 -0
  72. package/output/api/debug.d.ts +16 -0
  73. package/output/api/debug.js +23 -0
  74. package/output/api/languages/deu.d.ts +3 -0
  75. package/output/api/languages/deu.js +266 -0
  76. package/output/api/languages/fra.d.ts +3 -0
  77. package/output/api/languages/fra.js +266 -0
  78. package/output/api/languages/ita.d.ts +3 -0
  79. package/output/api/languages/ita.js +266 -0
  80. package/output/api/languages/nld.d.ts +3 -0
  81. package/output/api/languages/nld.js +266 -0
  82. package/output/api/languages/por.d.ts +3 -0
  83. package/output/api/languages/por.js +266 -0
  84. package/output/api/languages/spa.d.ts +3 -0
  85. package/output/api/languages/spa.js +266 -0
  86. package/output/api/parser.d.ts +93 -0
  87. package/output/api/parser.js +18 -0
  88. package/output/api/solve.d.ts +10 -0
  89. package/output/api/solve.js +17 -0
  90. package/output/api/structures.d.ts +10 -0
  91. package/output/api/structures.js +23 -0
  92. package/output/calculus/adapters.d.ts +8 -0
  93. package/output/calculus/adapters.js +41 -0
  94. package/output/calculus/derivative/diff.d.ts +30 -0
  95. package/output/calculus/derivative/diff.js +241 -0
  96. package/output/calculus/dispatch.d.ts +1 -0
  97. package/output/calculus/dispatch.js +25 -0
  98. package/output/calculus/fresnel.d.ts +16 -0
  99. package/output/calculus/fresnel.js +39 -0
  100. package/output/calculus/integrate/byParts.d.ts +18 -0
  101. package/output/calculus/integrate/byParts.js +339 -0
  102. package/output/calculus/integrate/bySubstitution.d.ts +135 -0
  103. package/output/calculus/integrate/bySubstitution.js +411 -0
  104. package/output/calculus/integrate/integrate.d.ts +38 -0
  105. package/output/calculus/integrate/integrate.js +652 -0
  106. package/output/calculus/integrate/integrationTable.d.ts +2 -0
  107. package/output/calculus/integrate/integrationTable.js +914 -0
  108. package/output/calculus/integrate/utils.d.ts +28 -0
  109. package/output/calculus/integrate/utils.js +96 -0
  110. package/output/calculus/laplace/ilaplace.d.ts +31 -0
  111. package/output/calculus/laplace/ilaplace.js +192 -0
  112. package/output/calculus/laplace/ilaplaceTable.d.ts +2 -0
  113. package/output/calculus/laplace/ilaplaceTable.js +200 -0
  114. package/output/calculus/laplace/laplace.d.ts +22 -0
  115. package/output/calculus/laplace/laplace.js +109 -0
  116. package/output/calculus/laplace/laplaceTable.d.ts +2 -0
  117. package/output/calculus/laplace/laplaceTable.js +187 -0
  118. package/output/calculus/limit/limit.d.ts +35 -0
  119. package/output/calculus/limit/limit.js +1183 -0
  120. package/output/calculus/limit/limitsTable.d.ts +2 -0
  121. package/output/calculus/limit/limitsTable.js +7 -0
  122. package/output/core/Settings.d.ts +32 -0
  123. package/output/core/Settings.js +68 -0
  124. package/output/core/classes/assumption/Assumption.d.ts +218 -0
  125. package/output/core/classes/assumption/Assumption.js +609 -0
  126. package/output/core/classes/assumption/assertiveFunctions.d.ts +6 -0
  127. package/output/core/classes/assumption/assertiveFunctions.js +64 -0
  128. package/output/core/classes/assumption/assume.d.ts +90 -0
  129. package/output/core/classes/assumption/assume.js +145 -0
  130. package/output/core/classes/assumption/dispatch.d.ts +1 -0
  131. package/output/core/classes/assumption/dispatch.js +11 -0
  132. package/output/core/classes/collection/Collection.d.ts +107 -0
  133. package/output/core/classes/collection/Collection.js +240 -0
  134. package/output/core/classes/complex/Complex.d.ts +109 -0
  135. package/output/core/classes/complex/Complex.js +153 -0
  136. package/output/core/classes/decimalSet/DecimalSet.d.ts +226 -0
  137. package/output/core/classes/decimalSet/DecimalSet.js +454 -0
  138. package/output/core/classes/dictionary/Dictionary.d.ts +102 -0
  139. package/output/core/classes/dictionary/Dictionary.js +216 -0
  140. package/output/core/classes/equation/Equation.d.ts +256 -0
  141. package/output/core/classes/equation/Equation.js +350 -0
  142. package/output/core/classes/expression/CoeffObject.d.ts +100 -0
  143. package/output/core/classes/expression/CoeffObject.js +197 -0
  144. package/output/core/classes/expression/Expression.d.ts +1691 -0
  145. package/output/core/classes/expression/Expression.js +2381 -0
  146. package/output/core/classes/expression/analysis.d.ts +25 -0
  147. package/output/core/classes/expression/analysis.js +218 -0
  148. package/output/core/classes/expression/collect.d.ts +9 -0
  149. package/output/core/classes/expression/collect.js +49 -0
  150. package/output/core/classes/expression/format.d.ts +54 -0
  151. package/output/core/classes/expression/format.js +340 -0
  152. package/output/core/classes/expression/products.d.ts +23 -0
  153. package/output/core/classes/expression/products.js +115 -0
  154. package/output/core/classes/expression/shortcuts.d.ts +35 -0
  155. package/output/core/classes/expression/shortcuts.js +129 -0
  156. package/output/core/classes/expression/traversal.d.ts +31 -0
  157. package/output/core/classes/expression/traversal.js +216 -0
  158. package/output/core/classes/expression/trig.d.ts +25 -0
  159. package/output/core/classes/expression/trig.js +40 -0
  160. package/output/core/classes/expression/utils.d.ts +61 -0
  161. package/output/core/classes/expression/utils.js +235 -0
  162. package/output/core/classes/lookupTable/LookupTable.d.ts +12 -0
  163. package/output/core/classes/lookupTable/LookupTable.js +55 -0
  164. package/output/core/classes/matrix/Matrix.d.ts +227 -0
  165. package/output/core/classes/matrix/Matrix.js +901 -0
  166. package/output/core/classes/matrix/Sylvester.d.ts +11 -0
  167. package/output/core/classes/matrix/Sylvester.js +54 -0
  168. package/output/core/classes/matrix/dispatch.d.ts +1 -0
  169. package/output/core/classes/matrix/dispatch.js +19 -0
  170. package/output/core/classes/matrix/functions.d.ts +28 -0
  171. package/output/core/classes/matrix/functions.js +57 -0
  172. package/output/core/classes/matrix/utils.d.ts +9 -0
  173. package/output/core/classes/matrix/utils.js +22 -0
  174. package/output/core/classes/parser/Parser.d.ts +493 -0
  175. package/output/core/classes/parser/Parser.js +1863 -0
  176. package/output/core/classes/parser/Token.d.ts +58 -0
  177. package/output/core/classes/parser/Token.js +137 -0
  178. package/output/core/classes/parser/constants.d.ts +162 -0
  179. package/output/core/classes/parser/constants.js +229 -0
  180. package/output/core/classes/parser/controlFlowSignals.d.ts +38 -0
  181. package/output/core/classes/parser/controlFlowSignals.js +60 -0
  182. package/output/core/classes/parser/helpers.d.ts +21 -0
  183. package/output/core/classes/parser/helpers.js +42 -0
  184. package/output/core/classes/parser/operations/add.d.ts +15 -0
  185. package/output/core/classes/parser/operations/add.js +236 -0
  186. package/output/core/classes/parser/operations/comma.d.ts +7 -0
  187. package/output/core/classes/parser/operations/comma.js +11 -0
  188. package/output/core/classes/parser/operations/compare.d.ts +21 -0
  189. package/output/core/classes/parser/operations/compare.js +474 -0
  190. package/output/core/classes/parser/operations/divide.d.ts +2 -0
  191. package/output/core/classes/parser/operations/divide.js +72 -0
  192. package/output/core/classes/parser/operations/functions.d.ts +46 -0
  193. package/output/core/classes/parser/operations/functions.js +438 -0
  194. package/output/core/classes/parser/operations/multiply.d.ts +11 -0
  195. package/output/core/classes/parser/operations/multiply.js +328 -0
  196. package/output/core/classes/parser/operations/power.d.ts +48 -0
  197. package/output/core/classes/parser/operations/power.js +673 -0
  198. package/output/core/classes/parser/operations/subtract.d.ts +3 -0
  199. package/output/core/classes/parser/operations/subtract.js +36 -0
  200. package/output/core/classes/parser/preprocess.d.ts +7 -0
  201. package/output/core/classes/parser/preprocess.js +246 -0
  202. package/output/core/classes/parser/scripting/controlFlow.d.ts +23 -0
  203. package/output/core/classes/parser/scripting/controlFlow.js +279 -0
  204. package/output/core/classes/parser/scripting/deferred.d.ts +4 -0
  205. package/output/core/classes/parser/scripting/deferred.js +65 -0
  206. package/output/core/classes/parser/scripting/dispatch.d.ts +1 -0
  207. package/output/core/classes/parser/scripting/dispatch.js +62 -0
  208. package/output/core/classes/parser/scripting/evaluate.d.ts +23 -0
  209. package/output/core/classes/parser/scripting/evaluate.js +128 -0
  210. package/output/core/classes/parser/scripting/functions.d.ts +14 -0
  211. package/output/core/classes/parser/scripting/functions.js +59 -0
  212. package/output/core/classes/parser/scripting/scope.d.ts +8 -0
  213. package/output/core/classes/parser/scripting/scope.js +132 -0
  214. package/output/core/classes/parser/types.d.ts +130 -0
  215. package/output/core/classes/parser/types.js +2 -0
  216. package/output/core/classes/parser/wrappers/IndexedReference.d.ts +31 -0
  217. package/output/core/classes/parser/wrappers/IndexedReference.js +68 -0
  218. package/output/core/classes/parser/wrappers/KeyValuePair.d.ts +24 -0
  219. package/output/core/classes/parser/wrappers/KeyValuePair.js +51 -0
  220. package/output/core/classes/polynomial/Polynomial.d.ts +504 -0
  221. package/output/core/classes/polynomial/Polynomial.js +1195 -0
  222. package/output/core/classes/polynomial/SparsePolynomial.d.ts +221 -0
  223. package/output/core/classes/polynomial/SparsePolynomial.js +824 -0
  224. package/output/core/classes/polynomial/SparsePolynomialAdapter.d.ts +56 -0
  225. package/output/core/classes/polynomial/SparsePolynomialAdapter.js +241 -0
  226. package/output/core/classes/polynomial/Term.d.ts +222 -0
  227. package/output/core/classes/polynomial/Term.js +430 -0
  228. package/output/core/classes/polynomial/adapters.d.ts +18 -0
  229. package/output/core/classes/polynomial/adapters.js +33 -0
  230. package/output/core/classes/polynomial/dispatch.d.ts +1 -0
  231. package/output/core/classes/polynomial/dispatch.js +14 -0
  232. package/output/core/classes/polynomial/functions.d.ts +77 -0
  233. package/output/core/classes/polynomial/functions.js +189 -0
  234. package/output/core/classes/polynomial/utils.d.ts +62 -0
  235. package/output/core/classes/polynomial/utils.js +207 -0
  236. package/output/core/classes/rational/Rational.d.ts +501 -0
  237. package/output/core/classes/rational/Rational.js +829 -0
  238. package/output/core/classes/seq/SEQ.d.ts +13 -0
  239. package/output/core/classes/seq/SEQ.js +137 -0
  240. package/output/core/classes/valuesSet/ValuesSet.d.ts +187 -0
  241. package/output/core/classes/valuesSet/ValuesSet.js +399 -0
  242. package/output/core/classes/vector/Vector.d.ts +222 -0
  243. package/output/core/classes/vector/Vector.js +501 -0
  244. package/output/core/classes/vector/dispatch.d.ts +1 -0
  245. package/output/core/classes/vector/dispatch.js +11 -0
  246. package/output/core/classes/vector/functions.d.ts +28 -0
  247. package/output/core/classes/vector/functions.js +47 -0
  248. package/output/core/common/classes/MathematicalAggregate.d.ts +53 -0
  249. package/output/core/common/classes/MathematicalAggregate.js +149 -0
  250. package/output/core/common/classes/Scope.d.ts +62 -0
  251. package/output/core/common/classes/Scope.js +122 -0
  252. package/output/core/common/classes/StructuredEntity.d.ts +55 -0
  253. package/output/core/common/classes/StructuredEntity.js +151 -0
  254. package/output/core/common/common.d.ts +62 -0
  255. package/output/core/common/common.js +74 -0
  256. package/output/core/common/functions/functions.d.ts +14 -0
  257. package/output/core/common/functions/functions.js +33 -0
  258. package/output/core/common/functions/structuredEntityUtils.d.ts +27 -0
  259. package/output/core/common/functions/structuredEntityUtils.js +40 -0
  260. package/output/core/converters/BaseConverter.d.ts +97 -0
  261. package/output/core/converters/BaseConverter.js +405 -0
  262. package/output/core/converters/Converter.d.ts +111 -0
  263. package/output/core/converters/Converter.js +806 -0
  264. package/output/core/converters/Pattern.d.ts +71 -0
  265. package/output/core/converters/Pattern.js +302 -0
  266. package/output/core/dispatch.d.ts +52 -0
  267. package/output/core/dispatch.js +26 -0
  268. package/output/core/errors.d.ts +316 -0
  269. package/output/core/errors.js +349 -0
  270. package/output/core/fullFunctions.d.ts +7 -0
  271. package/output/core/fullFunctions.js +31 -0
  272. package/output/core/functions/bigint/bigint.d.ts +133 -0
  273. package/output/core/functions/bigint/bigint.js +444 -0
  274. package/output/core/functions/bigint/primeFactor.d.ts +51 -0
  275. package/output/core/functions/bigint/primeFactor.js +267 -0
  276. package/output/core/functions/bigint/primes.d.ts +1 -0
  277. package/output/core/functions/bigint/primes.js +11 -0
  278. package/output/core/functions/build/definitions.d.ts +12 -0
  279. package/output/core/functions/build/definitions.js +139 -0
  280. package/output/core/functions/build/index.d.ts +32 -0
  281. package/output/core/functions/build/index.js +136 -0
  282. package/output/core/functions/complex.d.ts +90 -0
  283. package/output/core/functions/complex.dispatch.d.ts +1 -0
  284. package/output/core/functions/complex.dispatch.js +16 -0
  285. package/output/core/functions/complex.js +482 -0
  286. package/output/core/functions/decimal.d.ts +24 -0
  287. package/output/core/functions/decimal.js +665 -0
  288. package/output/core/functions/expand/expand.d.ts +42 -0
  289. package/output/core/functions/expand/expand.js +376 -0
  290. package/output/core/functions/fresnelNumeric.d.ts +12 -0
  291. package/output/core/functions/fresnelNumeric.js +123 -0
  292. package/output/core/functions/numeric.d.ts +140 -0
  293. package/output/core/functions/numeric.js +790 -0
  294. package/output/core/functions/rationalNormalization.d.ts +11 -0
  295. package/output/core/functions/rationalNormalization.js +117 -0
  296. package/output/core/functions/setFunction.d.ts +19 -0
  297. package/output/core/functions/setFunction.js +75 -0
  298. package/output/core/functions/string.d.ts +26 -0
  299. package/output/core/functions/string.js +102 -0
  300. package/output/core/functions/subst.d.ts +90 -0
  301. package/output/core/functions/subst.js +506 -0
  302. package/output/core/functions/utils.d.ts +24 -0
  303. package/output/core/functions/utils.js +51 -0
  304. package/output/core/parserFunctions.d.ts +7 -0
  305. package/output/core/parserFunctions.js +25 -0
  306. package/output/core/types.d.ts +48 -0
  307. package/output/core/types.js +2 -0
  308. package/output/index.d.ts +359 -0
  309. package/output/index.js +739 -0
  310. package/output/math/defint/defint.d.ts +18 -0
  311. package/output/math/defint/defint.js +60 -0
  312. package/output/math/defint/defintDecimal.d.ts +37 -0
  313. package/output/math/defint/defintDecimal.js +321 -0
  314. package/output/math/defint/defintNative.d.ts +57 -0
  315. package/output/math/defint/defintNative.js +281 -0
  316. package/output/math/dispatch.d.ts +1 -0
  317. package/output/math/dispatch.js +101 -0
  318. package/output/math/geometry.d.ts +12 -0
  319. package/output/math/geometry.js +55 -0
  320. package/output/math/math.d.ts +695 -0
  321. package/output/math/math.js +1955 -0
  322. package/output/math/trig.d.ts +518 -0
  323. package/output/math/trig.js +1444 -0
  324. package/output/math/trunc.d.ts +19 -0
  325. package/output/math/trunc.js +36 -0
  326. package/output/math/utils.d.ts +66 -0
  327. package/output/math/utils.js +219 -0
  328. package/output/solve/classes/DecimalMatrix.d.ts +17 -0
  329. package/output/solve/classes/DecimalMatrix.js +86 -0
  330. package/output/solve/classes/FunctionSolver.d.ts +135 -0
  331. package/output/solve/classes/FunctionSolver.js +433 -0
  332. package/output/solve/classes/MultivariateSolver.d.ts +84 -0
  333. package/output/solve/classes/MultivariateSolver.js +240 -0
  334. package/output/solve/classes/PolynomialSolver.d.ts +104 -0
  335. package/output/solve/classes/PolynomialSolver.js +492 -0
  336. package/output/solve/classes/SolutionSet.d.ts +172 -0
  337. package/output/solve/classes/SolutionSet.js +434 -0
  338. package/output/solve/classes/Solver.d.ts +17 -0
  339. package/output/solve/classes/Solver.js +132 -0
  340. package/output/solve/classes/SymbolicSolver.d.ts +74 -0
  341. package/output/solve/classes/SymbolicSolver.js +601 -0
  342. package/output/solve/dispatch.d.ts +1 -0
  343. package/output/solve/dispatch.js +13 -0
  344. package/output/solve/linsolve.d.ts +53 -0
  345. package/output/solve/linsolve.js +233 -0
  346. package/output/solve/solve.d.ts +44 -0
  347. package/output/solve/solve.js +368 -0
  348. package/output/solve/solveSystem.d.ts +31 -0
  349. package/output/solve/solveSystem.js +266 -0
  350. package/output/solve/utils.d.ts +10 -0
  351. package/output/solve/utils.js +58 -0
  352. package/output/utils/array.d.ts +42 -0
  353. package/output/utils/array.js +98 -0
  354. package/output/utils/debug.d.ts +131 -0
  355. package/output/utils/debug.js +296 -0
  356. package/output/utils/decimal.d.ts +3 -0
  357. package/output/utils/decimal.js +16 -0
  358. package/output/utils/numeric.d.ts +14 -0
  359. package/output/utils/numeric.js +51 -0
  360. package/output/utils/object.d.ts +26 -0
  361. package/output/utils/object.js +56 -0
  362. package/package.json +178 -57
  363. package/.travis.yml +0 -3
  364. package/Algebra.js +0 -4568
  365. package/CODE_OF_CONDUCT.md +0 -46
  366. package/CONTRIBUTING.md +0 -14
  367. package/Calculus.js +0 -2675
  368. package/Extra.js +0 -622
  369. package/Solve.js +0 -1783
  370. package/all.js +0 -16
  371. package/all.min.js +0 -1
  372. package/gulpfile.js +0 -16
  373. package/index.html +0 -158
  374. package/license.txt +0 -19
  375. package/nerdamer.core.js +0 -12510
  376. package/spec/LaTeX.spec.js +0 -302
  377. package/spec/TeXConvert.spec.js +0 -8
  378. package/spec/algebra.spec.js +0 -287
  379. package/spec/basic_parser.spec.js +0 -134
  380. package/spec/build.spec.js +0 -131
  381. package/spec/calculus.spec.js +0 -183
  382. package/spec/core.spec.js +0 -2970
  383. package/spec/extra.spec.js +0 -54
  384. package/spec/solve.spec.js +0 -126
  385. package/spec/support/jasmine.json +0 -11
  386. package/spec/support/utils.js +0 -42
  387. package/spec/text.spec.js +0 -132
@@ -0,0 +1,493 @@
1
+ import { Scope } from '../../common/classes/Scope';
2
+ import { Settings } from '../../Settings';
3
+ import type { Operator, OperatorDefinition } from '../../common/common';
4
+ import type { ParserEntity, ExpressionInput } from '../../types';
5
+ import type { Operation, PreFixFunction, PostFixFunction, OptionsObject, ParserValuesObject, ParserConstants } from './types';
6
+ type OperatorFunction = Operation | PostFixFunction | PreFixFunction;
7
+ /**
8
+ * Parses Nerdamer notation into symbolic and structured parser entities.
9
+ *
10
+ * @remarks
11
+ * The parser has three main stages: {@link tokenize} builds a nested token tree,
12
+ * {@link toRPN} applies the Shunting Yard algorithm within those scopes, and
13
+ * {@link parseRPN} evaluates the resulting stack representation. {@link parse} is
14
+ * the ordinary front end that runs that pipeline for a caller.
15
+ *
16
+ * Parsing does not always produce an {@link Expression}. Depending on the syntax
17
+ * and functions involved, the result can also be an equation, vector, matrix,
18
+ * collection, finite value set, or dictionary. Callers that require a specific
19
+ * parser entity should narrow the returned type rather than assuming an expression.
20
+ *
21
+ * The exported {@link Parser} singleton is the normal parser instance. Several
22
+ * parts of parser behavior are process-wide rather than instance-local, including
23
+ * parser settings, the constant and operator registries, Rational/Decimal precision,
24
+ * and the symbol reserved for the imaginary unit. {@link create} therefore creates
25
+ * another parser object, but it does not create an isolated parser context.
26
+ *
27
+ * The parser is a convenient notation front end, not the only supported way to use
28
+ * Nerdamer. Algorithms that already have {@link Expression} or other Nerdamer
29
+ * objects can operate on those objects directly without converting through text.
30
+ *
31
+ * @example
32
+ * ```ts
33
+ * Parser.parse('2*x + 1').text(); // "1+2*x"
34
+ * Parser.parse('x^2', { x: 3 }).text(); // "9"
35
+ * Parser.parse('[x, 2]').text(); // "[x, 2]"
36
+ * Parser.parse('{a => x, b => 2}').text(); // "{a => x, b => 2}"
37
+ * ```
38
+ */
39
+ declare class ExpressionParser {
40
+ /**
41
+ * Registry of named constants recognized by this parser.
42
+ *
43
+ * @remarks
44
+ * The registry object is shared by parser instances. Use {@link setConstants}
45
+ * instead of replacing or mutating this object directly so constant registration
46
+ * follows the parser's normal behavior.
47
+ */
48
+ private CONSTANTS;
49
+ /**
50
+ * The maximum number of operators a compound operator can consist of
51
+ */
52
+ private MAX_COMPOUND_OPERATOR_LENGTH;
53
+ private operators;
54
+ private VALUE_SETS;
55
+ private WHITE_SPACE;
56
+ /**
57
+ * Persistent known-value substitutions consulted during parsing.
58
+ *
59
+ * @remarks
60
+ * Known values are substituted only while the global `SUBSTITUTE` setting is
61
+ * enabled. A stored parser entity is copied before it is inserted into a parsed
62
+ * result, so ordinary substitution does not hand out the stored object itself.
63
+ */
64
+ KNOWN_VALUES: Record<string, ParserEntity>;
65
+ /**
66
+ * Converts an index scope to the zero-based indices used internally.
67
+ *
68
+ * Literal numeric indices are converted directly without parsing or evaluation.
69
+ * Symbolic or computed indices are returned as Expressions when they cannot yet
70
+ * be resolved. Resolved numeric values subtract `INDEX_BASE`; symbolic values retain
71
+ * the public index expressions so they can be evaluated later.
72
+ */
73
+ private extractIndices;
74
+ /**
75
+ * Extracts string keys from an index scope for Dictionary access.
76
+ * For d[x], the scope contains a single variable token "x" → returns ["x"].
77
+ * For d[myKey], returns ["myKey"].
78
+ */
79
+ private extractStringKeys;
80
+ /** Creates another spelling for an existing operator without changing its action. */
81
+ aliasOperator(symbol: string, alias: string): this;
82
+ /**
83
+ * Creates another parser instance.
84
+ *
85
+ * @remarks
86
+ * The returned parser object is distinct and starts with its own `KNOWN_VALUES`
87
+ * table, but it is not an isolated parser environment. Parser settings, constants,
88
+ * operators, Rational/Decimal precision, and the imaginary-unit symbol are shared
89
+ * process-wide. Changes made through methods such as {@link set},
90
+ * {@link setConstants}, {@link setPrecision}, or {@link setI} therefore affect
91
+ * parsing outside the newly created instance as well.
92
+ *
93
+ * @returns A distinct parser instance that shares Nerdamer's global parser state.
94
+ *
95
+ * @example
96
+ * ```ts
97
+ * const parser = Parser.create();
98
+ *
99
+ * parser === Parser; // false
100
+ * parser.parse('x + 1').text(); // "1+x"
101
+ * ```
102
+ */
103
+ create(): ExpressionParser;
104
+ /**
105
+ * Parses an expression with evaluation mode temporarily enabled.
106
+ *
107
+ * @remarks
108
+ * Supported numeric constants and functions are evaluated eagerly at the current
109
+ * configured precision, but this method does not guarantee a purely numeric result;
110
+ * symbolic terms that cannot be evaluated remain symbolic. The previous global
111
+ * `EVALUATE` setting is restored after parsing, including when parsing throws.
112
+ *
113
+ * @param str - Expression text to parse while evaluation mode is enabled.
114
+ * @param values - Optional call-scoped substitutions applied as in {@link parse}.
115
+ * @returns The parser entity produced by the evaluated parse.
116
+ *
117
+ * @example
118
+ * ```ts
119
+ * Parser.evaluate('2^10').text(); // "1024"
120
+ * Parser.evaluate('x+y', { x: 1, y: 2 }).text(); // "3"
121
+ * Parser.evaluate('x+1').text(); // "1+x"
122
+ * ```
123
+ */
124
+ evaluate(str: string, values?: ParserValuesObject): ParserEntity;
125
+ /**
126
+ * Reads the current value of a process-wide parser setting.
127
+ *
128
+ * @param setting - The parser setting to read.
129
+ * @returns The setting's current global value.
130
+ *
131
+ * @example
132
+ * ```ts
133
+ * const evaluate = Parser.get('EVALUATE');
134
+ * const indexBase = Parser.get('INDEX_BASE');
135
+ * ```
136
+ */
137
+ get(setting: keyof typeof Settings): number | bigint | boolean | import("../../errors").Language;
138
+ /**
139
+ * Returns the symbol currently reserved for the imaginary unit.
140
+ *
141
+ * @remarks
142
+ * The symbol is process-wide and can be changed through {@link setI}. Changing it
143
+ * affects subsequent parser behavior and complex-number classification; it does
144
+ * not rewrite expressions that have already been created.
145
+ *
146
+ * @returns The current imaginary-unit variable name.
147
+ *
148
+ * @example
149
+ * ```ts
150
+ * Parser.getI(); // "i" with the default configuration
151
+ * ```
152
+ */
153
+ getI(): string;
154
+ /** Returns a detached snapshot of registered operator metadata. */
155
+ getOperator(symbol: string): Operator | undefined;
156
+ /**
157
+ * Returns the current shared precision used by Decimal-backed numeric operations.
158
+ *
159
+ * @remarks
160
+ * This is the same precision reported by {@link Rational.getPrecision}. Exact
161
+ * rational arithmetic remains exact; the setting matters when Nerdamer crosses
162
+ * into Decimal-backed numerical work, generates numerical constants, or formats
163
+ * precision-sensitive decimal results.
164
+ *
165
+ * @returns The configured number of significant digits.
166
+ */
167
+ getPrecision(): number;
168
+ /**
169
+ * Reports whether a name is reserved by Nerdamer's parser or solver conventions.
170
+ *
171
+ * @remarks
172
+ * The result reflects the current process-wide parser state. In particular, changing
173
+ * the imaginary-unit symbol through {@link setI} removes the previous symbol from the
174
+ * restricted-name list and reserves the replacement. Solver-specific names such as
175
+ * `_n` and `all` are also reserved.
176
+ *
177
+ * @param name - Variable or symbol name to test.
178
+ * @returns Whether Nerdamer currently reserves the name.
179
+ */
180
+ isReserved(name: string): boolean;
181
+ /**
182
+ * Parses supported expression input into a Nerdamer parser entity.
183
+ *
184
+ * @remarks
185
+ * The input is converted to text, tokenized with {@link tokenize}, transformed
186
+ * with {@link toRPN}, and evaluated with {@link parseRPN}. Passing an existing
187
+ * {@link Expression} therefore reparses its textual representation rather than
188
+ * preserving that object's identity.
189
+ *
190
+ * The result is determined by the parsed syntax. Ordinary scalar input produces
191
+ * an {@link Expression}, while equations and structured syntax can produce other
192
+ * parser entities such as vectors, matrices, collections, finite value sets, or
193
+ * dictionaries.
194
+ *
195
+ * The `values` object provides substitutions for this parse call. The caller's
196
+ * object is not mutated; scalar values are normalized to expressions before use,
197
+ * while existing parser entities are preserved structurally. Each inserted parser
198
+ * entity is copied. Registered string constants are resolved before call-scoped
199
+ * values. Call-scoped values in turn take precedence over persistent known values
200
+ * and over function-backed constants such as `pi` and `e` when those constants are
201
+ * being numerically evaluated.
202
+ *
203
+ * Parser and operator errors are propagated when the input is malformed or an
204
+ * operation is not valid for the parsed operands.
205
+ *
206
+ * @param str - Expression-compatible input whose textual form should be parsed.
207
+ * @param values - Optional call-scoped substitutions. Scalar values are normalized
208
+ * to {@link Expression} objects; existing parser entities are preserved structurally
209
+ * and copied when inserted.
210
+ * @returns The expression or structured parser entity represented by the input.
211
+ *
212
+ * @example
213
+ * ```ts
214
+ * Parser.parse('x^2 + 2*x + 1').text(); // "1+2*x+x^2"
215
+ * Parser.parse('a + b', { a: 3, b: 4 }).text(); // "7"
216
+ * Parser.parse('x = 2').text(); // "x=2"
217
+ * Parser.parse('[x, 2, 3]').text(); // "[x, 2, 3]"
218
+ * ```
219
+ */
220
+ parse(str: ExpressionInput, values?: ParserValuesObject): ParserEntity;
221
+ /**
222
+ * Evaluates a token scope that has been converted to Reverse Polish Notation.
223
+ *
224
+ * @remarks
225
+ * This is the parser's core stack evaluator. It applies prefix, postfix, and
226
+ * binary operators; dispatches function calls; resolves substitutions and known
227
+ * values; performs indexing and indexed assignment; and routes operations involving
228
+ * equations or enumerable structures to the appropriate aggregate implementation.
229
+ *
230
+ * Square scopes become vectors. Curly scopes become dictionaries when they contain
231
+ * `=>` key/value markers and otherwise become finite value sets. Multiple unresolved
232
+ * top-level values become a collection. Internal stack markers used for indexing and
233
+ * dictionary construction are resolved or consumed before a successful return.
234
+ *
235
+ * When `assertive` is `true`, operators use their assertive actions where defined.
236
+ * This is used by assumption-related functions so comparisons can assert conditions
237
+ * instead of performing ordinary comparison evaluation.
238
+ *
239
+ * @param rpn - RPN scope, normally produced by {@link toRPN}.
240
+ * @param values - Optional call-scoped substitutions already prepared for parser use.
241
+ * @param assertive - Use assertion-oriented operator actions where the operator defines one.
242
+ * @returns The parser entity produced by evaluating the scope.
243
+ * @throws {@link ParserError} When the stack contains a malformed or unresolved parser construct.
244
+ */
245
+ parseRPN(rpn: Scope, values?: ParserValuesObject, assertive?: boolean): ParserEntity;
246
+ /**
247
+ * Converts a preprocessed TeX token scope to Nerdamer's ordinary parser syntax.
248
+ *
249
+ * @remarks
250
+ * This is a low-level conversion helper used by the TeX converter, not a complete
251
+ * LaTeX parser. The input is the nested scope produced after TeX-specific cleanup
252
+ * and tokenization; despite this method's historical name, callers should not assume
253
+ * that the scope has passed through {@link toRPN}.
254
+ *
255
+ * The converter recognizes the subset of commands handled in this routine, including
256
+ * fractions, integrals, sums, products, limits, square roots, infinity, real/imaginary
257
+ * part notation, and common trigonometric functions. Some command branches consume or
258
+ * modify child scopes while assembling the output, so callers should treat the supplied
259
+ * token tree as conversion input rather than as an immutable value to reuse afterward.
260
+ *
261
+ * Prefer the public TeX conversion API for ordinary LaTeX input.
262
+ *
263
+ * @param rpn - Preprocessed TeX token scope to convert.
264
+ * @returns Equivalent Nerdamer parser text for the supported TeX subset.
265
+ *
266
+ * @example
267
+ * ```ts
268
+ * // Internal conversion examples:
269
+ * // \frac{x}{2} -> "(x)/(2)"
270
+ * // \int x^2 dx -> "int(x^2,x)"
271
+ * ```
272
+ */
273
+ parseTeXRPN(rpn: Scope): string;
274
+ /**
275
+ * Runs a callback while temporarily overriding one global parser setting.
276
+ *
277
+ * @remarks
278
+ * The previous value is restored in a `finally` block, so it is restored even if
279
+ * the callback throws. The override is process-wide for the duration of the
280
+ * synchronous callback; it is not an isolated setting attached to this parser
281
+ * instance. The `setting` parameter remains a string for compatibility, so callers
282
+ * should supply a valid parser setting name.
283
+ *
284
+ * @param setting - Parser setting to override for the callback.
285
+ * @param value - Temporary boolean value for that setting.
286
+ * @param callback - Synchronous parser operation to run under the temporary setting.
287
+ * @returns The parser entity returned by `callback`.
288
+ *
289
+ * @example
290
+ * ```ts
291
+ * const symbolicPi = Parser.scopedBlock('EVALUATE', false, () => {
292
+ * return Parser.parse('pi');
293
+ * });
294
+ *
295
+ * symbolicPi.text(); // "pi"
296
+ * ```
297
+ */
298
+ scopedBlock(setting: string, value: boolean, callback: () => ParserEntity): ParserEntity;
299
+ /**
300
+ * Changes one or more process-wide parser settings.
301
+ *
302
+ * @remarks
303
+ * Settings persist until changed again and are shared by the exported parser,
304
+ * parsers returned by {@link create}, and higher-level Nerdamer entry points.
305
+ * Use {@link scopedBlock} when a setting should apply only for one synchronous
306
+ * operation.
307
+ *
308
+ * This method accepts string keys for compatibility and does not validate arbitrary
309
+ * setting names at runtime. Callers should use the settings defined by Nerdamer
310
+ * rather than adding ad hoc properties to the settings object.
311
+ *
312
+ * @param setting - Setting name, or an object containing settings to update.
313
+ * @param value - New value when `setting` is supplied as a single name.
314
+ * @returns This parser instance for chaining.
315
+ *
316
+ * @example
317
+ * ```ts
318
+ * Parser.set('EVALUATE', false);
319
+ * Parser.set({ EVALUATE: false, ALLOW_IMPLICIT_MULTIPLICATION: true });
320
+ * ```
321
+ */
322
+ set(setting: string | OptionsObject, value?: boolean | string | number | bigint): this;
323
+ /**
324
+ * Registers, updates, or removes named parser constants.
325
+ *
326
+ * @remarks
327
+ * The constant registry is shared by parser instances, so changes affect subsequent
328
+ * parsing throughout the process. String-valued constants are reparsed and substituted
329
+ * whenever their name is encountered, even when evaluation mode is disabled. They also
330
+ * take precedence over a same-named value supplied in a parse call.
331
+ *
332
+ * Function-valued constants are deferred factories. They are invoked when evaluation
333
+ * mode is enabled; otherwise the constant name remains symbolic. Nerdamer's built-in
334
+ * `pi` and `e` factories use this mechanism to generate values at the active precision.
335
+ *
336
+ * Assign an empty string to an existing constant to remove it. Changing the registry
337
+ * does not rewrite expressions that have already been parsed.
338
+ *
339
+ * @param constants - Constant names mapped to parser text or to factories that return
340
+ * parser text.
341
+ *
342
+ * @example
343
+ * ```ts
344
+ * Parser.setConstants({ G: '6.674e-11' });
345
+ * Parser.parse('G').text(); // "0.00000000006674"
346
+ *
347
+ * Parser.setConstants({ G: '' });
348
+ * Parser.parse('G').text(); // "G"
349
+ * ```
350
+ */
351
+ setConstants(constants: ParserConstants): void;
352
+ /**
353
+ * Changes the symbol Nerdamer treats as the imaginary unit.
354
+ *
355
+ * @remarks
356
+ * This is a process-wide change. The previous imaginary-unit name is removed from
357
+ * Nerdamer's restricted-variable list, the new name is reserved, and
358
+ * {@link Expression.imaginary} is updated. Existing expression trees are not renamed
359
+ * or reparsed, so changing this setting affects subsequent interpretation rather than
360
+ * rewriting values that already exist.
361
+ *
362
+ * @param variable - Parser variable name to reserve for the imaginary unit.
363
+ * @returns This parser instance for chaining.
364
+ *
365
+ * @example
366
+ * ```ts
367
+ * const previous = Parser.getI();
368
+ * Parser.setI('j');
369
+ * Parser.parse('3+2*j').text(); // "3+2*j"
370
+ * Parser.setI(previous);
371
+ * ```
372
+ */
373
+ setI(variable: string): this;
374
+ /**
375
+ * Alias for {@link setI}.
376
+ *
377
+ * @param variable - Parser variable name to reserve for the imaginary unit.
378
+ * @returns This parser instance for chaining.
379
+ */
380
+ setImaginary(variable: string): this;
381
+ /**
382
+ * Registers or updates an operator in the shared parser registry. Legacy `prefix`
383
+ * and `postfix` fields are accepted alongside the current metadata names.
384
+ */
385
+ setOperator(definition: OperatorDefinition, action?: OperatorFunction): this;
386
+ /**
387
+ * Sets the shared precision used by Decimal-backed numerical calculations.
388
+ *
389
+ * @remarks
390
+ * This delegates to {@link Rational.set}. It updates the global `decimal.js`
391
+ * precision and recomputes Nerdamer's finite-precision `pi` and `e` rational
392
+ * constants. Exact numerator/denominator arithmetic remains exact and does not
393
+ * become approximate merely because this setting changes.
394
+ *
395
+ * The setting is process-wide and affects parsers returned by {@link create} as
396
+ * well as the exported {@link Parser} singleton.
397
+ *
398
+ * @param precision - Number of significant digits for Decimal-backed work.
399
+ *
400
+ * @example
401
+ * ```ts
402
+ * const previous = Parser.getPrecision();
403
+ * Parser.setPrecision(50);
404
+ * Parser.getPrecision(); // 50
405
+ * Parser.setPrecision(previous);
406
+ * ```
407
+ */
408
+ setPrecision(precision: number): void;
409
+ /**
410
+ * Tokenizes parser text into a nested scope tree.
411
+ *
412
+ * @remarks
413
+ * The tokenizer recognizes numbers, variables, functions, keyword and symbolic
414
+ * operators, and round/square/curly bracket scopes. Scientific notation is normalized
415
+ * to decimal token text and configured aliases such as `π` and `∞` are normalized to
416
+ * their parser names.
417
+ *
418
+ * When implicit multiplication is enabled, the normal mode inserts synthetic `*`
419
+ * tokens where adjacency implies multiplication. Square-bracket adjacency is deferred:
420
+ * the child scope is marked so {@link parseRPN} can decide at evaluation time whether
421
+ * the construct is indexing or multiplication after the left operand's type is known.
422
+ * Unknown variable-parenthesis adjacency keeps its synthetic multiplication token but
423
+ * is also marked so {@link toRPN} can reinterpret it as a function call if the name is
424
+ * registered before that scope is converted. `options.pure` suppresses inserted
425
+ * multiplication tokens and is used by conversion code that needs the original token
426
+ * relationships. `options.keepWhiteSpace` retains whitespace tokens instead of
427
+ * discarding them.
428
+ *
429
+ * This is a low-level parser-pipeline API. Ordinary callers should normally use
430
+ * {@link parse} instead of depending on token representation details.
431
+ *
432
+ * @param inputStr - Parser text to tokenize.
433
+ * @param options - Tokenization options. Set `pure` to suppress synthetic
434
+ * implicit-multiplication tokens, or `keepWhiteSpace` to retain whitespace tokens.
435
+ * @returns The root `Scope` containing the nested token tree.
436
+ * @throws {@link UnexpectedTokenError} When brackets are mismatched or token adjacency is invalid.
437
+ *
438
+ * @example
439
+ * ```ts
440
+ * const tokens = Parser.tokenize('2*x + 1');
441
+ * tokens.text(); // "2 * x + 1"
442
+ * ```
443
+ */
444
+ tokenize(inputStr: string, options?: OptionsObject): Scope;
445
+ /**
446
+ * Converts a tokenized scope to Nerdamer's nested Reverse Polish Notation form.
447
+ *
448
+ * @remarks
449
+ * The conversion uses the Shunting Yard algorithm to apply precedence,
450
+ * associativity, prefix/postfix rules, and bracket scoping. Nested scopes remain
451
+ * nested; each child scope is recursively converted rather than flattening the
452
+ * entire expression into one token array. Deferred adjacency markers are retained
453
+ * on child scopes so square-bracket indexing can be decided by {@link parseRPN} and
454
+ * newly registered function names can be recognized before parenthesis adjacency is
455
+ * committed to implicit multiplication.
456
+ *
457
+ * The returned `Scope` containers are new, but token objects are reused. Prefix
458
+ * detection can retag those shared `Token` objects while converting the input, so
459
+ * callers should not treat the original token tree as an immutable snapshot after
460
+ * this method has run.
461
+ *
462
+ * @param scope - Tokenized scope, normally produced by {@link tokenize}.
463
+ * @returns A new scope hierarchy containing the tokens in evaluation order.
464
+ * @throws {@link ParserError} When an invalid operator sequence requires a prefix operator.
465
+ *
466
+ * @example
467
+ * ```ts
468
+ * const tokens = Parser.tokenize('2 + 3 * x');
469
+ * const rpn = Parser.toRPN(tokens);
470
+ *
471
+ * rpn.text(); // "2 3 x * +"
472
+ * ```
473
+ */
474
+ toRPN(scope: Scope): Scope;
475
+ }
476
+ /**
477
+ * The shared parser instance used by Nerdamer's ordinary parsing APIs.
478
+ *
479
+ * @remarks
480
+ * {@link Parser.parse} is the primary notation-to-object entry point. State-changing
481
+ * methods on this object can affect the rest of Nerdamer because settings, constants,
482
+ * numeric precision, operator metadata, and the imaginary-unit symbol are process-wide.
483
+ * Use scoped setting changes where possible, and do not assume that {@link Parser.create}
484
+ * provides an isolated parser environment.
485
+ *
486
+ * @example
487
+ * ```ts
488
+ * Parser.parse('x^2 + 1').text(); // "1+x^2"
489
+ * Parser.evaluate('2^10').text(); // "1024"
490
+ * ```
491
+ */
492
+ export declare const Parser: ExpressionParser;
493
+ export {};