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,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module sparsePolynomialAdapter
|
|
3
|
+
*
|
|
4
|
+
* Conversion from Nerdamer's expression-facing polynomial forms to the exact
|
|
5
|
+
* integer sparse polynomial representation.
|
|
6
|
+
*/
|
|
7
|
+
import { Expression } from '../expression/Expression';
|
|
8
|
+
import { SparsePolynomial } from './SparsePolynomial';
|
|
9
|
+
import type { Polynomial } from './Polynomial';
|
|
10
|
+
/**
|
|
11
|
+
* Converts an integer-coefficient polynomial expression directly to sparse form.
|
|
12
|
+
*
|
|
13
|
+
* Sums, products, and non-negative integer powers are evaluated with sparse
|
|
14
|
+
* polynomial arithmetic, so callers do not need to construct the legacy Polynomial
|
|
15
|
+
* representation first. Variables are ordered by ascending degree and then by name.
|
|
16
|
+
*/
|
|
17
|
+
export declare function expressionToSparsePolynomial(expression: Expression): Readonly<{
|
|
18
|
+
polynomial: SparsePolynomial;
|
|
19
|
+
variables: readonly string[];
|
|
20
|
+
}>;
|
|
21
|
+
/**
|
|
22
|
+
* Converts a rational-coefficient polynomial expression directly to integer sparse form.
|
|
23
|
+
*
|
|
24
|
+
* The supplied variables define the sparse ring coordinates. Rational denominators are
|
|
25
|
+
* carried separately while sums, products, and non-negative integer powers are evaluated,
|
|
26
|
+
* then reduced against common integer coefficient content.
|
|
27
|
+
*/
|
|
28
|
+
export declare function expressionToIntegerSparsePolynomial(expression: Expression, variables: readonly string[]): Readonly<{
|
|
29
|
+
polynomial: SparsePolynomial;
|
|
30
|
+
denominator: bigint;
|
|
31
|
+
}>;
|
|
32
|
+
/**
|
|
33
|
+
* Converts a Polynomial with rational numeric coefficients to an integer sparse
|
|
34
|
+
* polynomial by clearing one common positive denominator.
|
|
35
|
+
*
|
|
36
|
+
* The supplied variables define the sparse ring coordinates and must include every
|
|
37
|
+
* variable in the polynomial.
|
|
38
|
+
*/
|
|
39
|
+
export declare function polynomialToIntegerSparsePolynomial(polynomial: Polynomial, variables: readonly string[]): Readonly<{
|
|
40
|
+
polynomial: SparsePolynomial;
|
|
41
|
+
denominator: bigint;
|
|
42
|
+
}>;
|
|
43
|
+
/**
|
|
44
|
+
* Converts a Polynomial to an exact sparse polynomial over the integers.
|
|
45
|
+
*
|
|
46
|
+
* Coefficients must already be integers; use
|
|
47
|
+
* {@link polynomialToIntegerSparsePolynomial} when rational coefficients should be
|
|
48
|
+
* cleared first.
|
|
49
|
+
*/
|
|
50
|
+
export declare function polynomialToSparsePolynomial(polynomial: Polynomial, variables: readonly string[]): SparsePolynomial;
|
|
51
|
+
/**
|
|
52
|
+
* Converts an exact sparse polynomial directly to an Expression.
|
|
53
|
+
*
|
|
54
|
+
* Conversion does not pass through Polynomial, so bigint exponents remain exact.
|
|
55
|
+
*/
|
|
56
|
+
export declare function sparsePolynomialToExpression(polynomial: SparsePolynomial, variables: readonly string[]): Expression;
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @module sparsePolynomialAdapter
|
|
4
|
+
*
|
|
5
|
+
* Conversion from Nerdamer's expression-facing polynomial forms to the exact
|
|
6
|
+
* integer sparse polynomial representation.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.expressionToSparsePolynomial = expressionToSparsePolynomial;
|
|
10
|
+
exports.expressionToIntegerSparsePolynomial = expressionToIntegerSparsePolynomial;
|
|
11
|
+
exports.polynomialToIntegerSparsePolynomial = polynomialToIntegerSparsePolynomial;
|
|
12
|
+
exports.polynomialToSparsePolynomial = polynomialToSparsePolynomial;
|
|
13
|
+
exports.sparsePolynomialToExpression = sparsePolynomialToExpression;
|
|
14
|
+
const errors_1 = require("../../errors");
|
|
15
|
+
const bigint_1 = require("../../functions/bigint/bigint");
|
|
16
|
+
const Expression_1 = require("../expression/Expression");
|
|
17
|
+
const shortcuts_1 = require("../expression/shortcuts");
|
|
18
|
+
const SparsePolynomial_1 = require("./SparsePolynomial");
|
|
19
|
+
/**
|
|
20
|
+
* Converts an integer-coefficient polynomial expression directly to sparse form.
|
|
21
|
+
*
|
|
22
|
+
* Sums, products, and non-negative integer powers are evaluated with sparse
|
|
23
|
+
* polynomial arithmetic, so callers do not need to construct the legacy Polynomial
|
|
24
|
+
* representation first. Variables are ordered by ascending degree and then by name.
|
|
25
|
+
*/
|
|
26
|
+
function expressionToSparsePolynomial(expression) {
|
|
27
|
+
const sourceVariables = expression.variables().sort();
|
|
28
|
+
const variableIndices = new Map(sourceVariables.map((variable, index) => [variable, index]));
|
|
29
|
+
function powerOf(current) {
|
|
30
|
+
const power = current.getPower();
|
|
31
|
+
if (!power.isInteger() || power.sign() < 0) {
|
|
32
|
+
throw new errors_1.PolynomialError((0, errors_1.message)('notAPolynomial'));
|
|
33
|
+
}
|
|
34
|
+
return power.getMultiplier().numerator;
|
|
35
|
+
}
|
|
36
|
+
function integerMultiplier(current) {
|
|
37
|
+
const multiplier = current.getMultiplier();
|
|
38
|
+
if (multiplier.denominator !== 1n) {
|
|
39
|
+
throw new Error((0, errors_1.message)('integerRequired'));
|
|
40
|
+
}
|
|
41
|
+
return multiplier.numerator;
|
|
42
|
+
}
|
|
43
|
+
function convert(current) {
|
|
44
|
+
const variableCount = sourceVariables.length;
|
|
45
|
+
if (current.isNUM()) {
|
|
46
|
+
return SparsePolynomial_1.SparsePolynomial.constant(variableCount, integerMultiplier(current));
|
|
47
|
+
}
|
|
48
|
+
if (current.isVAR()) {
|
|
49
|
+
const variableIndex = variableIndices.get(current.value);
|
|
50
|
+
if (variableIndex === undefined) {
|
|
51
|
+
throw new errors_1.PolynomialError((0, errors_1.message)('notAPolynomial'));
|
|
52
|
+
}
|
|
53
|
+
const exponents = new Array(variableCount).fill(0n);
|
|
54
|
+
exponents[variableIndex] = powerOf(current);
|
|
55
|
+
return SparsePolynomial_1.SparsePolynomial.monomial(variableCount, integerMultiplier(current), exponents);
|
|
56
|
+
}
|
|
57
|
+
if (current.isSum()) {
|
|
58
|
+
let sum = SparsePolynomial_1.SparsePolynomial.zero(variableCount);
|
|
59
|
+
for (const term of current.elementsArray()) {
|
|
60
|
+
sum = sum.add(convert(term));
|
|
61
|
+
}
|
|
62
|
+
return sum.pow(powerOf(current)).scale(integerMultiplier(current));
|
|
63
|
+
}
|
|
64
|
+
if (current.isProduct()) {
|
|
65
|
+
let product = SparsePolynomial_1.SparsePolynomial.constant(variableCount, 1n);
|
|
66
|
+
for (const factor of current.elementsArray()) {
|
|
67
|
+
product = product.multiply(convert(factor));
|
|
68
|
+
}
|
|
69
|
+
return product.pow(powerOf(current)).scale(integerMultiplier(current));
|
|
70
|
+
}
|
|
71
|
+
throw new errors_1.PolynomialError((0, errors_1.message)('notAPolynomial'));
|
|
72
|
+
}
|
|
73
|
+
const source = convert(expression);
|
|
74
|
+
const order = sourceVariables
|
|
75
|
+
.map((variable, index) => ({
|
|
76
|
+
variable,
|
|
77
|
+
index,
|
|
78
|
+
degree: source.degree(index) ?? 0n,
|
|
79
|
+
}))
|
|
80
|
+
.sort((left, right) => {
|
|
81
|
+
if (left.degree < right.degree) {
|
|
82
|
+
return -1;
|
|
83
|
+
}
|
|
84
|
+
if (left.degree > right.degree) {
|
|
85
|
+
return 1;
|
|
86
|
+
}
|
|
87
|
+
return left.variable.localeCompare(right.variable);
|
|
88
|
+
});
|
|
89
|
+
const variables = order.map(entry => entry.variable);
|
|
90
|
+
if (order.every((entry, index) => entry.index === index)) {
|
|
91
|
+
return { polynomial: source, variables };
|
|
92
|
+
}
|
|
93
|
+
const terms = source.terms().map(term => ({
|
|
94
|
+
coefficient: term.coefficient,
|
|
95
|
+
exponents: order.map(entry => term.exponents[entry.index]),
|
|
96
|
+
}));
|
|
97
|
+
return {
|
|
98
|
+
polynomial: new SparsePolynomial_1.SparsePolynomial(source.variableCount, terms),
|
|
99
|
+
variables,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Converts a rational-coefficient polynomial expression directly to integer sparse form.
|
|
104
|
+
*
|
|
105
|
+
* The supplied variables define the sparse ring coordinates. Rational denominators are
|
|
106
|
+
* carried separately while sums, products, and non-negative integer powers are evaluated,
|
|
107
|
+
* then reduced against common integer coefficient content.
|
|
108
|
+
*/
|
|
109
|
+
function expressionToIntegerSparsePolynomial(expression, variables) {
|
|
110
|
+
const selected = new Set();
|
|
111
|
+
for (const variable of variables) {
|
|
112
|
+
if (selected.has(variable)) {
|
|
113
|
+
throw new RangeError((0, errors_1.message)('sparseAdapterVariablesUnique'));
|
|
114
|
+
}
|
|
115
|
+
selected.add(variable);
|
|
116
|
+
}
|
|
117
|
+
for (const variable of expression.variables()) {
|
|
118
|
+
if (!selected.has(variable)) {
|
|
119
|
+
throw new RangeError((0, errors_1.message)('sparseAdapterVariablesIncludeEvery'));
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
const variableCount = variables.length;
|
|
123
|
+
const variableIndices = new Map(variables.map((variable, index) => [variable, index]));
|
|
124
|
+
function powerOf(current) {
|
|
125
|
+
const power = current.getPower();
|
|
126
|
+
if (!power.isInteger() || power.sign() < 0) {
|
|
127
|
+
throw new errors_1.PolynomialError((0, errors_1.message)('notAPolynomial'));
|
|
128
|
+
}
|
|
129
|
+
return power.getMultiplier().numerator;
|
|
130
|
+
}
|
|
131
|
+
function normalize(polynomial, denominator) {
|
|
132
|
+
if (polynomial.isZero()) {
|
|
133
|
+
return { polynomial, denominator: 1n };
|
|
134
|
+
}
|
|
135
|
+
const divisor = (0, bigint_1.GCD)(polynomial.content(), denominator);
|
|
136
|
+
return divisor === 1n
|
|
137
|
+
? { polynomial, denominator }
|
|
138
|
+
: {
|
|
139
|
+
polynomial: polynomial.divideByScalarExact(divisor),
|
|
140
|
+
denominator: denominator / divisor,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
function applyPowerAndMultiplier(current, polynomial, denominator) {
|
|
144
|
+
const exponent = powerOf(current);
|
|
145
|
+
const multiplier = current.getMultiplier();
|
|
146
|
+
return normalize(polynomial.pow(exponent).scale(multiplier.numerator), denominator ** exponent * multiplier.denominator);
|
|
147
|
+
}
|
|
148
|
+
function convert(current) {
|
|
149
|
+
const multiplier = current.getMultiplier();
|
|
150
|
+
if (current.isNUM()) {
|
|
151
|
+
return normalize(SparsePolynomial_1.SparsePolynomial.constant(variableCount, multiplier.numerator), multiplier.denominator);
|
|
152
|
+
}
|
|
153
|
+
if (current.isVAR()) {
|
|
154
|
+
const variableIndex = variableIndices.get(current.value);
|
|
155
|
+
if (variableIndex === undefined) {
|
|
156
|
+
throw new errors_1.PolynomialError((0, errors_1.message)('notAPolynomial'));
|
|
157
|
+
}
|
|
158
|
+
const exponents = new Array(variableCount).fill(0n);
|
|
159
|
+
exponents[variableIndex] = powerOf(current);
|
|
160
|
+
return normalize(SparsePolynomial_1.SparsePolynomial.monomial(variableCount, multiplier.numerator, exponents), multiplier.denominator);
|
|
161
|
+
}
|
|
162
|
+
if (current.isSum()) {
|
|
163
|
+
let polynomial = SparsePolynomial_1.SparsePolynomial.zero(variableCount);
|
|
164
|
+
let denominator = 1n;
|
|
165
|
+
for (const term of current.elementsArray()) {
|
|
166
|
+
const converted = convert(term);
|
|
167
|
+
const commonDenominator = (0, bigint_1.LCM)(denominator, converted.denominator);
|
|
168
|
+
polynomial = polynomial
|
|
169
|
+
.scale(commonDenominator / denominator)
|
|
170
|
+
.add(converted.polynomial.scale(commonDenominator / converted.denominator));
|
|
171
|
+
denominator = commonDenominator;
|
|
172
|
+
}
|
|
173
|
+
return applyPowerAndMultiplier(current, polynomial, denominator);
|
|
174
|
+
}
|
|
175
|
+
if (current.isProduct()) {
|
|
176
|
+
let polynomial = SparsePolynomial_1.SparsePolynomial.constant(variableCount, 1n);
|
|
177
|
+
let denominator = 1n;
|
|
178
|
+
for (const factor of current.elementsArray()) {
|
|
179
|
+
const converted = convert(factor);
|
|
180
|
+
polynomial = polynomial.multiply(converted.polynomial);
|
|
181
|
+
denominator *= converted.denominator;
|
|
182
|
+
}
|
|
183
|
+
return applyPowerAndMultiplier(current, polynomial, denominator);
|
|
184
|
+
}
|
|
185
|
+
throw new errors_1.PolynomialError((0, errors_1.message)('notAPolynomial'));
|
|
186
|
+
}
|
|
187
|
+
const converted = convert(expression);
|
|
188
|
+
const terms = [...converted.polynomial.terms()].sort((left, right) => -SparsePolynomial_1.SparsePolynomial.compareMonomials(left.exponents, right.exponents, 'lex'));
|
|
189
|
+
return {
|
|
190
|
+
polynomial: new SparsePolynomial_1.SparsePolynomial(variableCount, terms),
|
|
191
|
+
denominator: converted.denominator,
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Converts a Polynomial with rational numeric coefficients to an integer sparse
|
|
196
|
+
* polynomial by clearing one common positive denominator.
|
|
197
|
+
*
|
|
198
|
+
* The supplied variables define the sparse ring coordinates and must include every
|
|
199
|
+
* variable in the polynomial.
|
|
200
|
+
*/
|
|
201
|
+
function polynomialToIntegerSparsePolynomial(polynomial, variables) {
|
|
202
|
+
return expressionToIntegerSparsePolynomial(polynomial.getExpression(), variables);
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Converts a Polynomial to an exact sparse polynomial over the integers.
|
|
206
|
+
*
|
|
207
|
+
* Coefficients must already be integers; use
|
|
208
|
+
* {@link polynomialToIntegerSparsePolynomial} when rational coefficients should be
|
|
209
|
+
* cleared first.
|
|
210
|
+
*/
|
|
211
|
+
function polynomialToSparsePolynomial(polynomial, variables) {
|
|
212
|
+
const converted = polynomialToIntegerSparsePolynomial(polynomial, variables);
|
|
213
|
+
if (converted.denominator !== 1n) {
|
|
214
|
+
throw new Error((0, errors_1.message)('integerRequired'));
|
|
215
|
+
}
|
|
216
|
+
return converted.polynomial;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Converts an exact sparse polynomial directly to an Expression.
|
|
220
|
+
*
|
|
221
|
+
* Conversion does not pass through Polynomial, so bigint exponents remain exact.
|
|
222
|
+
*/
|
|
223
|
+
function sparsePolynomialToExpression(polynomial, variables) {
|
|
224
|
+
if (variables.length !== polynomial.variableCount) {
|
|
225
|
+
throw new RangeError((0, errors_1.message)('sparseExpressionConversionNameCount'));
|
|
226
|
+
}
|
|
227
|
+
let result = (0, shortcuts_1.zero)();
|
|
228
|
+
for (const term of polynomial.terms()) {
|
|
229
|
+
let expression = Expression_1.Expression.Number(term.coefficient);
|
|
230
|
+
for (let variableIndex = 0; variableIndex < variables.length; variableIndex++) {
|
|
231
|
+
const exponent = term.exponents[variableIndex];
|
|
232
|
+
if (exponent === 0n) {
|
|
233
|
+
continue;
|
|
234
|
+
}
|
|
235
|
+
const variable = Expression_1.Expression.Variable(variables[variableIndex]);
|
|
236
|
+
expression = expression.times(exponent === 1n ? variable : variable.pow(Expression_1.Expression.Number(exponent)));
|
|
237
|
+
}
|
|
238
|
+
result = result.plus(expression);
|
|
239
|
+
}
|
|
240
|
+
return result;
|
|
241
|
+
}
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import { Expression } from '../expression/Expression';
|
|
2
|
+
import { TERM } from '../parser/constants';
|
|
3
|
+
/** Powers keyed by variable name. Missing variables have degree zero. */
|
|
4
|
+
export type PowersObject = Record<string, number>;
|
|
5
|
+
/**
|
|
6
|
+
* Represents one coefficient-monomial term in a {@link Polynomial}.
|
|
7
|
+
*
|
|
8
|
+
* @remarks
|
|
9
|
+
* A term stores an `Expression` coefficient, a mutable variable-to-power record, and
|
|
10
|
+
* a sorted copy of the supplied variable names. The coefficient and a power object
|
|
11
|
+
* supplied to the constructor are retained by reference; {@link Term.copy} creates
|
|
12
|
+
* independent copies of both.
|
|
13
|
+
*
|
|
14
|
+
* Multidegree, total power, expression, and value text are computed lazily and cached.
|
|
15
|
+
* Arithmetic methods return new terms and refresh their derived degree fields. Direct
|
|
16
|
+
* mutation of {@link Term.coeff}, {@link Term.powers}, or the setter overload of
|
|
17
|
+
* {@link Term.deg} does not invalidate every cached field, so callers should prefer a
|
|
18
|
+
* copied/reconstructed term when cached values may already have been read.
|
|
19
|
+
*/
|
|
20
|
+
export declare class Term {
|
|
21
|
+
/** Mutable symbolic coefficient. */
|
|
22
|
+
coeff: Expression;
|
|
23
|
+
/** Runtime tag used by Nerdamer's term type guard. */
|
|
24
|
+
dataType: typeof TERM;
|
|
25
|
+
/** Lazily cached expression representation. */
|
|
26
|
+
expression?: Expression;
|
|
27
|
+
/** Number of variables whose power is positive. */
|
|
28
|
+
length: number;
|
|
29
|
+
/** Lazily cached multidegree in {@link variables} order. */
|
|
30
|
+
multidegArray?: number[];
|
|
31
|
+
/** Mutable powers keyed by variable name. */
|
|
32
|
+
powers: PowersObject;
|
|
33
|
+
/** Lazily cached sum of all stored powers. */
|
|
34
|
+
totalPower?: number;
|
|
35
|
+
/** Lazily cached unit-coefficient monomial text. */
|
|
36
|
+
valueString?: string;
|
|
37
|
+
/** Sorted variable names used for multidegree and rendering order. */
|
|
38
|
+
variables: string[];
|
|
39
|
+
/**
|
|
40
|
+
* Creates a term from a coefficient and monomial powers.
|
|
41
|
+
*
|
|
42
|
+
* @param coeff - Expression coefficient or parser text. Existing expressions are retained.
|
|
43
|
+
* @param powers - Power record or comma-separated degrees aligned with `variables`.
|
|
44
|
+
* An object power record is retained by reference.
|
|
45
|
+
* @param variables - Variable order to interpret string powers. The term stores a sorted copy.
|
|
46
|
+
*/
|
|
47
|
+
constructor(coeff: Expression | string, powers: PowersObject | string, variables: string[]);
|
|
48
|
+
/**
|
|
49
|
+
* Checks if the given object is a Term
|
|
50
|
+
*
|
|
51
|
+
* @param obj - Value to test.
|
|
52
|
+
* @returns Whether `obj` carries Nerdamer's term discriminator.
|
|
53
|
+
*/
|
|
54
|
+
static isTerm(obj: unknown): obj is Term;
|
|
55
|
+
/**
|
|
56
|
+
* Gets the total number of non-unit variables in the term
|
|
57
|
+
*
|
|
58
|
+
* @returns The number of variables with positive powers.
|
|
59
|
+
*/
|
|
60
|
+
private getLength;
|
|
61
|
+
/** Recalculates degree-derived caches after term arithmetic and returns this term. */
|
|
62
|
+
private update;
|
|
63
|
+
/**
|
|
64
|
+
* Forces the multidegree array to be recalculated
|
|
65
|
+
*
|
|
66
|
+
* @returns The refreshed internal multidegree array.
|
|
67
|
+
*/
|
|
68
|
+
private updateMultiDegArray;
|
|
69
|
+
/**
|
|
70
|
+
* Forces the total power to be recalculated
|
|
71
|
+
*
|
|
72
|
+
* @returns The refreshed total degree.
|
|
73
|
+
*/
|
|
74
|
+
private updateTotalPower;
|
|
75
|
+
/**
|
|
76
|
+
* Tests whether two terms have the same unit-coefficient monomial.
|
|
77
|
+
*
|
|
78
|
+
* @param t - Term to compare.
|
|
79
|
+
* @returns Whether their rendered variable-and-power components match.
|
|
80
|
+
*/
|
|
81
|
+
canAddOrSubtract(t: Term): boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Creates an independently mutable copy of this term.
|
|
84
|
+
*
|
|
85
|
+
* @returns A term with copied coefficient, powers, and variable array. Lazy caches are rebuilt on demand.
|
|
86
|
+
*/
|
|
87
|
+
copy(): Term;
|
|
88
|
+
/**
|
|
89
|
+
* Returns the degree of one variable.
|
|
90
|
+
*
|
|
91
|
+
* @param v - Variable whose power is read.
|
|
92
|
+
* @returns The stored power, or zero when the variable is absent.
|
|
93
|
+
*/
|
|
94
|
+
deg(v: string): number;
|
|
95
|
+
/**
|
|
96
|
+
* Assigns the degree of one variable.
|
|
97
|
+
*
|
|
98
|
+
* @param v - Variable whose power is written.
|
|
99
|
+
* @param value - New numeric power.
|
|
100
|
+
* @returns This term after assignment. Lazy caches are not invalidated automatically.
|
|
101
|
+
*/
|
|
102
|
+
deg(v: string, value: number): Term;
|
|
103
|
+
/**
|
|
104
|
+
* Differentiates this term with respect to one variable.
|
|
105
|
+
*
|
|
106
|
+
* @param variable - Differentiation variable.
|
|
107
|
+
* @param n - Non-negative derivative order.
|
|
108
|
+
* @returns A new differentiated term, or a zero term when `n` exceeds the power.
|
|
109
|
+
*/
|
|
110
|
+
diff(variable: string, n?: number): Term;
|
|
111
|
+
/**
|
|
112
|
+
* Subtracts another term's multidegree from this term's multidegree.
|
|
113
|
+
*
|
|
114
|
+
* @param term - Term whose degree tuple is subtracted.
|
|
115
|
+
* @returns A new component-wise difference array in this term's variable order.
|
|
116
|
+
*/
|
|
117
|
+
difference(term: Term): number[];
|
|
118
|
+
/**
|
|
119
|
+
* Divides this term by the provided term
|
|
120
|
+
*
|
|
121
|
+
* @param t - Divisor term.
|
|
122
|
+
* @returns A new quotient term; negative powers are permitted by this low-level operation.
|
|
123
|
+
*/
|
|
124
|
+
div(t: Term): Term;
|
|
125
|
+
/**
|
|
126
|
+
* Checks if one term can divide another.
|
|
127
|
+
*
|
|
128
|
+
* @param t - Candidate dividend term.
|
|
129
|
+
* @returns Whether every power in this term is no greater than the corresponding power in `t`.
|
|
130
|
+
*/
|
|
131
|
+
divides(t: Term): boolean;
|
|
132
|
+
/**
|
|
133
|
+
* Checks for equality with another Term
|
|
134
|
+
*
|
|
135
|
+
* @param t - Term to compare.
|
|
136
|
+
* @returns Whether coefficient and monomial quotient equal one.
|
|
137
|
+
*/
|
|
138
|
+
eq(t: Term): boolean;
|
|
139
|
+
/**
|
|
140
|
+
* Tests whether this is a constant term equal to a number.
|
|
141
|
+
*
|
|
142
|
+
* @param n - Numeric value to compare with the coefficient.
|
|
143
|
+
*/
|
|
144
|
+
eqNumber(n: number | string): boolean;
|
|
145
|
+
/**
|
|
146
|
+
* Returns a lazily constructed expression for this term.
|
|
147
|
+
*
|
|
148
|
+
* @returns The cached internal expression reference.
|
|
149
|
+
*/
|
|
150
|
+
getExpression(): Expression;
|
|
151
|
+
/**
|
|
152
|
+
* Returns this term's multidegree in its stored variable order.
|
|
153
|
+
*
|
|
154
|
+
* @returns The cached internal degree array.
|
|
155
|
+
*/
|
|
156
|
+
getMultidegArray(): number[];
|
|
157
|
+
/**
|
|
158
|
+
* Returns the sum of powers in this term.
|
|
159
|
+
*
|
|
160
|
+
* @returns The cached total degree.
|
|
161
|
+
*/
|
|
162
|
+
getTotalPower(): number;
|
|
163
|
+
/**
|
|
164
|
+
* Formats the monomial with a unit coefficient.
|
|
165
|
+
*
|
|
166
|
+
* @param useVariables - Optional variable order used for this rendering.
|
|
167
|
+
* @returns Parser text such as `x^2*y`, or `1` for a constant term.
|
|
168
|
+
*/
|
|
169
|
+
getValueString(useVariables?: string[]): string;
|
|
170
|
+
/**
|
|
171
|
+
* Tests whether every stored variable power is zero.
|
|
172
|
+
*
|
|
173
|
+
* @returns Whether the term is constant, independent of its coefficient value.
|
|
174
|
+
*/
|
|
175
|
+
isConstant(): boolean;
|
|
176
|
+
/**
|
|
177
|
+
* Tests whether the coefficient is zero.
|
|
178
|
+
*
|
|
179
|
+
* @returns Whether the term's symbolic coefficient is zero.
|
|
180
|
+
*/
|
|
181
|
+
isZero(): boolean;
|
|
182
|
+
/**
|
|
183
|
+
* Calculates the LCM of two terms with numeric coefficients
|
|
184
|
+
* TODO: Extend to non-numeric coefficients
|
|
185
|
+
*
|
|
186
|
+
* @param t - Other monomial term.
|
|
187
|
+
* @param withCoeff - Include the exact numeric coefficient LCM instead of using one.
|
|
188
|
+
* @returns A new term containing maximum powers for the union of variables.
|
|
189
|
+
*/
|
|
190
|
+
LCM(t: Term, withCoeff?: boolean): Term;
|
|
191
|
+
/**
|
|
192
|
+
* Returns the variable name with the greatest stored power.
|
|
193
|
+
*/
|
|
194
|
+
max(): string;
|
|
195
|
+
/**
|
|
196
|
+
* Returns the variable name with the least stored power.
|
|
197
|
+
*/
|
|
198
|
+
min(): string;
|
|
199
|
+
/**
|
|
200
|
+
* Calculates the multidegree array
|
|
201
|
+
*
|
|
202
|
+
* @param variables - Variable order for the result.
|
|
203
|
+
* @returns A new power array, using zero for missing variables.
|
|
204
|
+
*/
|
|
205
|
+
multideg(variables: string[]): number[];
|
|
206
|
+
/**
|
|
207
|
+
* Gets the text representation of the monomial
|
|
208
|
+
*
|
|
209
|
+
* @param useVariables - Optional variable rendering order.
|
|
210
|
+
* @returns Canonical parser text for the coefficient and monomial.
|
|
211
|
+
*/
|
|
212
|
+
text(useVariables?: string[]): string;
|
|
213
|
+
/**
|
|
214
|
+
* Multiplies this term with the given term
|
|
215
|
+
*
|
|
216
|
+
* @param x - Multiplier term.
|
|
217
|
+
* @returns A new term with multiplied coefficients and added powers.
|
|
218
|
+
*/
|
|
219
|
+
times(x: Term): Term;
|
|
220
|
+
/** Returns the same parser text as {@link Term.text}. */
|
|
221
|
+
toString(): string;
|
|
222
|
+
}
|