nerdamer 1.1.13 → 2.0.0-rc.1
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/LICENSE.md +184 -0
- package/README.md +293 -312
- 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 +1960 -0
- package/index.d.ts +10 -426
- package/output/algebra/adapters.d.ts +33 -0
- package/output/algebra/adapters.js +109 -0
- package/output/algebra/algorithms/arith.d.ts +84 -0
- package/output/algebra/algorithms/arith.js +323 -0
- package/output/algebra/algorithms/factor.d.ts +3 -0
- package/output/algebra/algorithms/factor.js +5 -0
- package/output/algebra/algorithms/factorMultivariate.d.ts +23 -0
- package/output/algebra/algorithms/factorMultivariate.js +2393 -0
- package/output/algebra/algorithms/factorUnivariate.d.ts +72 -0
- package/output/algebra/algorithms/factorUnivariate.js +1072 -0
- package/output/algebra/algorithms/gcd.d.ts +22 -0
- package/output/algebra/algorithms/gcd.js +690 -0
- package/output/algebra/algorithms/groebnerBase.d.ts +157 -0
- package/output/algebra/algorithms/groebnerBase.js +1166 -0
- package/output/algebra/algorithms/multiPoly/MultiPoly.d.ts +137 -0
- package/output/algebra/algorithms/multiPoly/MultiPoly.js +346 -0
- package/output/algebra/algorithms/poly.d.ts +228 -0
- package/output/algebra/algorithms/poly.js +1299 -0
- package/output/algebra/algorithms/rational.d.ts +17 -0
- package/output/algebra/algorithms/rational.js +115 -0
- package/output/algebra/factor/factor.d.ts +62 -0
- package/output/algebra/factor/factor.js +158 -0
- package/output/algebra/gcd/gcd.d.ts +29 -0
- package/output/algebra/gcd/gcd.js +141 -0
- package/output/algebra/groebner.d.ts +21 -0
- package/output/algebra/groebner.js +42 -0
- package/output/algebra/partfrac.d.ts +19 -0
- package/output/algebra/partfrac.js +398 -0
- package/output/algebra/polynomialize.d.ts +20 -0
- package/output/algebra/polynomialize.js +24 -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 +228 -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 +7 -0
- package/output/api/advanced.js +18 -0
- package/output/api/algebra.d.ts +17 -0
- package/output/api/algebra.js +32 -0
- package/output/api/assumptions.d.ts +4 -0
- package/output/api/assumptions.js +11 -0
- package/output/api/calculus.d.ts +9 -0
- package/output/api/calculus.js +21 -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/parser.d.ts +85 -0
- package/output/api/parser.js +16 -0
- package/output/api/solve.d.ts +10 -0
- package/output/api/solve.js +16 -0
- package/output/api/structures.d.ts +10 -0
- package/output/api/structures.js +22 -0
- package/output/calculus/derivative/diff.d.ts +30 -0
- package/output/calculus/derivative/diff.js +238 -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/adapters.d.ts +18 -0
- package/output/core/adapters.js +40 -0
- package/output/core/classes/assumption/Assumption.d.ts +218 -0
- package/output/core/classes/assumption/Assumption.js +605 -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/collection/Collection.d.ts +107 -0
- package/output/core/classes/collection/Collection.js +231 -0
- package/output/core/classes/complex/Complex.d.ts +99 -0
- package/output/core/classes/complex/Complex.js +135 -0
- package/output/core/classes/decimalSet/DecimalSet.d.ts +226 -0
- package/output/core/classes/decimalSet/DecimalSet.js +453 -0
- package/output/core/classes/dictionary/Dictionary.d.ts +102 -0
- package/output/core/classes/dictionary/Dictionary.js +213 -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 +198 -0
- package/output/core/classes/expression/Expression.d.ts +1674 -0
- package/output/core/classes/expression/Expression.js +2332 -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 +45 -0
- package/output/core/classes/expression/format.js +217 -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 +52 -0
- package/output/core/classes/expression/utils.js +189 -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 +889 -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/functions.d.ts +26 -0
- package/output/core/classes/matrix/functions.js +52 -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 +480 -0
- package/output/core/classes/parser/Parser.js +1812 -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 +160 -0
- package/output/core/classes/parser/constants.js +227 -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 +238 -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 +461 -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 +430 -0
- package/output/core/classes/parser/operations/multiply.d.ts +11 -0
- package/output/core/classes/parser/operations/multiply.js +321 -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 +35 -0
- package/output/core/classes/parser/preprocess.d.ts +14 -0
- package/output/core/classes/parser/preprocess.js +259 -0
- package/output/core/classes/parser/scripting/controlFlow.d.ts +121 -0
- package/output/core/classes/parser/scripting/controlFlow.js +355 -0
- package/output/core/classes/parser/scripting/evaluate.d.ts +10 -0
- package/output/core/classes/parser/scripting/evaluate.js +112 -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 +35 -0
- package/output/core/classes/parser/scripting/scope.js +155 -0
- package/output/core/classes/parser/types.d.ts +125 -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 +500 -0
- package/output/core/classes/polynomial/Polynomial.js +1149 -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/functions.d.ts +69 -0
- package/output/core/classes/polynomial/functions.js +126 -0
- package/output/core/classes/polynomial/utils.d.ts +62 -0
- package/output/core/classes/polynomial/utils.js +206 -0
- package/output/core/classes/rational/Rational.d.ts +504 -0
- package/output/core/classes/rational/Rational.js +779 -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 +179 -0
- package/output/core/classes/valuesSet/ValuesSet.js +381 -0
- package/output/core/classes/vector/Vector.d.ts +222 -0
- package/output/core/classes/vector/Vector.js +497 -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 +140 -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 +63 -0
- package/output/core/common/common.js +279 -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 +802 -0
- package/output/core/converters/Pattern.d.ts +71 -0
- package/output/core/converters/Pattern.js +302 -0
- package/output/core/dispatch.d.ts +34 -0
- package/output/core/dispatch.js +304 -0
- package/output/core/errors.d.ts +531 -0
- package/output/core/errors.js +621 -0
- package/output/core/functions/bigint/bigint.d.ts +121 -0
- package/output/core/functions/bigint/bigint.js +392 -0
- package/output/core/functions/bigint/primeFactor.d.ts +49 -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 +133 -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.js +482 -0
- package/output/core/functions/decimal.d.ts +24 -0
- package/output/core/functions/decimal.js +664 -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 +101 -0
- package/output/core/functions/subst.d.ts +90 -0
- package/output/core/functions/subst.js +498 -0
- package/output/core/functions/utils.d.ts +24 -0
- package/output/core/functions/utils.js +51 -0
- package/output/core/types.d.ts +48 -0
- package/output/core/types.js +2 -0
- package/output/index.d.ts +339 -0
- package/output/index.js +715 -0
- package/output/math/defint/defintDecimal.d.ts +37 -0
- package/output/math/defint/defintDecimal.js +320 -0
- package/output/math/defint/defintNative.d.ts +57 -0
- package/output/math/defint/defintNative.js +292 -0
- package/output/math/geometry.d.ts +8 -0
- package/output/math/geometry.js +32 -0
- package/output/math/math.d.ts +655 -0
- package/output/math/math.js +1811 -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 +60 -0
- package/output/math/utils.js +180 -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 +85 -0
- package/output/solve/classes/PolynomialSolver.js +292 -0
- package/output/solve/classes/SolutionSet.d.ts +153 -0
- package/output/solve/classes/SolutionSet.js +357 -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/linsolve.d.ts +51 -0
- package/output/solve/linsolve.js +225 -0
- package/output/solve/solve.d.ts +34 -0
- package/output/solve/solve.js +260 -0
- package/output/solve/solveSystem.d.ts +31 -0
- package/output/solve/solveSystem.js +290 -0
- package/output/solve/utils.d.ts +9 -0
- package/output/solve/utils.js +62 -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 +295 -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 +213 -57
- package/.travis.yml +0 -3
- package/Algebra.js +0 -4568
- package/BREAKING_CHANGES.md +0 -5
- 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,290 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.solveSystem = solveSystem;
|
|
4
|
+
const adapters_1 = require("../algebra/adapters");
|
|
5
|
+
const groebnerBase_1 = require("../algebra/algorithms/groebnerBase");
|
|
6
|
+
const ratsimp_1 = require("../algebra/simplify/ratsimp");
|
|
7
|
+
const Dictionary_1 = require("../core/classes/dictionary/Dictionary");
|
|
8
|
+
const Equation_1 = require("../core/classes/equation/Equation");
|
|
9
|
+
const analysis_1 = require("../core/classes/expression/analysis");
|
|
10
|
+
const collect_1 = require("../core/classes/expression/collect");
|
|
11
|
+
const Expression_1 = require("../core/classes/expression/Expression");
|
|
12
|
+
const shortcuts_1 = require("../core/classes/expression/shortcuts");
|
|
13
|
+
const constants_1 = require("../core/classes/parser/constants");
|
|
14
|
+
const Parser_1 = require("../core/classes/parser/Parser");
|
|
15
|
+
const Polynomial_1 = require("../core/classes/polynomial/Polynomial");
|
|
16
|
+
const Vector_1 = require("../core/classes/vector/Vector");
|
|
17
|
+
const errors_1 = require("../core/errors");
|
|
18
|
+
const MultivariateSolver_1 = require("./classes/MultivariateSolver");
|
|
19
|
+
const linsolve_1 = require("./linsolve");
|
|
20
|
+
const solve_1 = require("./solve");
|
|
21
|
+
function toExpression(input) {
|
|
22
|
+
if (Equation_1.Equation.isEquation(input)) {
|
|
23
|
+
return input.toLHS().LHS;
|
|
24
|
+
}
|
|
25
|
+
if (Expression_1.Expression.isExpression(input)) {
|
|
26
|
+
return input;
|
|
27
|
+
}
|
|
28
|
+
const parsed = Parser_1.Parser.parse(String(input));
|
|
29
|
+
if (Equation_1.Equation.isEquation(parsed)) {
|
|
30
|
+
return parsed.toLHS().LHS;
|
|
31
|
+
}
|
|
32
|
+
if (Expression_1.Expression.isExpression(parsed)) {
|
|
33
|
+
return parsed;
|
|
34
|
+
}
|
|
35
|
+
throw new errors_1.UnexpectedInputError((0, errors_1.message)('expressionExpected', { type: constants_1.dataTypes[parsed.dataType] }));
|
|
36
|
+
}
|
|
37
|
+
function normalizeEquations(equations) {
|
|
38
|
+
if (Vector_1.Vector.isVector(equations)) {
|
|
39
|
+
const result = [];
|
|
40
|
+
for (let i = 0; i < equations.count(); i++) {
|
|
41
|
+
result.push(toExpression(equations.__get__([i])));
|
|
42
|
+
}
|
|
43
|
+
return result;
|
|
44
|
+
}
|
|
45
|
+
return equations.map(eq => toExpression(eq));
|
|
46
|
+
}
|
|
47
|
+
function symbolicBackSubstitution(basisExprs, vars) {
|
|
48
|
+
let partials = [
|
|
49
|
+
{ assignment: new Map(), basis: basisExprs },
|
|
50
|
+
];
|
|
51
|
+
for (let i = vars.length - 1; i >= 0; i--) {
|
|
52
|
+
const v = vars[i];
|
|
53
|
+
const unsolved = new Set(vars.slice(0, i));
|
|
54
|
+
const nextPartials = [];
|
|
55
|
+
for (const { assignment, basis } of partials) {
|
|
56
|
+
const univariates = basis.filter(expr => {
|
|
57
|
+
if (expr.isZero()) {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
const exprVars = expr.variables();
|
|
61
|
+
if (!exprVars.includes(v)) {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
for (const ev of exprVars) {
|
|
65
|
+
if (unsolved.has(ev)) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return true;
|
|
70
|
+
});
|
|
71
|
+
if (univariates.length === 0) {
|
|
72
|
+
nextPartials.push({ assignment: new Map(assignment), basis });
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
const solutions = (0, solve_1.solve)(univariates[0], v);
|
|
76
|
+
const roots = solutions.elements;
|
|
77
|
+
for (const root of roots) {
|
|
78
|
+
let consistent = true;
|
|
79
|
+
for (let k = 1; k < univariates.length; k++) {
|
|
80
|
+
const substituted = univariates[k].subst(v, root);
|
|
81
|
+
if (substituted.isConstant() && !substituted.isNearlyZero()) {
|
|
82
|
+
consistent = false;
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
if (!consistent) {
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
const newBasis = basis.map(expr => {
|
|
90
|
+
if (!expr.hasVariable(v)) {
|
|
91
|
+
return expr;
|
|
92
|
+
}
|
|
93
|
+
const exprVars = expr.variables();
|
|
94
|
+
const hasUnsolvedVars = exprVars.some(ev => unsolved.has(ev));
|
|
95
|
+
if (!hasUnsolvedVars && exprVars.length === 1 && exprVars[0] === v) {
|
|
96
|
+
return (0, shortcuts_1.zero)();
|
|
97
|
+
}
|
|
98
|
+
return expr.subst(v, root);
|
|
99
|
+
});
|
|
100
|
+
const ext = new Map(assignment);
|
|
101
|
+
ext.set(v, root);
|
|
102
|
+
nextPartials.push({ assignment: ext, basis: newBasis });
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
partials = nextPartials;
|
|
106
|
+
}
|
|
107
|
+
return partials.map(p => p.assignment);
|
|
108
|
+
}
|
|
109
|
+
function solutionsToDictionaries(solutions, vars) {
|
|
110
|
+
const dictionaries = [];
|
|
111
|
+
for (const solution of solutions) {
|
|
112
|
+
if (solution.size !== vars.length) {
|
|
113
|
+
throw new errors_1.UnsupportedOperationError((0, errors_1.message)('solveSystemInfiniteSolutions'));
|
|
114
|
+
}
|
|
115
|
+
const dictionary = new Dictionary_1.Dictionary();
|
|
116
|
+
for (const variable of vars) {
|
|
117
|
+
const value = solution.get(variable);
|
|
118
|
+
if (!value) {
|
|
119
|
+
throw new errors_1.UnsupportedOperationError((0, errors_1.message)('solveSystemInfiniteSolutions'));
|
|
120
|
+
}
|
|
121
|
+
dictionary.set(variable, value);
|
|
122
|
+
}
|
|
123
|
+
dictionaries.push(dictionary);
|
|
124
|
+
}
|
|
125
|
+
return dictionaries;
|
|
126
|
+
}
|
|
127
|
+
function isSystemSolution(expressions, domainRestrictions, solution) {
|
|
128
|
+
const values = {};
|
|
129
|
+
for (const [variable, value] of solution) {
|
|
130
|
+
values[variable] = value;
|
|
131
|
+
}
|
|
132
|
+
let retval = true;
|
|
133
|
+
try {
|
|
134
|
+
// A cleared denominator remains part of the original equation's domain.
|
|
135
|
+
// If it cannot be shown to be nonzero for this candidate, the rewrite is not
|
|
136
|
+
// sufficient to certify the candidate as a solution.
|
|
137
|
+
for (const restriction of domainRestrictions) {
|
|
138
|
+
const evaluated = restriction.evaluate(values);
|
|
139
|
+
if (!evaluated.isConstant() || evaluated.isZero()) {
|
|
140
|
+
retval = false;
|
|
141
|
+
break;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
if (retval) {
|
|
145
|
+
for (const expression of expressions) {
|
|
146
|
+
const evaluated = expression.evaluate(values);
|
|
147
|
+
if (!evaluated.isConstant() || !evaluated.isNearlyZero()) {
|
|
148
|
+
retval = false;
|
|
149
|
+
break;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
catch {
|
|
155
|
+
retval = false;
|
|
156
|
+
}
|
|
157
|
+
return retval;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Solves a system of expressions or equations for an ordered set of variables.
|
|
161
|
+
*
|
|
162
|
+
* Expressions are interpreted as equal to zero. The solver first tries exact
|
|
163
|
+
* linear reduction, then a lexicographic Groebner basis with symbolic back
|
|
164
|
+
* substitution for polynomial systems, and finally multivariate Newton-Raphson
|
|
165
|
+
* over a fixed search interval. Rational polynomial systems may have denominators
|
|
166
|
+
* cleared for symbolic work; candidates are checked against the original domain.
|
|
167
|
+
*
|
|
168
|
+
* @remarks
|
|
169
|
+
* The nonlinear numerical fallback is heuristic and does not guarantee all
|
|
170
|
+
* roots. A returned outer {@link Vector} contains one {@link Dictionary} per
|
|
171
|
+
* solution. An empty system has one empty solution, while no discovered or
|
|
172
|
+
* inconsistent solution is represented by an empty Vector.
|
|
173
|
+
*
|
|
174
|
+
* Infinite nonlinear solution sets are not represented. Underdetermined
|
|
175
|
+
* systems that reach numerical fallback are rejected.
|
|
176
|
+
*
|
|
177
|
+
* @param equations - Vector or array of equations and zero-valued expressions.
|
|
178
|
+
* @param variables - Optional variable order. When omitted, variables are
|
|
179
|
+
* collected from the normalized expressions.
|
|
180
|
+
* @returns A Vector of solution dictionaries keyed by variable name.
|
|
181
|
+
* @throws {@link core!UnexpectedInputError} If an input cannot be normalized to an
|
|
182
|
+
* Expression or Equation.
|
|
183
|
+
* @throws {@link core!UnsupportedOperationError} If a solution is not isolated or an
|
|
184
|
+
* underdetermined nonlinear system reaches numerical fallback.
|
|
185
|
+
*/
|
|
186
|
+
function solveSystem(equations, variables) {
|
|
187
|
+
const expressions = normalizeEquations(equations);
|
|
188
|
+
if (expressions.length === 0) {
|
|
189
|
+
return new Vector_1.Vector([new Dictionary_1.Dictionary()]);
|
|
190
|
+
}
|
|
191
|
+
const vars = variables ?? (0, collect_1.collectVariablesSet)(expressions);
|
|
192
|
+
if (vars.length === 0) {
|
|
193
|
+
return expressions.every(e => e.isZero()) ? new Vector_1.Vector([new Dictionary_1.Dictionary()]) : new Vector_1.Vector([]);
|
|
194
|
+
}
|
|
195
|
+
// Rational equations can still be polynomial equations after their denominators are
|
|
196
|
+
// cleared. Keep the original expressions for domain checks and numerical fallback,
|
|
197
|
+
// and only use the rewritten forms for symbolic solving.
|
|
198
|
+
const symbolicExpressions = [];
|
|
199
|
+
const domainRestrictions = [];
|
|
200
|
+
let hasRationalRewrite = false;
|
|
201
|
+
for (const expression of expressions) {
|
|
202
|
+
let symbolicExpression = expression;
|
|
203
|
+
if (!expression.isPolynomialLike()) {
|
|
204
|
+
const rational = (0, ratsimp_1.toCommonDenominator)(expression);
|
|
205
|
+
const numerator = rational.getNumerator().expand();
|
|
206
|
+
const denominator = rational.getDenominator().expand();
|
|
207
|
+
if (!denominator.isOne() &&
|
|
208
|
+
numerator.isPolynomialLike() &&
|
|
209
|
+
denominator.isPolynomialLike()) {
|
|
210
|
+
symbolicExpression = numerator;
|
|
211
|
+
domainRestrictions.push(denominator);
|
|
212
|
+
hasRationalRewrite = true;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
symbolicExpressions.push(symbolicExpression);
|
|
216
|
+
}
|
|
217
|
+
// 1. Try linear solver
|
|
218
|
+
try {
|
|
219
|
+
const linear = (0, linsolve_1.solveLinearSystem)(symbolicExpressions, vars);
|
|
220
|
+
if (linear.type === 'inconsistent') {
|
|
221
|
+
return new Vector_1.Vector([]);
|
|
222
|
+
}
|
|
223
|
+
if (linear.type === 'infinite') {
|
|
224
|
+
if (!hasRationalRewrite) {
|
|
225
|
+
const dictionary = new Dictionary_1.Dictionary();
|
|
226
|
+
for (const variable of vars) {
|
|
227
|
+
if (variable in linear.solutions) {
|
|
228
|
+
dictionary.set(variable, linear.solutions[variable]);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
return new Vector_1.Vector([dictionary]);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
else {
|
|
235
|
+
const dictionary = new Dictionary_1.Dictionary();
|
|
236
|
+
const solution = new Map();
|
|
237
|
+
for (const variable of vars) {
|
|
238
|
+
if (variable in linear.solutions) {
|
|
239
|
+
const value = linear.solutions[variable];
|
|
240
|
+
dictionary.set(variable, value);
|
|
241
|
+
solution.set(variable, value);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
if (!hasRationalRewrite || isSystemSolution(expressions, domainRestrictions, solution)) {
|
|
245
|
+
return new Vector_1.Vector([dictionary]);
|
|
246
|
+
}
|
|
247
|
+
return new Vector_1.Vector([]);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
catch (error) {
|
|
251
|
+
if (!(error instanceof Error) || !error.message.includes('Nonlinear term detected')) {
|
|
252
|
+
throw error;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
// 2. Nonlinear polynomial: Gröbner basis + symbolic back-substitution
|
|
256
|
+
const allPolynomial = symbolicExpressions.every(e => e.isPolynomialLike());
|
|
257
|
+
if (allPolynomial) {
|
|
258
|
+
try {
|
|
259
|
+
const polys = symbolicExpressions.map(expression => {
|
|
260
|
+
const cleared = (0, analysis_1.normalizeMultiplierDenominators)(expression);
|
|
261
|
+
return (0, adapters_1.polynomialToMultiPoly)(new Polynomial_1.Polynomial(cleared, vars), vars).poly;
|
|
262
|
+
});
|
|
263
|
+
const basis = (0, groebnerBase_1.Groebner)(polys, vars, 'LEX', true);
|
|
264
|
+
if (basis.length === 1 && basis[0].isConstant() && basis[0].constantTerm() !== 0n) {
|
|
265
|
+
return new Vector_1.Vector([]);
|
|
266
|
+
}
|
|
267
|
+
const basisExprs = basis.map(p => (0, adapters_1.multiPolyToExpression)(p, vars));
|
|
268
|
+
let solutions = symbolicBackSubstitution(basisExprs, vars);
|
|
269
|
+
if (hasRationalRewrite) {
|
|
270
|
+
solutions = solutions.filter(solution => isSystemSolution(expressions, domainRestrictions, solution));
|
|
271
|
+
}
|
|
272
|
+
if (solutions.length > 0) {
|
|
273
|
+
return new Vector_1.Vector(solutionsToDictionaries(solutions, vars));
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
catch {
|
|
277
|
+
// Fall through to numeric solver
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
// 3. Numeric fallback: multivariate Newton-Raphson
|
|
281
|
+
if (expressions.length < vars.length) {
|
|
282
|
+
throw new errors_1.UnsupportedOperationError((0, errors_1.message)('solveSystemInfiniteSolutions'));
|
|
283
|
+
}
|
|
284
|
+
const solver = new MultivariateSolver_1.MultivariateSolver(expressions, vars);
|
|
285
|
+
const numericSolutions = solver.roots();
|
|
286
|
+
if (numericSolutions.length === 0) {
|
|
287
|
+
return new Vector_1.Vector([]);
|
|
288
|
+
}
|
|
289
|
+
return new Vector_1.Vector(solutionsToDictionaries(numericSolutions, vars));
|
|
290
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Equation } from '../core/classes/equation/Equation';
|
|
2
|
+
import { Expression } from '../core/classes/expression/Expression';
|
|
3
|
+
import type { ExpressionInput } from '../core/types';
|
|
4
|
+
export interface SolverInputs {
|
|
5
|
+
x: string;
|
|
6
|
+
expression: Expression;
|
|
7
|
+
}
|
|
8
|
+
export declare function extractVariable(variable: ExpressionInput): string;
|
|
9
|
+
export declare function prepareSolverInputs(input: ExpressionInput | Equation | string, variable?: ExpressionInput): SolverInputs;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.extractVariable = extractVariable;
|
|
4
|
+
exports.prepareSolverInputs = prepareSolverInputs;
|
|
5
|
+
const Equation_1 = require("../core/classes/equation/Equation");
|
|
6
|
+
const Expression_1 = require("../core/classes/expression/Expression");
|
|
7
|
+
const constants_1 = require("../core/classes/parser/constants");
|
|
8
|
+
const Parser_1 = require("../core/classes/parser/Parser");
|
|
9
|
+
const errors_1 = require("../core/errors");
|
|
10
|
+
function extractVariable(variable) {
|
|
11
|
+
variable = Expression_1.Expression.create(variable);
|
|
12
|
+
if (!variable.isPlainVariable()) {
|
|
13
|
+
throw new errors_1.UnexpectedInputError((0, errors_1.message)('plainVariableExpected', { input: variable.text() }));
|
|
14
|
+
}
|
|
15
|
+
return variable.value;
|
|
16
|
+
}
|
|
17
|
+
function prepareSolverInputs(input, variable) {
|
|
18
|
+
let expression;
|
|
19
|
+
if (Equation_1.Equation.isEquation(input)) {
|
|
20
|
+
expression = input.toLHS().LHS;
|
|
21
|
+
}
|
|
22
|
+
else if (!Expression_1.Expression.isExpression(input)) {
|
|
23
|
+
// Cast them all to string
|
|
24
|
+
const parsed = Parser_1.Parser.parse(String(input));
|
|
25
|
+
// Was it an equation string?
|
|
26
|
+
if (Equation_1.Equation.isEquation(parsed)) {
|
|
27
|
+
expression = parsed.toLHS().LHS;
|
|
28
|
+
}
|
|
29
|
+
else if (!Expression_1.Expression.isExpression(parsed)) {
|
|
30
|
+
// Complain for any other types
|
|
31
|
+
throw new errors_1.UnexpectedInputError((0, errors_1.message)('expressionExpected', { type: constants_1.dataTypes[parsed.dataType] }));
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
expression = parsed;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
expression = input;
|
|
39
|
+
}
|
|
40
|
+
const vars = expression.variables();
|
|
41
|
+
let x;
|
|
42
|
+
// Get the variable to solve for
|
|
43
|
+
if (!variable) {
|
|
44
|
+
if (vars.length === 1) {
|
|
45
|
+
x = vars[0];
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
throw new errors_1.UnexpectedInputError((0, errors_1.message)('tooManyUnknowns'));
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
x = extractVariable(variable);
|
|
53
|
+
if (x && vars[0] && !vars.includes(x)) {
|
|
54
|
+
// Rethink. Throw a better error message.
|
|
55
|
+
throw new errors_1.UnexpectedInputError((0, errors_1.message)('tooManyUnknowns'));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
expression,
|
|
60
|
+
x,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Removes an element from an array
|
|
3
|
+
* @param arr
|
|
4
|
+
* @param value
|
|
5
|
+
* @returns
|
|
6
|
+
*/
|
|
7
|
+
export declare function remove<T>(arr: T[], value: T): T[];
|
|
8
|
+
/**
|
|
9
|
+
* Checks if two array are equal/having the same elements
|
|
10
|
+
*
|
|
11
|
+
* @param arr1
|
|
12
|
+
* @param arr2
|
|
13
|
+
* @returns
|
|
14
|
+
*/
|
|
15
|
+
export declare function isEqualArray<T>(arr1: T[], arr2: T[]): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Combines an array and sorts it
|
|
18
|
+
*
|
|
19
|
+
* @param a
|
|
20
|
+
* @param b
|
|
21
|
+
* @returns
|
|
22
|
+
*/
|
|
23
|
+
export declare function combinedArray<T>(a: T[], b: T[]): T[];
|
|
24
|
+
/**
|
|
25
|
+
* IMPROVE: Look into using Set.intersection
|
|
26
|
+
* Gets the intersection of two arrays. This can probably be replaced with Set.intersection in the future
|
|
27
|
+
*
|
|
28
|
+
* @param arr1
|
|
29
|
+
* @param arr2
|
|
30
|
+
* @returns
|
|
31
|
+
*/
|
|
32
|
+
export declare function intersection<T>(arr1: T[], arr2: T[]): T[];
|
|
33
|
+
/**
|
|
34
|
+
* Sorts two arrays in the same other maintaining the indices of the values
|
|
35
|
+
*
|
|
36
|
+
* @param arr1
|
|
37
|
+
* @param arr2
|
|
38
|
+
* @param compareFn
|
|
39
|
+
* @returns
|
|
40
|
+
*/
|
|
41
|
+
export declare function syncSort<T>(arr1: T[], arr2: T[], compareFn: (a: T, b: T) => number): T[][];
|
|
42
|
+
export declare function allEqual<T>(arr: T[]): boolean;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* --------------------- ABOUT THIS LIB --------------------- */
|
|
3
|
+
// This library ideally does not utilize any of the classes in nerdamer and sticks to pure TypeScript
|
|
4
|
+
// Use core.math.utils instead if it's a library specific utility function.
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.remove = remove;
|
|
7
|
+
exports.isEqualArray = isEqualArray;
|
|
8
|
+
exports.combinedArray = combinedArray;
|
|
9
|
+
exports.intersection = intersection;
|
|
10
|
+
exports.syncSort = syncSort;
|
|
11
|
+
exports.allEqual = allEqual;
|
|
12
|
+
/**
|
|
13
|
+
* Removes an element from an array
|
|
14
|
+
* @param arr
|
|
15
|
+
* @param value
|
|
16
|
+
* @returns
|
|
17
|
+
*/
|
|
18
|
+
function remove(arr, value) {
|
|
19
|
+
const index = arr.indexOf(value);
|
|
20
|
+
if (index > -1) {
|
|
21
|
+
arr.splice(index, 1);
|
|
22
|
+
}
|
|
23
|
+
return arr;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Checks if two array are equal/having the same elements
|
|
27
|
+
*
|
|
28
|
+
* @param arr1
|
|
29
|
+
* @param arr2
|
|
30
|
+
* @returns
|
|
31
|
+
*/
|
|
32
|
+
function isEqualArray(arr1, arr2) {
|
|
33
|
+
// If they're not the same length then we're done
|
|
34
|
+
if (arr1.length !== arr2.length) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
// Check each element
|
|
38
|
+
for (const a of arr1) {
|
|
39
|
+
if (!arr2.includes(a)) {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Combines an array and sorts it
|
|
47
|
+
*
|
|
48
|
+
* @param a
|
|
49
|
+
* @param b
|
|
50
|
+
* @returns
|
|
51
|
+
*/
|
|
52
|
+
function combinedArray(a, b) {
|
|
53
|
+
return [...new Set(a.concat(b))].sort();
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* IMPROVE: Look into using Set.intersection
|
|
57
|
+
* Gets the intersection of two arrays. This can probably be replaced with Set.intersection in the future
|
|
58
|
+
*
|
|
59
|
+
* @param arr1
|
|
60
|
+
* @param arr2
|
|
61
|
+
* @returns
|
|
62
|
+
*/
|
|
63
|
+
function intersection(arr1, arr2) {
|
|
64
|
+
// Ensure that we're looping over the shorter array
|
|
65
|
+
if (arr1.length > arr2.length) {
|
|
66
|
+
return intersection(arr2, arr1);
|
|
67
|
+
}
|
|
68
|
+
const retval = [];
|
|
69
|
+
for (const e of arr1) {
|
|
70
|
+
if (arr2.includes(e)) {
|
|
71
|
+
retval.push(e);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return retval;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Sorts two arrays in the same other maintaining the indices of the values
|
|
78
|
+
*
|
|
79
|
+
* @param arr1
|
|
80
|
+
* @param arr2
|
|
81
|
+
* @param compareFn
|
|
82
|
+
* @returns
|
|
83
|
+
*/
|
|
84
|
+
function syncSort(arr1, arr2, compareFn) {
|
|
85
|
+
const indices = arr1.map((_, index) => index);
|
|
86
|
+
indices.sort((a, b) => compareFn(arr1[a], arr1[b]));
|
|
87
|
+
const sortedArr1 = indices.map(index => arr1[index]);
|
|
88
|
+
const sortedArr2 = indices.map(index => arr2[index]);
|
|
89
|
+
return [sortedArr1, sortedArr2];
|
|
90
|
+
}
|
|
91
|
+
function allEqual(arr) {
|
|
92
|
+
// An empty array is considered to have all elements "the same"
|
|
93
|
+
if (arr.length === 0) {
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
const firstElement = arr[0];
|
|
97
|
+
return arr.every(element => element === firstElement);
|
|
98
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { Expression } from '../core/classes/expression/Expression';
|
|
2
|
+
import { Polynomial } from '../core/classes/polynomial/Polynomial';
|
|
3
|
+
import { Scope } from '../core/common/classes/Scope';
|
|
4
|
+
import type { ParserValuesObject } from '../core/classes/parser/types';
|
|
5
|
+
import type { Term } from '../core/classes/polynomial/Term';
|
|
6
|
+
import type { ParserEntity } from '../core/types';
|
|
7
|
+
export interface DebugToken {
|
|
8
|
+
kind: 'token';
|
|
9
|
+
position: number;
|
|
10
|
+
text: string;
|
|
11
|
+
type: string | null;
|
|
12
|
+
value: string;
|
|
13
|
+
}
|
|
14
|
+
export interface DebugScope {
|
|
15
|
+
column: number;
|
|
16
|
+
deferLHSResolution: boolean;
|
|
17
|
+
deferRHSResolution: boolean;
|
|
18
|
+
depth: number;
|
|
19
|
+
implicitMultiply: boolean;
|
|
20
|
+
isOpen: boolean;
|
|
21
|
+
items: DebugScopeItem[];
|
|
22
|
+
kind: 'scope';
|
|
23
|
+
text: string;
|
|
24
|
+
type: string;
|
|
25
|
+
typedText: string;
|
|
26
|
+
}
|
|
27
|
+
export type DebugScopeItem = DebugScope | DebugToken;
|
|
28
|
+
export interface DebugExpression {
|
|
29
|
+
args: DebugExpression[] | null;
|
|
30
|
+
base: DebugExpression | null;
|
|
31
|
+
dataType: string;
|
|
32
|
+
deferred: boolean;
|
|
33
|
+
elements: Record<string, DebugExpression> | null;
|
|
34
|
+
kind: 'Expression';
|
|
35
|
+
multiplier: string | null;
|
|
36
|
+
name: string | null;
|
|
37
|
+
power: DebugExpression | null;
|
|
38
|
+
precision: number | null;
|
|
39
|
+
text: string;
|
|
40
|
+
type: number;
|
|
41
|
+
typeName: string;
|
|
42
|
+
value: string;
|
|
43
|
+
}
|
|
44
|
+
export interface DebugEquation {
|
|
45
|
+
LHS: DebugExpression;
|
|
46
|
+
RHS: DebugExpression;
|
|
47
|
+
dataType: string;
|
|
48
|
+
kind: 'Equation';
|
|
49
|
+
text: string;
|
|
50
|
+
}
|
|
51
|
+
export interface DebugVector {
|
|
52
|
+
dataType: string;
|
|
53
|
+
elements: DebugEntity[];
|
|
54
|
+
kind: 'Vector';
|
|
55
|
+
text: string;
|
|
56
|
+
}
|
|
57
|
+
export interface DebugMatrix {
|
|
58
|
+
dataType: string;
|
|
59
|
+
elements: DebugExpression[][];
|
|
60
|
+
kind: 'Matrix';
|
|
61
|
+
text: string;
|
|
62
|
+
}
|
|
63
|
+
export interface DebugValuesSet {
|
|
64
|
+
dataType: string;
|
|
65
|
+
elements: DebugEntity[];
|
|
66
|
+
kind: 'ValuesSet';
|
|
67
|
+
text: string;
|
|
68
|
+
}
|
|
69
|
+
export interface DebugCollection {
|
|
70
|
+
dataType: string;
|
|
71
|
+
elements: DebugEntity[];
|
|
72
|
+
kind: 'Collection';
|
|
73
|
+
text: string;
|
|
74
|
+
}
|
|
75
|
+
export interface DebugDictionaryEntry {
|
|
76
|
+
key: string;
|
|
77
|
+
value: DebugEntity;
|
|
78
|
+
}
|
|
79
|
+
export interface DebugDictionary {
|
|
80
|
+
dataType: string;
|
|
81
|
+
entries: DebugDictionaryEntry[];
|
|
82
|
+
kind: 'Dictionary';
|
|
83
|
+
text: string;
|
|
84
|
+
}
|
|
85
|
+
export type DebugEntity = DebugExpression | DebugEquation | DebugVector | DebugMatrix | DebugValuesSet | DebugCollection | DebugDictionary;
|
|
86
|
+
export interface DebugTerm {
|
|
87
|
+
coefficient: DebugExpression;
|
|
88
|
+
kind: 'Term';
|
|
89
|
+
multidegree: number[];
|
|
90
|
+
powers: Record<string, number>;
|
|
91
|
+
text: string;
|
|
92
|
+
totalPower: number;
|
|
93
|
+
variables: string[];
|
|
94
|
+
}
|
|
95
|
+
export interface DebugPolynomial {
|
|
96
|
+
expression: DebugExpression;
|
|
97
|
+
isMultivariate: boolean;
|
|
98
|
+
kind: 'Polynomial';
|
|
99
|
+
ordering: string;
|
|
100
|
+
terms: DebugTerm[];
|
|
101
|
+
text: string;
|
|
102
|
+
variables: string[];
|
|
103
|
+
}
|
|
104
|
+
export interface ParseInspection {
|
|
105
|
+
normalizedSource: string;
|
|
106
|
+
result: DebugEntity;
|
|
107
|
+
rpn: DebugScope;
|
|
108
|
+
source: string;
|
|
109
|
+
tokens: DebugScope;
|
|
110
|
+
}
|
|
111
|
+
export declare function createTypesMap(): Record<number, string>;
|
|
112
|
+
/** Converts a parser token scope to JSON-safe diagnostic data. */
|
|
113
|
+
export declare function inspectTokens(scope: Scope): DebugScope;
|
|
114
|
+
/** Converts an Expression tree to JSON-safe diagnostic data without changing it. */
|
|
115
|
+
export declare function inspectExpressionData(obj: Expression): DebugExpression;
|
|
116
|
+
/** Converts any current parser entity to plain diagnostic data. */
|
|
117
|
+
export declare function inspectEntity(entity: ParserEntity): DebugEntity;
|
|
118
|
+
/** Inspects one parser input using the same preprocessing as Parser.parse(). */
|
|
119
|
+
export declare function inspectParse(source: string, values?: ParserValuesObject): ParseInspection;
|
|
120
|
+
/** Converts a polynomial Term to JSON-safe diagnostic data without touching its caches. */
|
|
121
|
+
export declare function inspectTermData(t: Term): DebugTerm;
|
|
122
|
+
/** Converts a Polynomial to JSON-safe diagnostic data. */
|
|
123
|
+
export declare function inspectPolynomialData(p: Polynomial): DebugPolynomial;
|
|
124
|
+
export declare function printE(obj: Record<string, unknown>): void;
|
|
125
|
+
export declare const printTokens: (tokens: Scope, valuesOnly?: boolean) => void;
|
|
126
|
+
export declare const printRPN: (str: string) => void;
|
|
127
|
+
export declare function inspectExpression(obj: Expression, depth?: number): string;
|
|
128
|
+
export declare function inspectTerm(t: Term): string;
|
|
129
|
+
export declare function inspectPolynomial(p: Polynomial): string;
|
|
130
|
+
export declare function hr(symbol?: string, length?: number): void;
|
|
131
|
+
export declare function simpleSerialize(obj: Record<string, unknown>): string;
|