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,235 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.product = product;
4
+ exports.sum = sum;
5
+ exports.stripPower = stripPower;
6
+ exports.cloneExpressionTree = cloneExpressionTree;
7
+ exports.copyOver = copyOver;
8
+ exports.toArrays = toArrays;
9
+ exports.largestPower = largestPower;
10
+ exports.assertPlainVariableAndGetString = assertPlainVariableAndGetString;
11
+ exports.getNumericOrAssumedValue = getNumericOrAssumedValue;
12
+ const errors_1 = require("../../errors");
13
+ const assume_1 = require("../assumption/assume");
14
+ const Expression_1 = require("./Expression");
15
+ const shortcuts_1 = require("./shortcuts");
16
+ /** Multiplies a series of Expressions into one product. */
17
+ function product(...args) {
18
+ let retval = (0, shortcuts_1.one)();
19
+ for (const x of args) {
20
+ retval = retval.times(x);
21
+ }
22
+ return retval;
23
+ }
24
+ /** Adds a series of Expressions into one sum. */
25
+ function sum(...args) {
26
+ let retval = (0, shortcuts_1.zero)();
27
+ for (const x of args) {
28
+ retval = retval.plus(x);
29
+ }
30
+ return retval;
31
+ }
32
+ /** Removes the power from an Expression. The original object is unchanged. */
33
+ function stripPower(x) {
34
+ const retval = x.copy();
35
+ delete retval.power;
36
+ return retval;
37
+ }
38
+ /**
39
+ * Deep-copies an Expression tree without routing every nested node back through the
40
+ * Expression constructor and factory.
41
+ *
42
+ * Expression.hook is still applied once for each copied node, matching the existing
43
+ * copy path. Mutable nested values are recreated so the returned tree remains
44
+ * independent from the source.
45
+ */
46
+ function cloneExpressionTree(source) {
47
+ const hooked = Expression_1.Expression.hook(source);
48
+ if (!Expression_1.Expression.isExpression(hooked)) {
49
+ return Expression_1.Expression.create(hooked);
50
+ }
51
+ const src = hooked;
52
+ const target = Object.create(Expression_1.Expression.prototype);
53
+ target.dataType = src.dataType;
54
+ target.deferred = src.deferred;
55
+ target.isEnumerable = src.isEnumerable;
56
+ target.type = src.type;
57
+ target.value = src.value;
58
+ target.precision = src.precision;
59
+ target.scientific = src.scientific;
60
+ if (src.multiplier) {
61
+ target.multiplier = src.multiplier.copy();
62
+ }
63
+ if (src.name !== undefined) {
64
+ target.name = src.name;
65
+ }
66
+ if (src.power) {
67
+ target.power = cloneExpressionTree(src.power);
68
+ }
69
+ if (src.args) {
70
+ target.args = src.args.map(cloneExpressionTree);
71
+ }
72
+ if (src.base) {
73
+ target.base = cloneExpressionTree(src.base);
74
+ }
75
+ if (src.elements) {
76
+ target.elements = {};
77
+ for (const key in src.elements) {
78
+ target.elements[key] = cloneExpressionTree(src.elements[key]);
79
+ }
80
+ }
81
+ return target;
82
+ }
83
+ /**
84
+ * Copies over all the properties of the provided symbolic essentially cloning it to x.
85
+ *
86
+ * @param sym
87
+ * @returns
88
+ */
89
+ function copyOver(src, target, options) {
90
+ options = {
91
+ ...{ omitMultiplier: false, omitPower: false },
92
+ ...options,
93
+ };
94
+ // Copy over the multiplier
95
+ if (src.multiplier && !options.omitMultiplier) {
96
+ target.multiplier = src.multiplier.copy();
97
+ }
98
+ // toFunctions have name so we need those copied
99
+ if (src.name !== undefined) {
100
+ target.name = src.name;
101
+ }
102
+ // Copy over the power
103
+ if (src.power && !options.omitPower) {
104
+ target.power = cloneExpressionTree(src.power);
105
+ }
106
+ // Copy over the args if any
107
+ if (src.args) {
108
+ target.args = [];
109
+ for (const arg of src.args) {
110
+ target.args.push(cloneExpressionTree(arg));
111
+ }
112
+ }
113
+ // Copy over the base if an
114
+ if (src.base) {
115
+ target.base = cloneExpressionTree(src.base);
116
+ }
117
+ // Copy over the elements if any
118
+ if (src.elements) {
119
+ target.elements = {};
120
+ for (const x in src.elements) {
121
+ target.elements[x] = cloneExpressionTree(src.elements[x]);
122
+ }
123
+ }
124
+ // Last but not least
125
+ target.type = src.type;
126
+ target.value = src.value;
127
+ target.precision = src.precision;
128
+ target.scientific = src.scientific;
129
+ target.deferred = src.deferred;
130
+ return target;
131
+ }
132
+ /**
133
+ * This function converts the expression in a collection of arrays
134
+ *
135
+ * @param x
136
+ * @param arrayObj
137
+ * @returns
138
+ */
139
+ function toArrays(x, arrayObj) {
140
+ /*
141
+ * The first thing to realize is that only PRD elements can have a numerator and denominators.
142
+ * All others are either the numerator or the denominator. To illustrate let look at some examples:
143
+ * x^2/4 => x^2/4
144
+ * cos(x)^(1/3) => cos(x)^(1/3)
145
+ * 5*x^-1+(5/6)*x^3+x => (5*x^3)/6+x+5/x
146
+ * (x+1)/(x+5) => (x+1)/(x+5)
147
+ * Out of all the examples, the only one with symbolic values in the denominator is the last one which is of type PRD.
148
+ * We can now simplify the problem by only focusing on PRD elements for symbolic denominators
149
+ */
150
+ const retval = arrayObj || {
151
+ num: [],
152
+ den: [],
153
+ };
154
+ function addMultiplier(m) {
155
+ retval.num.push(Expression_1.Expression.Number(m.numerator));
156
+ // Only add the denominator if it's not one
157
+ if (m.denominator !== 1n) {
158
+ retval.den.push(Expression_1.Expression.Number(m.denominator));
159
+ }
160
+ }
161
+ if (x.isNUM()) {
162
+ addMultiplier(x.getMultiplier());
163
+ }
164
+ else {
165
+ addMultiplier(x.getMultiplier());
166
+ const power = x.getPower();
167
+ // Handle products. Their elements should be distributed over the numerator and denominator
168
+ // Consider 2*x*y/(a*b). The desired output is { num: [2, y, y], den: [a, b]}
169
+ if (x.isProduct()) {
170
+ const elements = x.elementsArray();
171
+ for (const element of elements) {
172
+ // Pass in this object so they're added to the numerator or the denominator of this retval object
173
+ toArrays(element, retval);
174
+ }
175
+ }
176
+ // Consider 2/3*x. The desired output is { num: [2, x], den [3] };
177
+ // Consider (3*y)^(2/3). The desired output = { num: [3, y], den: [], power: { num: [2], den: [3]} };
178
+ else {
179
+ const term = stripPower(x.toUnitMultiplier());
180
+ // Put it in numerator if positive power else the denominator
181
+ const target = power.getMultiplier().isNegative() ? retval.den : retval.num;
182
+ target.push(term);
183
+ }
184
+ // Handle the power. Remember that x^(-2) is now 1/x^2 so the power has to be the absolute value
185
+ retval.power = toArrays(power.abs());
186
+ // Handle args
187
+ // Consider cos(2*pi). The desired output = { name: 'cos', args[{ num: [2, pi], den: [] }] }
188
+ if (x.args) {
189
+ retval.args = x.getArguments().map(x => {
190
+ return toArrays(x);
191
+ });
192
+ }
193
+ }
194
+ return retval;
195
+ }
196
+ /**
197
+ * Gets the max between two or more Expressions. Just know that if two variable arguments are provided,
198
+ * it will not be able to know with any certainty which is bigger so the first one will be returned.
199
+ *
200
+ * @param x
201
+ * @param args
202
+ * @returns
203
+ */
204
+ function largestPower(x, ...args) {
205
+ let retval = x;
206
+ for (const y of args) {
207
+ if (y.getPower().gt(retval.getPower())) {
208
+ retval = y;
209
+ }
210
+ }
211
+ return retval;
212
+ }
213
+ function assertPlainVariableAndGetString(x) {
214
+ if (!x.isVAR()) {
215
+ throw new errors_1.UnexpectedInputError((0, errors_1.message)('plainVariableExpected', { input: x.text() }));
216
+ }
217
+ return x.value;
218
+ }
219
+ function getNumericOrAssumedValue(x) {
220
+ let retval = undefined;
221
+ // If it's numeric then we're done
222
+ if (x.isNUM()) {
223
+ retval = x;
224
+ }
225
+ else {
226
+ // Check the assumptions
227
+ const assumedValue = (0, assume_1.getAssumptionFor)(x);
228
+ // Make sure it's a single value. Since this is used for comparison,
229
+ // we cannot compare a point to a range.
230
+ if (assumedValue && assumedValue.isSingleton) {
231
+ retval = assumedValue.getSingletonValue();
232
+ }
233
+ }
234
+ return retval;
235
+ }
@@ -0,0 +1,12 @@
1
+ import type { Pattern } from '../../converters/Pattern';
2
+ import type { Expression } from '../expression/Expression';
3
+ export type TableEntryHandler = (f: Pattern, depth?: number) => Expression | undefined;
4
+ export type TableEntries = Record<string, TableEntryHandler>;
5
+ export declare class LookupTable {
6
+ private _entries;
7
+ private addEntry;
8
+ private get;
9
+ addEntries(table: TableEntries): void;
10
+ lookup(pattern: Pattern, depth?: number): Expression | undefined;
11
+ set(pattern: string, handler: TableEntryHandler): boolean;
12
+ }
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LookupTable = void 0;
4
+ class LookupTable {
5
+ _entries = new Map();
6
+ addEntry(pattern, handler) {
7
+ // Check if there's an existing entry
8
+ const existingEntry = this._entries.get(pattern);
9
+ // If not then just add it
10
+ if (!existingEntry) {
11
+ this._entries.set(pattern, [handler]);
12
+ }
13
+ // Add the handler if there's an existing entry
14
+ else {
15
+ existingEntry.push(handler);
16
+ }
17
+ }
18
+ get(pattern) {
19
+ return this._entries.get(pattern);
20
+ }
21
+ addEntries(table) {
22
+ for (const pattern in table) {
23
+ // Get the handler in the table
24
+ const handler = table[pattern];
25
+ this.addEntry(pattern, handler);
26
+ }
27
+ }
28
+ lookup(pattern, depth) {
29
+ // Get the handlers
30
+ const handlers = this.get(pattern.patternString);
31
+ // console.log('Looking up\n');
32
+ // console.log(
33
+ // `pattern: ${pattern.patternString}, expression: ${pattern.expression}, handler found: ${handlers ? handlers.length : 'none'}\n`
34
+ // );
35
+ if (handlers) {
36
+ // If there are handlers then try each one until a match is found.
37
+ for (const handler of handlers) {
38
+ const result = handler(pattern, depth);
39
+ if (result) {
40
+ return result;
41
+ }
42
+ }
43
+ }
44
+ return undefined;
45
+ }
46
+ set(pattern, handler) {
47
+ const handlers = this._entries.get(pattern);
48
+ if (handler) {
49
+ handlers?.push(handler);
50
+ return true;
51
+ }
52
+ return false;
53
+ }
54
+ }
55
+ exports.LookupTable = LookupTable;
@@ -0,0 +1,227 @@
1
+ import { StructuredEntity } from '../../common/classes/StructuredEntity';
2
+ import { Expression } from '../expression/Expression';
3
+ import { MATRIX } from '../parser/constants';
4
+ import { Vector } from '../vector/Vector';
5
+ import type { StructuredEntityType, ParserEntity, NerdamerInput } from '../../types';
6
+ import type { ParserValuesObject } from '../parser/types';
7
+ /**
8
+ * A rectangular two-dimensional matrix of scalar {@link Expression} elements.
9
+ *
10
+ * @remarks
11
+ * Construction validates that all nonempty rows have the same length and
12
+ * converts every entry to an Expression; nested parser aggregates are not
13
+ * matrix elements. Existing Expression entries are retained, so use
14
+ * {@link copy} when independent element objects are required. `copy`,
15
+ * {@link evaluate}, and {@link expand} return deep independent matrices.
16
+ *
17
+ * Addition, subtraction, and division remain element-wise. {@link times}
18
+ * implements scalar scaling, matrix multiplication, and matrix-vector multiplication,
19
+ * while {@link pow} implements integer matrix powers. Scalar and matrix products return
20
+ * new Matrices; a matrix-vector product returns a new Vector. {@link each}, {@link set},
21
+ * and parser assignment mutate this matrix. `each` may also be used for observation by
22
+ * returning nothing; use {@link forEach} when no transformation is intended.
23
+ *
24
+ * Direct `get`/`set` indices are zero-based. The compatibility accessor
25
+ * {@link e} and the {@link row}/{@link col} helpers are one-based. Matrix
26
+ * comparisons are component-wise predicates, not a total or lexicographic
27
+ * ordering; a type or dimension mismatch compares false.
28
+ */
29
+ export declare class Matrix extends StructuredEntity<Matrix, Vector> {
30
+ /**
31
+ * Number of row swaps performed during the last toRightTriangular call.
32
+ * Used internally by determinant() to correct the sign.
33
+ */
34
+ private _rowSwaps;
35
+ dataType: typeof MATRIX;
36
+ elements: Expression[][];
37
+ isEnumerable: boolean;
38
+ precision?: number | undefined;
39
+ /**
40
+ * Creates a matrix from array or Vector rows.
41
+ *
42
+ * @param elements - Rows containing values convertible to scalar Expressions.
43
+ * @throws {@link core!MathError} If nonempty rows have different lengths.
44
+ * @throws {@link core!UnexpectedDataType} If an entry cannot be converted to an
45
+ * Expression.
46
+ */
47
+ constructor(...elements: (NerdamerInput[] | Vector)[]);
48
+ /** Creates a matrix whose cells are independent copies of `value`. */
49
+ static fill(rows: number, cols: number, value: Expression): Matrix;
50
+ /** Creates the `n` by `n` identity matrix. */
51
+ static identity(n: number): Matrix;
52
+ static isMatrix(obj: unknown): obj is Matrix;
53
+ /** Creates a matrix filled with symbolic zeros. */
54
+ static zeroMatrix(rows: number, cols: number): Matrix;
55
+ /**
56
+ * Returns a row at the given zero-based index as a Vector.
57
+ * Used by the parser for bracket indexing, e.g. matrix[0] returns the first row.
58
+ * This enables chained indexing: matrix[0][1] returns the element at row 0, col 1.
59
+ *
60
+ * @param indices Zero-based indices (after INDEX_BASE adjustment).
61
+ * Single index [i] returns row i as a Vector.
62
+ * Two indices [i, j] returns the element at row i, col j.
63
+ * @returns A copied row Vector for one index, or the stored Expression for two.
64
+ * @throws {@link core!MathError} If either index is out of bounds.
65
+ */
66
+ __get__(indices: number[]): ParserEntity;
67
+ /**
68
+ * Sets a zero-based cell or replaces an entire row.
69
+ * [i, j] sets the element at row i, col j.
70
+ * [i] requires a Vector whose length matches the matrix column count.
71
+ *
72
+ * @param indices Zero-based indices
73
+ * @param value The value to set
74
+ * @throws {@link core!UnexpectedDataType} If a full-row assignment does not receive a Vector.
75
+ * @throws {@link core!MathError} If an index is out of bounds or a replacement row has the wrong length.
76
+ */
77
+ __set__(indices: number[] | string, value: ParserEntity): void;
78
+ /**
79
+ * Returns the horizontal augmentation `[this | matrix]` without mutating either input.
80
+ *
81
+ * @throws {@link core!MathError} If the row counts differ.
82
+ */
83
+ augment(matrix: Matrix): Matrix;
84
+ canMultiplyFromLeft(M: Matrix): boolean;
85
+ col(n: number): Matrix;
86
+ cols(): number;
87
+ /** Copies the matrix and every Expression element. */
88
+ copy(): Matrix;
89
+ /**
90
+ * Computes the determinant by triangular elimination.
91
+ *
92
+ * The determinant of the empty matrix is one.
93
+ *
94
+ * @throws {@link core!UnsupportedOperationError} If the matrix is not square.
95
+ */
96
+ determinant(): Expression;
97
+ dimensions(): number[];
98
+ dimensionsMatch(M: StructuredEntityType): M is Matrix;
99
+ /**
100
+ * Divides corresponding entries, or broadcasts a scalar divisor.
101
+ *
102
+ * @throws {@link core!DimensionError} If a Matrix divisor has different dimensions.
103
+ */
104
+ div(x: NerdamerInput): Matrix;
105
+ /**
106
+ * Returns a one-based matrix element for compatibility with the legacy accessor.
107
+ *
108
+ * @throws {@link core!MathError} If either index is out of bounds.
109
+ */
110
+ e(i: number, j: number): Expression;
111
+ /**
112
+ * Visits or replaces every element in row-major order.
113
+ * Returning `void` leaves the current cell unchanged. Callback row and column
114
+ * indices are zero-based.
115
+ */
116
+ each(fn: (e: Expression, i?: string | number, j?: string | number) => Expression | void): Matrix;
117
+ eq(M: ParserEntity): boolean;
118
+ /** Evaluates a copied matrix, resolving symbolic cell access when values are supplied. */
119
+ evaluate(): Matrix;
120
+ evaluate(values: ParserValuesObject): ParserEntity;
121
+ /** Expands a copied matrix, leaving this one unchanged. */
122
+ expand(): Matrix;
123
+ /** Visits every cell without changing the matrix. */
124
+ forEach(callback: (value: Expression, row: number, col: number) => void): void;
125
+ /**
126
+ * Returns the stored Expression at a zero-based row and column.
127
+ *
128
+ * @throws {@link core!MathError} If either index is out of bounds.
129
+ */
130
+ get(row: number, col: number): Expression;
131
+ gt(M: ParserEntity): boolean;
132
+ gte(M: ParserEntity): boolean;
133
+ inspect(): string;
134
+ /**
135
+ * Computes an inverse by augmenting with the identity and eliminating rows.
136
+ *
137
+ * @returns A new inverse matrix; this matrix is unchanged.
138
+ * @throws {@link core!UnsupportedOperationError} If the matrix is not square.
139
+ * @throws {@link core!MathError} If the matrix is singular.
140
+ */
141
+ inverse(): Matrix;
142
+ isSingular(): boolean;
143
+ isSquare(): boolean;
144
+ lt(M: ParserEntity): boolean;
145
+ lte(M: ParserEntity): boolean;
146
+ /** Returns a new matrix populated by callback results without mutating this matrix. */
147
+ map(callback: (a: Expression, row?: string | number, col?: string | number) => Expression): Matrix;
148
+ /**
149
+ * Subtracts corresponding entries, or broadcasts a scalar subtrahend.
150
+ *
151
+ * @throws {@link core!DimensionError} If a Matrix operand has different dimensions.
152
+ */
153
+ minus(x: NerdamerInput): Matrix;
154
+ /** Delegates the public multiplication alias to the Matrix-specific times() method. */
155
+ multiply(x: Expression): Matrix;
156
+ multiply(x: Matrix): Matrix;
157
+ multiply(x: Vector): Vector;
158
+ multiply(x: ParserEntity): Matrix | Vector;
159
+ /**
160
+ * Computes a basis for the nullspace using the same reduced row-echelon form as {@link rref}.
161
+ *
162
+ * @remarks
163
+ * Without `prime`, the basis is computed with exact symbolic Expression arithmetic. When
164
+ * `prime` is supplied, the existing modular arithmetic path is preserved and basis entries
165
+ * are reduced modulo that value. Each free column contributes one basis vector, ordered by
166
+ * increasing free-column index. A full-column-rank matrix therefore returns an empty basis.
167
+ *
168
+ * @param prime - Optional modulus for finite-field nullspace arithmetic.
169
+ * @returns Basis vectors as independent Expression arrays ordered by matrix column.
170
+ */
171
+ nullspace(prime?: string | number | Expression): Expression[][];
172
+ /**
173
+ * Adds corresponding entries, or broadcasts a scalar addend.
174
+ *
175
+ * @throws {@link core!DimensionError} If a Matrix operand has different dimensions.
176
+ */
177
+ plus(x: NerdamerInput): Matrix;
178
+ /**
179
+ * Raises this matrix to an integer power without mutating it.
180
+ *
181
+ * Positive powers use matrix multiplication, zero returns the identity, and
182
+ * negative powers use the matrix inverse. A rectangular matrix is accepted only
183
+ * for the identity power `1`; all other matrix powers require a square matrix.
184
+ *
185
+ * @throws {@link core!UnsupportedOperationError} If the exponent is not an integer,
186
+ * or if a nontrivial power is requested for a rectangular matrix.
187
+ * @throws {@link core!MathError} If a negative power requires the inverse of a singular matrix.
188
+ */
189
+ pow(x: NerdamerInput): Matrix;
190
+ rank(): number;
191
+ row(n: number): Matrix;
192
+ rows(): number;
193
+ /**
194
+ * Returns reduced row-echelon form without mutating this matrix.
195
+ *
196
+ * When `prime` is supplied, pivot arithmetic is performed modulo that value.
197
+ * Otherwise pivots and zero rows are determined by exact Expression equality.
198
+ */
199
+ rref(prime?: string | number | Expression): Matrix;
200
+ /** Sets a zero-based cell after converting `value` to an Expression. */
201
+ set(row: number, col: number, value: ParserEntity): this;
202
+ text(): string;
203
+ /**
204
+ * Returns scalar multiplication, the matrix product `this * M`, or the
205
+ * matrix-vector product `this * v`.
206
+ *
207
+ * @throws {@link core!MathError} If matrix or vector dimensions are incompatible.
208
+ * @throws {@link core!UnsupportedOperationError} If the operand is not a supported
209
+ * scalar, Matrix, or Vector.
210
+ */
211
+ times(M: Expression): Matrix;
212
+ times(M: Matrix): Matrix;
213
+ times(M: Vector): Vector;
214
+ times(M: ParserEntity): Matrix | Vector;
215
+ /** Returns a row-echelon copy produced by forward elimination and row swaps. */
216
+ toRightTriangular(): Matrix;
217
+ toUpperTriangular(): Matrix;
218
+ /**
219
+ * Returns the sum of the main diagonal. The empty matrix has trace zero.
220
+ * @throws {@link core!MathError} If the matrix is not square.
221
+ */
222
+ trace(): Expression;
223
+ /** Returns a transposed matrix. Existing elements are normalized by the constructor. */
224
+ transpose(): Matrix;
225
+ /** Returns elements as a column-major Vector. */
226
+ unroll(): Vector;
227
+ }