nerdamer 2.0.0-rc.1 → 2.0.0
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 -0
- package/README.md +168 -229
- package/dist/bundle.js +1 -1
- package/dist/bundle.js.LICENSE.txt +6 -6
- package/output/algebra/adapters.d.ts +3 -33
- package/output/algebra/adapters.js +7 -105
- package/output/algebra/algorithms/arith.js +10 -9
- package/output/algebra/algorithms/groebnerBase.d.ts +24 -20
- package/output/algebra/algorithms/groebnerBase.js +486 -723
- package/output/algebra/dispatch.d.ts +1 -0
- package/output/algebra/dispatch.js +25 -0
- package/output/algebra/factor/factor.d.ts +15 -0
- package/output/algebra/factor/factor.js +99 -12
- package/output/algebra/gcd/gcd.d.ts +8 -7
- package/output/algebra/gcd/gcd.js +32 -78
- package/output/algebra/groebner.d.ts +2 -2
- package/output/algebra/groebner.js +6 -12
- package/output/algebra/partfrac.d.ts +3 -3
- package/output/algebra/partfrac.js +28 -61
- 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.js +4 -2
- package/output/algebra/simplify/funcsimp.js +1 -1
- package/output/algebra/simplify/ratsimp.js +1 -1
- package/output/algebra/simplify/simplify.js +11 -2
- package/output/algebra/utils.d.ts +1 -1
- package/output/algebra/utils.js +3 -3
- package/output/api/advanced.d.ts +2 -1
- package/output/api/advanced.js +3 -3
- package/output/api/algebra.d.ts +21 -4
- package/output/api/algebra.js +22 -3
- package/output/api/assumptions.d.ts +1 -1
- package/output/api/assumptions.js +2 -1
- package/output/api/calculus.d.ts +2 -1
- package/output/api/calculus.js +2 -1
- package/output/api/core.d.ts +28 -7
- package/output/api/core.js +28 -2
- 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 +10 -2
- package/output/api/parser.js +2 -0
- package/output/api/solve.d.ts +1 -1
- package/output/api/solve.js +2 -1
- package/output/api/structures.d.ts +1 -1
- package/output/api/structures.js +2 -1
- package/output/calculus/adapters.d.ts +8 -0
- package/output/calculus/adapters.js +41 -0
- package/output/calculus/derivative/diff.js +6 -3
- package/output/calculus/dispatch.d.ts +1 -0
- package/output/calculus/dispatch.js +25 -0
- package/output/calculus/integrate/integrate.js +4 -4
- package/output/calculus/integrate/integrationTable.js +16 -16
- package/output/calculus/laplace/ilaplace.js +1 -1
- package/output/calculus/laplace/ilaplaceTable.js +18 -17
- package/output/calculus/laplace/laplaceTable.js +3 -2
- package/output/calculus/limit/limit.js +1 -1
- package/output/core/classes/assumption/Assumption.js +14 -10
- package/output/core/classes/assumption/assume.d.ts +6 -0
- package/output/core/classes/assumption/assume.js +9 -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.js +11 -2
- package/output/core/classes/complex/Complex.d.ts +10 -0
- package/output/core/classes/complex/Complex.js +19 -1
- package/output/core/classes/decimalSet/DecimalSet.js +5 -4
- package/output/core/classes/dictionary/Dictionary.js +4 -1
- package/output/core/classes/expression/CoeffObject.d.ts +1 -1
- package/output/core/classes/expression/CoeffObject.js +1 -2
- package/output/core/classes/expression/Expression.d.ts +35 -26
- package/output/core/classes/expression/Expression.js +77 -50
- package/output/core/classes/expression/analysis.d.ts +1 -1
- package/output/core/classes/expression/analysis.js +7 -7
- package/output/core/classes/expression/format.d.ts +9 -0
- package/output/core/classes/expression/format.js +130 -7
- package/output/core/classes/expression/utils.d.ts +9 -0
- package/output/core/classes/expression/utils.js +52 -6
- package/output/core/classes/matrix/Matrix.d.ts +2 -3
- package/output/core/classes/matrix/Matrix.js +26 -23
- 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 +2 -0
- package/output/core/classes/matrix/functions.js +5 -0
- package/output/core/classes/parser/Parser.d.ts +31 -5
- package/output/core/classes/parser/Parser.js +357 -444
- package/output/core/classes/parser/constants.d.ts +2 -0
- package/output/core/classes/parser/constants.js +4 -2
- package/output/core/classes/parser/controlFlowSignals.d.ts +38 -0
- package/output/core/classes/parser/controlFlowSignals.js +60 -0
- package/output/core/classes/parser/operations/add.js +14 -16
- package/output/core/classes/parser/operations/compare.js +13 -0
- package/output/core/classes/parser/operations/functions.d.ts +3 -4
- package/output/core/classes/parser/operations/functions.js +48 -102
- package/output/core/classes/parser/operations/multiply.js +22 -15
- package/output/core/classes/parser/operations/power.js +11 -11
- package/output/core/classes/parser/operations/subtract.js +2 -1
- package/output/core/classes/parser/preprocess.d.ts +0 -7
- package/output/core/classes/parser/preprocess.js +33 -39
- package/output/core/classes/parser/scripting/controlFlow.d.ts +4 -102
- package/output/core/classes/parser/scripting/controlFlow.js +134 -186
- 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 +13 -0
- package/output/core/classes/parser/scripting/evaluate.js +17 -1
- package/output/core/classes/parser/scripting/scope.d.ts +1 -28
- package/output/core/classes/parser/scripting/scope.js +36 -40
- package/output/core/classes/parser/types.d.ts +5 -5
- package/output/core/classes/parser/wrappers/IndexedReference.d.ts +4 -3
- package/output/core/classes/parser/wrappers/IndexedReference.js +8 -0
- package/output/core/classes/parser/wrappers/KeyValuePair.d.ts +2 -2
- package/output/core/classes/polynomial/Polynomial.d.ts +5 -1
- package/output/core/classes/polynomial/Polynomial.js +53 -7
- 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.js +2 -2
- package/output/core/{adapters.d.ts → classes/polynomial/adapters.d.ts} +2 -2
- 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 +8 -0
- package/output/core/classes/polynomial/functions.js +71 -8
- package/output/core/classes/polynomial/utils.js +2 -1
- package/output/core/classes/rational/Rational.d.ts +8 -11
- package/output/core/classes/rational/Rational.js +70 -20
- package/output/core/classes/seq/SEQ.js +4 -4
- package/output/core/classes/valuesSet/ValuesSet.d.ts +9 -1
- package/output/core/classes/valuesSet/ValuesSet.js +22 -4
- package/output/core/classes/vector/Vector.d.ts +2 -3
- package/output/core/classes/vector/Vector.js +11 -15
- package/output/core/classes/vector/dispatch.d.ts +1 -0
- package/output/core/classes/vector/dispatch.js +11 -0
- package/output/core/common/classes/MathematicalAggregate.js +11 -2
- package/output/core/common/classes/StructuredEntity.d.ts +0 -17
- package/output/core/common/classes/StructuredEntity.js +3 -64
- package/output/core/common/common.d.ts +0 -1
- package/output/core/common/common.js +29 -234
- package/output/core/converters/BaseConverter.js +3 -2
- package/output/core/converters/Converter.js +9 -5
- package/output/core/converters/Pattern.js +1 -1
- package/output/core/dispatch.d.ts +18 -0
- package/output/core/dispatch.js +3 -281
- package/output/core/errors.d.ts +259 -474
- package/output/core/errors.js +270 -542
- package/output/core/fullFunctions.d.ts +7 -0
- package/output/core/fullFunctions.js +31 -0
- package/output/core/functions/bigint/bigint.d.ts +13 -1
- package/output/core/functions/bigint/bigint.js +56 -4
- package/output/core/functions/bigint/primeFactor.d.ts +2 -0
- package/output/core/functions/bigint/primeFactor.js +13 -13
- package/output/core/functions/build/definitions.js +6 -0
- package/output/core/functions/complex.d.ts +2 -2
- 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 +7 -7
- package/output/core/functions/decimal.js +2 -1
- package/output/core/functions/expand/expand.js +2 -2
- package/output/core/functions/numeric.d.ts +1 -1
- package/output/core/functions/string.js +2 -1
- package/output/core/functions/subst.js +21 -13
- package/output/core/parserFunctions.d.ts +7 -0
- package/output/core/parserFunctions.js +25 -0
- package/output/index.d.ts +50 -30
- package/output/index.js +147 -19
- package/output/math/defint/defint.d.ts +18 -0
- package/output/math/defint/defint.js +60 -0
- package/output/math/defint/defintDecimal.js +6 -5
- package/output/math/defint/defintNative.js +7 -18
- package/output/math/dispatch.d.ts +1 -0
- package/output/math/dispatch.js +101 -0
- package/output/math/geometry.d.ts +4 -0
- package/output/math/geometry.js +23 -0
- package/output/math/math.d.ts +59 -19
- package/output/math/math.js +244 -100
- package/output/math/trig.js +4 -4
- package/output/math/utils.d.ts +6 -0
- package/output/math/utils.js +39 -0
- package/output/solve/classes/PolynomialSolver.d.ts +33 -14
- package/output/solve/classes/PolynomialSolver.js +267 -67
- package/output/solve/classes/SolutionSet.d.ts +20 -1
- package/output/solve/classes/SolutionSet.js +82 -5
- package/output/solve/dispatch.d.ts +1 -0
- package/output/solve/dispatch.js +13 -0
- package/output/solve/linsolve.d.ts +2 -0
- package/output/solve/linsolve.js +13 -5
- package/output/solve/solve.d.ts +10 -0
- package/output/solve/solve.js +128 -20
- package/output/solve/solveSystem.d.ts +1 -1
- package/output/solve/solveSystem.js +8 -32
- package/output/solve/utils.d.ts +2 -1
- package/output/solve/utils.js +18 -22
- package/output/utils/array.d.ts +1 -1
- package/output/utils/debug.js +2 -1
- package/package.json +22 -38
- package/dist/parser.js +0 -2
- package/dist/parser.js.LICENSE.txt +0 -7
- package/docs-data/parser-functions.json +0 -1960
- package/output/algebra/algorithms/factor.d.ts +0 -3
- package/output/algebra/algorithms/factor.js +0 -5
- package/output/algebra/algorithms/factorMultivariate.d.ts +0 -23
- package/output/algebra/algorithms/factorMultivariate.js +0 -2393
- package/output/algebra/algorithms/factorUnivariate.d.ts +0 -72
- package/output/algebra/algorithms/factorUnivariate.js +0 -1072
- package/output/algebra/algorithms/gcd.d.ts +0 -22
- package/output/algebra/algorithms/gcd.js +0 -690
- package/output/algebra/algorithms/multiPoly/MultiPoly.d.ts +0 -137
- package/output/algebra/algorithms/multiPoly/MultiPoly.js +0 -346
- package/output/algebra/algorithms/poly.d.ts +0 -228
- package/output/algebra/algorithms/poly.js +0 -1299
- package/output/algebra/algorithms/rational.d.ts +0 -17
- package/output/algebra/algorithms/rational.js +0 -115
- package/output/core/adapters.js +0 -40
- package/output/core/classes/parser/operations/comma.d.ts +0 -7
- package/output/core/classes/parser/operations/comma.js +0 -11
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export type Rat = {
|
|
2
|
-
n: bigint;
|
|
3
|
-
d: bigint;
|
|
4
|
-
};
|
|
5
|
-
export declare function ratNorm(r: Rat): Rat;
|
|
6
|
-
export declare function rat(n: bigint, d?: bigint): Rat;
|
|
7
|
-
export declare function ratAdd(a: Rat, b: Rat): Rat;
|
|
8
|
-
export declare function ratSub(a: Rat, b: Rat): Rat;
|
|
9
|
-
export declare function ratMul(a: Rat, b: Rat): Rat;
|
|
10
|
-
export declare function ratDiv(a: Rat, b: Rat): Rat;
|
|
11
|
-
export declare function ratToInt(r: Rat): bigint | null;
|
|
12
|
-
export declare function uniAddRat(a: Rat[], b: Rat[]): Rat[];
|
|
13
|
-
export declare function uniMulRat(a: Rat[], b: Rat[]): Rat[];
|
|
14
|
-
export declare function interpolateUnivariateRat(points: Array<{
|
|
15
|
-
x: bigint;
|
|
16
|
-
y: Rat;
|
|
17
|
-
}>): Rat[];
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ratNorm = ratNorm;
|
|
4
|
-
exports.rat = rat;
|
|
5
|
-
exports.ratAdd = ratAdd;
|
|
6
|
-
exports.ratSub = ratSub;
|
|
7
|
-
exports.ratMul = ratMul;
|
|
8
|
-
exports.ratDiv = ratDiv;
|
|
9
|
-
exports.ratToInt = ratToInt;
|
|
10
|
-
exports.uniAddRat = uniAddRat;
|
|
11
|
-
exports.uniMulRat = uniMulRat;
|
|
12
|
-
exports.interpolateUnivariateRat = interpolateUnivariateRat;
|
|
13
|
-
const arith_1 = require("./arith");
|
|
14
|
-
function ratNorm(r) {
|
|
15
|
-
if (r.d === 0n) {
|
|
16
|
-
throw new Error('Rat: division by zero');
|
|
17
|
-
}
|
|
18
|
-
if (r.n === 0n) {
|
|
19
|
-
return { n: 0n, d: 1n };
|
|
20
|
-
}
|
|
21
|
-
let n = r.n;
|
|
22
|
-
let d = r.d;
|
|
23
|
-
if (d < 0n) {
|
|
24
|
-
n = -n;
|
|
25
|
-
d = -d;
|
|
26
|
-
}
|
|
27
|
-
const g0 = (0, arith_1.gcd)(n, d);
|
|
28
|
-
return { n: n / g0, d: d / g0 };
|
|
29
|
-
}
|
|
30
|
-
function rat(n, d = 1n) {
|
|
31
|
-
return ratNorm({ n, d });
|
|
32
|
-
}
|
|
33
|
-
function ratAdd(a, b) {
|
|
34
|
-
return ratNorm({ n: a.n * b.d + b.n * a.d, d: a.d * b.d });
|
|
35
|
-
}
|
|
36
|
-
function ratSub(a, b) {
|
|
37
|
-
return ratNorm({ n: a.n * b.d - b.n * a.d, d: a.d * b.d });
|
|
38
|
-
}
|
|
39
|
-
function ratMul(a, b) {
|
|
40
|
-
return ratNorm({ n: a.n * b.n, d: a.d * b.d });
|
|
41
|
-
}
|
|
42
|
-
function ratDiv(a, b) {
|
|
43
|
-
if (b.n === 0n) {
|
|
44
|
-
throw new Error('Rat: divide by zero');
|
|
45
|
-
}
|
|
46
|
-
return ratNorm({ n: a.n * b.d, d: a.d * b.n });
|
|
47
|
-
}
|
|
48
|
-
function ratToInt(r) {
|
|
49
|
-
return r.d === 1n ? r.n : null;
|
|
50
|
-
}
|
|
51
|
-
function uniAddRat(a, b) {
|
|
52
|
-
const len = Math.max(a.length, b.length);
|
|
53
|
-
const out = new Array(len).fill(0).map(() => rat(0n));
|
|
54
|
-
for (let i = 0; i < len; i++) {
|
|
55
|
-
out[i] = ratAdd(a[i] ?? rat(0n), b[i] ?? rat(0n));
|
|
56
|
-
}
|
|
57
|
-
while (out.length > 1 && out[out.length - 1].n === 0n) {
|
|
58
|
-
out.pop();
|
|
59
|
-
}
|
|
60
|
-
return out;
|
|
61
|
-
}
|
|
62
|
-
function uniMulRat(a, b) {
|
|
63
|
-
const out = new Array(a.length + b.length - 1).fill(0).map(() => rat(0n));
|
|
64
|
-
for (let i = 0; i < a.length; i++) {
|
|
65
|
-
for (let j = 0; j < b.length; j++) {
|
|
66
|
-
out[i + j] = ratAdd(out[i + j], ratMul(a[i], b[j]));
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
while (out.length > 1 && out[out.length - 1].n === 0n) {
|
|
70
|
-
out.pop();
|
|
71
|
-
}
|
|
72
|
-
return out;
|
|
73
|
-
}
|
|
74
|
-
function interpolateUnivariateRat(points) {
|
|
75
|
-
if (points.length === 0) {
|
|
76
|
-
return [rat(0n)];
|
|
77
|
-
}
|
|
78
|
-
const byX = new Map();
|
|
79
|
-
for (const p of points) {
|
|
80
|
-
const prev = byX.get(p.x);
|
|
81
|
-
if (!prev) {
|
|
82
|
-
byX.set(p.x, p.y);
|
|
83
|
-
continue;
|
|
84
|
-
}
|
|
85
|
-
if (ratSub(prev, p.y).n !== 0n) {
|
|
86
|
-
throw new Error('interpolateUnivariateRat: duplicate x with conflicting y');
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
const uniq = [...byX.entries()]
|
|
90
|
-
.map(([x, y]) => ({ x, y }))
|
|
91
|
-
.sort((a, b) => (a.x < b.x ? -1 : a.x > b.x ? 1 : 0));
|
|
92
|
-
const n = uniq.length;
|
|
93
|
-
if (n === 1) {
|
|
94
|
-
return [uniq[0].y];
|
|
95
|
-
}
|
|
96
|
-
let poly = [rat(0n)];
|
|
97
|
-
for (let i = 0; i < n; i++) {
|
|
98
|
-
let basis = [rat(1n)];
|
|
99
|
-
let denom = rat(1n);
|
|
100
|
-
for (let j = 0; j < n; j++) {
|
|
101
|
-
if (j === i) {
|
|
102
|
-
continue;
|
|
103
|
-
}
|
|
104
|
-
basis = uniMulRat(basis, [rat(-uniq[j].x), rat(1n)]);
|
|
105
|
-
denom = ratMul(denom, rat(uniq[i].x - uniq[j].x));
|
|
106
|
-
}
|
|
107
|
-
const scale = ratDiv(uniq[i].y, denom);
|
|
108
|
-
const scaled = basis.map(c => ratMul(c, scale));
|
|
109
|
-
poly = uniAddRat(poly, scaled);
|
|
110
|
-
}
|
|
111
|
-
while (poly.length > 1 && poly[poly.length - 1].n === 0n) {
|
|
112
|
-
poly.pop();
|
|
113
|
-
}
|
|
114
|
-
return poly;
|
|
115
|
-
}
|
package/output/core/adapters.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.expressionToZPoly = expressionToZPoly;
|
|
4
|
-
const Expression_1 = require("./classes/expression/Expression");
|
|
5
|
-
const Polynomial_1 = require("./classes/polynomial/Polynomial");
|
|
6
|
-
const bigint_1 = require("./functions/bigint/bigint");
|
|
7
|
-
/**
|
|
8
|
-
* Extracts the Z Polynomial from Q.
|
|
9
|
-
* Given a polynomial with rational coefficients, returns:
|
|
10
|
-
* - zPoly: the polynomial scaled to have integer coefficients (primitive part)
|
|
11
|
-
* - content: the GCD of the integer coefficients after clearing denominators
|
|
12
|
-
* - denominator: the common denominator used to clear fractions
|
|
13
|
-
*
|
|
14
|
-
* The relationship is: original = (content / denominator) * zPoly
|
|
15
|
-
*
|
|
16
|
-
* @param x
|
|
17
|
-
*/
|
|
18
|
-
function expressionToZPoly(x) {
|
|
19
|
-
x = Expression_1.Expression.create(x);
|
|
20
|
-
const p = new Polynomial_1.Polynomial(x);
|
|
21
|
-
const denominators = [];
|
|
22
|
-
for (const term of p.terms) {
|
|
23
|
-
const m = term.coeff.getMultiplier();
|
|
24
|
-
denominators.push(m.denominator);
|
|
25
|
-
}
|
|
26
|
-
// LCM of all denominators to clear fractions
|
|
27
|
-
const lcmDenom = denominators.reduce((acc, d) => (0, bigint_1.LCM)(acc, d), 1n);
|
|
28
|
-
const common = new Polynomial_1.Polynomial(Expression_1.Expression.Number(lcmDenom));
|
|
29
|
-
// Scale to integer coefficients
|
|
30
|
-
const q = p.times(common);
|
|
31
|
-
// Extract content (GCD of integer coefficients)
|
|
32
|
-
const content = new Polynomial_1.Polynomial(q.content());
|
|
33
|
-
// Get the primitive part
|
|
34
|
-
const pp = q.div(content)[0];
|
|
35
|
-
return {
|
|
36
|
-
zPoly: pp,
|
|
37
|
-
content: content,
|
|
38
|
-
denominator: common,
|
|
39
|
-
};
|
|
40
|
-
}
|