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.
- package/BREAKING_CHANGES.md +244 -5
- package/LICENSE.md +184 -0
- package/README.md +232 -318
- package/dist/bundle.js +2 -0
- package/dist/bundle.js.LICENSE.txt +7 -0
- package/dist/parser.js +2 -0
- package/dist/parser.js.LICENSE.txt +7 -0
- package/docs-data/parser-functions.json +2248 -0
- package/index.d.ts +10 -426
- package/output/algebra/adapters.d.ts +3 -0
- package/output/algebra/adapters.js +11 -0
- package/output/algebra/algorithms/arith.d.ts +84 -0
- package/output/algebra/algorithms/arith.js +324 -0
- package/output/algebra/algorithms/groebnerBase.d.ts +161 -0
- package/output/algebra/algorithms/groebnerBase.js +929 -0
- package/output/algebra/dispatch.d.ts +1 -0
- package/output/algebra/dispatch.js +25 -0
- package/output/algebra/factor/factor.d.ts +77 -0
- package/output/algebra/factor/factor.js +245 -0
- package/output/algebra/gcd/gcd.d.ts +30 -0
- package/output/algebra/gcd/gcd.js +95 -0
- package/output/algebra/groebner.d.ts +21 -0
- package/output/algebra/groebner.js +36 -0
- package/output/algebra/partfrac.d.ts +19 -0
- package/output/algebra/partfrac.js +365 -0
- package/output/algebra/polynomial/ModularSparsePolynomial.d.ts +131 -0
- package/output/algebra/polynomial/ModularSparsePolynomial.js +378 -0
- package/output/algebra/polynomial/ModularSparsePolynomialFactor.d.ts +40 -0
- package/output/algebra/polynomial/ModularSparsePolynomialFactor.js +661 -0
- package/output/algebra/polynomial/SparsePolynomialFactor.d.ts +64 -0
- package/output/algebra/polynomial/SparsePolynomialFactor.js +492 -0
- package/output/algebra/polynomial/SparsePolynomialGcd.d.ts +29 -0
- package/output/algebra/polynomial/SparsePolynomialGcd.js +259 -0
- package/output/algebra/polynomial/SparsePolynomialMultivariateFactor.d.ts +82 -0
- package/output/algebra/polynomial/SparsePolynomialMultivariateFactor.js +604 -0
- package/output/algebra/polynomial/modularGcd.d.ts +40 -0
- package/output/algebra/polynomial/modularGcd.js +365 -0
- package/output/algebra/polynomialize.d.ts +20 -0
- package/output/algebra/polynomialize.js +26 -0
- package/output/algebra/simplify/complexsimp.d.ts +7 -0
- package/output/algebra/simplify/complexsimp.js +24 -0
- package/output/algebra/simplify/factorCommon.d.ts +13 -0
- package/output/algebra/simplify/factorCommon.js +136 -0
- package/output/algebra/simplify/funcsimp.d.ts +26 -0
- package/output/algebra/simplify/funcsimp.js +633 -0
- package/output/algebra/simplify/invtrigrewrite.d.ts +10 -0
- package/output/algebra/simplify/invtrigrewrite.js +96 -0
- package/output/algebra/simplify/ratsimp.d.ts +21 -0
- package/output/algebra/simplify/ratsimp.js +140 -0
- package/output/algebra/simplify/simplify.d.ts +25 -0
- package/output/algebra/simplify/simplify.js +237 -0
- package/output/algebra/simplify/trigreduce.d.ts +38 -0
- package/output/algebra/simplify/trigreduce.js +424 -0
- package/output/algebra/simplify/trigrewrite.d.ts +17 -0
- package/output/algebra/simplify/trigrewrite.js +156 -0
- package/output/algebra/simplify/trigsimp.d.ts +11 -0
- package/output/algebra/simplify/trigsimp.js +369 -0
- package/output/algebra/simplify/utils.d.ts +32 -0
- package/output/algebra/simplify/utils.js +56 -0
- package/output/algebra/utils.d.ts +32 -0
- package/output/algebra/utils.js +48 -0
- package/output/api/advanced.d.ts +8 -0
- package/output/api/advanced.js +18 -0
- package/output/api/algebra.d.ts +17 -0
- package/output/api/algebra.js +35 -0
- package/output/api/assumptions.d.ts +4 -0
- package/output/api/assumptions.js +11 -0
- package/output/api/calculus.d.ts +10 -0
- package/output/api/calculus.js +22 -0
- package/output/api/core.d.ts +17 -0
- package/output/api/core.js +41 -0
- package/output/api/debug.d.ts +16 -0
- package/output/api/debug.js +23 -0
- package/output/api/languages/deu.d.ts +3 -0
- package/output/api/languages/deu.js +266 -0
- package/output/api/languages/fra.d.ts +3 -0
- package/output/api/languages/fra.js +266 -0
- package/output/api/languages/ita.d.ts +3 -0
- package/output/api/languages/ita.js +266 -0
- package/output/api/languages/nld.d.ts +3 -0
- package/output/api/languages/nld.js +266 -0
- package/output/api/languages/por.d.ts +3 -0
- package/output/api/languages/por.js +266 -0
- package/output/api/languages/spa.d.ts +3 -0
- package/output/api/languages/spa.js +266 -0
- package/output/api/parser.d.ts +93 -0
- package/output/api/parser.js +18 -0
- package/output/api/solve.d.ts +10 -0
- package/output/api/solve.js +17 -0
- package/output/api/structures.d.ts +10 -0
- package/output/api/structures.js +23 -0
- package/output/calculus/adapters.d.ts +8 -0
- package/output/calculus/adapters.js +41 -0
- package/output/calculus/derivative/diff.d.ts +30 -0
- package/output/calculus/derivative/diff.js +241 -0
- package/output/calculus/dispatch.d.ts +1 -0
- package/output/calculus/dispatch.js +25 -0
- package/output/calculus/fresnel.d.ts +16 -0
- package/output/calculus/fresnel.js +39 -0
- package/output/calculus/integrate/byParts.d.ts +18 -0
- package/output/calculus/integrate/byParts.js +339 -0
- package/output/calculus/integrate/bySubstitution.d.ts +135 -0
- package/output/calculus/integrate/bySubstitution.js +411 -0
- package/output/calculus/integrate/integrate.d.ts +38 -0
- package/output/calculus/integrate/integrate.js +652 -0
- package/output/calculus/integrate/integrationTable.d.ts +2 -0
- package/output/calculus/integrate/integrationTable.js +914 -0
- package/output/calculus/integrate/utils.d.ts +28 -0
- package/output/calculus/integrate/utils.js +96 -0
- package/output/calculus/laplace/ilaplace.d.ts +31 -0
- package/output/calculus/laplace/ilaplace.js +192 -0
- package/output/calculus/laplace/ilaplaceTable.d.ts +2 -0
- package/output/calculus/laplace/ilaplaceTable.js +200 -0
- package/output/calculus/laplace/laplace.d.ts +22 -0
- package/output/calculus/laplace/laplace.js +109 -0
- package/output/calculus/laplace/laplaceTable.d.ts +2 -0
- package/output/calculus/laplace/laplaceTable.js +187 -0
- package/output/calculus/limit/limit.d.ts +35 -0
- package/output/calculus/limit/limit.js +1183 -0
- package/output/calculus/limit/limitsTable.d.ts +2 -0
- package/output/calculus/limit/limitsTable.js +7 -0
- package/output/core/Settings.d.ts +32 -0
- package/output/core/Settings.js +68 -0
- package/output/core/classes/assumption/Assumption.d.ts +218 -0
- package/output/core/classes/assumption/Assumption.js +609 -0
- package/output/core/classes/assumption/assertiveFunctions.d.ts +6 -0
- package/output/core/classes/assumption/assertiveFunctions.js +64 -0
- package/output/core/classes/assumption/assume.d.ts +90 -0
- package/output/core/classes/assumption/assume.js +145 -0
- package/output/core/classes/assumption/dispatch.d.ts +1 -0
- package/output/core/classes/assumption/dispatch.js +11 -0
- package/output/core/classes/collection/Collection.d.ts +107 -0
- package/output/core/classes/collection/Collection.js +240 -0
- package/output/core/classes/complex/Complex.d.ts +109 -0
- package/output/core/classes/complex/Complex.js +153 -0
- package/output/core/classes/decimalSet/DecimalSet.d.ts +226 -0
- package/output/core/classes/decimalSet/DecimalSet.js +454 -0
- package/output/core/classes/dictionary/Dictionary.d.ts +102 -0
- package/output/core/classes/dictionary/Dictionary.js +216 -0
- package/output/core/classes/equation/Equation.d.ts +256 -0
- package/output/core/classes/equation/Equation.js +350 -0
- package/output/core/classes/expression/CoeffObject.d.ts +100 -0
- package/output/core/classes/expression/CoeffObject.js +197 -0
- package/output/core/classes/expression/Expression.d.ts +1691 -0
- package/output/core/classes/expression/Expression.js +2381 -0
- package/output/core/classes/expression/analysis.d.ts +25 -0
- package/output/core/classes/expression/analysis.js +218 -0
- package/output/core/classes/expression/collect.d.ts +9 -0
- package/output/core/classes/expression/collect.js +49 -0
- package/output/core/classes/expression/format.d.ts +54 -0
- package/output/core/classes/expression/format.js +340 -0
- package/output/core/classes/expression/products.d.ts +23 -0
- package/output/core/classes/expression/products.js +115 -0
- package/output/core/classes/expression/shortcuts.d.ts +35 -0
- package/output/core/classes/expression/shortcuts.js +129 -0
- package/output/core/classes/expression/traversal.d.ts +31 -0
- package/output/core/classes/expression/traversal.js +216 -0
- package/output/core/classes/expression/trig.d.ts +25 -0
- package/output/core/classes/expression/trig.js +40 -0
- package/output/core/classes/expression/utils.d.ts +61 -0
- package/output/core/classes/expression/utils.js +235 -0
- package/output/core/classes/lookupTable/LookupTable.d.ts +12 -0
- package/output/core/classes/lookupTable/LookupTable.js +55 -0
- package/output/core/classes/matrix/Matrix.d.ts +227 -0
- package/output/core/classes/matrix/Matrix.js +901 -0
- package/output/core/classes/matrix/Sylvester.d.ts +11 -0
- package/output/core/classes/matrix/Sylvester.js +54 -0
- package/output/core/classes/matrix/dispatch.d.ts +1 -0
- package/output/core/classes/matrix/dispatch.js +19 -0
- package/output/core/classes/matrix/functions.d.ts +28 -0
- package/output/core/classes/matrix/functions.js +57 -0
- package/output/core/classes/matrix/utils.d.ts +9 -0
- package/output/core/classes/matrix/utils.js +22 -0
- package/output/core/classes/parser/Parser.d.ts +493 -0
- package/output/core/classes/parser/Parser.js +1863 -0
- package/output/core/classes/parser/Token.d.ts +58 -0
- package/output/core/classes/parser/Token.js +137 -0
- package/output/core/classes/parser/constants.d.ts +162 -0
- package/output/core/classes/parser/constants.js +229 -0
- package/output/core/classes/parser/controlFlowSignals.d.ts +38 -0
- package/output/core/classes/parser/controlFlowSignals.js +60 -0
- package/output/core/classes/parser/helpers.d.ts +21 -0
- package/output/core/classes/parser/helpers.js +42 -0
- package/output/core/classes/parser/operations/add.d.ts +15 -0
- package/output/core/classes/parser/operations/add.js +236 -0
- package/output/core/classes/parser/operations/comma.d.ts +7 -0
- package/output/core/classes/parser/operations/comma.js +11 -0
- package/output/core/classes/parser/operations/compare.d.ts +21 -0
- package/output/core/classes/parser/operations/compare.js +474 -0
- package/output/core/classes/parser/operations/divide.d.ts +2 -0
- package/output/core/classes/parser/operations/divide.js +72 -0
- package/output/core/classes/parser/operations/functions.d.ts +46 -0
- package/output/core/classes/parser/operations/functions.js +438 -0
- package/output/core/classes/parser/operations/multiply.d.ts +11 -0
- package/output/core/classes/parser/operations/multiply.js +328 -0
- package/output/core/classes/parser/operations/power.d.ts +48 -0
- package/output/core/classes/parser/operations/power.js +673 -0
- package/output/core/classes/parser/operations/subtract.d.ts +3 -0
- package/output/core/classes/parser/operations/subtract.js +36 -0
- package/output/core/classes/parser/preprocess.d.ts +7 -0
- package/output/core/classes/parser/preprocess.js +246 -0
- package/output/core/classes/parser/scripting/controlFlow.d.ts +23 -0
- package/output/core/classes/parser/scripting/controlFlow.js +279 -0
- package/output/core/classes/parser/scripting/deferred.d.ts +4 -0
- package/output/core/classes/parser/scripting/deferred.js +65 -0
- package/output/core/classes/parser/scripting/dispatch.d.ts +1 -0
- package/output/core/classes/parser/scripting/dispatch.js +62 -0
- package/output/core/classes/parser/scripting/evaluate.d.ts +23 -0
- package/output/core/classes/parser/scripting/evaluate.js +128 -0
- package/output/core/classes/parser/scripting/functions.d.ts +14 -0
- package/output/core/classes/parser/scripting/functions.js +59 -0
- package/output/core/classes/parser/scripting/scope.d.ts +8 -0
- package/output/core/classes/parser/scripting/scope.js +132 -0
- package/output/core/classes/parser/types.d.ts +130 -0
- package/output/core/classes/parser/types.js +2 -0
- package/output/core/classes/parser/wrappers/IndexedReference.d.ts +31 -0
- package/output/core/classes/parser/wrappers/IndexedReference.js +68 -0
- package/output/core/classes/parser/wrappers/KeyValuePair.d.ts +24 -0
- package/output/core/classes/parser/wrappers/KeyValuePair.js +51 -0
- package/output/core/classes/polynomial/Polynomial.d.ts +504 -0
- package/output/core/classes/polynomial/Polynomial.js +1195 -0
- package/output/core/classes/polynomial/SparsePolynomial.d.ts +221 -0
- package/output/core/classes/polynomial/SparsePolynomial.js +824 -0
- package/output/core/classes/polynomial/SparsePolynomialAdapter.d.ts +56 -0
- package/output/core/classes/polynomial/SparsePolynomialAdapter.js +241 -0
- package/output/core/classes/polynomial/Term.d.ts +222 -0
- package/output/core/classes/polynomial/Term.js +430 -0
- package/output/core/classes/polynomial/adapters.d.ts +18 -0
- package/output/core/classes/polynomial/adapters.js +33 -0
- package/output/core/classes/polynomial/dispatch.d.ts +1 -0
- package/output/core/classes/polynomial/dispatch.js +14 -0
- package/output/core/classes/polynomial/functions.d.ts +77 -0
- package/output/core/classes/polynomial/functions.js +189 -0
- package/output/core/classes/polynomial/utils.d.ts +62 -0
- package/output/core/classes/polynomial/utils.js +207 -0
- package/output/core/classes/rational/Rational.d.ts +501 -0
- package/output/core/classes/rational/Rational.js +829 -0
- package/output/core/classes/seq/SEQ.d.ts +13 -0
- package/output/core/classes/seq/SEQ.js +137 -0
- package/output/core/classes/valuesSet/ValuesSet.d.ts +187 -0
- package/output/core/classes/valuesSet/ValuesSet.js +399 -0
- package/output/core/classes/vector/Vector.d.ts +222 -0
- package/output/core/classes/vector/Vector.js +501 -0
- package/output/core/classes/vector/dispatch.d.ts +1 -0
- package/output/core/classes/vector/dispatch.js +11 -0
- package/output/core/classes/vector/functions.d.ts +28 -0
- package/output/core/classes/vector/functions.js +47 -0
- package/output/core/common/classes/MathematicalAggregate.d.ts +53 -0
- package/output/core/common/classes/MathematicalAggregate.js +149 -0
- package/output/core/common/classes/Scope.d.ts +62 -0
- package/output/core/common/classes/Scope.js +122 -0
- package/output/core/common/classes/StructuredEntity.d.ts +55 -0
- package/output/core/common/classes/StructuredEntity.js +151 -0
- package/output/core/common/common.d.ts +62 -0
- package/output/core/common/common.js +74 -0
- package/output/core/common/functions/functions.d.ts +14 -0
- package/output/core/common/functions/functions.js +33 -0
- package/output/core/common/functions/structuredEntityUtils.d.ts +27 -0
- package/output/core/common/functions/structuredEntityUtils.js +40 -0
- package/output/core/converters/BaseConverter.d.ts +97 -0
- package/output/core/converters/BaseConverter.js +405 -0
- package/output/core/converters/Converter.d.ts +111 -0
- package/output/core/converters/Converter.js +806 -0
- package/output/core/converters/Pattern.d.ts +71 -0
- package/output/core/converters/Pattern.js +302 -0
- package/output/core/dispatch.d.ts +52 -0
- package/output/core/dispatch.js +26 -0
- package/output/core/errors.d.ts +316 -0
- package/output/core/errors.js +349 -0
- package/output/core/fullFunctions.d.ts +7 -0
- package/output/core/fullFunctions.js +31 -0
- package/output/core/functions/bigint/bigint.d.ts +133 -0
- package/output/core/functions/bigint/bigint.js +444 -0
- package/output/core/functions/bigint/primeFactor.d.ts +51 -0
- package/output/core/functions/bigint/primeFactor.js +267 -0
- package/output/core/functions/bigint/primes.d.ts +1 -0
- package/output/core/functions/bigint/primes.js +11 -0
- package/output/core/functions/build/definitions.d.ts +12 -0
- package/output/core/functions/build/definitions.js +139 -0
- package/output/core/functions/build/index.d.ts +32 -0
- package/output/core/functions/build/index.js +136 -0
- package/output/core/functions/complex.d.ts +90 -0
- package/output/core/functions/complex.dispatch.d.ts +1 -0
- package/output/core/functions/complex.dispatch.js +16 -0
- package/output/core/functions/complex.js +482 -0
- package/output/core/functions/decimal.d.ts +24 -0
- package/output/core/functions/decimal.js +665 -0
- package/output/core/functions/expand/expand.d.ts +42 -0
- package/output/core/functions/expand/expand.js +376 -0
- package/output/core/functions/fresnelNumeric.d.ts +12 -0
- package/output/core/functions/fresnelNumeric.js +123 -0
- package/output/core/functions/numeric.d.ts +140 -0
- package/output/core/functions/numeric.js +790 -0
- package/output/core/functions/rationalNormalization.d.ts +11 -0
- package/output/core/functions/rationalNormalization.js +117 -0
- package/output/core/functions/setFunction.d.ts +19 -0
- package/output/core/functions/setFunction.js +75 -0
- package/output/core/functions/string.d.ts +26 -0
- package/output/core/functions/string.js +102 -0
- package/output/core/functions/subst.d.ts +90 -0
- package/output/core/functions/subst.js +506 -0
- package/output/core/functions/utils.d.ts +24 -0
- package/output/core/functions/utils.js +51 -0
- package/output/core/parserFunctions.d.ts +7 -0
- package/output/core/parserFunctions.js +25 -0
- package/output/core/types.d.ts +48 -0
- package/output/core/types.js +2 -0
- package/output/index.d.ts +359 -0
- package/output/index.js +739 -0
- package/output/math/defint/defint.d.ts +18 -0
- package/output/math/defint/defint.js +60 -0
- package/output/math/defint/defintDecimal.d.ts +37 -0
- package/output/math/defint/defintDecimal.js +321 -0
- package/output/math/defint/defintNative.d.ts +57 -0
- package/output/math/defint/defintNative.js +281 -0
- package/output/math/dispatch.d.ts +1 -0
- package/output/math/dispatch.js +101 -0
- package/output/math/geometry.d.ts +12 -0
- package/output/math/geometry.js +55 -0
- package/output/math/math.d.ts +695 -0
- package/output/math/math.js +1955 -0
- package/output/math/trig.d.ts +518 -0
- package/output/math/trig.js +1444 -0
- package/output/math/trunc.d.ts +19 -0
- package/output/math/trunc.js +36 -0
- package/output/math/utils.d.ts +66 -0
- package/output/math/utils.js +219 -0
- package/output/solve/classes/DecimalMatrix.d.ts +17 -0
- package/output/solve/classes/DecimalMatrix.js +86 -0
- package/output/solve/classes/FunctionSolver.d.ts +135 -0
- package/output/solve/classes/FunctionSolver.js +433 -0
- package/output/solve/classes/MultivariateSolver.d.ts +84 -0
- package/output/solve/classes/MultivariateSolver.js +240 -0
- package/output/solve/classes/PolynomialSolver.d.ts +104 -0
- package/output/solve/classes/PolynomialSolver.js +492 -0
- package/output/solve/classes/SolutionSet.d.ts +172 -0
- package/output/solve/classes/SolutionSet.js +434 -0
- package/output/solve/classes/Solver.d.ts +17 -0
- package/output/solve/classes/Solver.js +132 -0
- package/output/solve/classes/SymbolicSolver.d.ts +74 -0
- package/output/solve/classes/SymbolicSolver.js +601 -0
- package/output/solve/dispatch.d.ts +1 -0
- package/output/solve/dispatch.js +13 -0
- package/output/solve/linsolve.d.ts +53 -0
- package/output/solve/linsolve.js +233 -0
- package/output/solve/solve.d.ts +44 -0
- package/output/solve/solve.js +368 -0
- package/output/solve/solveSystem.d.ts +31 -0
- package/output/solve/solveSystem.js +266 -0
- package/output/solve/utils.d.ts +10 -0
- package/output/solve/utils.js +58 -0
- package/output/utils/array.d.ts +42 -0
- package/output/utils/array.js +98 -0
- package/output/utils/debug.d.ts +131 -0
- package/output/utils/debug.js +296 -0
- package/output/utils/decimal.d.ts +3 -0
- package/output/utils/decimal.js +16 -0
- package/output/utils/numeric.d.ts +14 -0
- package/output/utils/numeric.js +51 -0
- package/output/utils/object.d.ts +26 -0
- package/output/utils/object.js +56 -0
- package/package.json +178 -57
- package/.travis.yml +0 -3
- package/Algebra.js +0 -4568
- package/CODE_OF_CONDUCT.md +0 -46
- package/CONTRIBUTING.md +0 -14
- package/Calculus.js +0 -2675
- package/Extra.js +0 -622
- package/Solve.js +0 -1783
- package/all.js +0 -16
- package/all.min.js +0 -1
- package/gulpfile.js +0 -16
- package/index.html +0 -158
- package/license.txt +0 -19
- package/nerdamer.core.js +0 -12510
- package/spec/LaTeX.spec.js +0 -302
- package/spec/TeXConvert.spec.js +0 -8
- package/spec/algebra.spec.js +0 -287
- package/spec/basic_parser.spec.js +0 -134
- package/spec/build.spec.js +0 -131
- package/spec/calculus.spec.js +0 -183
- package/spec/core.spec.js +0 -2970
- package/spec/extra.spec.js +0 -54
- package/spec/solve.spec.js +0 -126
- package/spec/support/jasmine.json +0 -11
- package/spec/support/utils.js +0 -42
- package/spec/text.spec.js +0 -132
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.printRPN = exports.printTokens = void 0;
|
|
4
|
+
exports.createTypesMap = createTypesMap;
|
|
5
|
+
exports.inspectTokens = inspectTokens;
|
|
6
|
+
exports.inspectExpressionData = inspectExpressionData;
|
|
7
|
+
exports.inspectEntity = inspectEntity;
|
|
8
|
+
exports.inspectParse = inspectParse;
|
|
9
|
+
exports.inspectTermData = inspectTermData;
|
|
10
|
+
exports.inspectPolynomialData = inspectPolynomialData;
|
|
11
|
+
exports.printE = printE;
|
|
12
|
+
exports.inspectExpression = inspectExpression;
|
|
13
|
+
exports.inspectTerm = inspectTerm;
|
|
14
|
+
exports.inspectPolynomial = inspectPolynomial;
|
|
15
|
+
exports.hr = hr;
|
|
16
|
+
exports.simpleSerialize = simpleSerialize;
|
|
17
|
+
const Collection_1 = require("../core/classes/collection/Collection");
|
|
18
|
+
const Dictionary_1 = require("../core/classes/dictionary/Dictionary");
|
|
19
|
+
const Equation_1 = require("../core/classes/equation/Equation");
|
|
20
|
+
const Expression_1 = require("../core/classes/expression/Expression");
|
|
21
|
+
const Matrix_1 = require("../core/classes/matrix/Matrix");
|
|
22
|
+
const Parser_1 = require("../core/classes/parser/Parser");
|
|
23
|
+
const preprocess_1 = require("../core/classes/parser/preprocess");
|
|
24
|
+
const Polynomial_1 = require("../core/classes/polynomial/Polynomial");
|
|
25
|
+
const ValuesSet_1 = require("../core/classes/valuesSet/ValuesSet");
|
|
26
|
+
const Vector_1 = require("../core/classes/vector/Vector");
|
|
27
|
+
const Scope_1 = require("../core/common/classes/Scope");
|
|
28
|
+
const dispatch_1 = require("../core/dispatch");
|
|
29
|
+
const errors_1 = require("../core/errors");
|
|
30
|
+
function createTypesMap() {
|
|
31
|
+
const map = {};
|
|
32
|
+
for (const [type, value] of Object.entries(Expression_1.Expression.TYPES)) {
|
|
33
|
+
map[value] = type;
|
|
34
|
+
}
|
|
35
|
+
return map;
|
|
36
|
+
}
|
|
37
|
+
/** Converts a parser token scope to JSON-safe diagnostic data. */
|
|
38
|
+
function inspectTokens(scope) {
|
|
39
|
+
const items = [];
|
|
40
|
+
for (const item of scope) {
|
|
41
|
+
let inspected;
|
|
42
|
+
if (Scope_1.Scope.isScope(item)) {
|
|
43
|
+
inspected = inspectTokens(item);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
inspected = {
|
|
47
|
+
kind: 'token',
|
|
48
|
+
value: item.value,
|
|
49
|
+
type: item.type ?? null,
|
|
50
|
+
position: item.position,
|
|
51
|
+
text: item.toString(),
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
items.push(inspected);
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
kind: 'scope',
|
|
58
|
+
type: scope.type,
|
|
59
|
+
depth: scope.depth,
|
|
60
|
+
column: scope.column,
|
|
61
|
+
isOpen: scope.isOpen,
|
|
62
|
+
implicitMultiply: scope.implicitMultiply,
|
|
63
|
+
deferLHSResolution: scope.deferLHSResolution,
|
|
64
|
+
deferRHSResolution: scope.deferRHSResolution,
|
|
65
|
+
text: scope.text(),
|
|
66
|
+
typedText: scope.text(false),
|
|
67
|
+
items,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
/** Converts an Expression tree to JSON-safe diagnostic data without changing it. */
|
|
71
|
+
function inspectExpressionData(obj) {
|
|
72
|
+
const typesMap = createTypesMap();
|
|
73
|
+
let elements = null;
|
|
74
|
+
let args = null;
|
|
75
|
+
if (obj.elements) {
|
|
76
|
+
elements = {};
|
|
77
|
+
for (const [key, element] of Object.entries(obj.elements)) {
|
|
78
|
+
elements[key] = inspectExpressionData(element);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
if (obj.args) {
|
|
82
|
+
args = obj.args.map(argument => inspectExpressionData(argument));
|
|
83
|
+
}
|
|
84
|
+
return {
|
|
85
|
+
kind: 'Expression',
|
|
86
|
+
type: obj.type,
|
|
87
|
+
typeName: typesMap[obj.type] ?? 'UNKNOWN',
|
|
88
|
+
dataType: obj.dataType,
|
|
89
|
+
text: obj.copy().text(),
|
|
90
|
+
value: obj.value,
|
|
91
|
+
name: obj.name ?? null,
|
|
92
|
+
precision: obj.precision ?? null,
|
|
93
|
+
deferred: obj.deferred,
|
|
94
|
+
multiplier: obj.multiplier ? obj.multiplier.text() : null,
|
|
95
|
+
power: obj.power ? inspectExpressionData(obj.power) : null,
|
|
96
|
+
base: obj.base ? inspectExpressionData(obj.base) : null,
|
|
97
|
+
elements,
|
|
98
|
+
args,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
/** Converts any current parser entity to plain diagnostic data. */
|
|
102
|
+
function inspectEntity(entity) {
|
|
103
|
+
let retval;
|
|
104
|
+
if (Expression_1.Expression.isExpression(entity)) {
|
|
105
|
+
retval = inspectExpressionData(entity);
|
|
106
|
+
}
|
|
107
|
+
else if (Equation_1.Equation.isEquation(entity)) {
|
|
108
|
+
retval = {
|
|
109
|
+
kind: 'Equation',
|
|
110
|
+
dataType: entity.dataType,
|
|
111
|
+
text: entity.copy().text(),
|
|
112
|
+
LHS: inspectExpressionData(entity.LHS),
|
|
113
|
+
RHS: inspectExpressionData(entity.RHS),
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
else if (Vector_1.Vector.isVector(entity)) {
|
|
117
|
+
retval = {
|
|
118
|
+
kind: 'Vector',
|
|
119
|
+
dataType: entity.dataType,
|
|
120
|
+
text: entity.copy().text(),
|
|
121
|
+
elements: entity.elements.map(element => inspectEntity(element)),
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
else if (Matrix_1.Matrix.isMatrix(entity)) {
|
|
125
|
+
retval = {
|
|
126
|
+
kind: 'Matrix',
|
|
127
|
+
dataType: entity.dataType,
|
|
128
|
+
text: entity.copy().text(),
|
|
129
|
+
elements: entity.elements.map(row => row.map(element => inspectExpressionData(element))),
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
else if (ValuesSet_1.ValuesSet.isValuesSet(entity)) {
|
|
133
|
+
retval = {
|
|
134
|
+
kind: 'ValuesSet',
|
|
135
|
+
dataType: entity.dataType,
|
|
136
|
+
text: entity.copy().text(),
|
|
137
|
+
elements: entity.elements.map(element => inspectEntity(element)),
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
else if (Dictionary_1.Dictionary.isDictionary(entity)) {
|
|
141
|
+
retval = {
|
|
142
|
+
kind: 'Dictionary',
|
|
143
|
+
dataType: entity.dataType,
|
|
144
|
+
text: entity.copy().text(),
|
|
145
|
+
entries: entity.entries().map(([key, value]) => ({
|
|
146
|
+
key,
|
|
147
|
+
value: inspectEntity(value),
|
|
148
|
+
})),
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
else if (Collection_1.Collection.isCollection(entity)) {
|
|
152
|
+
retval = {
|
|
153
|
+
kind: 'Collection',
|
|
154
|
+
dataType: entity.dataType,
|
|
155
|
+
text: entity.copy().text(),
|
|
156
|
+
elements: entity.getElements().map(element => inspectEntity(element)),
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
throw new TypeError((0, errors_1.message)('unsupportedParserEntity'));
|
|
161
|
+
}
|
|
162
|
+
return retval;
|
|
163
|
+
}
|
|
164
|
+
/** Inspects one parser input using the same preprocessing as Parser.parse(). */
|
|
165
|
+
function inspectParse(source, values) {
|
|
166
|
+
const normalizedSource = (0, preprocess_1.preprocess)(source, dispatch_1.mathFunctionRegistry);
|
|
167
|
+
const tokenScope = Parser_1.Parser.tokenize(normalizedSource);
|
|
168
|
+
const tokens = inspectTokens(tokenScope);
|
|
169
|
+
const rpn = inspectTokens(Parser_1.Parser.toRPN(tokenScope));
|
|
170
|
+
const result = inspectEntity(Parser_1.Parser.parse(source, values));
|
|
171
|
+
return {
|
|
172
|
+
source,
|
|
173
|
+
normalizedSource,
|
|
174
|
+
tokens,
|
|
175
|
+
rpn,
|
|
176
|
+
result,
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
/** Converts a polynomial Term to JSON-safe diagnostic data without touching its caches. */
|
|
180
|
+
function inspectTermData(t) {
|
|
181
|
+
const multidegree = t.variables.map(variable => t.powers[variable] ?? 0);
|
|
182
|
+
const totalPower = multidegree.reduce((sum, power) => sum + power, 0);
|
|
183
|
+
return {
|
|
184
|
+
kind: 'Term',
|
|
185
|
+
text: t.copy().text(),
|
|
186
|
+
coefficient: inspectExpressionData(t.coeff),
|
|
187
|
+
powers: { ...t.powers },
|
|
188
|
+
multidegree,
|
|
189
|
+
totalPower,
|
|
190
|
+
variables: [...t.variables],
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
/** Converts a Polynomial to JSON-safe diagnostic data. */
|
|
194
|
+
function inspectPolynomialData(p) {
|
|
195
|
+
return {
|
|
196
|
+
kind: 'Polynomial',
|
|
197
|
+
text: new Polynomial_1.Polynomial(p).text(),
|
|
198
|
+
expression: inspectExpressionData(p.expression),
|
|
199
|
+
ordering: p.ordering,
|
|
200
|
+
isMultivariate: p.isMultivariate,
|
|
201
|
+
variables: [...p.variables],
|
|
202
|
+
terms: p.terms.map(term => inspectTermData(term)),
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
// https://stackoverflow.com/questions/57802057/eslint-configuring-no-unused-vars-for-typescript
|
|
206
|
+
function printE(obj) {
|
|
207
|
+
const output = [];
|
|
208
|
+
for (const x in obj) {
|
|
209
|
+
let str = String(obj[x]);
|
|
210
|
+
if (typeof obj === 'object') {
|
|
211
|
+
try {
|
|
212
|
+
// Try to get a better representation that [object Object]
|
|
213
|
+
str = JSON.stringify(obj[x]);
|
|
214
|
+
}
|
|
215
|
+
catch { }
|
|
216
|
+
}
|
|
217
|
+
output.push(`${x}: ${str}`);
|
|
218
|
+
}
|
|
219
|
+
console.log(output.join(', '));
|
|
220
|
+
}
|
|
221
|
+
;
|
|
222
|
+
const printTokens = (tokens, valuesOnly = true) => {
|
|
223
|
+
console.log(tokens.text(valuesOnly));
|
|
224
|
+
};
|
|
225
|
+
exports.printTokens = printTokens;
|
|
226
|
+
const printRPN = (str) => {
|
|
227
|
+
const source = (0, preprocess_1.preprocess)(str, dispatch_1.mathFunctionRegistry);
|
|
228
|
+
(0, exports.printTokens)(Parser_1.Parser.toRPN(Parser_1.Parser.tokenize(source)));
|
|
229
|
+
};
|
|
230
|
+
exports.printRPN = printRPN;
|
|
231
|
+
function inspectExpression(obj, depth = 0) {
|
|
232
|
+
const tab = '\t'.repeat(depth);
|
|
233
|
+
const typesMap = createTypesMap();
|
|
234
|
+
let elementsStr = tab + '{\n';
|
|
235
|
+
if (obj.elements) {
|
|
236
|
+
const elements = obj.getElements();
|
|
237
|
+
for (const x in elements) {
|
|
238
|
+
elementsStr += inspectExpression(elements[x], depth + 1);
|
|
239
|
+
}
|
|
240
|
+
elementsStr += `\n ${tab}}`;
|
|
241
|
+
}
|
|
242
|
+
else {
|
|
243
|
+
elementsStr = 'undefined';
|
|
244
|
+
}
|
|
245
|
+
let argsStr = tab + '[\n';
|
|
246
|
+
if (obj.args) {
|
|
247
|
+
const args = obj.getArguments();
|
|
248
|
+
for (const arg of args) {
|
|
249
|
+
argsStr += inspectExpression(arg, depth + 1);
|
|
250
|
+
}
|
|
251
|
+
argsStr += `\n ${tab}]`;
|
|
252
|
+
}
|
|
253
|
+
else {
|
|
254
|
+
argsStr = 'undefined';
|
|
255
|
+
}
|
|
256
|
+
return `
|
|
257
|
+
${tab}{
|
|
258
|
+
${tab} type: ${typesMap[obj.type]},
|
|
259
|
+
${tab} dataType: ${obj.dataType},
|
|
260
|
+
${tab} precision: ${obj.precision},
|
|
261
|
+
${tab} value: ${obj.value},
|
|
262
|
+
${tab} multiplier: ${obj.multiplier ? obj.multiplier?.text() : obj.multiplier},
|
|
263
|
+
${tab} power: ${obj.power ? obj.power?.text() : obj.power},
|
|
264
|
+
${tab} name: ${obj.name},
|
|
265
|
+
${tab} deferred: ${obj.deferred},
|
|
266
|
+
${tab} elements: ${elementsStr},
|
|
267
|
+
${tab} args: ${argsStr},
|
|
268
|
+
${tab}}`;
|
|
269
|
+
}
|
|
270
|
+
function inspectTerm(t) {
|
|
271
|
+
return `<Term(${t.text()}) coeff: ${t.coeff}, mdg: ${t.getMultidegArray()}, total power: ${t.getTotalPower()}, vars: ${t.variables}>`;
|
|
272
|
+
}
|
|
273
|
+
function inspectPolynomial(p) {
|
|
274
|
+
let terms = '';
|
|
275
|
+
for (const t of p.terms) {
|
|
276
|
+
terms += `\t ${inspectTerm(t)}\n`;
|
|
277
|
+
}
|
|
278
|
+
return `<Polynomial(${p.text()})
|
|
279
|
+
terms:
|
|
280
|
+
${terms}\tLM: ${p.LM()}
|
|
281
|
+
ordering: ${p.ordering}
|
|
282
|
+
>`;
|
|
283
|
+
}
|
|
284
|
+
function hr(symbol = '_', length = 70) {
|
|
285
|
+
console.log(symbol.repeat(length));
|
|
286
|
+
}
|
|
287
|
+
function simpleSerialize(obj) {
|
|
288
|
+
let retval = '{';
|
|
289
|
+
for (const x in obj) {
|
|
290
|
+
retval += `${x}: ${obj[x]},`;
|
|
291
|
+
}
|
|
292
|
+
if (retval.at(-1) === ',') {
|
|
293
|
+
retval = retval.slice(0, -1);
|
|
294
|
+
}
|
|
295
|
+
return retval + '}';
|
|
296
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.gcd = gcd;
|
|
4
|
+
exports.isEven = isEven;
|
|
5
|
+
const decimal_js_1 = require("decimal.js");
|
|
6
|
+
function gcd(a, b) {
|
|
7
|
+
while (!b.equals(0)) {
|
|
8
|
+
const t = a;
|
|
9
|
+
a = b;
|
|
10
|
+
b = t.mod(b);
|
|
11
|
+
}
|
|
12
|
+
return a;
|
|
13
|
+
}
|
|
14
|
+
function isEven(n) {
|
|
15
|
+
return decimal_js_1.Decimal.mod(n, 2).eq(0);
|
|
16
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates a pair of numbers given a set of prime numbers
|
|
3
|
+
* @param factors The list of prime factors to be used to generate the pairs
|
|
4
|
+
* @param target The target number that the pairs must equal
|
|
5
|
+
* @returns
|
|
6
|
+
*/
|
|
7
|
+
export declare function factorPairs(factors: number[], target: number): number[][];
|
|
8
|
+
/**
|
|
9
|
+
* Gets the largest factor pair given a set of prime factors and a target
|
|
10
|
+
* @param factors The list of prime factors to be used to generate the pairs
|
|
11
|
+
* @param target The target number that the pairs must equal
|
|
12
|
+
* @returns
|
|
13
|
+
*/
|
|
14
|
+
export declare function maxPair(factors: number[], target: number): number[];
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.factorPairs = factorPairs;
|
|
4
|
+
exports.maxPair = maxPair;
|
|
5
|
+
/**
|
|
6
|
+
* Generates a pair of numbers given a set of prime numbers
|
|
7
|
+
* @param factors The list of prime factors to be used to generate the pairs
|
|
8
|
+
* @param target The target number that the pairs must equal
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
11
|
+
function factorPairs(factors, target) {
|
|
12
|
+
const products = new Set();
|
|
13
|
+
// Generate all subset products
|
|
14
|
+
function backtrack(index, currentProduct) {
|
|
15
|
+
if (index === factors.length) {
|
|
16
|
+
products.add(currentProduct);
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
// Skip current number
|
|
20
|
+
backtrack(index + 1, currentProduct);
|
|
21
|
+
// Include current number
|
|
22
|
+
backtrack(index + 1, currentProduct * factors[index]);
|
|
23
|
+
}
|
|
24
|
+
backtrack(0, 1);
|
|
25
|
+
const result = [];
|
|
26
|
+
const seen = new Set();
|
|
27
|
+
for (const p of products) {
|
|
28
|
+
if (p > 0 && target % p === 0) {
|
|
29
|
+
const q = target / p;
|
|
30
|
+
const key = Math.min(p, q); // prevent mirrored duplicates
|
|
31
|
+
if (!seen.has(key)) {
|
|
32
|
+
seen.add(key);
|
|
33
|
+
result.push([Math.min(p, q), Math.max(p, q)]);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return result.sort((a, b) => a[0] - b[0]);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Gets the largest factor pair given a set of prime factors and a target
|
|
41
|
+
* @param factors The list of prime factors to be used to generate the pairs
|
|
42
|
+
* @param target The target number that the pairs must equal
|
|
43
|
+
* @returns
|
|
44
|
+
*/
|
|
45
|
+
function maxPair(factors, target) {
|
|
46
|
+
const pair = factorPairs(factors, target).at(-1);
|
|
47
|
+
if (!pair) {
|
|
48
|
+
return [1, target];
|
|
49
|
+
}
|
|
50
|
+
return pair;
|
|
51
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get the first encountered element in an object
|
|
3
|
+
*
|
|
4
|
+
* @param obj Any object
|
|
5
|
+
* @returns The first element encountered
|
|
6
|
+
*/
|
|
7
|
+
export declare function anyObject<T>(obj: Record<string, T>): T | undefined;
|
|
8
|
+
/**
|
|
9
|
+
* Converts an array to an object with the key specified as a callback.
|
|
10
|
+
*
|
|
11
|
+
* @param arr
|
|
12
|
+
* @param key
|
|
13
|
+
* @returns
|
|
14
|
+
*/
|
|
15
|
+
export declare function arrayToObject<T>(arr: T[], key: (k: T, i: number) => number | string): Record<string | number, T>;
|
|
16
|
+
/**
|
|
17
|
+
* Generates a random object that can be used to evaluate a function
|
|
18
|
+
*
|
|
19
|
+
* @param vars
|
|
20
|
+
* @param min
|
|
21
|
+
* @param max
|
|
22
|
+
* @returns
|
|
23
|
+
*/
|
|
24
|
+
export declare function randomEvalObj(vars: string[], min?: number, max?: number): {
|
|
25
|
+
[variable: string]: number;
|
|
26
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Get the first encountered element in an object
|
|
4
|
+
*
|
|
5
|
+
* @param obj Any object
|
|
6
|
+
* @returns The first element encountered
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.anyObject = anyObject;
|
|
10
|
+
exports.arrayToObject = arrayToObject;
|
|
11
|
+
exports.randomEvalObj = randomEvalObj;
|
|
12
|
+
const numeric_1 = require("../core/functions/numeric");
|
|
13
|
+
function anyObject(obj) {
|
|
14
|
+
for (const x in obj) {
|
|
15
|
+
return obj[x];
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Converts an array to an object with the key specified as a callback.
|
|
20
|
+
*
|
|
21
|
+
* @param arr
|
|
22
|
+
* @param key
|
|
23
|
+
* @returns
|
|
24
|
+
*/
|
|
25
|
+
function arrayToObject(arr, key) {
|
|
26
|
+
const obj = {};
|
|
27
|
+
for (let i = 0; i < arr.length; i++) {
|
|
28
|
+
const e = arr[i];
|
|
29
|
+
obj[key(e, i)] = e;
|
|
30
|
+
}
|
|
31
|
+
return obj;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Generates a random object that can be used to evaluate a function
|
|
35
|
+
*
|
|
36
|
+
* @param vars
|
|
37
|
+
* @param min
|
|
38
|
+
* @param max
|
|
39
|
+
* @returns
|
|
40
|
+
*/
|
|
41
|
+
function randomEvalObj(vars, min = 2, max) {
|
|
42
|
+
const evalObj = {};
|
|
43
|
+
max ??= (vars.length + 2) * 2;
|
|
44
|
+
// Avoid duplicate numbers
|
|
45
|
+
const values = [];
|
|
46
|
+
for (const v of vars) {
|
|
47
|
+
let randomInt = (0, numeric_1.getRandomInt)(min, max);
|
|
48
|
+
// Select a random number which hasn't been chosen already
|
|
49
|
+
while (values.includes(randomInt)) {
|
|
50
|
+
randomInt = (0, numeric_1.getRandomInt)(min, max);
|
|
51
|
+
}
|
|
52
|
+
values.push(randomInt);
|
|
53
|
+
evalObj[v] = randomInt;
|
|
54
|
+
}
|
|
55
|
+
return evalObj;
|
|
56
|
+
}
|