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
package/output/index.js
ADDED
|
@@ -0,0 +1,715 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
const package_json_1 = __importDefault(require("../package.json"));
|
|
40
|
+
const factor_1 = require("./algebra/factor/factor");
|
|
41
|
+
const gcd_1 = require("./algebra/gcd/gcd");
|
|
42
|
+
const groebner_1 = require("./algebra/groebner");
|
|
43
|
+
const partfrac_1 = require("./algebra/partfrac");
|
|
44
|
+
const simplify_1 = require("./algebra/simplify/simplify");
|
|
45
|
+
const utils_1 = require("./algebra/utils");
|
|
46
|
+
const diff_1 = require("./calculus/derivative/diff");
|
|
47
|
+
const fresnel_1 = require("./calculus/fresnel");
|
|
48
|
+
const integrate_1 = require("./calculus/integrate/integrate");
|
|
49
|
+
const ilaplace_1 = require("./calculus/laplace/ilaplace");
|
|
50
|
+
const laplace_1 = require("./calculus/laplace/laplace");
|
|
51
|
+
const limit_1 = require("./calculus/limit/limit");
|
|
52
|
+
const assume_1 = require("./core/classes/assumption/assume");
|
|
53
|
+
const Assumption_1 = require("./core/classes/assumption/Assumption");
|
|
54
|
+
const Collection_1 = require("./core/classes/collection/Collection");
|
|
55
|
+
const Dictionary_1 = require("./core/classes/dictionary/Dictionary");
|
|
56
|
+
const Equation_1 = require("./core/classes/equation/Equation");
|
|
57
|
+
const Expression_1 = require("./core/classes/expression/Expression");
|
|
58
|
+
const shortcuts_1 = require("./core/classes/expression/shortcuts");
|
|
59
|
+
const functions_1 = require("./core/classes/matrix/functions");
|
|
60
|
+
const Matrix_1 = require("./core/classes/matrix/Matrix");
|
|
61
|
+
const utils_2 = require("./core/classes/matrix/utils");
|
|
62
|
+
const constants_1 = require("./core/classes/parser/constants");
|
|
63
|
+
const Parser_1 = require("./core/classes/parser/Parser");
|
|
64
|
+
const scope_1 = require("./core/classes/parser/scripting/scope");
|
|
65
|
+
const functions_2 = require("./core/classes/polynomial/functions");
|
|
66
|
+
const Polynomial_1 = require("./core/classes/polynomial/Polynomial");
|
|
67
|
+
const Rational_1 = require("./core/classes/rational/Rational");
|
|
68
|
+
const ValuesSet_1 = require("./core/classes/valuesSet/ValuesSet");
|
|
69
|
+
const functions_3 = require("./core/classes/vector/functions");
|
|
70
|
+
const Vector_1 = require("./core/classes/vector/Vector");
|
|
71
|
+
const Converter_1 = require("./core/converters/Converter");
|
|
72
|
+
const dispatch_1 = require("./core/dispatch");
|
|
73
|
+
const errors = __importStar(require("./core/errors"));
|
|
74
|
+
const build_1 = require("./core/functions/build");
|
|
75
|
+
const complex_1 = require("./core/functions/complex");
|
|
76
|
+
const expand_1 = require("./core/functions/expand/expand");
|
|
77
|
+
const setFunction_1 = require("./core/functions/setFunction");
|
|
78
|
+
const subst_1 = require("./core/functions/subst");
|
|
79
|
+
const geometry_1 = require("./math/geometry");
|
|
80
|
+
const math_1 = require("./math/math");
|
|
81
|
+
const trig_1 = require("./math/trig");
|
|
82
|
+
const trunc_1 = require("./math/trunc");
|
|
83
|
+
const utils_3 = require("./math/utils");
|
|
84
|
+
const SolutionSet_1 = require("./solve/classes/SolutionSet");
|
|
85
|
+
const solve_1 = require("./solve/solve");
|
|
86
|
+
const solveSystem_1 = require("./solve/solveSystem");
|
|
87
|
+
/**
|
|
88
|
+
* Adds selected root functions as instance methods without changing the source classes.
|
|
89
|
+
* Existing class methods win, so a class can keep a more specific implementation.
|
|
90
|
+
*/
|
|
91
|
+
function extendApi(classes, methods, scalarMethods = {}) {
|
|
92
|
+
for (const cls of classes) {
|
|
93
|
+
const prototype = cls.prototype;
|
|
94
|
+
for (const methodName in methods) {
|
|
95
|
+
// Keep native implementations such as Matrix.expand().
|
|
96
|
+
if (!(methodName in prototype)) {
|
|
97
|
+
const method = methods[methodName];
|
|
98
|
+
Object.defineProperty(prototype, methodName, {
|
|
99
|
+
configurable: true,
|
|
100
|
+
writable: true,
|
|
101
|
+
value: function (...args) {
|
|
102
|
+
const apply = (value) => {
|
|
103
|
+
let retval;
|
|
104
|
+
// Equations are not enumerable, but transformations apply to both sides.
|
|
105
|
+
if (Equation_1.Equation.isEquation(value)) {
|
|
106
|
+
retval = value.each(e => apply(e));
|
|
107
|
+
}
|
|
108
|
+
else if (value.isEnumerable) {
|
|
109
|
+
// Structured values receive the operation element-wise on a copy.
|
|
110
|
+
const enumerable = value;
|
|
111
|
+
retval = enumerable.copy().each(e => apply(e));
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
// Scalar expressions can be passed directly to the root function.
|
|
115
|
+
retval = method(value, ...args);
|
|
116
|
+
}
|
|
117
|
+
return retval;
|
|
118
|
+
};
|
|
119
|
+
return apply(this);
|
|
120
|
+
},
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
for (const methodName in scalarMethods) {
|
|
125
|
+
if (!(methodName in prototype)) {
|
|
126
|
+
const method = scalarMethods[methodName];
|
|
127
|
+
Object.defineProperty(prototype, methodName, {
|
|
128
|
+
configurable: true,
|
|
129
|
+
writable: true,
|
|
130
|
+
value: function (...args) {
|
|
131
|
+
if (!Expression_1.Expression.isExpression(this)) {
|
|
132
|
+
throw new errors.UnexpectedDataType(errors.message('expressionExpected', {
|
|
133
|
+
type: constants_1.dataTypes[this.dataType] ?? this.dataType,
|
|
134
|
+
}));
|
|
135
|
+
}
|
|
136
|
+
return method(this, ...args);
|
|
137
|
+
},
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
// -----------------------------------------------------------------------------
|
|
144
|
+
// Shared conversion helpers
|
|
145
|
+
// -----------------------------------------------------------------------------
|
|
146
|
+
const latexConverter = new Converter_1.Converter();
|
|
147
|
+
const textConverter = new Converter_1.Converter('text');
|
|
148
|
+
function normalizeTeXOptions(options) {
|
|
149
|
+
let retval;
|
|
150
|
+
if (typeof options === 'string') {
|
|
151
|
+
retval = { decimal: true };
|
|
152
|
+
}
|
|
153
|
+
else if (options?.decimals === true && !('decimal' in options)) {
|
|
154
|
+
retval = { ...options, decimal: true };
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
retval = options;
|
|
158
|
+
}
|
|
159
|
+
return retval;
|
|
160
|
+
}
|
|
161
|
+
// -----------------------------------------------------------------------------
|
|
162
|
+
// Main callable API
|
|
163
|
+
// -----------------------------------------------------------------------------
|
|
164
|
+
/**
|
|
165
|
+
* Parses Nerdamer notation into a supported parser entity.
|
|
166
|
+
*
|
|
167
|
+
* The returned runtime type depends on the notation and can be an
|
|
168
|
+
* {@link Expression}, equation, or structured parser value. Most type-specific methods
|
|
169
|
+
* still require the corresponding class guard. Full-package methods declared across all
|
|
170
|
+
* parser results can be called directly; scalar-only methods such as `buildFunction()`
|
|
171
|
+
* reject structured results at runtime.
|
|
172
|
+
*
|
|
173
|
+
* @remarks
|
|
174
|
+
* Entries in `values` are substituted while parsing and take precedence over
|
|
175
|
+
* known parser values, including otherwise restricted names. Parser and
|
|
176
|
+
* registration settings are shared by this module-level Nerdamer instance.
|
|
177
|
+
*
|
|
178
|
+
* @param e - Expression-compatible input to parse.
|
|
179
|
+
* @param values - Optional name-to-value substitutions for this parse.
|
|
180
|
+
* @returns The parsed {@link ParserEntity}; inspect its runtime type when the
|
|
181
|
+
* input can produce more than an Expression.
|
|
182
|
+
*
|
|
183
|
+
* @example
|
|
184
|
+
* ```ts
|
|
185
|
+
* nerdamer('x+2*x+1').text(); // '1+3*x'
|
|
186
|
+
* nerdamer('2*[a, b, 3]').text(); // '[2*a, 2*b, 6]'
|
|
187
|
+
* nerdamer('x+6*y+a', {x: 1, y: 2, a:'t'}).text(); // '13+t'
|
|
188
|
+
*
|
|
189
|
+
* // Evaluation allows even restricted variables to be overridden
|
|
190
|
+
* nerdamer('e+pi', {π: 1, e: 2}).text(); // '2+pi'
|
|
191
|
+
* ```
|
|
192
|
+
*/
|
|
193
|
+
function nerdamer(e, values) {
|
|
194
|
+
return Parser_1.Parser.parse(e, values);
|
|
195
|
+
}
|
|
196
|
+
// -----------------------------------------------------------------------------
|
|
197
|
+
// Full-package Expression and Equation methods
|
|
198
|
+
// -----------------------------------------------------------------------------
|
|
199
|
+
/**
|
|
200
|
+
* Solves this expression for the requested variable.
|
|
201
|
+
*/
|
|
202
|
+
Expression_1.Expression.prototype.solveFor = function (variable) {
|
|
203
|
+
return (0, solve_1.solve)(this, variable);
|
|
204
|
+
};
|
|
205
|
+
/**
|
|
206
|
+
* Solves this equation for the requested variable without modifying the equation.
|
|
207
|
+
*
|
|
208
|
+
* @param variable - Variable to solve for.
|
|
209
|
+
* @returns The solver's {@link SolutionSet}.
|
|
210
|
+
*/
|
|
211
|
+
Equation_1.Equation.prototype.solveFor = function (variable) {
|
|
212
|
+
return (0, solve_1.solve)(this, variable);
|
|
213
|
+
};
|
|
214
|
+
/**
|
|
215
|
+
* Converts the expression to TeX.
|
|
216
|
+
*/
|
|
217
|
+
Expression_1.Expression.prototype.toTeX = function (options) {
|
|
218
|
+
return latexConverter.convert(this, normalizeTeXOptions(options));
|
|
219
|
+
};
|
|
220
|
+
/**
|
|
221
|
+
* Converts the expression to formatted text.
|
|
222
|
+
*/
|
|
223
|
+
Expression_1.Expression.prototype.toText = function () {
|
|
224
|
+
return textConverter.convert(this);
|
|
225
|
+
};
|
|
226
|
+
/** Legacy TeX conversion alias. */
|
|
227
|
+
Expression_1.Expression.prototype.latex = function (options) {
|
|
228
|
+
return latexConverter.convert(this, normalizeTeXOptions(options));
|
|
229
|
+
};
|
|
230
|
+
/** Legacy infinity check alias. */
|
|
231
|
+
Expression_1.Expression.prototype.isInfinity = function () {
|
|
232
|
+
return this.isInf();
|
|
233
|
+
};
|
|
234
|
+
/** Legacy fractional-multiplier check. */
|
|
235
|
+
Expression_1.Expression.prototype.isFraction = function () {
|
|
236
|
+
return !this.getMultiplier().isInteger();
|
|
237
|
+
};
|
|
238
|
+
/** Legacy integral-presence check. */
|
|
239
|
+
Expression_1.Expression.prototype.hasIntegral = function () {
|
|
240
|
+
return this.hasFunction('integrate', true);
|
|
241
|
+
};
|
|
242
|
+
/** Legacy equation-building helper. */
|
|
243
|
+
Expression_1.Expression.prototype.equals = function (value) {
|
|
244
|
+
return new Equation_1.Equation(this, Expression_1.Expression.create(value));
|
|
245
|
+
};
|
|
246
|
+
// -----------------------------------------------------------------------------
|
|
247
|
+
// Parsing and conversion
|
|
248
|
+
// -----------------------------------------------------------------------------
|
|
249
|
+
/**
|
|
250
|
+
* Formats a parser entity or notation string as TeX or normalized text.
|
|
251
|
+
*
|
|
252
|
+
* @param e - Parser entity or notation string to format.
|
|
253
|
+
* @param type - Output format. Defaults to `'TeX'`.
|
|
254
|
+
* @returns Formatted text without modifying an entity input.
|
|
255
|
+
*
|
|
256
|
+
* @example
|
|
257
|
+
* ```ts
|
|
258
|
+
* const f = nerdamer('x^2+1+2*x');
|
|
259
|
+
* nerdamer.pretty(f, 'text'); // 'x^2+2*x+1'
|
|
260
|
+
* nerdamer.pretty(f, 'TeX'); // 'x^{2}+2 \\cdot x+1'
|
|
261
|
+
* nerdamer.pretty('a*x+b*x^2+cos(x)', 'text'); // 'cos(x)+a*x+b*x^2'
|
|
262
|
+
* ```
|
|
263
|
+
*/
|
|
264
|
+
nerdamer.pretty = function (e, type = 'TeX') {
|
|
265
|
+
const converter = type === 'TeX' ? latexConverter : textConverter;
|
|
266
|
+
return converter.convert(e);
|
|
267
|
+
};
|
|
268
|
+
/**
|
|
269
|
+
* Parses the supported TeX subset into a Nerdamer parser entity.
|
|
270
|
+
*
|
|
271
|
+
* @param TeX - TeX source accepted by {@link Converter.fromTeX}.
|
|
272
|
+
* @returns The parsed parser entity. Not every TeX construct is supported.
|
|
273
|
+
*
|
|
274
|
+
* @example
|
|
275
|
+
* ```ts
|
|
276
|
+
* nerdamer.convertFromLaTeX('x^{2}+2 \\cdot x+1').text(); // '1+2*x+x^2'
|
|
277
|
+
* ```
|
|
278
|
+
*/
|
|
279
|
+
nerdamer.convertFromLaTeX = function (TeX) {
|
|
280
|
+
return latexConverter.fromTeX(TeX);
|
|
281
|
+
};
|
|
282
|
+
/**
|
|
283
|
+
* Converts an expression to TeX math markup without requiring the caller to construct a converter.
|
|
284
|
+
* String input follows the legacy source-preserving path before symbolic normalization;
|
|
285
|
+
* entity input keeps ordinary structured Converter behavior.
|
|
286
|
+
*
|
|
287
|
+
* @param expression - Parser entity or notation string to format.
|
|
288
|
+
* @param options - Converter formatting options. The legacy `'decimal'`, `'decimals'`,
|
|
289
|
+
* and `decimals: true` spellings are normalized to the 2.0 `decimal: true` option.
|
|
290
|
+
* Decimal conversion uses the evaluated Converter path.
|
|
291
|
+
* @returns TeX math markup generated by the shared converter.
|
|
292
|
+
*/
|
|
293
|
+
nerdamer.convertToTeX = function (expression, options) {
|
|
294
|
+
let conversionOptions = normalizeTeXOptions(options);
|
|
295
|
+
if (typeof expression === 'string' && !conversionOptions?.decimal) {
|
|
296
|
+
conversionOptions = { ...(conversionOptions ?? {}), preserveSource: true };
|
|
297
|
+
}
|
|
298
|
+
return latexConverter.convert(expression, conversionOptions);
|
|
299
|
+
};
|
|
300
|
+
/**
|
|
301
|
+
* Legacy alias for {@link nerdamer.convertToTeX}.
|
|
302
|
+
*
|
|
303
|
+
* @deprecated Use {@link nerdamer.convertToTeX} for TeX math output.
|
|
304
|
+
*/
|
|
305
|
+
nerdamer.convertToLaTeX = nerdamer.convertToTeX;
|
|
306
|
+
// -----------------------------------------------------------------------------
|
|
307
|
+
// Configuration and parser state
|
|
308
|
+
// -----------------------------------------------------------------------------
|
|
309
|
+
/**
|
|
310
|
+
* Registers a symbolic function using the legacy public signature.
|
|
311
|
+
*
|
|
312
|
+
* Calls subsequently parsed with `name` substitute their arguments into `body`
|
|
313
|
+
* in the supplied order. Registration changes shared parser state.
|
|
314
|
+
*
|
|
315
|
+
* @param name - Function name.
|
|
316
|
+
* @param args - Argument names in call order.
|
|
317
|
+
* @param body - Symbolic function body.
|
|
318
|
+
* @returns The root `nerdamer` function for chaining.
|
|
319
|
+
*/
|
|
320
|
+
nerdamer.setFunction = function (name, args, body) {
|
|
321
|
+
(0, setFunction_1.setFunction)({
|
|
322
|
+
type: 'symbolic',
|
|
323
|
+
name,
|
|
324
|
+
argsOrder: args,
|
|
325
|
+
fn: body,
|
|
326
|
+
});
|
|
327
|
+
return nerdamer;
|
|
328
|
+
};
|
|
329
|
+
/**
|
|
330
|
+
* Registers or removes a parser constant using the legacy public entry point.
|
|
331
|
+
*
|
|
332
|
+
* Numeric values are converted to exact rational text before registration so
|
|
333
|
+
* they do not introduce decimal-formatting intent. The string `'delete'`
|
|
334
|
+
* removes the constant. Registration changes shared parser state.
|
|
335
|
+
*
|
|
336
|
+
* @param name - Constant name.
|
|
337
|
+
* @param value - Constant value, or `'delete'` to remove it.
|
|
338
|
+
* @returns The root `nerdamer` function for chaining.
|
|
339
|
+
*/
|
|
340
|
+
nerdamer.setConstant = function (name, value) {
|
|
341
|
+
let constantValue = value === 'delete' ? '' : String(value);
|
|
342
|
+
// Legacy setConstant treats numeric values as exact constants rather than
|
|
343
|
+
// carrying decimal formatting intent into expressions that use them.
|
|
344
|
+
if (typeof value === 'number') {
|
|
345
|
+
const rational = Rational_1.Rational.create(String(value));
|
|
346
|
+
constantValue =
|
|
347
|
+
rational.denominator === 1n
|
|
348
|
+
? String(rational.numerator)
|
|
349
|
+
: `${rational.numerator}/${rational.denominator}`;
|
|
350
|
+
}
|
|
351
|
+
Parser_1.Parser.setConstants({ [name]: constantValue });
|
|
352
|
+
return nerdamer;
|
|
353
|
+
};
|
|
354
|
+
/**
|
|
355
|
+
* Returns the current text registered for a parser constant.
|
|
356
|
+
*
|
|
357
|
+
* Built-in constants are generated at the active precision before being returned.
|
|
358
|
+
* As in the legacy API, an unknown constant is reported as the string `'undefined'`.
|
|
359
|
+
*
|
|
360
|
+
* @param name - Constant name to read.
|
|
361
|
+
* @returns The registered constant text.
|
|
362
|
+
*/
|
|
363
|
+
nerdamer.getConstant = function (name) {
|
|
364
|
+
const constants = constants_1.PARSER_CONSTANTS;
|
|
365
|
+
const constant = constants[name];
|
|
366
|
+
return String(typeof constant === 'function' ? constant() : constant);
|
|
367
|
+
};
|
|
368
|
+
/**
|
|
369
|
+
* Changes one or more shared parser settings.
|
|
370
|
+
*
|
|
371
|
+
* The legacy `PRECISION` setting is routed through {@link Parser.setPrecision} so Decimal-backed
|
|
372
|
+
* calculations and the finite-precision `pi` and `e` constants remain synchronized.
|
|
373
|
+
*
|
|
374
|
+
* @param setting - Setting name or settings object accepted by {@link Parser.set}.
|
|
375
|
+
* @param value - Value used when `setting` is a single name.
|
|
376
|
+
* @returns The root `nerdamer` function for chaining.
|
|
377
|
+
*/
|
|
378
|
+
nerdamer.set = function (setting, value) {
|
|
379
|
+
if (setting === 'PRECISION') {
|
|
380
|
+
Parser_1.Parser.setPrecision(Number(value));
|
|
381
|
+
}
|
|
382
|
+
else if (typeof setting === 'object' && 'PRECISION' in setting) {
|
|
383
|
+
const { PRECISION, ...remainingSettings } = setting;
|
|
384
|
+
Parser_1.Parser.set(remainingSettings);
|
|
385
|
+
Parser_1.Parser.setPrecision(Number(PRECISION));
|
|
386
|
+
}
|
|
387
|
+
else {
|
|
388
|
+
Parser_1.Parser.set(setting, value);
|
|
389
|
+
}
|
|
390
|
+
return nerdamer;
|
|
391
|
+
};
|
|
392
|
+
/**
|
|
393
|
+
* Reads the current value of a shared parser setting.
|
|
394
|
+
*
|
|
395
|
+
* `PRECISION` mirrors the root setter's special handling and is read from the
|
|
396
|
+
* shared Rational/Decimal precision. Other settings delegate to the parser.
|
|
397
|
+
*
|
|
398
|
+
* @param setting - Parser setting to read.
|
|
399
|
+
* @returns The setting's current value.
|
|
400
|
+
*/
|
|
401
|
+
nerdamer.get = function (setting) {
|
|
402
|
+
let retval;
|
|
403
|
+
if (setting === 'PRECISION') {
|
|
404
|
+
retval = Parser_1.Parser.getPrecision();
|
|
405
|
+
}
|
|
406
|
+
else {
|
|
407
|
+
retval = Parser_1.Parser.get(setting);
|
|
408
|
+
}
|
|
409
|
+
return retval;
|
|
410
|
+
};
|
|
411
|
+
/** Returns a detached snapshot of a registered parser operator. */
|
|
412
|
+
nerdamer.getOperator = function (symbol) {
|
|
413
|
+
return Parser_1.Parser.getOperator(symbol);
|
|
414
|
+
};
|
|
415
|
+
/** Registers or updates a parser operator and returns the root API for chaining. */
|
|
416
|
+
nerdamer.setOperator = function (operator, action) {
|
|
417
|
+
Parser_1.Parser.setOperator(operator, action);
|
|
418
|
+
return nerdamer;
|
|
419
|
+
};
|
|
420
|
+
/** Aliases an existing parser operator and returns the root API for chaining. */
|
|
421
|
+
nerdamer.aliasOperator = function (symbol, alias) {
|
|
422
|
+
Parser_1.Parser.aliasOperator(symbol, alias);
|
|
423
|
+
return nerdamer;
|
|
424
|
+
};
|
|
425
|
+
/**
|
|
426
|
+
* Sets a known parser value. Unlike a constant, a known value can be overridden
|
|
427
|
+
* by the values object supplied to a parse call.
|
|
428
|
+
*
|
|
429
|
+
* @param name - Known-value name.
|
|
430
|
+
* @param value - Value to assign, or `'delete'` to remove the assignment.
|
|
431
|
+
* @returns Nothing. This operation changes shared parser state.
|
|
432
|
+
*/
|
|
433
|
+
nerdamer.setVar = function (name, value) {
|
|
434
|
+
if (value === 'delete') {
|
|
435
|
+
(0, scope_1.unassign)(name);
|
|
436
|
+
}
|
|
437
|
+
else {
|
|
438
|
+
(0, scope_1.assign)(name, String(value));
|
|
439
|
+
}
|
|
440
|
+
};
|
|
441
|
+
/**
|
|
442
|
+
* Clears all known parser values.
|
|
443
|
+
*
|
|
444
|
+
* @returns The nerdamer function for chaining.
|
|
445
|
+
*/
|
|
446
|
+
nerdamer.clearVars = function () {
|
|
447
|
+
for (const name of Object.keys(Parser_1.Parser.KNOWN_VALUES)) {
|
|
448
|
+
(0, scope_1.unassign)(name);
|
|
449
|
+
}
|
|
450
|
+
return nerdamer;
|
|
451
|
+
};
|
|
452
|
+
/**
|
|
453
|
+
* Returns a snapshot of all known parser values in text or TeX form.
|
|
454
|
+
*
|
|
455
|
+
* @param option - Output format. Defaults to `'text'`.
|
|
456
|
+
* @returns A new record keyed by known-value name.
|
|
457
|
+
*/
|
|
458
|
+
nerdamer.getVars = function (option = 'text') {
|
|
459
|
+
const converter = option === 'LaTeX' ? latexConverter : textConverter;
|
|
460
|
+
const retval = {};
|
|
461
|
+
for (const name of Object.keys(Parser_1.Parser.KNOWN_VALUES)) {
|
|
462
|
+
retval[name] = converter.convert(Parser_1.Parser.KNOWN_VALUES[name]);
|
|
463
|
+
}
|
|
464
|
+
return retval;
|
|
465
|
+
};
|
|
466
|
+
/**
|
|
467
|
+
* Lists currently registered parser functions by registration level.
|
|
468
|
+
*
|
|
469
|
+
* @returns New `user` and `system` name arrays reflecting current shared state.
|
|
470
|
+
*/
|
|
471
|
+
nerdamer.functions = function () {
|
|
472
|
+
const retval = { user: [], system: [] };
|
|
473
|
+
for (const x in dispatch_1.mathFunctionRegistry) {
|
|
474
|
+
const f = dispatch_1.mathFunctionRegistry[x];
|
|
475
|
+
retval[f.level].push(x);
|
|
476
|
+
}
|
|
477
|
+
return retval;
|
|
478
|
+
};
|
|
479
|
+
// -----------------------------------------------------------------------------
|
|
480
|
+
// Root utilities and compatibility namespaces
|
|
481
|
+
// -----------------------------------------------------------------------------
|
|
482
|
+
/** Creates frozen plain-variable Expressions keyed by their requested names. */
|
|
483
|
+
nerdamer.symbols = shortcuts_1.symbols;
|
|
484
|
+
/**
|
|
485
|
+
* Returns the package version declared by this Nerdamer build.
|
|
486
|
+
* @returns The semantic version string.
|
|
487
|
+
*
|
|
488
|
+
* @example
|
|
489
|
+
* ```ts
|
|
490
|
+
* nerdamer.version(); // '2.0.0'
|
|
491
|
+
* ```
|
|
492
|
+
*/
|
|
493
|
+
nerdamer.version = function () {
|
|
494
|
+
return package_json_1.default.version;
|
|
495
|
+
};
|
|
496
|
+
/**
|
|
497
|
+
* Runtime namespace containing Nerdamer's public error constructors.
|
|
498
|
+
*
|
|
499
|
+
* Use these constructors for reliable `instanceof` checks when calling the
|
|
500
|
+
* compatibility root API.
|
|
501
|
+
*/
|
|
502
|
+
nerdamer.errors = errors;
|
|
503
|
+
/**
|
|
504
|
+
* Compiles an expression into a native JavaScript-number function.
|
|
505
|
+
*
|
|
506
|
+
* @remarks
|
|
507
|
+
* This uses dynamic JavaScript function construction and may be unavailable under
|
|
508
|
+
* a strict Content Security Policy. It favors native-number throughput over
|
|
509
|
+
* Nerdamer's exact or arbitrary-precision arithmetic. Scalar function calls are linked
|
|
510
|
+
* to explicit numerical implementations; symbolic-only or structured operations that
|
|
511
|
+
* survive to this stage are rejected rather than compiled incorrectly. When `argsArray`
|
|
512
|
+
* is omitted, variable names are sorted alphabetically.
|
|
513
|
+
*
|
|
514
|
+
* Values returned by `nerdamer(...)` also expose `buildFunction()` for convenient
|
|
515
|
+
* chaining. That form succeeds only when the parsed result is an Expression; structured
|
|
516
|
+
* results throw {@link core!UnexpectedDataType} instead of compiling their members.
|
|
517
|
+
*
|
|
518
|
+
* @param x - Expression to compile.
|
|
519
|
+
* @param argsArray - Optional argument names in call order.
|
|
520
|
+
* @returns A numeric function accepting and returning JavaScript numbers.
|
|
521
|
+
* @throws {@link core!UnsupportedOperationError} If a surviving function has no faithful
|
|
522
|
+
* JavaScript-number implementation.
|
|
523
|
+
*
|
|
524
|
+
* @example
|
|
525
|
+
* ```ts
|
|
526
|
+
* nerdamer.buildFunction('x-y')(9, 7); // 2
|
|
527
|
+
* nerdamer.buildFunction('x-y', ['y', 'x'])(9, 7); // -2
|
|
528
|
+
* nerdamer.buildFunction('erf(x)+2')(9) // 3
|
|
529
|
+
* nerdamer('cos(x)').buildFunction(['x'])(0); // 1
|
|
530
|
+
* ```
|
|
531
|
+
*/
|
|
532
|
+
nerdamer.buildFunction = build_1.build;
|
|
533
|
+
/**
|
|
534
|
+
* Compatibility registry of selected Nerdamer constructors and the shared Parser instance.
|
|
535
|
+
*
|
|
536
|
+
* @remarks
|
|
537
|
+
* This registry is retained as a supported compatibility surface for 2.0. Typed code
|
|
538
|
+
* should prefer the documented package subpaths, which provide domain-specific and advanced
|
|
539
|
+
* import paths without relying on registry membership.
|
|
540
|
+
*/
|
|
541
|
+
nerdamer.classes = {
|
|
542
|
+
Expression: Expression_1.Expression,
|
|
543
|
+
Rational: Rational_1.Rational,
|
|
544
|
+
Polynomial: Polynomial_1.Polynomial,
|
|
545
|
+
Matrix: Matrix_1.Matrix,
|
|
546
|
+
Vector: Vector_1.Vector,
|
|
547
|
+
Collection: Collection_1.Collection,
|
|
548
|
+
Converter: Converter_1.Converter,
|
|
549
|
+
Dictionary: Dictionary_1.Dictionary,
|
|
550
|
+
ValuesSet: ValuesSet_1.ValuesSet,
|
|
551
|
+
SolutionSet: SolutionSet_1.SolutionSet,
|
|
552
|
+
Assumption: Assumption_1.Assumption,
|
|
553
|
+
Equation: Equation_1.Equation,
|
|
554
|
+
instance: {
|
|
555
|
+
Parser: Parser_1.Parser,
|
|
556
|
+
},
|
|
557
|
+
};
|
|
558
|
+
// -----------------------------------------------------------------------------
|
|
559
|
+
// Mathematical root API
|
|
560
|
+
// -----------------------------------------------------------------------------
|
|
561
|
+
// Trigonometric functions
|
|
562
|
+
nerdamer.cos = trig_1.cos;
|
|
563
|
+
nerdamer.sin = trig_1.sin;
|
|
564
|
+
nerdamer.tan = trig_1.tan;
|
|
565
|
+
nerdamer.acos = trig_1.acos;
|
|
566
|
+
nerdamer.asin = trig_1.asin;
|
|
567
|
+
nerdamer.atan = trig_1.atan;
|
|
568
|
+
nerdamer.arccos = trig_1.acos;
|
|
569
|
+
nerdamer.arcsin = trig_1.asin;
|
|
570
|
+
nerdamer.arctan = trig_1.atan;
|
|
571
|
+
nerdamer.atan2 = trig_1.atan2;
|
|
572
|
+
nerdamer.sec = trig_1.sec;
|
|
573
|
+
nerdamer.csc = trig_1.csc;
|
|
574
|
+
nerdamer.cot = trig_1.cot;
|
|
575
|
+
nerdamer.asec = trig_1.asec;
|
|
576
|
+
nerdamer.acsc = trig_1.acsc;
|
|
577
|
+
nerdamer.acot = trig_1.acot;
|
|
578
|
+
// Hyperbolic functions
|
|
579
|
+
nerdamer.cosh = trig_1.cosh;
|
|
580
|
+
nerdamer.sinh = trig_1.sinh;
|
|
581
|
+
nerdamer.tanh = trig_1.tanh;
|
|
582
|
+
nerdamer.acosh = trig_1.acosh;
|
|
583
|
+
nerdamer.asinh = trig_1.asinh;
|
|
584
|
+
nerdamer.atanh = trig_1.atanh;
|
|
585
|
+
nerdamer.sech = trig_1.sech;
|
|
586
|
+
nerdamer.csch = trig_1.csch;
|
|
587
|
+
nerdamer.coth = trig_1.coth;
|
|
588
|
+
nerdamer.asech = trig_1.asech;
|
|
589
|
+
nerdamer.acsch = trig_1.acsch;
|
|
590
|
+
nerdamer.acoth = trig_1.acoth;
|
|
591
|
+
// Elementary and numeric functions
|
|
592
|
+
nerdamer.log = math_1.log;
|
|
593
|
+
nerdamer.exp = math_1.exp;
|
|
594
|
+
nerdamer.sqrt = math_1.sqrt;
|
|
595
|
+
nerdamer.cbrt = math_1.cbrt;
|
|
596
|
+
nerdamer.nthroot = math_1.nthroot;
|
|
597
|
+
nerdamer.numeric = math_1.numeric;
|
|
598
|
+
nerdamer.abs = math_1.abs;
|
|
599
|
+
nerdamer.sign = math_1.sign;
|
|
600
|
+
nerdamer.min = math_1.min;
|
|
601
|
+
nerdamer.max = math_1.max;
|
|
602
|
+
nerdamer.round = math_1.round;
|
|
603
|
+
nerdamer.floor = math_1.floor;
|
|
604
|
+
nerdamer.ceil = math_1.ceiling;
|
|
605
|
+
nerdamer.trunc = trunc_1.trunc;
|
|
606
|
+
nerdamer.hypot = geometry_1.hypot;
|
|
607
|
+
// Discrete and number-theoretic functions
|
|
608
|
+
nerdamer.fact = math_1.factorial;
|
|
609
|
+
nerdamer.factorial = math_1.factorial;
|
|
610
|
+
nerdamer.dfact = math_1.doubleFactorial;
|
|
611
|
+
nerdamer.dfactorial = math_1.doubleFactorial;
|
|
612
|
+
nerdamer.fib = math_1.fibonacci;
|
|
613
|
+
nerdamer.mod = math_1.mod;
|
|
614
|
+
nerdamer.modInv = math_1.modInv;
|
|
615
|
+
nerdamer.isPrime = utils_3.isprime;
|
|
616
|
+
// Complex functions
|
|
617
|
+
nerdamer.imagpart = complex_1.imagPart;
|
|
618
|
+
nerdamer.realpart = complex_1.realPart;
|
|
619
|
+
nerdamer.polarform = complex_1.polarForm;
|
|
620
|
+
nerdamer.rectform = complex_1.rectForm;
|
|
621
|
+
nerdamer.arg = complex_1.arg;
|
|
622
|
+
nerdamer.conjugate = complex_1.conjugate;
|
|
623
|
+
nerdamer.csgn = complex_1.csgn;
|
|
624
|
+
// Special functions
|
|
625
|
+
nerdamer.gamma = math_1.gamma;
|
|
626
|
+
nerdamer.erf = math_1.erf;
|
|
627
|
+
nerdamer.erfc = math_1.erfc;
|
|
628
|
+
nerdamer.heaviside = math_1.heaviside;
|
|
629
|
+
nerdamer.delta = math_1.dirac;
|
|
630
|
+
nerdamer.Ci = math_1.Ci;
|
|
631
|
+
nerdamer.Chi = math_1.Chi;
|
|
632
|
+
nerdamer.Si = math_1.Si;
|
|
633
|
+
nerdamer.Shi = math_1.Shi;
|
|
634
|
+
nerdamer.Li = math_1.Li;
|
|
635
|
+
nerdamer.Ei = math_1.Ei;
|
|
636
|
+
nerdamer.sinc = math_1.sinc;
|
|
637
|
+
// Symbolic utilities
|
|
638
|
+
nerdamer.contains = math_1.contains;
|
|
639
|
+
nerdamer.subst = subst_1.subst;
|
|
640
|
+
nerdamer.uSub = subst_1.uSub;
|
|
641
|
+
nerdamer.uUnSub = subst_1.uUnSub;
|
|
642
|
+
// Algebra
|
|
643
|
+
nerdamer.expand = expand_1.expand;
|
|
644
|
+
nerdamer.factor = factor_1.factor;
|
|
645
|
+
nerdamer.polyFactors = factor_1.polyFactors;
|
|
646
|
+
nerdamer.completeSquare = utils_1.sqcomp;
|
|
647
|
+
nerdamer.gcd = gcd_1.gcd;
|
|
648
|
+
nerdamer.lcm = gcd_1.lcm;
|
|
649
|
+
nerdamer.partfrac = partfrac_1.partfrac;
|
|
650
|
+
nerdamer.div = functions_2.div;
|
|
651
|
+
nerdamer.divide = functions_2.divide;
|
|
652
|
+
nerdamer.simplify = simplify_1.simplify;
|
|
653
|
+
nerdamer.groebner = groebner_1.groebner;
|
|
654
|
+
// Solvers
|
|
655
|
+
nerdamer.solve = solve_1.solve;
|
|
656
|
+
nerdamer.solveSystem = solveSystem_1.solveSystem;
|
|
657
|
+
nerdamer.solveeqs = solveSystem_1.solveSystem;
|
|
658
|
+
// Calculus
|
|
659
|
+
nerdamer.diff = diff_1.diff;
|
|
660
|
+
nerdamer.integrate = integrate_1.integrate;
|
|
661
|
+
nerdamer.laplace = laplace_1.laplace;
|
|
662
|
+
nerdamer.ilaplace = ilaplace_1.ilaplace;
|
|
663
|
+
nerdamer.ilt = ilaplace_1.ilaplace;
|
|
664
|
+
nerdamer.sum = math_1.sum;
|
|
665
|
+
nerdamer.product = math_1.product;
|
|
666
|
+
nerdamer.limit = limit_1.limit;
|
|
667
|
+
nerdamer.defint = math_1.defint;
|
|
668
|
+
nerdamer.S = fresnel_1.S;
|
|
669
|
+
nerdamer.C = fresnel_1.C;
|
|
670
|
+
// Matrix operations
|
|
671
|
+
nerdamer.matrix = math_1.matrix;
|
|
672
|
+
nerdamer.imatrix = utils_2.imatrix;
|
|
673
|
+
nerdamer.determinant = functions_1.determinant;
|
|
674
|
+
nerdamer.nullspace = functions_1.nullspace;
|
|
675
|
+
// Vector operations
|
|
676
|
+
nerdamer.dot = functions_3.dot;
|
|
677
|
+
nerdamer.cross = functions_3.cross;
|
|
678
|
+
// Polynomial operations
|
|
679
|
+
nerdamer.deg = functions_2.deg;
|
|
680
|
+
nerdamer.content = functions_2.content;
|
|
681
|
+
// Assumptions
|
|
682
|
+
/**
|
|
683
|
+
* Registers a process-wide numeric interval assumption.
|
|
684
|
+
*
|
|
685
|
+
* @remarks
|
|
686
|
+
* Repeated constraints for a variable are intersected. Assumptions are consulted by
|
|
687
|
+
* symbolic comparisons and by algorithms that depend on those comparisons. The root
|
|
688
|
+
* compatibility API uses global state in 2.0; callers that need to clear or inspect it
|
|
689
|
+
* directly can use the documented assumption-domain functions.
|
|
690
|
+
*/
|
|
691
|
+
nerdamer.assume = assume_1.assume;
|
|
692
|
+
// -----------------------------------------------------------------------------
|
|
693
|
+
// Complete the full-package instance API
|
|
694
|
+
// -----------------------------------------------------------------------------
|
|
695
|
+
//
|
|
696
|
+
// Root functions are exposed as chainable instance methods only after the complete
|
|
697
|
+
// Nerdamer API has been assembled above. Native class methods are left untouched.
|
|
698
|
+
nerdamer.updateAPI = function () {
|
|
699
|
+
const methods = {
|
|
700
|
+
diff: nerdamer.diff,
|
|
701
|
+
expand: nerdamer.expand,
|
|
702
|
+
factor: nerdamer.factor,
|
|
703
|
+
integrate: nerdamer.integrate,
|
|
704
|
+
numeric: nerdamer.numeric,
|
|
705
|
+
simplify: nerdamer.simplify,
|
|
706
|
+
subst: nerdamer.subst,
|
|
707
|
+
};
|
|
708
|
+
const scalarMethods = {
|
|
709
|
+
buildFunction: nerdamer.buildFunction,
|
|
710
|
+
};
|
|
711
|
+
extendApi([Expression_1.Expression, Matrix_1.Matrix, Vector_1.Vector, Collection_1.Collection, Dictionary_1.Dictionary, ValuesSet_1.ValuesSet, Equation_1.Equation], methods, scalarMethods);
|
|
712
|
+
return nerdamer;
|
|
713
|
+
};
|
|
714
|
+
nerdamer.updateAPI();
|
|
715
|
+
exports.default = nerdamer;
|