@danielsimonjr/mathts-expression 0.4.5 → 0.5.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/dist/index.d.ts +1518 -453
- package/dist/index.js +2061 -186
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -136,6 +136,9 @@ function isBigNumber(x) {
|
|
|
136
136
|
}
|
|
137
137
|
return false;
|
|
138
138
|
}
|
|
139
|
+
function isBigInt(x) {
|
|
140
|
+
return typeof x === "bigint";
|
|
141
|
+
}
|
|
139
142
|
function isComplex(x) {
|
|
140
143
|
return !!(x && typeof x === "object" && Object.getPrototypeOf(x).isComplex === true);
|
|
141
144
|
}
|
|
@@ -156,6 +159,14 @@ function isMatrix(x) {
|
|
|
156
159
|
const obj = x;
|
|
157
160
|
return obj.constructor?.prototype?.isMatrix === true;
|
|
158
161
|
}
|
|
162
|
+
function isCollection(x) {
|
|
163
|
+
return Array.isArray(x) || isMatrix(x);
|
|
164
|
+
}
|
|
165
|
+
function isRange(x) {
|
|
166
|
+
if (!x || typeof x !== "object") return false;
|
|
167
|
+
const obj = x;
|
|
168
|
+
return obj.constructor?.prototype?.isRange === true;
|
|
169
|
+
}
|
|
159
170
|
function isHelp(x) {
|
|
160
171
|
if (!x || typeof x !== "object") return false;
|
|
161
172
|
const obj = x;
|
|
@@ -611,28 +622,28 @@ var MathjsError = class _MathjsError extends Error {
|
|
|
611
622
|
};
|
|
612
623
|
|
|
613
624
|
// src/utils/factory.ts
|
|
614
|
-
function factory(
|
|
625
|
+
function factory(name47, dependencies47, create, meta) {
|
|
615
626
|
function assertAndCreate(scope) {
|
|
616
|
-
const deps = pickShallow(scope,
|
|
617
|
-
assertDependencies(
|
|
627
|
+
const deps = pickShallow(scope, dependencies47.map(stripOptionalNotation));
|
|
628
|
+
assertDependencies(name47, dependencies47, scope);
|
|
618
629
|
return create(deps);
|
|
619
630
|
}
|
|
620
631
|
assertAndCreate.isFactory = true;
|
|
621
|
-
assertAndCreate.fn =
|
|
622
|
-
assertAndCreate.dependencies =
|
|
632
|
+
assertAndCreate.fn = name47;
|
|
633
|
+
assertAndCreate.dependencies = dependencies47.slice().sort();
|
|
623
634
|
if (meta) {
|
|
624
635
|
assertAndCreate.meta = meta;
|
|
625
636
|
}
|
|
626
637
|
return assertAndCreate;
|
|
627
638
|
}
|
|
628
|
-
function assertDependencies(
|
|
629
|
-
const allDefined =
|
|
639
|
+
function assertDependencies(name47, dependencies47, scope) {
|
|
640
|
+
const allDefined = dependencies47.filter((dependency) => !isOptionalDependency(dependency)).every((dependency) => scope[dependency] !== void 0);
|
|
630
641
|
if (!allDefined) {
|
|
631
|
-
const missingDependencies =
|
|
642
|
+
const missingDependencies = dependencies47.filter(
|
|
632
643
|
(dependency) => scope[dependency] === void 0
|
|
633
644
|
);
|
|
634
645
|
throw new MathjsError(
|
|
635
|
-
`Cannot create function "${
|
|
646
|
+
`Cannot create function "${name47}", some dependencies are missing: ${missingDependencies.map((d) => `"${d}"`).join(", ")}.`
|
|
636
647
|
);
|
|
637
648
|
}
|
|
638
649
|
}
|
|
@@ -1404,17 +1415,17 @@ var createParse = /* @__PURE__ */ factory(
|
|
|
1404
1415
|
}
|
|
1405
1416
|
}
|
|
1406
1417
|
function parseAssignment(state) {
|
|
1407
|
-
let
|
|
1418
|
+
let name47;
|
|
1408
1419
|
let args;
|
|
1409
1420
|
let value;
|
|
1410
1421
|
let valid;
|
|
1411
1422
|
const node = parseConditional(state);
|
|
1412
1423
|
if (state.token === "=") {
|
|
1413
1424
|
if (isSymbolNode(node)) {
|
|
1414
|
-
|
|
1425
|
+
name47 = node.name;
|
|
1415
1426
|
getTokenSkipNewline(state);
|
|
1416
1427
|
value = parseAssignment(state);
|
|
1417
|
-
return new AssignmentNode(new SymbolNode(
|
|
1428
|
+
return new AssignmentNode(new SymbolNode(name47), value);
|
|
1418
1429
|
} else if (isAccessorNode(node)) {
|
|
1419
1430
|
const accessor = node;
|
|
1420
1431
|
if (accessor.optionalChaining) {
|
|
@@ -1427,7 +1438,7 @@ var createParse = /* @__PURE__ */ factory(
|
|
|
1427
1438
|
valid = true;
|
|
1428
1439
|
args = [];
|
|
1429
1440
|
const fnNode = node;
|
|
1430
|
-
|
|
1441
|
+
name47 = fnNode.name;
|
|
1431
1442
|
fnNode.args.forEach(function(arg, index) {
|
|
1432
1443
|
if (isSymbolNode(arg)) {
|
|
1433
1444
|
args[index] = arg.name;
|
|
@@ -1438,7 +1449,7 @@ var createParse = /* @__PURE__ */ factory(
|
|
|
1438
1449
|
if (valid) {
|
|
1439
1450
|
getTokenSkipNewline(state);
|
|
1440
1451
|
value = parseAssignment(state);
|
|
1441
|
-
return new FunctionAssignmentNode(
|
|
1452
|
+
return new FunctionAssignmentNode(name47, args, value);
|
|
1442
1453
|
}
|
|
1443
1454
|
}
|
|
1444
1455
|
throw createSyntaxError(state, "Invalid left hand side of assignment operator =");
|
|
@@ -1541,7 +1552,7 @@ var createParse = /* @__PURE__ */ factory(
|
|
|
1541
1552
|
}
|
|
1542
1553
|
function parseShift(state) {
|
|
1543
1554
|
let node;
|
|
1544
|
-
let
|
|
1555
|
+
let name47;
|
|
1545
1556
|
let fn;
|
|
1546
1557
|
let params;
|
|
1547
1558
|
node = parseConversion(state);
|
|
@@ -1551,17 +1562,17 @@ var createParse = /* @__PURE__ */ factory(
|
|
|
1551
1562
|
">>>": "rightLogShift"
|
|
1552
1563
|
};
|
|
1553
1564
|
while (hasOwnProperty(operators, state.token)) {
|
|
1554
|
-
|
|
1555
|
-
fn = operators[
|
|
1565
|
+
name47 = state.token;
|
|
1566
|
+
fn = operators[name47];
|
|
1556
1567
|
getTokenSkipNewline(state);
|
|
1557
1568
|
params = [node, parseConversion(state)];
|
|
1558
|
-
node = new OperatorNode(
|
|
1569
|
+
node = new OperatorNode(name47, fn, params);
|
|
1559
1570
|
}
|
|
1560
1571
|
return node;
|
|
1561
1572
|
}
|
|
1562
1573
|
function parseConversion(state) {
|
|
1563
1574
|
let node;
|
|
1564
|
-
let
|
|
1575
|
+
let name47;
|
|
1565
1576
|
let fn;
|
|
1566
1577
|
let params;
|
|
1567
1578
|
node = parseRange(state);
|
|
@@ -1571,14 +1582,14 @@ var createParse = /* @__PURE__ */ factory(
|
|
|
1571
1582
|
// alias of 'to'
|
|
1572
1583
|
};
|
|
1573
1584
|
while (hasOwnProperty(operators, state.token)) {
|
|
1574
|
-
|
|
1575
|
-
fn = operators[
|
|
1585
|
+
name47 = state.token;
|
|
1586
|
+
fn = operators[name47];
|
|
1576
1587
|
getTokenSkipNewline(state);
|
|
1577
|
-
if (
|
|
1588
|
+
if (name47 === "in" && "])},;".includes(state.token)) {
|
|
1578
1589
|
node = new OperatorNode("*", "multiply", [node, new SymbolNode("in")], true);
|
|
1579
1590
|
} else {
|
|
1580
1591
|
params = [node, parseRange(state)];
|
|
1581
|
-
node = new OperatorNode(
|
|
1592
|
+
node = new OperatorNode(name47, fn, params);
|
|
1582
1593
|
}
|
|
1583
1594
|
}
|
|
1584
1595
|
return node;
|
|
@@ -1618,7 +1629,7 @@ var createParse = /* @__PURE__ */ factory(
|
|
|
1618
1629
|
}
|
|
1619
1630
|
function parseAddSubtract(state) {
|
|
1620
1631
|
let node;
|
|
1621
|
-
let
|
|
1632
|
+
let name47;
|
|
1622
1633
|
let fn;
|
|
1623
1634
|
let params;
|
|
1624
1635
|
node = parseMultiplyDivideModulus(state);
|
|
@@ -1627,8 +1638,8 @@ var createParse = /* @__PURE__ */ factory(
|
|
|
1627
1638
|
"-": "subtract"
|
|
1628
1639
|
};
|
|
1629
1640
|
while (hasOwnProperty(operators, state.token)) {
|
|
1630
|
-
|
|
1631
|
-
fn = operators[
|
|
1641
|
+
name47 = state.token;
|
|
1642
|
+
fn = operators[name47];
|
|
1632
1643
|
getTokenSkipNewline(state);
|
|
1633
1644
|
const rightNode = parseMultiplyDivideModulus(state);
|
|
1634
1645
|
if (rightNode.isPercentage) {
|
|
@@ -1636,14 +1647,14 @@ var createParse = /* @__PURE__ */ factory(
|
|
|
1636
1647
|
} else {
|
|
1637
1648
|
params = [node, rightNode];
|
|
1638
1649
|
}
|
|
1639
|
-
node = new OperatorNode(
|
|
1650
|
+
node = new OperatorNode(name47, fn, params);
|
|
1640
1651
|
}
|
|
1641
1652
|
return node;
|
|
1642
1653
|
}
|
|
1643
1654
|
function parseMultiplyDivideModulus(state) {
|
|
1644
1655
|
let node;
|
|
1645
1656
|
let last;
|
|
1646
|
-
let
|
|
1657
|
+
let name47;
|
|
1647
1658
|
let fn;
|
|
1648
1659
|
node = parseImplicitMultiplication(state);
|
|
1649
1660
|
last = node;
|
|
@@ -1657,11 +1668,11 @@ var createParse = /* @__PURE__ */ factory(
|
|
|
1657
1668
|
};
|
|
1658
1669
|
while (true) {
|
|
1659
1670
|
if (hasOwnProperty(operators, state.token)) {
|
|
1660
|
-
|
|
1661
|
-
fn = operators[
|
|
1671
|
+
name47 = state.token;
|
|
1672
|
+
fn = operators[name47];
|
|
1662
1673
|
getTokenSkipNewline(state);
|
|
1663
1674
|
last = parseImplicitMultiplication(state);
|
|
1664
|
-
node = new OperatorNode(
|
|
1675
|
+
node = new OperatorNode(name47, fn, [node, last]);
|
|
1665
1676
|
} else {
|
|
1666
1677
|
break;
|
|
1667
1678
|
}
|
|
@@ -1735,7 +1746,7 @@ var createParse = /* @__PURE__ */ factory(
|
|
|
1735
1746
|
return node;
|
|
1736
1747
|
}
|
|
1737
1748
|
function parseUnary(state) {
|
|
1738
|
-
let
|
|
1749
|
+
let name47;
|
|
1739
1750
|
let params;
|
|
1740
1751
|
let fn;
|
|
1741
1752
|
const operators = {
|
|
@@ -1746,25 +1757,25 @@ var createParse = /* @__PURE__ */ factory(
|
|
|
1746
1757
|
};
|
|
1747
1758
|
if (hasOwnProperty(operators, state.token)) {
|
|
1748
1759
|
fn = operators[state.token];
|
|
1749
|
-
|
|
1760
|
+
name47 = state.token;
|
|
1750
1761
|
getTokenSkipNewline(state);
|
|
1751
1762
|
params = [parseUnary(state)];
|
|
1752
|
-
return new OperatorNode(
|
|
1763
|
+
return new OperatorNode(name47, fn, params);
|
|
1753
1764
|
}
|
|
1754
1765
|
return parsePow(state);
|
|
1755
1766
|
}
|
|
1756
1767
|
function parsePow(state) {
|
|
1757
1768
|
let node;
|
|
1758
|
-
let
|
|
1769
|
+
let name47;
|
|
1759
1770
|
let fn;
|
|
1760
1771
|
let params;
|
|
1761
1772
|
node = parseNullishCoalescing(state);
|
|
1762
1773
|
if (state.token === "^" || state.token === ".^") {
|
|
1763
|
-
|
|
1764
|
-
fn =
|
|
1774
|
+
name47 = state.token;
|
|
1775
|
+
fn = name47 === "^" ? "pow" : "dotPow";
|
|
1765
1776
|
getTokenSkipNewline(state);
|
|
1766
1777
|
params = [node, parseUnary(state)];
|
|
1767
|
-
node = new OperatorNode(
|
|
1778
|
+
node = new OperatorNode(name47, fn, params);
|
|
1768
1779
|
}
|
|
1769
1780
|
return node;
|
|
1770
1781
|
}
|
|
@@ -1778,7 +1789,7 @@ var createParse = /* @__PURE__ */ factory(
|
|
|
1778
1789
|
}
|
|
1779
1790
|
function parseLeftHandOperators(state) {
|
|
1780
1791
|
let node;
|
|
1781
|
-
let
|
|
1792
|
+
let name47;
|
|
1782
1793
|
let fn;
|
|
1783
1794
|
let params;
|
|
1784
1795
|
node = parseCustomNodes(state);
|
|
@@ -1787,11 +1798,11 @@ var createParse = /* @__PURE__ */ factory(
|
|
|
1787
1798
|
"'": "ctranspose"
|
|
1788
1799
|
};
|
|
1789
1800
|
while (hasOwnProperty(operators, state.token)) {
|
|
1790
|
-
|
|
1791
|
-
fn = operators[
|
|
1801
|
+
name47 = state.token;
|
|
1802
|
+
fn = operators[name47];
|
|
1792
1803
|
getToken(state);
|
|
1793
1804
|
params = [node];
|
|
1794
|
-
node = new OperatorNode(
|
|
1805
|
+
node = new OperatorNode(name47, fn, params);
|
|
1795
1806
|
node = parseAccessors(state, node);
|
|
1796
1807
|
}
|
|
1797
1808
|
return node;
|
|
@@ -1824,16 +1835,16 @@ var createParse = /* @__PURE__ */ factory(
|
|
|
1824
1835
|
}
|
|
1825
1836
|
function parseSymbol(state) {
|
|
1826
1837
|
let node;
|
|
1827
|
-
let
|
|
1838
|
+
let name47;
|
|
1828
1839
|
if (state.tokenType === 3 /* SYMBOL */ || state.tokenType === 1 /* DELIMITER */ && state.token in NAMED_DELIMITERS) {
|
|
1829
|
-
|
|
1840
|
+
name47 = state.token;
|
|
1830
1841
|
getToken(state);
|
|
1831
|
-
if (hasOwnProperty(CONSTANTS,
|
|
1832
|
-
node = new ConstantNode(CONSTANTS[
|
|
1833
|
-
} else if (NUMERIC_CONSTANTS.includes(
|
|
1834
|
-
node = new ConstantNode(numeric(
|
|
1842
|
+
if (hasOwnProperty(CONSTANTS, name47)) {
|
|
1843
|
+
node = new ConstantNode(CONSTANTS[name47]);
|
|
1844
|
+
} else if (NUMERIC_CONSTANTS.includes(name47)) {
|
|
1845
|
+
node = new ConstantNode(numeric(name47, "number"));
|
|
1835
1846
|
} else {
|
|
1836
|
-
node = new SymbolNode(
|
|
1847
|
+
node = new SymbolNode(name47);
|
|
1837
1848
|
}
|
|
1838
1849
|
node = parseAccessors(state, node);
|
|
1839
1850
|
return node;
|
|
@@ -2344,8 +2355,8 @@ var createParserClass = /* @__PURE__ */ factory(
|
|
|
2344
2355
|
Parser.prototype.evaluate = function(expr) {
|
|
2345
2356
|
return evaluate(expr, this.scope);
|
|
2346
2357
|
};
|
|
2347
|
-
Parser.prototype.get = function(
|
|
2348
|
-
return this.scope.has(
|
|
2358
|
+
Parser.prototype.get = function(name47) {
|
|
2359
|
+
return this.scope.has(name47) ? this.scope.get(name47) : void 0;
|
|
2349
2360
|
};
|
|
2350
2361
|
Parser.prototype.getAll = function() {
|
|
2351
2362
|
return toObject(this.scope);
|
|
@@ -2353,14 +2364,14 @@ var createParserClass = /* @__PURE__ */ factory(
|
|
|
2353
2364
|
Parser.prototype.getAllAsMap = function() {
|
|
2354
2365
|
return this.scope;
|
|
2355
2366
|
};
|
|
2356
|
-
function isValidVariableName(
|
|
2357
|
-
if (
|
|
2367
|
+
function isValidVariableName(name47) {
|
|
2368
|
+
if (name47.length === 0) {
|
|
2358
2369
|
return false;
|
|
2359
2370
|
}
|
|
2360
|
-
for (let i = 0; i <
|
|
2361
|
-
const cPrev =
|
|
2362
|
-
const c =
|
|
2363
|
-
const cNext =
|
|
2371
|
+
for (let i = 0; i < name47.length; i++) {
|
|
2372
|
+
const cPrev = name47.charAt(i - 1);
|
|
2373
|
+
const c = name47.charAt(i);
|
|
2374
|
+
const cNext = name47.charAt(i + 1);
|
|
2364
2375
|
const valid = parse.isAlpha(c, cPrev, cNext) || i > 0 && parse.isDigit(c);
|
|
2365
2376
|
if (!valid) {
|
|
2366
2377
|
return false;
|
|
@@ -2368,17 +2379,17 @@ var createParserClass = /* @__PURE__ */ factory(
|
|
|
2368
2379
|
}
|
|
2369
2380
|
return true;
|
|
2370
2381
|
}
|
|
2371
|
-
Parser.prototype.set = function(
|
|
2372
|
-
if (!isValidVariableName(
|
|
2382
|
+
Parser.prototype.set = function(name47, value) {
|
|
2383
|
+
if (!isValidVariableName(name47)) {
|
|
2373
2384
|
throw new Error(
|
|
2374
|
-
`Invalid variable name: '${
|
|
2385
|
+
`Invalid variable name: '${name47}'. Variable names must follow the specified rules.`
|
|
2375
2386
|
);
|
|
2376
2387
|
}
|
|
2377
|
-
this.scope.set(
|
|
2388
|
+
this.scope.set(name47, value);
|
|
2378
2389
|
return value;
|
|
2379
2390
|
};
|
|
2380
|
-
Parser.prototype.remove = function(
|
|
2381
|
-
this.scope.delete(
|
|
2391
|
+
Parser.prototype.remove = function(name47) {
|
|
2392
|
+
this.scope.delete(name47);
|
|
2382
2393
|
};
|
|
2383
2394
|
Parser.prototype.clear = function() {
|
|
2384
2395
|
this.scope.clear();
|
|
@@ -2389,21 +2400,21 @@ var createParserClass = /* @__PURE__ */ factory(
|
|
|
2389
2400
|
variables: {},
|
|
2390
2401
|
functions: {}
|
|
2391
2402
|
};
|
|
2392
|
-
for (const [
|
|
2403
|
+
for (const [name47, value] of this.scope) {
|
|
2393
2404
|
if (isFunction(value)) {
|
|
2394
2405
|
if (!isExpressionFunction(value)) {
|
|
2395
|
-
throw new Error(`Cannot serialize external function ${
|
|
2406
|
+
throw new Error(`Cannot serialize external function ${name47}`);
|
|
2396
2407
|
}
|
|
2397
|
-
json.functions[
|
|
2408
|
+
json.functions[name47] = `${value.syntax} = ${value.expr}`;
|
|
2398
2409
|
} else {
|
|
2399
|
-
json.variables[
|
|
2410
|
+
json.variables[name47] = value;
|
|
2400
2411
|
}
|
|
2401
2412
|
}
|
|
2402
2413
|
return json;
|
|
2403
2414
|
};
|
|
2404
2415
|
Parser.fromJSON = function(json) {
|
|
2405
2416
|
const parser = new Parser();
|
|
2406
|
-
Object.entries(json.variables || {}).forEach(([
|
|
2417
|
+
Object.entries(json.variables || {}).forEach(([name47, value]) => parser.set(name47, value));
|
|
2407
2418
|
Object.entries(json.functions || {}).forEach(([_name, fn]) => parser.evaluate(fn));
|
|
2408
2419
|
return parser;
|
|
2409
2420
|
};
|
|
@@ -5864,6 +5875,926 @@ var solveODEDocs = {
|
|
|
5864
5875
|
seealso: ["derivative", "simplifyCore"]
|
|
5865
5876
|
};
|
|
5866
5877
|
|
|
5878
|
+
// src/embeddedDocs/function/algebra/apart.ts
|
|
5879
|
+
var apartDocs = {
|
|
5880
|
+
name: "apart",
|
|
5881
|
+
category: "Algebra",
|
|
5882
|
+
syntax: ["apart(expr)"],
|
|
5883
|
+
description: "Partial fraction decomposition of numeric fractions.",
|
|
5884
|
+
examples: ["apart('7/3')"],
|
|
5885
|
+
seealso: ["together", "cancel"]
|
|
5886
|
+
};
|
|
5887
|
+
|
|
5888
|
+
// src/embeddedDocs/function/algebra/cancel.ts
|
|
5889
|
+
var cancelDocs = {
|
|
5890
|
+
name: "cancel",
|
|
5891
|
+
category: "Algebra",
|
|
5892
|
+
syntax: ["cancel(expr)"],
|
|
5893
|
+
description: "Cancel common factors in a rational expression (numeric fractions).",
|
|
5894
|
+
examples: ["cancel('6/4')", "cancel('10/5')"],
|
|
5895
|
+
seealso: ["together", "apart"]
|
|
5896
|
+
};
|
|
5897
|
+
|
|
5898
|
+
// src/embeddedDocs/function/algebra/coefficientList.ts
|
|
5899
|
+
var coefficientListDocs = {
|
|
5900
|
+
name: "coefficientList",
|
|
5901
|
+
category: "Algebra",
|
|
5902
|
+
syntax: ["coefficientList(coeffs)"],
|
|
5903
|
+
description: "Extract the coefficient list of a polynomial, trimming leading zeros from the high end.",
|
|
5904
|
+
examples: ["coefficientList([1, 2, 0, 0])"],
|
|
5905
|
+
seealso: ["degree", "polyval"]
|
|
5906
|
+
};
|
|
5907
|
+
|
|
5908
|
+
// src/embeddedDocs/function/algebra/collect.ts
|
|
5909
|
+
var collectDocs = {
|
|
5910
|
+
name: "collect",
|
|
5911
|
+
category: "Algebra",
|
|
5912
|
+
syntax: ["collect(expr, var)"],
|
|
5913
|
+
description: "Collect like terms with respect to a variable, grouping by powers.",
|
|
5914
|
+
examples: ["collect('2*x + 3*x + 5', 'x')"],
|
|
5915
|
+
seealso: ["expand", "factor"]
|
|
5916
|
+
};
|
|
5917
|
+
|
|
5918
|
+
// src/embeddedDocs/function/algebra/combine.ts
|
|
5919
|
+
var combineDocs = {
|
|
5920
|
+
name: "combine",
|
|
5921
|
+
category: "Algebra",
|
|
5922
|
+
syntax: ["combine(a, b)"],
|
|
5923
|
+
description: "Combine two expressions by addition.",
|
|
5924
|
+
examples: ["combine('x^2', '2*y')"],
|
|
5925
|
+
seealso: ["expand", "collect"]
|
|
5926
|
+
};
|
|
5927
|
+
|
|
5928
|
+
// src/embeddedDocs/function/algebra/complexExpand.ts
|
|
5929
|
+
var complexExpandDocs = {
|
|
5930
|
+
name: "complexExpand",
|
|
5931
|
+
category: "Algebra",
|
|
5932
|
+
syntax: ["complexExpand(expr)"],
|
|
5933
|
+
description: "Expand complex-valued expressions using i^2 = -1.",
|
|
5934
|
+
examples: ["complexExpand('a + b*i^2')"],
|
|
5935
|
+
seealso: ["expand", "trigToExp"]
|
|
5936
|
+
};
|
|
5937
|
+
|
|
5938
|
+
// src/embeddedDocs/function/algebra/degree.ts
|
|
5939
|
+
var degreeDocs = {
|
|
5940
|
+
name: "degree",
|
|
5941
|
+
category: "Algebra",
|
|
5942
|
+
syntax: ["degree(coeffs)"],
|
|
5943
|
+
description: "Return the degree of a polynomial (highest power with non-zero coefficient).",
|
|
5944
|
+
examples: ["degree([1, 2, 3])", "degree([5])"],
|
|
5945
|
+
seealso: ["coefficientList", "polyval"]
|
|
5946
|
+
};
|
|
5947
|
+
|
|
5948
|
+
// src/embeddedDocs/function/algebra/differences.ts
|
|
5949
|
+
var differencesDocs = {
|
|
5950
|
+
name: "differences",
|
|
5951
|
+
category: "Algebra",
|
|
5952
|
+
syntax: ["differences(arr)", "differences(arr, n)"],
|
|
5953
|
+
description: "Compute finite differences of a sequence by applying the forward difference operator.",
|
|
5954
|
+
examples: ["differences([1, 4, 9, 16])", "differences([1, 4, 9, 16], 2)"],
|
|
5955
|
+
seealso: ["polyder"]
|
|
5956
|
+
};
|
|
5957
|
+
|
|
5958
|
+
// src/embeddedDocs/function/algebra/discriminant.ts
|
|
5959
|
+
var discriminantDocs = {
|
|
5960
|
+
name: "discriminant",
|
|
5961
|
+
category: "Algebra",
|
|
5962
|
+
syntax: ["discriminant(coeffs)"],
|
|
5963
|
+
description: "Compute the discriminant of a polynomial. For quadratic ax^2+bx+c: b^2-4ac.",
|
|
5964
|
+
examples: ["discriminant([-1, 0, 1])", "discriminant([1, 1, 1])"],
|
|
5965
|
+
seealso: ["degree", "polynomialRoot"]
|
|
5966
|
+
};
|
|
5967
|
+
|
|
5968
|
+
// src/embeddedDocs/function/algebra/element.ts
|
|
5969
|
+
var elementDocs = {
|
|
5970
|
+
name: "element",
|
|
5971
|
+
category: "Algebra",
|
|
5972
|
+
syntax: ["element(arr, index)"],
|
|
5973
|
+
description: "Extract an element from an array at the specified zero-based index.",
|
|
5974
|
+
examples: ["element([10, 20, 30], 1)"],
|
|
5975
|
+
seealso: ["subset"]
|
|
5976
|
+
};
|
|
5977
|
+
|
|
5978
|
+
// src/embeddedDocs/function/algebra/eliminate.ts
|
|
5979
|
+
var eliminateDocs = {
|
|
5980
|
+
name: "eliminate",
|
|
5981
|
+
category: "Algebra",
|
|
5982
|
+
syntax: ["eliminate(system, var)"],
|
|
5983
|
+
description: "Eliminate a variable from a system of equations using Gaussian elimination.",
|
|
5984
|
+
examples: ["eliminate(['2*x + 3*y = 5', 'x + y = 2'], 'x')"],
|
|
5985
|
+
seealso: ["variables", "substitute"]
|
|
5986
|
+
};
|
|
5987
|
+
|
|
5988
|
+
// src/embeddedDocs/function/algebra/expToTrig.ts
|
|
5989
|
+
var expToTrigDocs = {
|
|
5990
|
+
name: "expToTrig",
|
|
5991
|
+
category: "Algebra",
|
|
5992
|
+
syntax: ["expToTrig(expr)"],
|
|
5993
|
+
description: "Convert exponential expressions to trigonometric form using Euler formula.",
|
|
5994
|
+
examples: ["expToTrig('exp(i*x)')"],
|
|
5995
|
+
seealso: ["trigToExp", "trigExpand"]
|
|
5996
|
+
};
|
|
5997
|
+
|
|
5998
|
+
// src/embeddedDocs/function/algebra/expand.ts
|
|
5999
|
+
var expandDocs = {
|
|
6000
|
+
name: "expand",
|
|
6001
|
+
category: "Algebra",
|
|
6002
|
+
syntax: ["expand(expr)"],
|
|
6003
|
+
description: "Expand an expression by distributing multiplication over addition.",
|
|
6004
|
+
examples: ["expand('(a+b)*(c+d)')"],
|
|
6005
|
+
seealso: ["factor", "collect", "simplify"]
|
|
6006
|
+
};
|
|
6007
|
+
|
|
6008
|
+
// src/embeddedDocs/function/algebra/factor.ts
|
|
6009
|
+
var factorDocs = {
|
|
6010
|
+
name: "factor",
|
|
6011
|
+
category: "Algebra",
|
|
6012
|
+
syntax: ["factor(expr)"],
|
|
6013
|
+
description: "Factor an expression by extracting common numeric factors from terms.",
|
|
6014
|
+
examples: ["factor('6*x + 4*y')"],
|
|
6015
|
+
seealso: ["expand", "collect"]
|
|
6016
|
+
};
|
|
6017
|
+
|
|
6018
|
+
// src/embeddedDocs/function/algebra/fullSimplify.ts
|
|
6019
|
+
var fullSimplifyDocs = {
|
|
6020
|
+
name: "fullSimplify",
|
|
6021
|
+
category: "Algebra",
|
|
6022
|
+
syntax: ["fullSimplify(expr)"],
|
|
6023
|
+
description: "Full simplification with identity removal, constant folding, and numeric reduction.",
|
|
6024
|
+
examples: ["fullSimplify('1 * x + 0')", "fullSimplify('x^1')"],
|
|
6025
|
+
seealso: ["simplify", "reduce"]
|
|
6026
|
+
};
|
|
6027
|
+
|
|
6028
|
+
// src/embeddedDocs/function/algebra/functionExpand.ts
|
|
6029
|
+
var functionExpandDocs = {
|
|
6030
|
+
name: "functionExpand",
|
|
6031
|
+
category: "Algebra",
|
|
6032
|
+
syntax: ["functionExpand(expr)"],
|
|
6033
|
+
description: "Expand special function expressions: exp(a+b) => exp(a)*exp(b), ln(a*b) => ln(a)+ln(b).",
|
|
6034
|
+
examples: ["functionExpand('exp(a+b)')", "functionExpand('ln(a*b)')"],
|
|
6035
|
+
seealso: ["expand", "trigExpand"]
|
|
6036
|
+
};
|
|
6037
|
+
|
|
6038
|
+
// src/embeddedDocs/function/algebra/normalForm.ts
|
|
6039
|
+
var normalFormDocs = {
|
|
6040
|
+
name: "normalForm",
|
|
6041
|
+
category: "Algebra",
|
|
6042
|
+
syntax: ["normalForm(expr)"],
|
|
6043
|
+
description: "Convert expression to canonical normal form by sorting terms alphabetically.",
|
|
6044
|
+
examples: ["normalForm('c + a + b')"],
|
|
6045
|
+
seealso: ["collect", "fullSimplify"]
|
|
6046
|
+
};
|
|
6047
|
+
|
|
6048
|
+
// src/embeddedDocs/function/algebra/partialDerivative.ts
|
|
6049
|
+
var partialDerivativeDocs = {
|
|
6050
|
+
name: "partialDerivative",
|
|
6051
|
+
category: "Algebra",
|
|
6052
|
+
syntax: ["partialDerivative(expr, var)"],
|
|
6053
|
+
description: "Compute a partial derivative of an expression string using basic symbolic rules.",
|
|
6054
|
+
examples: ["partialDerivative('x^2', 'x')"],
|
|
6055
|
+
seealso: ["polyder", "tangentLine", "derivative"]
|
|
6056
|
+
};
|
|
6057
|
+
|
|
6058
|
+
// src/embeddedDocs/function/algebra/polyadd.ts
|
|
6059
|
+
var polyaddDocs = {
|
|
6060
|
+
name: "polyadd",
|
|
6061
|
+
category: "Algebra",
|
|
6062
|
+
syntax: ["polyadd(a, b)"],
|
|
6063
|
+
description: "Add two polynomials represented as coefficient arrays (index = power).",
|
|
6064
|
+
examples: ["polyadd([1, 2], [3, 4, 5])"],
|
|
6065
|
+
seealso: ["polymul", "polyval", "polyder"]
|
|
6066
|
+
};
|
|
6067
|
+
|
|
6068
|
+
// src/embeddedDocs/function/algebra/polyder.ts
|
|
6069
|
+
var polyderDocs = {
|
|
6070
|
+
name: "polyder",
|
|
6071
|
+
category: "Algebra",
|
|
6072
|
+
syntax: ["polyder(coeffs)", "polyder(coeffs, n)"],
|
|
6073
|
+
description: "Compute the n-th derivative of a polynomial. Default n=1.",
|
|
6074
|
+
examples: ["polyder([1, 2, 3])", "polyder([1, 2, 3, 4], 2)"],
|
|
6075
|
+
seealso: ["polyval", "polyadd", "polymul"]
|
|
6076
|
+
};
|
|
6077
|
+
|
|
6078
|
+
// src/embeddedDocs/function/algebra/polymul.ts
|
|
6079
|
+
var polymulDocs = {
|
|
6080
|
+
name: "polymul",
|
|
6081
|
+
category: "Algebra",
|
|
6082
|
+
syntax: ["polymul(a, b)"],
|
|
6083
|
+
description: "Multiply two polynomials (convolution of coefficient arrays).",
|
|
6084
|
+
examples: ["polymul([1, 1], [1, 1])"],
|
|
6085
|
+
seealso: ["polyadd", "polyval", "polyder"]
|
|
6086
|
+
};
|
|
6087
|
+
|
|
6088
|
+
// src/embeddedDocs/function/algebra/polynomialGCD.ts
|
|
6089
|
+
var polynomialGCDDocs = {
|
|
6090
|
+
name: "polynomialGCD",
|
|
6091
|
+
category: "Algebra",
|
|
6092
|
+
syntax: ["polynomialGCD(a, b)"],
|
|
6093
|
+
description: "Compute the GCD of two polynomials using the Euclidean algorithm. Result is monic.",
|
|
6094
|
+
examples: ["polynomialGCD([-1, 0, 1], [-1, 1])"],
|
|
6095
|
+
seealso: ["polynomialLCM", "polynomialQuotient", "polynomialRemainder"]
|
|
6096
|
+
};
|
|
6097
|
+
|
|
6098
|
+
// src/embeddedDocs/function/algebra/polynomialLCM.ts
|
|
6099
|
+
var polynomialLCMDocs = {
|
|
6100
|
+
name: "polynomialLCM",
|
|
6101
|
+
category: "Algebra",
|
|
6102
|
+
syntax: ["polynomialLCM(a, b)"],
|
|
6103
|
+
description: "Compute the LCM of two polynomials: LCM(a, b) = (a * b) / GCD(a, b).",
|
|
6104
|
+
examples: ["polynomialLCM([-1, 1], [1, 1])"],
|
|
6105
|
+
seealso: ["polynomialGCD", "polymul"]
|
|
6106
|
+
};
|
|
6107
|
+
|
|
6108
|
+
// src/embeddedDocs/function/algebra/polynomialQuotient.ts
|
|
6109
|
+
var polynomialQuotientDocs = {
|
|
6110
|
+
name: "polynomialQuotient",
|
|
6111
|
+
category: "Algebra",
|
|
6112
|
+
syntax: ["polynomialQuotient(a, b)"],
|
|
6113
|
+
description: "Compute the quotient of polynomial division a / b.",
|
|
6114
|
+
examples: ["polynomialQuotient([-1, 0, 1], [-1, 1])"],
|
|
6115
|
+
seealso: ["polynomialRemainder", "polynomialGCD"]
|
|
6116
|
+
};
|
|
6117
|
+
|
|
6118
|
+
// src/embeddedDocs/function/algebra/polynomialRemainder.ts
|
|
6119
|
+
var polynomialRemainderDocs = {
|
|
6120
|
+
name: "polynomialRemainder",
|
|
6121
|
+
category: "Algebra",
|
|
6122
|
+
syntax: ["polynomialRemainder(a, b)"],
|
|
6123
|
+
description: "Compute the remainder of polynomial division a / b.",
|
|
6124
|
+
examples: ["polynomialRemainder([1, 0, 1], [-1, 1])"],
|
|
6125
|
+
seealso: ["polynomialQuotient", "polynomialGCD"]
|
|
6126
|
+
};
|
|
6127
|
+
|
|
6128
|
+
// src/embeddedDocs/function/algebra/polyval.ts
|
|
6129
|
+
var polyvalDocs = {
|
|
6130
|
+
name: "polyval",
|
|
6131
|
+
category: "Algebra",
|
|
6132
|
+
syntax: ["polyval(coeffs, x)"],
|
|
6133
|
+
description: "Evaluate a polynomial at a given point using Horner method. Coefficients ordered by ascending power.",
|
|
6134
|
+
examples: ["polyval([1, 2, 3], 2)", "polyval([1, 0, -1], 3)"],
|
|
6135
|
+
seealso: ["polyder", "polyadd", "polymul"]
|
|
6136
|
+
};
|
|
6137
|
+
|
|
6138
|
+
// src/embeddedDocs/function/algebra/powerExpand.ts
|
|
6139
|
+
var powerExpandDocs = {
|
|
6140
|
+
name: "powerExpand",
|
|
6141
|
+
category: "Algebra",
|
|
6142
|
+
syntax: ["powerExpand(expr)"],
|
|
6143
|
+
description: "Expand powers: (a*b)^n => a^n * b^n and (a^m)^n => a^(m*n).",
|
|
6144
|
+
examples: ["powerExpand('(a*b)^3')", "powerExpand('(a^2)^3')"],
|
|
6145
|
+
seealso: ["expand", "fullSimplify"]
|
|
6146
|
+
};
|
|
6147
|
+
|
|
6148
|
+
// src/embeddedDocs/function/algebra/reduce.ts
|
|
6149
|
+
var reduceDocs = {
|
|
6150
|
+
name: "reduce",
|
|
6151
|
+
category: "Algebra",
|
|
6152
|
+
syntax: ["reduce(expr)"],
|
|
6153
|
+
description: "Reduce an expression to its simplest form by evaluating pure-numeric sub-expressions.",
|
|
6154
|
+
examples: ["reduce('2 + 3')", "reduce('2^3')"],
|
|
6155
|
+
seealso: ["fullSimplify", "simplify"]
|
|
6156
|
+
};
|
|
6157
|
+
|
|
6158
|
+
// src/embeddedDocs/function/algebra/resultant.ts
|
|
6159
|
+
var resultantDocs = {
|
|
6160
|
+
name: "resultant",
|
|
6161
|
+
category: "Algebra",
|
|
6162
|
+
syntax: ["resultant(p, q)"],
|
|
6163
|
+
description: "Compute the resultant of two polynomials via the Sylvester matrix determinant.",
|
|
6164
|
+
examples: ["resultant([-1, 0, 1], [-1, 1])"],
|
|
6165
|
+
seealso: ["polynomialGCD", "discriminant"]
|
|
6166
|
+
};
|
|
6167
|
+
|
|
6168
|
+
// src/embeddedDocs/function/algebra/substitute.ts
|
|
6169
|
+
var substituteDocs = {
|
|
6170
|
+
name: "substitute",
|
|
6171
|
+
category: "Algebra",
|
|
6172
|
+
syntax: ["substitute(expr, vars)"],
|
|
6173
|
+
description: "Substitute variables in an expression string with replacement values.",
|
|
6174
|
+
examples: ["substitute('x^2 + y', {x: 3, y: 1})"],
|
|
6175
|
+
seealso: ["variables", "expand"]
|
|
6176
|
+
};
|
|
6177
|
+
|
|
6178
|
+
// src/embeddedDocs/function/algebra/tangentLine.ts
|
|
6179
|
+
var tangentLineDocs = {
|
|
6180
|
+
name: "tangentLine",
|
|
6181
|
+
category: "Algebra",
|
|
6182
|
+
syntax: ["tangentLine(f, x0)"],
|
|
6183
|
+
description: "Compute the tangent line to a function at a given point. Returns [slope, intercept].",
|
|
6184
|
+
examples: ["tangentLine(x => x**2, 3)"],
|
|
6185
|
+
seealso: ["partialDerivative", "polyder"]
|
|
6186
|
+
};
|
|
6187
|
+
|
|
6188
|
+
// src/embeddedDocs/function/algebra/together.ts
|
|
6189
|
+
var togetherDocs = {
|
|
6190
|
+
name: "together",
|
|
6191
|
+
category: "Algebra",
|
|
6192
|
+
syntax: ["together(expr)"],
|
|
6193
|
+
description: "Combine fractions to a common denominator.",
|
|
6194
|
+
examples: ["together('1/2 + 1/3')"],
|
|
6195
|
+
seealso: ["apart", "cancel"]
|
|
6196
|
+
};
|
|
6197
|
+
|
|
6198
|
+
// src/embeddedDocs/function/algebra/trigExpand.ts
|
|
6199
|
+
var trigExpandDocs = {
|
|
6200
|
+
name: "trigExpand",
|
|
6201
|
+
category: "Algebra",
|
|
6202
|
+
syntax: ["trigExpand(expr)"],
|
|
6203
|
+
description: "Expand trigonometric expressions using angle addition formulas.",
|
|
6204
|
+
examples: ["trigExpand('sin(2*x)')", "trigExpand('cos(a+b)')"],
|
|
6205
|
+
seealso: ["trigReduce", "trigToExp"]
|
|
6206
|
+
};
|
|
6207
|
+
|
|
6208
|
+
// src/embeddedDocs/function/algebra/trigReduce.ts
|
|
6209
|
+
var trigReduceDocs = {
|
|
6210
|
+
name: "trigReduce",
|
|
6211
|
+
category: "Algebra",
|
|
6212
|
+
syntax: ["trigReduce(expr)"],
|
|
6213
|
+
description: "Reduce trigonometric expressions using product-to-sum formulas.",
|
|
6214
|
+
examples: ["trigReduce('sin(x)*cos(x)')"],
|
|
6215
|
+
seealso: ["trigExpand", "trigToExp"]
|
|
6216
|
+
};
|
|
6217
|
+
|
|
6218
|
+
// src/embeddedDocs/function/algebra/trigToExp.ts
|
|
6219
|
+
var trigToExpDocs = {
|
|
6220
|
+
name: "trigToExp",
|
|
6221
|
+
category: "Algebra",
|
|
6222
|
+
syntax: ["trigToExp(expr)"],
|
|
6223
|
+
description: "Convert trigonometric functions to exponential form using Euler formula.",
|
|
6224
|
+
examples: ["trigToExp('sin(x)')", "trigToExp('cos(x)')"],
|
|
6225
|
+
seealso: ["expToTrig", "trigExpand"]
|
|
6226
|
+
};
|
|
6227
|
+
|
|
6228
|
+
// src/embeddedDocs/function/algebra/variables.ts
|
|
6229
|
+
var variablesDocs = {
|
|
6230
|
+
name: "variables",
|
|
6231
|
+
category: "Algebra",
|
|
6232
|
+
syntax: ["variables(expr)"],
|
|
6233
|
+
description: "Extract free variable names from an expression string, excluding math keywords.",
|
|
6234
|
+
examples: ["variables('x^2 + 2*y + sin(z)')", "variables('pi * r^2')"],
|
|
6235
|
+
seealso: ["substitute"]
|
|
6236
|
+
};
|
|
6237
|
+
|
|
6238
|
+
// src/embeddedDocs/function/combinatorics/doubleFactorial.ts
|
|
6239
|
+
var doubleFactorialDocs = {
|
|
6240
|
+
name: "doubleFactorial",
|
|
6241
|
+
category: "Combinatorics",
|
|
6242
|
+
syntax: ["doubleFactorial(n)"],
|
|
6243
|
+
description: "Compute the double factorial n!! = n * (n-2) * (n-4) * ... Special cases: 0!! = 1, (-1)!! = 1.",
|
|
6244
|
+
examples: ["doubleFactorial(7)", "doubleFactorial(6)", "doubleFactorial(0)"],
|
|
6245
|
+
seealso: ["factorial", "subfactorial"]
|
|
6246
|
+
};
|
|
6247
|
+
|
|
6248
|
+
// src/embeddedDocs/function/combinatorics/fallingFactorial.ts
|
|
6249
|
+
var fallingFactorialDocs = {
|
|
6250
|
+
name: "fallingFactorial",
|
|
6251
|
+
category: "Combinatorics",
|
|
6252
|
+
syntax: ["fallingFactorial(x, n)"],
|
|
6253
|
+
description: "Compute the falling factorial. x_(n) = x * (x-1) * ... * (x-n+1).",
|
|
6254
|
+
examples: ["fallingFactorial(5, 3)", "fallingFactorial(5, 5)"],
|
|
6255
|
+
seealso: ["risingFactorial", "factorial", "permutations"]
|
|
6256
|
+
};
|
|
6257
|
+
|
|
6258
|
+
// src/embeddedDocs/function/combinatorics/fibonacci.ts
|
|
6259
|
+
var fibonacciDocs = {
|
|
6260
|
+
name: "fibonacci",
|
|
6261
|
+
category: "Combinatorics",
|
|
6262
|
+
syntax: ["fibonacci(n)"],
|
|
6263
|
+
description: "Compute the nth Fibonacci number using the fast doubling method. O(log n) time complexity.",
|
|
6264
|
+
examples: ["fibonacci(10)", "fibonacci(20)", "fibonacci(0)"],
|
|
6265
|
+
seealso: ["lucas", "factorial", "combinations"]
|
|
6266
|
+
};
|
|
6267
|
+
|
|
6268
|
+
// src/embeddedDocs/function/combinatorics/lucas.ts
|
|
6269
|
+
var lucasDocs = {
|
|
6270
|
+
name: "lucas",
|
|
6271
|
+
category: "Combinatorics",
|
|
6272
|
+
syntax: ["lucas(n)"],
|
|
6273
|
+
description: "Compute the nth Lucas number. Lucas numbers follow L(0)=2, L(1)=1, L(n)=L(n-1)+L(n-2).",
|
|
6274
|
+
examples: ["lucas(0)", "lucas(1)", "lucas(10)"],
|
|
6275
|
+
seealso: ["fibonacci", "factorial"]
|
|
6276
|
+
};
|
|
6277
|
+
|
|
6278
|
+
// src/embeddedDocs/function/combinatorics/risingFactorial.ts
|
|
6279
|
+
var risingFactorialDocs = {
|
|
6280
|
+
name: "risingFactorial",
|
|
6281
|
+
category: "Combinatorics",
|
|
6282
|
+
syntax: ["risingFactorial(x, n)"],
|
|
6283
|
+
description: "Compute the rising factorial (Pochhammer symbol). x^(n) = x * (x+1) * ... * (x+n-1).",
|
|
6284
|
+
examples: ["risingFactorial(3, 4)", "risingFactorial(1, 5)"],
|
|
6285
|
+
seealso: ["fallingFactorial", "factorial", "combinations"]
|
|
6286
|
+
};
|
|
6287
|
+
|
|
6288
|
+
// src/embeddedDocs/function/combinatorics/subfactorial.ts
|
|
6289
|
+
var subfactorialDocs = {
|
|
6290
|
+
name: "subfactorial",
|
|
6291
|
+
category: "Combinatorics",
|
|
6292
|
+
syntax: ["subfactorial(n)"],
|
|
6293
|
+
description: "Compute the subfactorial (number of derangements). !n counts permutations with no fixed points.",
|
|
6294
|
+
examples: ["subfactorial(0)", "subfactorial(5)", "subfactorial(6)"],
|
|
6295
|
+
seealso: ["factorial", "doubleFactorial", "combinations"]
|
|
6296
|
+
};
|
|
6297
|
+
|
|
6298
|
+
// src/embeddedDocs/function/geometry/angle2D.ts
|
|
6299
|
+
var angle2DDocs = {
|
|
6300
|
+
name: "angle2D",
|
|
6301
|
+
category: "Geometry",
|
|
6302
|
+
syntax: ["angle2D(v1, v2)"],
|
|
6303
|
+
description: "Compute the angle in radians between two 2D vectors.",
|
|
6304
|
+
examples: ["angle2D([1, 0], [0, 1])"],
|
|
6305
|
+
seealso: ["angle3D", "dot3D", "cross3D"]
|
|
6306
|
+
};
|
|
6307
|
+
|
|
6308
|
+
// src/embeddedDocs/function/geometry/angle3D.ts
|
|
6309
|
+
var angle3DDocs = {
|
|
6310
|
+
name: "angle3D",
|
|
6311
|
+
category: "Geometry",
|
|
6312
|
+
syntax: ["angle3D(v1, v2)"],
|
|
6313
|
+
description: "Compute the angle in radians between two 3D vectors.",
|
|
6314
|
+
examples: ["angle3D([1, 0, 0], [0, 1, 0])"],
|
|
6315
|
+
seealso: ["angle2D", "dot3D", "cross3D"]
|
|
6316
|
+
};
|
|
6317
|
+
|
|
6318
|
+
// src/embeddedDocs/function/geometry/convexHull.ts
|
|
6319
|
+
var convexHullDocs = {
|
|
6320
|
+
name: "convexHull",
|
|
6321
|
+
category: "Geometry",
|
|
6322
|
+
syntax: ["convexHull(points)"],
|
|
6323
|
+
description: "Compute the convex hull of a set of 2D points using Andrew's monotone chain algorithm.",
|
|
6324
|
+
examples: ["convexHull([[0,0], [1,0], [0.5,1], [0.5,0.5]])"],
|
|
6325
|
+
seealso: ["pointInPolygon", "polygonArea"]
|
|
6326
|
+
};
|
|
6327
|
+
|
|
6328
|
+
// src/embeddedDocs/function/geometry/cross3D.ts
|
|
6329
|
+
var cross3DDocs = {
|
|
6330
|
+
name: "cross3D",
|
|
6331
|
+
category: "Geometry",
|
|
6332
|
+
syntax: ["cross3D(a, b)"],
|
|
6333
|
+
description: "Compute the cross product of two 3D vectors.",
|
|
6334
|
+
examples: ["cross3D([1, 0, 0], [0, 1, 0])"],
|
|
6335
|
+
seealso: ["dot3D", "angle3D"]
|
|
6336
|
+
};
|
|
6337
|
+
|
|
6338
|
+
// src/embeddedDocs/function/geometry/distance2D.ts
|
|
6339
|
+
var distance2DDocs = {
|
|
6340
|
+
name: "distance2D",
|
|
6341
|
+
category: "Geometry",
|
|
6342
|
+
syntax: ["distance2D(a, b)"],
|
|
6343
|
+
description: "Compute the Euclidean distance between two 2D points.",
|
|
6344
|
+
examples: ["distance2D([0, 0], [3, 4])"],
|
|
6345
|
+
seealso: ["distance3D", "distanceND", "distance"]
|
|
6346
|
+
};
|
|
6347
|
+
|
|
6348
|
+
// src/embeddedDocs/function/geometry/distance3D.ts
|
|
6349
|
+
var distance3DDocs = {
|
|
6350
|
+
name: "distance3D",
|
|
6351
|
+
category: "Geometry",
|
|
6352
|
+
syntax: ["distance3D(a, b)"],
|
|
6353
|
+
description: "Compute the Euclidean distance between two 3D points.",
|
|
6354
|
+
examples: ["distance3D([0, 0, 0], [1, 2, 2])"],
|
|
6355
|
+
seealso: ["distance2D", "distanceND", "distance"]
|
|
6356
|
+
};
|
|
6357
|
+
|
|
6358
|
+
// src/embeddedDocs/function/geometry/distanceND.ts
|
|
6359
|
+
var distanceNDDocs = {
|
|
6360
|
+
name: "distanceND",
|
|
6361
|
+
category: "Geometry",
|
|
6362
|
+
syntax: ["distanceND(a, b)"],
|
|
6363
|
+
description: "Compute the Euclidean distance between two N-dimensional points.",
|
|
6364
|
+
examples: ["distanceND([0, 0, 0, 0], [1, 1, 1, 1])"],
|
|
6365
|
+
seealso: ["distance2D", "distance3D"]
|
|
6366
|
+
};
|
|
6367
|
+
|
|
6368
|
+
// src/embeddedDocs/function/geometry/distancePointToLine2D.ts
|
|
6369
|
+
var distancePointToLine2DDocs = {
|
|
6370
|
+
name: "distancePointToLine2D",
|
|
6371
|
+
category: "Geometry",
|
|
6372
|
+
syntax: ["distancePointToLine2D(point, lineStart, lineEnd)"],
|
|
6373
|
+
description: "Compute the shortest distance from a point to a 2D line segment.",
|
|
6374
|
+
examples: ["distancePointToLine2D([0, 1], [0, 0], [1, 0])"],
|
|
6375
|
+
seealso: ["distance2D", "intersectLines2D"]
|
|
6376
|
+
};
|
|
6377
|
+
|
|
6378
|
+
// src/embeddedDocs/function/geometry/dot3D.ts
|
|
6379
|
+
var dot3DDocs = {
|
|
6380
|
+
name: "dot3D",
|
|
6381
|
+
category: "Geometry",
|
|
6382
|
+
syntax: ["dot3D(a, b)"],
|
|
6383
|
+
description: "Compute the dot product of two 3D vectors.",
|
|
6384
|
+
examples: ["dot3D([1, 2, 3], [4, 5, 6])"],
|
|
6385
|
+
seealso: ["cross3D", "angle3D"]
|
|
6386
|
+
};
|
|
6387
|
+
|
|
6388
|
+
// src/embeddedDocs/function/geometry/intersectLines2D.ts
|
|
6389
|
+
var intersectLines2DDocs = {
|
|
6390
|
+
name: "intersectLines2D",
|
|
6391
|
+
category: "Geometry",
|
|
6392
|
+
syntax: ["intersectLines2D(p1, d1, p2, d2)"],
|
|
6393
|
+
description: "Find the intersection point of two infinite 2D lines, each defined by a point and direction vector. Returns null if parallel.",
|
|
6394
|
+
examples: ["intersectLines2D([0, 0], [1, 1], [1, 0], [0, 1])"],
|
|
6395
|
+
seealso: ["intersectSegments2D", "distancePointToLine2D"]
|
|
6396
|
+
};
|
|
6397
|
+
|
|
6398
|
+
// src/embeddedDocs/function/geometry/intersectSegments2D.ts
|
|
6399
|
+
var intersectSegments2DDocs = {
|
|
6400
|
+
name: "intersectSegments2D",
|
|
6401
|
+
category: "Geometry",
|
|
6402
|
+
syntax: ["intersectSegments2D(a1, a2, b1, b2)"],
|
|
6403
|
+
description: "Find the intersection point of two 2D line segments. Returns null if they do not intersect.",
|
|
6404
|
+
examples: ["intersectSegments2D([0, 0], [1, 1], [0, 1], [1, 0])"],
|
|
6405
|
+
seealso: ["intersectLines2D", "pointInPolygon"]
|
|
6406
|
+
};
|
|
6407
|
+
|
|
6408
|
+
// src/embeddedDocs/function/geometry/pointInPolygon.ts
|
|
6409
|
+
var pointInPolygonDocs = {
|
|
6410
|
+
name: "pointInPolygon",
|
|
6411
|
+
category: "Geometry",
|
|
6412
|
+
syntax: ["pointInPolygon(point, polygon)"],
|
|
6413
|
+
description: "Determine if a 2D point lies inside a polygon using the ray casting algorithm.",
|
|
6414
|
+
examples: ["pointInPolygon([0.5, 0.5], [[0,0], [1,0], [1,1], [0,1]])"],
|
|
6415
|
+
seealso: ["convexHull", "polygonArea"]
|
|
6416
|
+
};
|
|
6417
|
+
|
|
6418
|
+
// src/embeddedDocs/function/geometry/polygonArea.ts
|
|
6419
|
+
var polygonAreaDocs = {
|
|
6420
|
+
name: "polygonArea",
|
|
6421
|
+
category: "Geometry",
|
|
6422
|
+
syntax: ["polygonArea(vertices)"],
|
|
6423
|
+
description: "Compute the area of a simple polygon given ordered 2D vertices using the shoelace formula.",
|
|
6424
|
+
examples: ["polygonArea([[0,0], [1,0], [1,1], [0,1]])"],
|
|
6425
|
+
seealso: ["triangleArea", "convexHull"]
|
|
6426
|
+
};
|
|
6427
|
+
|
|
6428
|
+
// src/embeddedDocs/function/geometry/projectVector.ts
|
|
6429
|
+
var projectVectorDocs = {
|
|
6430
|
+
name: "projectVector",
|
|
6431
|
+
category: "Geometry",
|
|
6432
|
+
syntax: ["projectVector(v, onto)"],
|
|
6433
|
+
description: "Project vector v onto another vector.",
|
|
6434
|
+
examples: ["projectVector([3, 4], [1, 0])"],
|
|
6435
|
+
seealso: ["reflectVector", "dot3D"]
|
|
6436
|
+
};
|
|
6437
|
+
|
|
6438
|
+
// src/embeddedDocs/function/geometry/reflectVector.ts
|
|
6439
|
+
var reflectVectorDocs = {
|
|
6440
|
+
name: "reflectVector",
|
|
6441
|
+
category: "Geometry",
|
|
6442
|
+
syntax: ["reflectVector(v, normal)"],
|
|
6443
|
+
description: "Reflect a vector across a plane defined by its normal vector.",
|
|
6444
|
+
examples: ["reflectVector([1, 1], [0, 1])"],
|
|
6445
|
+
seealso: ["rotateVector2D", "projectVector"]
|
|
6446
|
+
};
|
|
6447
|
+
|
|
6448
|
+
// src/embeddedDocs/function/geometry/rotateVector2D.ts
|
|
6449
|
+
var rotateVector2DDocs = {
|
|
6450
|
+
name: "rotateVector2D",
|
|
6451
|
+
category: "Geometry",
|
|
6452
|
+
syntax: ["rotateVector2D(v, angle)"],
|
|
6453
|
+
description: "Rotate a 2D vector by a given angle in radians.",
|
|
6454
|
+
examples: ["rotateVector2D([1, 0], pi / 2)"],
|
|
6455
|
+
seealso: ["rotateVector3D", "reflectVector"]
|
|
6456
|
+
};
|
|
6457
|
+
|
|
6458
|
+
// src/embeddedDocs/function/geometry/rotateVector3D.ts
|
|
6459
|
+
var rotateVector3DDocs = {
|
|
6460
|
+
name: "rotateVector3D",
|
|
6461
|
+
category: "Geometry",
|
|
6462
|
+
syntax: ["rotateVector3D(v, axis, angle)"],
|
|
6463
|
+
description: "Rotate a 3D vector around an arbitrary axis by a given angle using Rodrigues' formula.",
|
|
6464
|
+
examples: ["rotateVector3D([1, 0, 0], [0, 0, 1], pi / 2)"],
|
|
6465
|
+
seealso: ["rotateVector2D", "reflectVector"]
|
|
6466
|
+
};
|
|
6467
|
+
|
|
6468
|
+
// src/embeddedDocs/function/geometry/triangleArea.ts
|
|
6469
|
+
var triangleAreaDocs = {
|
|
6470
|
+
name: "triangleArea",
|
|
6471
|
+
category: "Geometry",
|
|
6472
|
+
syntax: ["triangleArea(a, b, c)"],
|
|
6473
|
+
description: "Compute the area of a triangle given three 2D vertices.",
|
|
6474
|
+
examples: ["triangleArea([0, 0], [1, 0], [0, 1])"],
|
|
6475
|
+
seealso: ["polygonArea"]
|
|
6476
|
+
};
|
|
6477
|
+
|
|
6478
|
+
// src/embeddedDocs/function/numeric/cubicSpline.ts
|
|
6479
|
+
var cubicSplineDocs = {
|
|
6480
|
+
name: "cubicSpline",
|
|
6481
|
+
category: "Numeric",
|
|
6482
|
+
syntax: ["cubicSpline(xs, ys)"],
|
|
6483
|
+
description: "Natural cubic spline interpolation. Returns a function that evaluates the spline at any point. Uses natural boundary conditions (second derivative = 0 at endpoints).",
|
|
6484
|
+
examples: ["const s = cubicSpline([0,1,2,3], [0,1,4,9]); s(1.5)"],
|
|
6485
|
+
seealso: ["linearInterp", "pchipInterp", "hermiteInterp"]
|
|
6486
|
+
};
|
|
6487
|
+
|
|
6488
|
+
// src/embeddedDocs/function/numeric/gaussQuad.ts
|
|
6489
|
+
var gaussQuadDocs = {
|
|
6490
|
+
name: "gaussQuad",
|
|
6491
|
+
category: "Numeric",
|
|
6492
|
+
syntax: ["gaussQuad(f, a, b)", "gaussQuad(f, a, b, n)"],
|
|
6493
|
+
description: "Numerical integration using Gauss-Legendre quadrature with n points (2-5, default 5). Exact for polynomials up to degree 2n-1.",
|
|
6494
|
+
examples: ["gaussQuad(x => x**2, 0, 1, 3)", "gaussQuad(Math.exp, 0, 1)"],
|
|
6495
|
+
seealso: ["trapz", "simpson", "romberg"]
|
|
6496
|
+
};
|
|
6497
|
+
|
|
6498
|
+
// src/embeddedDocs/function/numeric/hermiteInterp.ts
|
|
6499
|
+
var hermiteInterpDocs = {
|
|
6500
|
+
name: "hermiteInterp",
|
|
6501
|
+
category: "Numeric",
|
|
6502
|
+
syntax: ["hermiteInterp(xs, ys, dys, x)"],
|
|
6503
|
+
description: "Hermite interpolation using function values and derivatives at data points. Constructs the unique polynomial matching both values and first derivatives.",
|
|
6504
|
+
examples: ["hermiteInterp([0, 1], [0, 1], [1, 1], 0.5)"],
|
|
6505
|
+
seealso: ["lagrangeInterp", "cubicSpline", "pchipInterp"]
|
|
6506
|
+
};
|
|
6507
|
+
|
|
6508
|
+
// src/embeddedDocs/function/numeric/lagrangeInterp.ts
|
|
6509
|
+
var lagrangeInterpDocs = {
|
|
6510
|
+
name: "lagrangeInterp",
|
|
6511
|
+
category: "Numeric",
|
|
6512
|
+
syntax: ["lagrangeInterp(xs, ys, x)"],
|
|
6513
|
+
description: "Lagrange polynomial interpolation. Evaluates the unique polynomial of degree n-1 passing through n data points at the given x.",
|
|
6514
|
+
examples: ["lagrangeInterp([0, 1, 2], [0, 1, 4], 1.5)"],
|
|
6515
|
+
seealso: ["linearInterp", "hermiteInterp", "cubicSpline"]
|
|
6516
|
+
};
|
|
6517
|
+
|
|
6518
|
+
// src/embeddedDocs/function/numeric/linearInterp.ts
|
|
6519
|
+
var linearInterpDocs = {
|
|
6520
|
+
name: "linearInterp",
|
|
6521
|
+
category: "Numeric",
|
|
6522
|
+
syntax: ["linearInterp(xs, ys, x)"],
|
|
6523
|
+
description: "Linear interpolation between data points. Finds the interval containing x and linearly interpolates. Extrapolates outside the data range.",
|
|
6524
|
+
examples: ["linearInterp([0, 1], [0, 1], 0.5)", "linearInterp([0, 1, 2], [0, 1, 4], 1.5)"],
|
|
6525
|
+
seealso: ["lagrangeInterp", "cubicSpline", "pchipInterp"]
|
|
6526
|
+
};
|
|
6527
|
+
|
|
6528
|
+
// src/embeddedDocs/function/numeric/pchipInterp.ts
|
|
6529
|
+
var pchipInterpDocs = {
|
|
6530
|
+
name: "pchipInterp",
|
|
6531
|
+
category: "Numeric",
|
|
6532
|
+
syntax: ["pchipInterp(xs, ys, x)"],
|
|
6533
|
+
description: "Shape-preserving Piecewise Cubic Hermite Interpolating Polynomial (PCHIP). Unlike cubic splines, PCHIP preserves monotonicity and avoids overshoot.",
|
|
6534
|
+
examples: ["pchipInterp([0, 1, 2, 3], [0, 1, 4, 9], 1.5)"],
|
|
6535
|
+
seealso: ["linearInterp", "cubicSpline", "hermiteInterp"]
|
|
6536
|
+
};
|
|
6537
|
+
|
|
6538
|
+
// src/embeddedDocs/function/numeric/polyFit.ts
|
|
6539
|
+
var polyFitDocs = {
|
|
6540
|
+
name: "polyFit",
|
|
6541
|
+
category: "Numeric",
|
|
6542
|
+
syntax: ["polyFit(xs, ys, degree)"],
|
|
6543
|
+
description: "Least-squares polynomial fit. Returns coefficients [a0, a1, ..., ad] for p(x) = a0 + a1*x + ... + ad*x^d.",
|
|
6544
|
+
examples: ["polyFit([0,1,2,3], [0,1,4,9], 2)"],
|
|
6545
|
+
seealso: ["linearInterp", "lagrangeInterp"]
|
|
6546
|
+
};
|
|
6547
|
+
|
|
6548
|
+
// src/embeddedDocs/function/numeric/romberg.ts
|
|
6549
|
+
var rombergDocs = {
|
|
6550
|
+
name: "romberg",
|
|
6551
|
+
category: "Numeric",
|
|
6552
|
+
syntax: ["romberg(f, a, b)", "romberg(f, a, b, tol)"],
|
|
6553
|
+
description: "Adaptive numerical integration using Romberg method (Richardson extrapolation on the trapezoidal rule). Converges to the specified tolerance (default 1e-12).",
|
|
6554
|
+
examples: ["romberg(Math.sin, 0, Math.PI)", "romberg(x => 1/x, 1, 2)"],
|
|
6555
|
+
seealso: ["trapz", "simpson", "gaussQuad"]
|
|
6556
|
+
};
|
|
6557
|
+
|
|
6558
|
+
// src/embeddedDocs/function/numeric/simpson.ts
|
|
6559
|
+
var simpsonDocs = {
|
|
6560
|
+
name: "simpson",
|
|
6561
|
+
category: "Numeric",
|
|
6562
|
+
syntax: ["simpson(f, a, b)", "simpson(f, a, b, n)"],
|
|
6563
|
+
description: "Numerical integration using Simpson's 1/3 rule. Divides [a,b] into n subintervals (default 100, must be even).",
|
|
6564
|
+
examples: ["simpson(x => x**2, 0, 1)", "simpson(Math.sin, 0, Math.PI)"],
|
|
6565
|
+
seealso: ["trapz", "romberg", "gaussQuad"]
|
|
6566
|
+
};
|
|
6567
|
+
|
|
6568
|
+
// src/embeddedDocs/function/numeric/trapz.ts
|
|
6569
|
+
var trapzDocs = {
|
|
6570
|
+
name: "trapz",
|
|
6571
|
+
category: "Numeric",
|
|
6572
|
+
syntax: ["trapz(y)", "trapz(y, x)"],
|
|
6573
|
+
description: "Numerical integration using the trapezoidal rule. If x is omitted, uniform spacing (h=1) is assumed.",
|
|
6574
|
+
examples: ["trapz([1, 2, 3], [0, 1, 2])", "trapz([0, 1, 0])"],
|
|
6575
|
+
seealso: ["simpson", "romberg", "gaussQuad"]
|
|
6576
|
+
};
|
|
6577
|
+
|
|
6578
|
+
// src/embeddedDocs/function/probability/bernoulliPMF.ts
|
|
6579
|
+
var bernoulliPMFDocs = {
|
|
6580
|
+
name: "bernoulliPMF",
|
|
6581
|
+
category: "Probability",
|
|
6582
|
+
syntax: ["bernoulliPMF(k, p)"],
|
|
6583
|
+
description: "Compute the Bernoulli probability mass function: p if k=1, (1-p) if k=0. The simplest discrete distribution.",
|
|
6584
|
+
examples: ["bernoulliPMF(1, 0.7)", "bernoulliPMF(0, 0.7)", "bernoulliPMF(1, 0.5)"],
|
|
6585
|
+
seealso: ["binomialPMF", "geometricPMF"]
|
|
6586
|
+
};
|
|
6587
|
+
|
|
6588
|
+
// src/embeddedDocs/function/probability/binomialPMF.ts
|
|
6589
|
+
var binomialPMFDocs = {
|
|
6590
|
+
name: "binomialPMF",
|
|
6591
|
+
category: "Probability",
|
|
6592
|
+
syntax: ["binomialPMF(k, n, p)"],
|
|
6593
|
+
description: "Compute the binomial probability mass function: C(n, k) * p^k * (1-p)^(n-k). Computed in log-space to avoid overflow.",
|
|
6594
|
+
examples: ["binomialPMF(3, 10, 0.5)", "binomialPMF(0, 5, 0.3)", "binomialPMF(5, 5, 0.3)"],
|
|
6595
|
+
seealso: ["poissonPMF", "bernoulliPMF", "combinations"]
|
|
6596
|
+
};
|
|
6597
|
+
|
|
6598
|
+
// src/embeddedDocs/function/probability/entropy.ts
|
|
6599
|
+
var entropyDocs = {
|
|
6600
|
+
name: "entropy",
|
|
6601
|
+
category: "Probability",
|
|
6602
|
+
syntax: ["entropy(probs)"],
|
|
6603
|
+
description: "Compute the Shannon entropy of a discrete probability distribution in bits: H(P) = -sum(p_i * log2(p_i)).",
|
|
6604
|
+
examples: ["entropy([0.5, 0.5])", "entropy([0.25, 0.25, 0.25, 0.25])", "entropy([1, 0])"],
|
|
6605
|
+
seealso: ["jsDivergence", "kldivergence"]
|
|
6606
|
+
};
|
|
6607
|
+
|
|
6608
|
+
// src/embeddedDocs/function/probability/exponentialCDF.ts
|
|
6609
|
+
var exponentialCDFDocs = {
|
|
6610
|
+
name: "exponentialCDF",
|
|
6611
|
+
category: "Probability",
|
|
6612
|
+
syntax: ["exponentialCDF(x, lambda)"],
|
|
6613
|
+
description: "Compute the exponential cumulative distribution function: 1 - exp(-lambda * x) for x >= 0.",
|
|
6614
|
+
examples: ["exponentialCDF(1, 1)", "exponentialCDF(0, 1)", "exponentialCDF(2, 0.5)"],
|
|
6615
|
+
seealso: ["exponentialPDF"]
|
|
6616
|
+
};
|
|
6617
|
+
|
|
6618
|
+
// src/embeddedDocs/function/probability/exponentialPDF.ts
|
|
6619
|
+
var exponentialPDFDocs = {
|
|
6620
|
+
name: "exponentialPDF",
|
|
6621
|
+
category: "Probability",
|
|
6622
|
+
syntax: ["exponentialPDF(x, lambda)"],
|
|
6623
|
+
description: "Compute the exponential probability density function: lambda * exp(-lambda * x) for x >= 0.",
|
|
6624
|
+
examples: ["exponentialPDF(0, 1)", "exponentialPDF(1, 1)", "exponentialPDF(0, 2)"],
|
|
6625
|
+
seealso: ["exponentialCDF"]
|
|
6626
|
+
};
|
|
6627
|
+
|
|
6628
|
+
// src/embeddedDocs/function/probability/geometricPMF.ts
|
|
6629
|
+
var geometricPMFDocs = {
|
|
6630
|
+
name: "geometricPMF",
|
|
6631
|
+
category: "Probability",
|
|
6632
|
+
syntax: ["geometricPMF(k, p)"],
|
|
6633
|
+
description: "Compute the geometric probability mass function: (1-p)^(k-1) * p for k = 1, 2, 3, ... Models the number of trials until the first success.",
|
|
6634
|
+
examples: ["geometricPMF(1, 0.5)", "geometricPMF(3, 0.5)", "geometricPMF(1, 1)"],
|
|
6635
|
+
seealso: ["bernoulliPMF", "binomialPMF"]
|
|
6636
|
+
};
|
|
6637
|
+
|
|
6638
|
+
// src/embeddedDocs/function/probability/jsDivergence.ts
|
|
6639
|
+
var jsDivergenceDocs = {
|
|
6640
|
+
name: "jsDivergence",
|
|
6641
|
+
category: "Probability",
|
|
6642
|
+
syntax: ["jsDivergence(p, q)"],
|
|
6643
|
+
description: "Compute the Jensen-Shannon divergence between two probability distributions in bits. Always non-negative and symmetric: JSD(P||Q) = JSD(Q||P).",
|
|
6644
|
+
examples: ["jsDivergence([0.5, 0.5], [0.5, 0.5])", "jsDivergence([1, 0], [0, 1])"],
|
|
6645
|
+
seealso: ["entropy", "kldivergence"]
|
|
6646
|
+
};
|
|
6647
|
+
|
|
6648
|
+
// src/embeddedDocs/function/probability/normalCDF.ts
|
|
6649
|
+
var normalCDFDocs = {
|
|
6650
|
+
name: "normalCDF",
|
|
6651
|
+
category: "Probability",
|
|
6652
|
+
syntax: ["normalCDF(x)", "normalCDF(x, mu, sigma)"],
|
|
6653
|
+
description: "Compute the normal (Gaussian) cumulative distribution function P(X <= x). With one argument, uses the standard normal (mu=0, sigma=1).",
|
|
6654
|
+
examples: ["normalCDF(0)", "normalCDF(1.96)", "normalCDF(0, 5, 2)"],
|
|
6655
|
+
seealso: ["normalPDF", "erf", "erfc"]
|
|
6656
|
+
};
|
|
6657
|
+
|
|
6658
|
+
// src/embeddedDocs/function/probability/normalPDF.ts
|
|
6659
|
+
var normalPDFDocs = {
|
|
6660
|
+
name: "normalPDF",
|
|
6661
|
+
category: "Probability",
|
|
6662
|
+
syntax: ["normalPDF(x)", "normalPDF(x, mu, sigma)"],
|
|
6663
|
+
description: "Compute the normal (Gaussian) probability density function. With one argument, uses the standard normal (mu=0, sigma=1).",
|
|
6664
|
+
examples: ["normalPDF(0)", "normalPDF(0, 0, 1)", "normalPDF(1, 0, 2)"],
|
|
6665
|
+
seealso: ["normalCDF", "erf"]
|
|
6666
|
+
};
|
|
6667
|
+
|
|
6668
|
+
// src/embeddedDocs/function/probability/poissonPMF.ts
|
|
6669
|
+
var poissonPMFDocs = {
|
|
6670
|
+
name: "poissonPMF",
|
|
6671
|
+
category: "Probability",
|
|
6672
|
+
syntax: ["poissonPMF(k, lambda)"],
|
|
6673
|
+
description: "Compute the Poisson probability mass function: e^(-lambda) * lambda^k / k!. Computed in log-space to avoid overflow.",
|
|
6674
|
+
examples: ["poissonPMF(0, 1)", "poissonPMF(3, 2.5)", "poissonPMF(5, 5)"],
|
|
6675
|
+
seealso: ["binomialPMF", "exponentialPDF"]
|
|
6676
|
+
};
|
|
6677
|
+
|
|
6678
|
+
// src/embeddedDocs/function/signal/autoCorrelation.ts
|
|
6679
|
+
var autoCorrelationDocs = {
|
|
6680
|
+
name: "autoCorrelation",
|
|
6681
|
+
category: "Signal",
|
|
6682
|
+
syntax: ["autoCorrelation(a)"],
|
|
6683
|
+
description: "Compute the auto-correlation of a signal (cross-correlation with itself).",
|
|
6684
|
+
examples: ["autoCorrelation([1, 2, 3])"],
|
|
6685
|
+
seealso: ["crossCorrelation", "xcorr"]
|
|
6686
|
+
};
|
|
6687
|
+
|
|
6688
|
+
// src/embeddedDocs/function/signal/crossCorrelation.ts
|
|
6689
|
+
var crossCorrelationDocs = {
|
|
6690
|
+
name: "crossCorrelation",
|
|
6691
|
+
category: "Signal",
|
|
6692
|
+
syntax: ["crossCorrelation(a, b)"],
|
|
6693
|
+
description: "Compute the cross-correlation of two real signals via sliding dot product.",
|
|
6694
|
+
examples: ["crossCorrelation([1, 2, 3], [1, 2, 3])"],
|
|
6695
|
+
seealso: ["autoCorrelation", "conv"]
|
|
6696
|
+
};
|
|
6697
|
+
|
|
6698
|
+
// src/embeddedDocs/function/signal/groupDelay.ts
|
|
6699
|
+
var groupDelayDocs = {
|
|
6700
|
+
name: "groupDelay",
|
|
6701
|
+
category: "Signal",
|
|
6702
|
+
syntax: ["groupDelay(b, a)", "groupDelay(b, a, w)"],
|
|
6703
|
+
description: "Compute the group delay of a digital filter defined by numerator (b) and denominator (a) polynomial coefficients.",
|
|
6704
|
+
examples: ["groupDelay([1, 2, 1], [1])"],
|
|
6705
|
+
seealso: ["unwrapPhase", "fft"]
|
|
6706
|
+
};
|
|
6707
|
+
|
|
6708
|
+
// src/embeddedDocs/function/signal/unwrapPhase.ts
|
|
6709
|
+
var unwrapPhaseDocs = {
|
|
6710
|
+
name: "unwrapPhase",
|
|
6711
|
+
category: "Signal",
|
|
6712
|
+
syntax: ["unwrapPhase(phase)"],
|
|
6713
|
+
description: "Unwrap phase angles by adding multiples of 2*pi to remove discontinuities.",
|
|
6714
|
+
examples: ["unwrapPhase([0, 1, 2, 3, -2.28])"],
|
|
6715
|
+
seealso: ["groupDelay", "fft"]
|
|
6716
|
+
};
|
|
6717
|
+
|
|
6718
|
+
// src/embeddedDocs/function/special/besselJ0.ts
|
|
6719
|
+
var besselJ0Docs = {
|
|
6720
|
+
name: "besselJ0",
|
|
6721
|
+
category: "Special",
|
|
6722
|
+
syntax: ["besselJ0(x)"],
|
|
6723
|
+
description: "Compute the Bessel function of the first kind, order 0. Uses polynomial approximation from Hart (1968).",
|
|
6724
|
+
examples: ["besselJ0(0)", "besselJ0(1)", "besselJ0(2.4048)"],
|
|
6725
|
+
seealso: ["besselJ1", "besselY0", "besselY1"]
|
|
6726
|
+
};
|
|
6727
|
+
|
|
6728
|
+
// src/embeddedDocs/function/special/besselJ1.ts
|
|
6729
|
+
var besselJ1Docs = {
|
|
6730
|
+
name: "besselJ1",
|
|
6731
|
+
category: "Special",
|
|
6732
|
+
syntax: ["besselJ1(x)"],
|
|
6733
|
+
description: "Compute the Bessel function of the first kind, order 1. Uses polynomial approximation from Hart (1968).",
|
|
6734
|
+
examples: ["besselJ1(0)", "besselJ1(1)", "besselJ1(3.8317)"],
|
|
6735
|
+
seealso: ["besselJ0", "besselY0", "besselY1"]
|
|
6736
|
+
};
|
|
6737
|
+
|
|
6738
|
+
// src/embeddedDocs/function/special/besselY0.ts
|
|
6739
|
+
var besselY0Docs = {
|
|
6740
|
+
name: "besselY0",
|
|
6741
|
+
category: "Special",
|
|
6742
|
+
syntax: ["besselY0(x)"],
|
|
6743
|
+
description: "Compute the Bessel function of the second kind, order 0. Valid only for x > 0. Uses polynomial approximation from Hart (1968).",
|
|
6744
|
+
examples: ["besselY0(1)", "besselY0(5)", "besselY0(10)"],
|
|
6745
|
+
seealso: ["besselJ0", "besselJ1", "besselY1"]
|
|
6746
|
+
};
|
|
6747
|
+
|
|
6748
|
+
// src/embeddedDocs/function/special/besselY1.ts
|
|
6749
|
+
var besselY1Docs = {
|
|
6750
|
+
name: "besselY1",
|
|
6751
|
+
category: "Special",
|
|
6752
|
+
syntax: ["besselY1(x)"],
|
|
6753
|
+
description: "Compute the Bessel function of the second kind, order 1. Valid only for x > 0. Uses polynomial approximation from Hart (1968).",
|
|
6754
|
+
examples: ["besselY1(1)", "besselY1(5)", "besselY1(10)"],
|
|
6755
|
+
seealso: ["besselJ0", "besselJ1", "besselY0"]
|
|
6756
|
+
};
|
|
6757
|
+
|
|
6758
|
+
// src/embeddedDocs/function/special/beta.ts
|
|
6759
|
+
var betaDocs = {
|
|
6760
|
+
name: "beta",
|
|
6761
|
+
category: "Special",
|
|
6762
|
+
syntax: ["beta(a, b)"],
|
|
6763
|
+
description: "Compute the beta function B(a, b) = Gamma(a) * Gamma(b) / Gamma(a+b). Computed via the log-gamma function to avoid overflow.",
|
|
6764
|
+
examples: ["beta(2, 3)", "beta(0.5, 0.5)", "beta(1, 5)"],
|
|
6765
|
+
seealso: ["gamma", "lgamma"]
|
|
6766
|
+
};
|
|
6767
|
+
|
|
6768
|
+
// src/embeddedDocs/function/special/digamma.ts
|
|
6769
|
+
var digammaDocs = {
|
|
6770
|
+
name: "digamma",
|
|
6771
|
+
category: "Special",
|
|
6772
|
+
syntax: ["digamma(x)"],
|
|
6773
|
+
description: "Compute the digamma (psi) function, the logarithmic derivative of the gamma function: psi(x) = d/dx ln(Gamma(x)). Uses asymptotic expansion with recurrence relation.",
|
|
6774
|
+
examples: ["digamma(1)", "digamma(2)", "digamma(0.5)"],
|
|
6775
|
+
seealso: ["gamma", "lgamma"]
|
|
6776
|
+
};
|
|
6777
|
+
|
|
6778
|
+
// src/embeddedDocs/function/special/erfc.ts
|
|
6779
|
+
var erfcDocs = {
|
|
6780
|
+
name: "erfc",
|
|
6781
|
+
category: "Special",
|
|
6782
|
+
syntax: ["erfc(x)"],
|
|
6783
|
+
description: "Compute the complementary error function erfc(x) = 1 - erf(x). Uses the Abramowitz & Stegun rational approximation.",
|
|
6784
|
+
examples: ["erfc(0)", "erfc(1)", "erfc(0.5)", "erfc(-1)"],
|
|
6785
|
+
seealso: ["erf"]
|
|
6786
|
+
};
|
|
6787
|
+
|
|
6788
|
+
// src/embeddedDocs/function/special/gammainc.ts
|
|
6789
|
+
var gammaincDocs = {
|
|
6790
|
+
name: "gammainc",
|
|
6791
|
+
category: "Special",
|
|
6792
|
+
syntax: ["gammainc(a, x)"],
|
|
6793
|
+
description: "Compute the regularized lower incomplete gamma function P(a, x) = gamma(a, x) / Gamma(a). Uses series expansion for small x and continued fraction for large x.",
|
|
6794
|
+
examples: ["gammainc(1, 1)", "gammainc(0.5, 1)", "gammainc(3, 2)"],
|
|
6795
|
+
seealso: ["gamma", "lgamma"]
|
|
6796
|
+
};
|
|
6797
|
+
|
|
5867
6798
|
// src/embeddedDocs/embeddedDocs.ts
|
|
5868
6799
|
var embeddedDocs = {
|
|
5869
6800
|
// construction functions
|
|
@@ -6240,7 +7171,100 @@ var embeddedDocs = {
|
|
|
6240
7171
|
isZero: isZeroDocs,
|
|
6241
7172
|
print: printDocs,
|
|
6242
7173
|
typeOf: typeOfDocs,
|
|
6243
|
-
numeric: numericDocs
|
|
7174
|
+
numeric: numericDocs,
|
|
7175
|
+
// MathTS-native extension docs (wired 2026-07-05)
|
|
7176
|
+
apart: apartDocs,
|
|
7177
|
+
cancel: cancelDocs,
|
|
7178
|
+
coefficientList: coefficientListDocs,
|
|
7179
|
+
collect: collectDocs,
|
|
7180
|
+
combine: combineDocs,
|
|
7181
|
+
complexExpand: complexExpandDocs,
|
|
7182
|
+
degree: degreeDocs,
|
|
7183
|
+
differences: differencesDocs,
|
|
7184
|
+
discriminant: discriminantDocs,
|
|
7185
|
+
element: elementDocs,
|
|
7186
|
+
eliminate: eliminateDocs,
|
|
7187
|
+
expToTrig: expToTrigDocs,
|
|
7188
|
+
expand: expandDocs,
|
|
7189
|
+
factor: factorDocs,
|
|
7190
|
+
fullSimplify: fullSimplifyDocs,
|
|
7191
|
+
functionExpand: functionExpandDocs,
|
|
7192
|
+
normalForm: normalFormDocs,
|
|
7193
|
+
partialDerivative: partialDerivativeDocs,
|
|
7194
|
+
polyadd: polyaddDocs,
|
|
7195
|
+
polyder: polyderDocs,
|
|
7196
|
+
polymul: polymulDocs,
|
|
7197
|
+
polynomialGCD: polynomialGCDDocs,
|
|
7198
|
+
polynomialLCM: polynomialLCMDocs,
|
|
7199
|
+
polynomialQuotient: polynomialQuotientDocs,
|
|
7200
|
+
polynomialRemainder: polynomialRemainderDocs,
|
|
7201
|
+
polyval: polyvalDocs,
|
|
7202
|
+
powerExpand: powerExpandDocs,
|
|
7203
|
+
reduce: reduceDocs,
|
|
7204
|
+
resultant: resultantDocs,
|
|
7205
|
+
substitute: substituteDocs,
|
|
7206
|
+
tangentLine: tangentLineDocs,
|
|
7207
|
+
together: togetherDocs,
|
|
7208
|
+
trigExpand: trigExpandDocs,
|
|
7209
|
+
trigReduce: trigReduceDocs,
|
|
7210
|
+
trigToExp: trigToExpDocs,
|
|
7211
|
+
variables: variablesDocs,
|
|
7212
|
+
doubleFactorial: doubleFactorialDocs,
|
|
7213
|
+
fallingFactorial: fallingFactorialDocs,
|
|
7214
|
+
fibonacci: fibonacciDocs,
|
|
7215
|
+
lucas: lucasDocs,
|
|
7216
|
+
risingFactorial: risingFactorialDocs,
|
|
7217
|
+
subfactorial: subfactorialDocs,
|
|
7218
|
+
angle2D: angle2DDocs,
|
|
7219
|
+
angle3D: angle3DDocs,
|
|
7220
|
+
convexHull: convexHullDocs,
|
|
7221
|
+
cross3D: cross3DDocs,
|
|
7222
|
+
distance2D: distance2DDocs,
|
|
7223
|
+
distance3D: distance3DDocs,
|
|
7224
|
+
distanceND: distanceNDDocs,
|
|
7225
|
+
distancePointToLine2D: distancePointToLine2DDocs,
|
|
7226
|
+
dot3D: dot3DDocs,
|
|
7227
|
+
intersectLines2D: intersectLines2DDocs,
|
|
7228
|
+
intersectSegments2D: intersectSegments2DDocs,
|
|
7229
|
+
pointInPolygon: pointInPolygonDocs,
|
|
7230
|
+
polygonArea: polygonAreaDocs,
|
|
7231
|
+
projectVector: projectVectorDocs,
|
|
7232
|
+
reflectVector: reflectVectorDocs,
|
|
7233
|
+
rotateVector2D: rotateVector2DDocs,
|
|
7234
|
+
rotateVector3D: rotateVector3DDocs,
|
|
7235
|
+
triangleArea: triangleAreaDocs,
|
|
7236
|
+
cubicSpline: cubicSplineDocs,
|
|
7237
|
+
gaussQuad: gaussQuadDocs,
|
|
7238
|
+
hermiteInterp: hermiteInterpDocs,
|
|
7239
|
+
lagrangeInterp: lagrangeInterpDocs,
|
|
7240
|
+
linearInterp: linearInterpDocs,
|
|
7241
|
+
pchipInterp: pchipInterpDocs,
|
|
7242
|
+
polyFit: polyFitDocs,
|
|
7243
|
+
romberg: rombergDocs,
|
|
7244
|
+
simpson: simpsonDocs,
|
|
7245
|
+
trapz: trapzDocs,
|
|
7246
|
+
bernoulliPMF: bernoulliPMFDocs,
|
|
7247
|
+
binomialPMF: binomialPMFDocs,
|
|
7248
|
+
entropy: entropyDocs,
|
|
7249
|
+
exponentialCDF: exponentialCDFDocs,
|
|
7250
|
+
exponentialPDF: exponentialPDFDocs,
|
|
7251
|
+
geometricPMF: geometricPMFDocs,
|
|
7252
|
+
jsDivergence: jsDivergenceDocs,
|
|
7253
|
+
normalCDF: normalCDFDocs,
|
|
7254
|
+
normalPDF: normalPDFDocs,
|
|
7255
|
+
poissonPMF: poissonPMFDocs,
|
|
7256
|
+
autoCorrelation: autoCorrelationDocs,
|
|
7257
|
+
crossCorrelation: crossCorrelationDocs,
|
|
7258
|
+
groupDelay: groupDelayDocs,
|
|
7259
|
+
unwrapPhase: unwrapPhaseDocs,
|
|
7260
|
+
besselJ0: besselJ0Docs,
|
|
7261
|
+
besselJ1: besselJ1Docs,
|
|
7262
|
+
besselY0: besselY0Docs,
|
|
7263
|
+
besselY1: besselY1Docs,
|
|
7264
|
+
beta: betaDocs,
|
|
7265
|
+
digamma: digammaDocs,
|
|
7266
|
+
erfc: erfcDocs,
|
|
7267
|
+
gammainc: gammaincDocs
|
|
6244
7268
|
};
|
|
6245
7269
|
|
|
6246
7270
|
// src/compiler/compile.ts
|
|
@@ -6316,25 +7340,25 @@ function compileConstantNode(node) {
|
|
|
6316
7340
|
};
|
|
6317
7341
|
}
|
|
6318
7342
|
function compileSymbolNode(node, math, argNames) {
|
|
6319
|
-
const
|
|
6320
|
-
if (argNames[
|
|
7343
|
+
const name47 = node.name;
|
|
7344
|
+
if (argNames[name47] === true) {
|
|
6321
7345
|
return function evalSymbolArg(_scope, args) {
|
|
6322
|
-
return args[
|
|
7346
|
+
return args[name47];
|
|
6323
7347
|
};
|
|
6324
7348
|
}
|
|
6325
|
-
if (Object.prototype.hasOwnProperty.call(math,
|
|
7349
|
+
if (Object.prototype.hasOwnProperty.call(math, name47)) {
|
|
6326
7350
|
return function evalSymbolNode(scope) {
|
|
6327
|
-
if (scope.has(
|
|
6328
|
-
return scope.get(
|
|
7351
|
+
if (scope.has(name47)) {
|
|
7352
|
+
return scope.get(name47);
|
|
6329
7353
|
}
|
|
6330
|
-
return math[
|
|
7354
|
+
return math[name47];
|
|
6331
7355
|
};
|
|
6332
7356
|
}
|
|
6333
7357
|
return function evalSymbolNode(scope) {
|
|
6334
|
-
if (scope.has(
|
|
6335
|
-
return scope.get(
|
|
7358
|
+
if (scope.has(name47)) {
|
|
7359
|
+
return scope.get(name47);
|
|
6336
7360
|
}
|
|
6337
|
-
throw new Error(`Undefined symbol "${
|
|
7361
|
+
throw new Error(`Undefined symbol "${name47}"`);
|
|
6338
7362
|
};
|
|
6339
7363
|
}
|
|
6340
7364
|
function compileOperatorNode(node, math, argNames) {
|
|
@@ -6344,6 +7368,12 @@ function compileOperatorNode(node, math, argNames) {
|
|
|
6344
7368
|
throw new Error(`Function "${fnName}" missing in provided namespace "math"`);
|
|
6345
7369
|
}
|
|
6346
7370
|
const fn = math[fnName];
|
|
7371
|
+
if (fn.rawArgs === true) {
|
|
7372
|
+
const rawNodes = opNode.args;
|
|
7373
|
+
return function evalOperatorNodeRaw(scope) {
|
|
7374
|
+
return fn(rawNodes, math, scope);
|
|
7375
|
+
};
|
|
7376
|
+
}
|
|
6347
7377
|
const evalArgs = opNode.args.map((arg) => compileNode(arg, math, argNames));
|
|
6348
7378
|
if (evalArgs.length === 1) {
|
|
6349
7379
|
const evalArg0 = evalArgs[0];
|
|
@@ -6365,51 +7395,70 @@ function compileOperatorNode(node, math, argNames) {
|
|
|
6365
7395
|
}
|
|
6366
7396
|
function compileFunctionNode(node, math, argNames) {
|
|
6367
7397
|
const fnNodeOuter = node;
|
|
6368
|
-
const evalArgs = fnNodeOuter.args.map((arg) => compileNode(arg, math, argNames));
|
|
6369
7398
|
const fnNode = fnNodeOuter.fn;
|
|
6370
7399
|
if (fnNode && fnNode.isSymbolNode) {
|
|
6371
|
-
const
|
|
7400
|
+
const name47 = fnNode.name;
|
|
7401
|
+
const staticFn = Object.prototype.hasOwnProperty.call(math, name47) ? math[name47] : void 0;
|
|
7402
|
+
if (typeof staticFn === "function" && staticFn.rawArgs === true) {
|
|
7403
|
+
const rawNodes = fnNodeOuter.args;
|
|
7404
|
+
return function evalFunctionNodeRaw(scope) {
|
|
7405
|
+
const shadow = scope.has(name47) ? scope.get(name47) : void 0;
|
|
7406
|
+
if (typeof shadow === "function" && shadow.rawArgs !== true) {
|
|
7407
|
+
const values = rawNodes.map(
|
|
7408
|
+
(rn) => compileNode(rn, math, argNames)(scope, {}, void 0)
|
|
7409
|
+
);
|
|
7410
|
+
return shadow(...values);
|
|
7411
|
+
}
|
|
7412
|
+
return staticFn(rawNodes, math, scope);
|
|
7413
|
+
};
|
|
7414
|
+
}
|
|
7415
|
+
const evalArgs2 = fnNodeOuter.args.map(
|
|
7416
|
+
(arg) => compileNode(arg, math, argNames)
|
|
7417
|
+
);
|
|
6372
7418
|
const resolveFn = (scope) => {
|
|
6373
|
-
if (scope.has(
|
|
6374
|
-
const value = scope.get(
|
|
7419
|
+
if (scope.has(name47)) {
|
|
7420
|
+
const value = scope.get(name47);
|
|
6375
7421
|
if (typeof value === "function") return value;
|
|
6376
|
-
throw new TypeError(`'${
|
|
7422
|
+
throw new TypeError(`'${name47}' is not a function; its value is:
|
|
6377
7423
|
${value}`);
|
|
6378
7424
|
}
|
|
6379
|
-
if (Object.prototype.hasOwnProperty.call(math,
|
|
6380
|
-
const value = math[
|
|
7425
|
+
if (Object.prototype.hasOwnProperty.call(math, name47)) {
|
|
7426
|
+
const value = math[name47];
|
|
6381
7427
|
if (typeof value === "function") return value;
|
|
6382
|
-
throw new TypeError(`'${
|
|
7428
|
+
throw new TypeError(`'${name47}' is not a function; its value is:
|
|
6383
7429
|
${value}`);
|
|
6384
7430
|
}
|
|
6385
|
-
throw new Error(`Undefined function "${
|
|
7431
|
+
throw new Error(`Undefined function "${name47}"`);
|
|
6386
7432
|
};
|
|
6387
|
-
switch (
|
|
7433
|
+
switch (evalArgs2.length) {
|
|
6388
7434
|
case 0:
|
|
6389
7435
|
return function evalFunctionNode(scope, _args, _context) {
|
|
6390
7436
|
return resolveFn(scope)();
|
|
6391
7437
|
};
|
|
6392
7438
|
case 1: {
|
|
6393
|
-
const evalArg0 =
|
|
7439
|
+
const evalArg0 = evalArgs2[0];
|
|
6394
7440
|
return function evalFunctionNode(scope, args, context) {
|
|
6395
7441
|
return resolveFn(scope)(evalArg0(scope, args, context));
|
|
6396
7442
|
};
|
|
6397
7443
|
}
|
|
6398
7444
|
case 2: {
|
|
6399
|
-
const evalArg0 =
|
|
6400
|
-
const evalArg1 =
|
|
7445
|
+
const evalArg0 = evalArgs2[0];
|
|
7446
|
+
const evalArg1 = evalArgs2[1];
|
|
6401
7447
|
return function evalFunctionNode(scope, args, context) {
|
|
6402
7448
|
return resolveFn(scope)(evalArg0(scope, args, context), evalArg1(scope, args, context));
|
|
6403
7449
|
};
|
|
6404
7450
|
}
|
|
6405
7451
|
default:
|
|
6406
7452
|
return function evalFunctionNode(scope, args, context) {
|
|
6407
|
-
const values =
|
|
7453
|
+
const values = evalArgs2.map((e) => e(scope, args, context));
|
|
6408
7454
|
return resolveFn(scope)(...values);
|
|
6409
7455
|
};
|
|
6410
7456
|
}
|
|
6411
7457
|
}
|
|
6412
7458
|
if (fnNode && fnNode.isAccessorNode && fnNode.index && fnNode.index.isObjectProperty && fnNode.index.isObjectProperty()) {
|
|
7459
|
+
const evalArgs2 = fnNodeOuter.args.map(
|
|
7460
|
+
(arg) => compileNode(arg, math, argNames)
|
|
7461
|
+
);
|
|
6413
7462
|
const evalObject = compileNode(fnNode.object, math, argNames);
|
|
6414
7463
|
const methodName = fnNode.index.getObjectProperty();
|
|
6415
7464
|
return function evalFunctionNode(scope, args, context) {
|
|
@@ -6418,10 +7467,11 @@ function compileFunctionNode(node, math, argNames) {
|
|
|
6418
7467
|
if (typeof fn !== "function") {
|
|
6419
7468
|
throw new TypeError("Expression does not evaluate to a function");
|
|
6420
7469
|
}
|
|
6421
|
-
const values =
|
|
7470
|
+
const values = evalArgs2.map((e) => e(scope, args, context));
|
|
6422
7471
|
return fn.apply(obj, values);
|
|
6423
7472
|
};
|
|
6424
7473
|
}
|
|
7474
|
+
const evalArgs = fnNodeOuter.args.map((arg) => compileNode(arg, math, argNames));
|
|
6425
7475
|
const evalFn = compileNode(fnNode, math, argNames);
|
|
6426
7476
|
return function evalFunctionNode(scope, args, context) {
|
|
6427
7477
|
const fn = evalFn(scope, args, context);
|
|
@@ -6443,10 +7493,10 @@ function compileAssignmentNode(node, math, argNames) {
|
|
|
6443
7493
|
const asgNode = node;
|
|
6444
7494
|
const evalValue = compileNode(asgNode.value, math, argNames);
|
|
6445
7495
|
if (asgNode.object && asgNode.object.isSymbolNode && !asgNode.index) {
|
|
6446
|
-
const
|
|
7496
|
+
const name48 = asgNode.object.name;
|
|
6447
7497
|
return function evalAssignmentNode(scope, args, context) {
|
|
6448
7498
|
const value = evalValue(scope, args, context);
|
|
6449
|
-
scope.set(
|
|
7499
|
+
scope.set(name48, value);
|
|
6450
7500
|
return value;
|
|
6451
7501
|
};
|
|
6452
7502
|
}
|
|
@@ -6461,11 +7511,11 @@ function compileAssignmentNode(node, math, argNames) {
|
|
|
6461
7511
|
};
|
|
6462
7512
|
}
|
|
6463
7513
|
}
|
|
6464
|
-
const
|
|
6465
|
-
if (
|
|
7514
|
+
const name47 = asgNode.name || asgNode.object && asgNode.object.name;
|
|
7515
|
+
if (name47) {
|
|
6466
7516
|
return function evalAssignmentNode(scope, args, context) {
|
|
6467
7517
|
const value = evalValue(scope, args, context);
|
|
6468
|
-
scope.set(
|
|
7518
|
+
scope.set(name47, value);
|
|
6469
7519
|
return value;
|
|
6470
7520
|
};
|
|
6471
7521
|
}
|
|
@@ -6565,7 +7615,7 @@ function compileFunctionAssignmentNode(node, math, argNames) {
|
|
|
6565
7615
|
childArgNames[param] = true;
|
|
6566
7616
|
}
|
|
6567
7617
|
const evalExpr = compileNode(faNode.expr, math, childArgNames);
|
|
6568
|
-
const
|
|
7618
|
+
const name47 = faNode.name;
|
|
6569
7619
|
const params = faNode.params;
|
|
6570
7620
|
return function evalFunctionAssignmentNode(scope, args, _context) {
|
|
6571
7621
|
const fn = function(...fnArgs) {
|
|
@@ -6575,8 +7625,8 @@ function compileFunctionAssignmentNode(node, math, argNames) {
|
|
|
6575
7625
|
}
|
|
6576
7626
|
return evalExpr(scope, childArgs, void 0);
|
|
6577
7627
|
};
|
|
6578
|
-
fn.syntax =
|
|
6579
|
-
scope.set(
|
|
7628
|
+
fn.syntax = name47 + "(" + params.join(", ") + ")";
|
|
7629
|
+
scope.set(name47, fn);
|
|
6580
7630
|
return fn;
|
|
6581
7631
|
};
|
|
6582
7632
|
}
|
|
@@ -6595,7 +7645,7 @@ function compileAccessorNode(node, math, argNames) {
|
|
|
6595
7645
|
return function evalAccessorNode(scope, args, context) {
|
|
6596
7646
|
const object = evalObject(scope, args, context);
|
|
6597
7647
|
if (accNode.optionalChaining && object == null) return void 0;
|
|
6598
|
-
const index = evalIndex(scope, args,
|
|
7648
|
+
const index = evalIndex(scope, args, object);
|
|
6599
7649
|
if (math.subset) {
|
|
6600
7650
|
return math.subset(object, index);
|
|
6601
7651
|
}
|
|
@@ -6607,11 +7657,36 @@ function compileAccessorNode(node, math, argNames) {
|
|
|
6607
7657
|
}
|
|
6608
7658
|
function compileIndexNode(node, math, argNames) {
|
|
6609
7659
|
const dimensionNodes = node.dimensions;
|
|
6610
|
-
const
|
|
6611
|
-
(dim) =>
|
|
7660
|
+
const usesEnd = dimensionNodes.map(
|
|
7661
|
+
(dim) => dim.filter?.(
|
|
7662
|
+
(n) => n.isSymbolNode === true && n.name === "end"
|
|
7663
|
+
)?.length ?? 0
|
|
6612
7664
|
);
|
|
7665
|
+
const evalDimensions = dimensionNodes.map((dim, i) => {
|
|
7666
|
+
if (usesEnd[i]) {
|
|
7667
|
+
const childArgNames = Object.create(argNames);
|
|
7668
|
+
childArgNames.end = true;
|
|
7669
|
+
return compileNode(dim, math, childArgNames);
|
|
7670
|
+
}
|
|
7671
|
+
return compileNode(dim, math, argNames);
|
|
7672
|
+
});
|
|
7673
|
+
const anyEnd = usesEnd.some((n) => n > 0);
|
|
6613
7674
|
return function evalIndexNode(scope, args, context) {
|
|
6614
|
-
const dimensions = evalDimensions.map((e) =>
|
|
7675
|
+
const dimensions = evalDimensions.map((e, i) => {
|
|
7676
|
+
if (usesEnd[i]) {
|
|
7677
|
+
const sizeFn = math.size;
|
|
7678
|
+
if (!sizeFn || context === void 0 || context === null) {
|
|
7679
|
+
throw new Error('Cannot resolve "end": no indexing context');
|
|
7680
|
+
}
|
|
7681
|
+
const s = sizeFn(context);
|
|
7682
|
+
const sizes = Array.isArray(s) ? s : s.valueOf();
|
|
7683
|
+
const childArgs = Object.create(args);
|
|
7684
|
+
childArgs.end = sizes[i];
|
|
7685
|
+
return e(scope, childArgs, context);
|
|
7686
|
+
}
|
|
7687
|
+
return e(scope, args, context);
|
|
7688
|
+
});
|
|
7689
|
+
void anyEnd;
|
|
6615
7690
|
if (math.index) {
|
|
6616
7691
|
return math.index(...dimensions);
|
|
6617
7692
|
}
|
|
@@ -6805,18 +7880,18 @@ var INLINE_OP = {
|
|
|
6805
7880
|
function escapeMathML(s) {
|
|
6806
7881
|
return s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
6807
7882
|
}
|
|
6808
|
-
function mi(
|
|
6809
|
-
return `<mi>${mathmlSymbols[
|
|
7883
|
+
function mi(name47) {
|
|
7884
|
+
return `<mi>${mathmlSymbols[name47] ?? escapeMathML(name47)}</mi>`;
|
|
6810
7885
|
}
|
|
6811
|
-
function toMathMLSymbol(
|
|
6812
|
-
const us =
|
|
6813
|
-
if (us > 0 && us <
|
|
6814
|
-
const base =
|
|
6815
|
-
const sub =
|
|
7886
|
+
function toMathMLSymbol(name47) {
|
|
7887
|
+
const us = name47.indexOf("_");
|
|
7888
|
+
if (us > 0 && us < name47.length - 1) {
|
|
7889
|
+
const base = name47.slice(0, us);
|
|
7890
|
+
const sub = name47.slice(us + 1);
|
|
6816
7891
|
const subEl = /^\d+$/.test(sub) ? `<mn>${sub}</mn>` : mi(sub);
|
|
6817
7892
|
return `<msub>${mi(base)}${subEl}</msub>`;
|
|
6818
7893
|
}
|
|
6819
|
-
return mi(
|
|
7894
|
+
return mi(name47);
|
|
6820
7895
|
}
|
|
6821
7896
|
function numberToMathML(value) {
|
|
6822
7897
|
if (!Number.isFinite(value)) return `<mn>${escapeMathML(String(value))}</mn>`;
|
|
@@ -7748,14 +8823,14 @@ var createAssignmentNode = /* @__PURE__ */ factory(
|
|
|
7748
8823
|
const evalObject = this.object._compile(math, argNames);
|
|
7749
8824
|
const evalIndex = this.index ? this.index._compile(math, argNames) : null;
|
|
7750
8825
|
const evalValue = this.value._compile(math, argNames);
|
|
7751
|
-
const
|
|
8826
|
+
const name47 = this.object.name;
|
|
7752
8827
|
if (!this.index) {
|
|
7753
8828
|
if (!isSymbolNode(this.object)) {
|
|
7754
8829
|
throw new TypeError("SymbolNode expected as object");
|
|
7755
8830
|
}
|
|
7756
8831
|
return function evalAssignmentNode(scope, args, context) {
|
|
7757
8832
|
const value = evalValue(scope, args, context);
|
|
7758
|
-
scope.set(
|
|
8833
|
+
scope.set(name47, value);
|
|
7759
8834
|
return value;
|
|
7760
8835
|
};
|
|
7761
8836
|
} else if (this.index.isObjectProperty()) {
|
|
@@ -7771,7 +8846,7 @@ var createAssignmentNode = /* @__PURE__ */ factory(
|
|
|
7771
8846
|
const childObject = evalObject(scope, args, context);
|
|
7772
8847
|
const value = evalValue(scope, args, context);
|
|
7773
8848
|
const index = evalIndex(scope, args, childObject);
|
|
7774
|
-
scope.set(
|
|
8849
|
+
scope.set(name47, assign(childObject, index, value));
|
|
7775
8850
|
return value;
|
|
7776
8851
|
};
|
|
7777
8852
|
} else {
|
|
@@ -7890,8 +8965,8 @@ var createAssignmentNode = /* @__PURE__ */ factory(
|
|
|
7890
8965
|
_toMathML() {
|
|
7891
8966
|
const obj = this.object;
|
|
7892
8967
|
if (obj && isSymbolNode(obj) && !this.index && this.value) {
|
|
7893
|
-
const
|
|
7894
|
-
return `<mrow>${toMathMLSymbol(
|
|
8968
|
+
const name47 = obj.name;
|
|
8969
|
+
return `<mrow>${toMathMLSymbol(name47)}<mo>=</mo>${this.value.toMathML()}</mrow>`;
|
|
7895
8970
|
}
|
|
7896
8971
|
return `<mtext>${escapeMathML(this.toString())}</mtext>`;
|
|
7897
8972
|
}
|
|
@@ -8648,18 +9723,18 @@ var latexUnits = {
|
|
|
8648
9723
|
function escapeLatex(string) {
|
|
8649
9724
|
return (0, import_escape_latex.default)(string, { preserveFormatting: true });
|
|
8650
9725
|
}
|
|
8651
|
-
function toSymbol(
|
|
9726
|
+
function toSymbol(name47, isUnit2) {
|
|
8652
9727
|
isUnit2 = typeof isUnit2 === "undefined" ? false : isUnit2;
|
|
8653
9728
|
if (isUnit2) {
|
|
8654
|
-
if (hasOwnProperty(latexUnits,
|
|
8655
|
-
return latexUnits[
|
|
9729
|
+
if (hasOwnProperty(latexUnits, name47)) {
|
|
9730
|
+
return latexUnits[name47];
|
|
8656
9731
|
}
|
|
8657
|
-
return "\\mathrm{" + escapeLatex(
|
|
9732
|
+
return "\\mathrm{" + escapeLatex(name47) + "}";
|
|
8658
9733
|
}
|
|
8659
|
-
if (hasOwnProperty(latexSymbols,
|
|
8660
|
-
return latexSymbols[
|
|
9734
|
+
if (hasOwnProperty(latexSymbols, name47)) {
|
|
9735
|
+
return latexSymbols[name47];
|
|
8661
9736
|
}
|
|
8662
|
-
return escapeLatex(
|
|
9737
|
+
return escapeLatex(name47);
|
|
8663
9738
|
}
|
|
8664
9739
|
|
|
8665
9740
|
// src/node/ConstantNode.ts
|
|
@@ -8860,9 +9935,9 @@ var createFunctionAssignmentNode = /* @__PURE__ */ factory(
|
|
|
8860
9935
|
* and type of the parameter
|
|
8861
9936
|
* @param {Node} expr The function expression
|
|
8862
9937
|
*/
|
|
8863
|
-
constructor(
|
|
9938
|
+
constructor(name47, params, expr) {
|
|
8864
9939
|
super();
|
|
8865
|
-
if (typeof
|
|
9940
|
+
if (typeof name47 !== "string") {
|
|
8866
9941
|
throw new TypeError('String expected for parameter "name"');
|
|
8867
9942
|
}
|
|
8868
9943
|
if (!Array.isArray(params)) {
|
|
@@ -8873,8 +9948,8 @@ var createFunctionAssignmentNode = /* @__PURE__ */ factory(
|
|
|
8873
9948
|
if (!isNode(expr)) {
|
|
8874
9949
|
throw new TypeError('Node expected for parameter "expr"');
|
|
8875
9950
|
}
|
|
8876
|
-
if (keywords.has(
|
|
8877
|
-
throw new Error('Illegal function name, "' +
|
|
9951
|
+
if (keywords.has(name47)) {
|
|
9952
|
+
throw new Error('Illegal function name, "' + name47 + '" is a reserved keyword');
|
|
8878
9953
|
}
|
|
8879
9954
|
const paramNames = /* @__PURE__ */ new Set();
|
|
8880
9955
|
for (const param of params) {
|
|
@@ -8885,7 +9960,7 @@ var createFunctionAssignmentNode = /* @__PURE__ */ factory(
|
|
|
8885
9960
|
paramNames.add(paramName);
|
|
8886
9961
|
}
|
|
8887
9962
|
}
|
|
8888
|
-
this.name =
|
|
9963
|
+
this.name = name47;
|
|
8889
9964
|
this.params = params.map(function(param) {
|
|
8890
9965
|
return param && param.name || param;
|
|
8891
9966
|
});
|
|
@@ -8921,10 +9996,10 @@ var createFunctionAssignmentNode = /* @__PURE__ */ factory(
|
|
|
8921
9996
|
});
|
|
8922
9997
|
const expr = this.expr;
|
|
8923
9998
|
const evalExpr = expr._compile(math, childArgNames);
|
|
8924
|
-
const
|
|
9999
|
+
const name47 = this.name;
|
|
8925
10000
|
const params = this.params;
|
|
8926
10001
|
const signature = join(this.types, ",");
|
|
8927
|
-
const syntax =
|
|
10002
|
+
const syntax = name47 + "(" + join(this.params, ", ") + ")";
|
|
8928
10003
|
return function evalFunctionAssignmentNode(scope, args, context) {
|
|
8929
10004
|
const signatures = {};
|
|
8930
10005
|
signatures[signature] = function(...fnArgs) {
|
|
@@ -8934,10 +10009,10 @@ var createFunctionAssignmentNode = /* @__PURE__ */ factory(
|
|
|
8934
10009
|
}
|
|
8935
10010
|
return evalExpr(scope, childArgs, context);
|
|
8936
10011
|
};
|
|
8937
|
-
const fn = typed(
|
|
10012
|
+
const fn = typed(name47, signatures);
|
|
8938
10013
|
fn.syntax = syntax;
|
|
8939
10014
|
fn.expr = expr.toString();
|
|
8940
|
-
scope.set(
|
|
10015
|
+
scope.set(name47, fn);
|
|
8941
10016
|
return fn;
|
|
8942
10017
|
};
|
|
8943
10018
|
}
|
|
@@ -9187,22 +10262,22 @@ var createFunctionNode = /* @__PURE__ */ factory(
|
|
|
9187
10262
|
const evalArgs = this.args.map((arg) => arg._compile(math2, argNames));
|
|
9188
10263
|
const fromOptionalChaining = this.optional || isAccessorNode(this.fn) && this.fn.optionalChaining;
|
|
9189
10264
|
if (isSymbolNode(this.fn)) {
|
|
9190
|
-
const
|
|
9191
|
-
if (!argNames[
|
|
9192
|
-
const fn =
|
|
10265
|
+
const name47 = this.fn.name;
|
|
10266
|
+
if (!argNames[name47]) {
|
|
10267
|
+
const fn = name47 in math2 ? getSafeProperty(math2, name47) : void 0;
|
|
9193
10268
|
const isRaw = typeof fn === "function" && fn.rawArgs === true;
|
|
9194
10269
|
const resolveFn = (scope) => {
|
|
9195
10270
|
let value;
|
|
9196
|
-
if (scope.has(
|
|
9197
|
-
value = scope.get(
|
|
9198
|
-
} else if (
|
|
9199
|
-
value = getSafeProperty(math2,
|
|
10271
|
+
if (scope.has(name47)) {
|
|
10272
|
+
value = scope.get(name47);
|
|
10273
|
+
} else if (name47 in math2) {
|
|
10274
|
+
value = getSafeProperty(math2, name47);
|
|
9200
10275
|
} else if (fromOptionalChaining) value = void 0;
|
|
9201
|
-
else return FunctionNode.onUndefinedFunction(
|
|
10276
|
+
else return FunctionNode.onUndefinedFunction(name47);
|
|
9202
10277
|
if (typeof value === "function" || fromOptionalChaining && value === void 0) {
|
|
9203
10278
|
return value;
|
|
9204
10279
|
}
|
|
9205
|
-
throw new TypeError(`'${
|
|
10280
|
+
throw new TypeError(`'${name47}' is not a function; its value is:
|
|
9206
10281
|
${strin(value)}`);
|
|
9207
10282
|
};
|
|
9208
10283
|
if (isRaw) {
|
|
@@ -9251,11 +10326,11 @@ var createFunctionNode = /* @__PURE__ */ factory(
|
|
|
9251
10326
|
} else {
|
|
9252
10327
|
const rawArgs = this.args;
|
|
9253
10328
|
return function evalFunctionNode(scope, args, context) {
|
|
9254
|
-
const fn = getSafeProperty(args,
|
|
10329
|
+
const fn = getSafeProperty(args, name47);
|
|
9255
10330
|
if (fromOptionalChaining && fn === void 0) return void 0;
|
|
9256
10331
|
if (typeof fn !== "function") {
|
|
9257
10332
|
throw new TypeError(
|
|
9258
|
-
`Argument '${
|
|
10333
|
+
`Argument '${name47}' was not a function; received: ${strin(fn)}`
|
|
9259
10334
|
);
|
|
9260
10335
|
}
|
|
9261
10336
|
if (fn.rawArgs) {
|
|
@@ -9341,8 +10416,8 @@ var createFunctionNode = /* @__PURE__ */ factory(
|
|
|
9341
10416
|
* Throws an error 'Undefined function {name}'
|
|
9342
10417
|
* @param {string} name
|
|
9343
10418
|
*/
|
|
9344
|
-
static onUndefinedFunction = function(
|
|
9345
|
-
throw new Error("Undefined function " +
|
|
10419
|
+
static onUndefinedFunction = function(name47) {
|
|
10420
|
+
throw new Error("Undefined function " + name47);
|
|
9346
10421
|
};
|
|
9347
10422
|
/**
|
|
9348
10423
|
* Get string representation. (wrapper function)
|
|
@@ -9358,9 +10433,9 @@ var createFunctionNode = /* @__PURE__ */ factory(
|
|
|
9358
10433
|
*/
|
|
9359
10434
|
toString(options) {
|
|
9360
10435
|
let customString;
|
|
9361
|
-
const
|
|
9362
|
-
if (options && typeof options.handler === "object" && hasOwnProperty(options.handler,
|
|
9363
|
-
customString = options.handler[
|
|
10436
|
+
const name47 = this.fn.toString(options);
|
|
10437
|
+
if (options && typeof options.handler === "object" && hasOwnProperty(options.handler, name47)) {
|
|
10438
|
+
customString = options.handler[name47](this, options);
|
|
9364
10439
|
}
|
|
9365
10440
|
if (typeof customString !== "undefined") {
|
|
9366
10441
|
return customString;
|
|
@@ -9439,20 +10514,20 @@ var createFunctionNode = /* @__PURE__ */ factory(
|
|
|
9439
10514
|
*/
|
|
9440
10515
|
_toMathML() {
|
|
9441
10516
|
const fnNode = this.fn;
|
|
9442
|
-
const
|
|
10517
|
+
const name47 = fnNode.name ?? String(this.fn);
|
|
9443
10518
|
const args = this.args;
|
|
9444
|
-
if (
|
|
9445
|
-
if (
|
|
10519
|
+
if (name47 === "sqrt" && args.length === 1) return `<msqrt>${args[0].toMathML()}</msqrt>`;
|
|
10520
|
+
if (name47 === "cbrt" && args.length === 1) {
|
|
9446
10521
|
return `<mroot><mrow>${args[0].toMathML()}</mrow><mn>3</mn></mroot>`;
|
|
9447
10522
|
}
|
|
9448
|
-
if (
|
|
10523
|
+
if (name47 === "nthRoot" && args.length === 2) {
|
|
9449
10524
|
return `<mroot><mrow>${args[0].toMathML()}</mrow><mrow>${args[1].toMathML()}</mrow></mroot>`;
|
|
9450
10525
|
}
|
|
9451
|
-
if (
|
|
10526
|
+
if (name47 === "abs" && args.length === 1) {
|
|
9452
10527
|
return `<mrow><mo>|</mo>${args[0].toMathML()}<mo>|</mo></mrow>`;
|
|
9453
10528
|
}
|
|
9454
10529
|
const inner = args.map((a) => a.toMathML()).join("<mo>,</mo>");
|
|
9455
|
-
return `<mrow>${toMathMLSymbol(
|
|
10530
|
+
return `<mrow>${toMathMLSymbol(name47)}<mo>⁡</mo><mrow><mo>(</mo>${inner}<mo>)</mo></mrow></mrow>`;
|
|
9456
10531
|
}
|
|
9457
10532
|
_toTex(options) {
|
|
9458
10533
|
const args = this.args.map(function(arg) {
|
|
@@ -11076,8 +12151,8 @@ var createSymbolNode = /* @__PURE__ */ factory(
|
|
|
11076
12151
|
name20,
|
|
11077
12152
|
dependencies20,
|
|
11078
12153
|
({ math, Unit, Node }) => {
|
|
11079
|
-
function isValuelessUnit(
|
|
11080
|
-
return Unit ? Unit.isValuelessUnit(
|
|
12154
|
+
function isValuelessUnit(name47) {
|
|
12155
|
+
return Unit ? Unit.isValuelessUnit(name47) : false;
|
|
11081
12156
|
}
|
|
11082
12157
|
class SymbolNode extends Node {
|
|
11083
12158
|
name;
|
|
@@ -11088,12 +12163,12 @@ var createSymbolNode = /* @__PURE__ */ factory(
|
|
|
11088
12163
|
* @param {string} name
|
|
11089
12164
|
* @extends {Node}
|
|
11090
12165
|
*/
|
|
11091
|
-
constructor(
|
|
12166
|
+
constructor(name47) {
|
|
11092
12167
|
super();
|
|
11093
|
-
if (typeof
|
|
12168
|
+
if (typeof name47 !== "string") {
|
|
11094
12169
|
throw new TypeError('String expected for parameter "name"');
|
|
11095
12170
|
}
|
|
11096
|
-
this.name =
|
|
12171
|
+
this.name = name47;
|
|
11097
12172
|
}
|
|
11098
12173
|
get type() {
|
|
11099
12174
|
return "SymbolNode";
|
|
@@ -11115,19 +12190,19 @@ var createSymbolNode = /* @__PURE__ */ factory(
|
|
|
11115
12190
|
* evalNode(scope: Object, args: Object, context: *)
|
|
11116
12191
|
*/
|
|
11117
12192
|
_compile(math2, argNames) {
|
|
11118
|
-
const
|
|
11119
|
-
if (argNames[
|
|
12193
|
+
const name47 = this.name;
|
|
12194
|
+
if (argNames[name47] === true) {
|
|
11120
12195
|
return function(_scope, args, _context) {
|
|
11121
|
-
return getSafeProperty(args,
|
|
12196
|
+
return getSafeProperty(args, name47);
|
|
11122
12197
|
};
|
|
11123
|
-
} else if (
|
|
12198
|
+
} else if (name47 in math2) {
|
|
11124
12199
|
return function(scope, _args, _context) {
|
|
11125
|
-
return scope.has(
|
|
12200
|
+
return scope.has(name47) ? scope.get(name47) : getSafeProperty(math2, name47);
|
|
11126
12201
|
};
|
|
11127
12202
|
} else {
|
|
11128
|
-
const isUnit2 = isValuelessUnit(
|
|
12203
|
+
const isUnit2 = isValuelessUnit(name47);
|
|
11129
12204
|
return function(scope, _args, _context) {
|
|
11130
|
-
return scope.has(
|
|
12205
|
+
return scope.has(name47) ? scope.get(name47) : isUnit2 ? new Unit(null, name47) : SymbolNode.onUndefinedSymbol(name47);
|
|
11131
12206
|
};
|
|
11132
12207
|
}
|
|
11133
12208
|
}
|
|
@@ -11150,8 +12225,8 @@ var createSymbolNode = /* @__PURE__ */ factory(
|
|
|
11150
12225
|
* Throws an error 'Undefined symbol {name}'
|
|
11151
12226
|
* @param {string} name
|
|
11152
12227
|
*/
|
|
11153
|
-
static onUndefinedSymbol(
|
|
11154
|
-
throw new Error("Undefined symbol " +
|
|
12228
|
+
static onUndefinedSymbol(name47) {
|
|
12229
|
+
throw new Error("Undefined symbol " + name47);
|
|
11155
12230
|
}
|
|
11156
12231
|
/**
|
|
11157
12232
|
* Create a clone of this node, a shallow copy
|
|
@@ -11177,21 +12252,21 @@ var createSymbolNode = /* @__PURE__ */ factory(
|
|
|
11177
12252
|
* @override
|
|
11178
12253
|
*/
|
|
11179
12254
|
_toHTML(_options) {
|
|
11180
|
-
const
|
|
11181
|
-
if (
|
|
11182
|
-
return '<span class="math-symbol math-boolean">' +
|
|
11183
|
-
} else if (
|
|
11184
|
-
return '<span class="math-symbol math-imaginary-symbol">' +
|
|
11185
|
-
} else if (
|
|
11186
|
-
return '<span class="math-symbol math-infinity-symbol">' +
|
|
11187
|
-
} else if (
|
|
11188
|
-
return '<span class="math-symbol math-nan-symbol">' +
|
|
11189
|
-
} else if (
|
|
11190
|
-
return '<span class="math-symbol math-null-symbol">' +
|
|
11191
|
-
} else if (
|
|
11192
|
-
return '<span class="math-symbol math-undefined-symbol">' +
|
|
11193
|
-
}
|
|
11194
|
-
return '<span class="math-symbol">' +
|
|
12255
|
+
const name47 = escape(this.name);
|
|
12256
|
+
if (name47 === "true" || name47 === "false") {
|
|
12257
|
+
return '<span class="math-symbol math-boolean">' + name47 + "</span>";
|
|
12258
|
+
} else if (name47 === "i") {
|
|
12259
|
+
return '<span class="math-symbol math-imaginary-symbol">' + name47 + "</span>";
|
|
12260
|
+
} else if (name47 === "Infinity") {
|
|
12261
|
+
return '<span class="math-symbol math-infinity-symbol">' + name47 + "</span>";
|
|
12262
|
+
} else if (name47 === "NaN") {
|
|
12263
|
+
return '<span class="math-symbol math-nan-symbol">' + name47 + "</span>";
|
|
12264
|
+
} else if (name47 === "null") {
|
|
12265
|
+
return '<span class="math-symbol math-null-symbol">' + name47 + "</span>";
|
|
12266
|
+
} else if (name47 === "undefined") {
|
|
12267
|
+
return '<span class="math-symbol math-undefined-symbol">' + name47 + "</span>";
|
|
12268
|
+
}
|
|
12269
|
+
return '<span class="math-symbol">' + name47 + "</span>";
|
|
11195
12270
|
}
|
|
11196
12271
|
/**
|
|
11197
12272
|
* Get a JSON representation of the node
|
|
@@ -11238,30 +12313,830 @@ var createSymbolNode = /* @__PURE__ */ factory(
|
|
|
11238
12313
|
},
|
|
11239
12314
|
{ isClass: true, isNode: true }
|
|
11240
12315
|
);
|
|
12316
|
+
|
|
12317
|
+
// src/transform/and.transform.ts
|
|
12318
|
+
var name21 = "and";
|
|
12319
|
+
var dependencies21 = ["and"];
|
|
12320
|
+
var createAndTransform = /* @__PURE__ */ factory(
|
|
12321
|
+
name21,
|
|
12322
|
+
dependencies21,
|
|
12323
|
+
({ and }) => {
|
|
12324
|
+
function andTransform(args, _math, scope) {
|
|
12325
|
+
const condition1 = args[0].compile().evaluate(scope);
|
|
12326
|
+
if (!isCollection(condition1) && !and(condition1, true)) {
|
|
12327
|
+
return false;
|
|
12328
|
+
}
|
|
12329
|
+
const condition2 = args[1].compile().evaluate(scope);
|
|
12330
|
+
return and(condition1, condition2);
|
|
12331
|
+
}
|
|
12332
|
+
andTransform.rawArgs = true;
|
|
12333
|
+
return andTransform;
|
|
12334
|
+
},
|
|
12335
|
+
{ isTransformFunction: true }
|
|
12336
|
+
);
|
|
12337
|
+
|
|
12338
|
+
// src/transform/bitAnd.transform.ts
|
|
12339
|
+
var name22 = "bitAnd";
|
|
12340
|
+
var dependencies22 = ["bitAnd"];
|
|
12341
|
+
var createBitAndTransform = /* @__PURE__ */ factory(
|
|
12342
|
+
name22,
|
|
12343
|
+
dependencies22,
|
|
12344
|
+
({ bitAnd }) => {
|
|
12345
|
+
function bitAndTransform(args, _math, scope) {
|
|
12346
|
+
const condition1 = args[0].compile().evaluate(scope);
|
|
12347
|
+
if (!isCollection(condition1)) {
|
|
12348
|
+
if (isNaN(condition1)) {
|
|
12349
|
+
return NaN;
|
|
12350
|
+
}
|
|
12351
|
+
if (condition1 === 0 || condition1 === false) {
|
|
12352
|
+
return 0;
|
|
12353
|
+
}
|
|
12354
|
+
}
|
|
12355
|
+
const condition2 = args[1].compile().evaluate(scope);
|
|
12356
|
+
return bitAnd(condition1, condition2);
|
|
12357
|
+
}
|
|
12358
|
+
bitAndTransform.rawArgs = true;
|
|
12359
|
+
return bitAndTransform;
|
|
12360
|
+
},
|
|
12361
|
+
{ isTransformFunction: true }
|
|
12362
|
+
);
|
|
12363
|
+
|
|
12364
|
+
// src/transform/bitOr.transform.ts
|
|
12365
|
+
var name23 = "bitOr";
|
|
12366
|
+
var dependencies23 = ["bitOr"];
|
|
12367
|
+
var createBitOrTransform = /* @__PURE__ */ factory(
|
|
12368
|
+
name23,
|
|
12369
|
+
dependencies23,
|
|
12370
|
+
({ bitOr }) => {
|
|
12371
|
+
function bitOrTransform(args, _math, scope) {
|
|
12372
|
+
const condition1 = args[0].compile().evaluate(scope);
|
|
12373
|
+
if (!isCollection(condition1)) {
|
|
12374
|
+
if (isNaN(condition1)) {
|
|
12375
|
+
return NaN;
|
|
12376
|
+
}
|
|
12377
|
+
if (condition1 === -1) {
|
|
12378
|
+
return -1;
|
|
12379
|
+
}
|
|
12380
|
+
if (condition1 === true) {
|
|
12381
|
+
return 1;
|
|
12382
|
+
}
|
|
12383
|
+
}
|
|
12384
|
+
const condition2 = args[1].compile().evaluate(scope);
|
|
12385
|
+
return bitOr(condition1, condition2);
|
|
12386
|
+
}
|
|
12387
|
+
bitOrTransform.rawArgs = true;
|
|
12388
|
+
return bitOrTransform;
|
|
12389
|
+
},
|
|
12390
|
+
{ isTransformFunction: true }
|
|
12391
|
+
);
|
|
12392
|
+
|
|
12393
|
+
// src/transform/column.transform.ts
|
|
12394
|
+
var name24 = "column";
|
|
12395
|
+
var dependencies24 = ["typed", "column"];
|
|
12396
|
+
var createColumnTransform = /* @__PURE__ */ factory(
|
|
12397
|
+
name24,
|
|
12398
|
+
dependencies24,
|
|
12399
|
+
({ typed, column }) => {
|
|
12400
|
+
return typed("column", {
|
|
12401
|
+
"...any": function(args) {
|
|
12402
|
+
const lastIndex = args.length - 1;
|
|
12403
|
+
const last = args[lastIndex];
|
|
12404
|
+
if (isNumber(last)) {
|
|
12405
|
+
args[lastIndex] = last - 1;
|
|
12406
|
+
}
|
|
12407
|
+
try {
|
|
12408
|
+
return column(...args);
|
|
12409
|
+
} catch (err) {
|
|
12410
|
+
throw errorTransform(err);
|
|
12411
|
+
}
|
|
12412
|
+
}
|
|
12413
|
+
});
|
|
12414
|
+
},
|
|
12415
|
+
{ isTransformFunction: true }
|
|
12416
|
+
);
|
|
12417
|
+
|
|
12418
|
+
// src/transform/concat.transform.ts
|
|
12419
|
+
var name25 = "concat";
|
|
12420
|
+
var dependencies25 = ["typed", "concat"];
|
|
12421
|
+
var createConcatTransform = /* @__PURE__ */ factory(
|
|
12422
|
+
name25,
|
|
12423
|
+
dependencies25,
|
|
12424
|
+
({ typed, concat }) => {
|
|
12425
|
+
return typed("concat", {
|
|
12426
|
+
"...any": function(args) {
|
|
12427
|
+
const lastIndex = args.length - 1;
|
|
12428
|
+
const last = args[lastIndex];
|
|
12429
|
+
if (isNumber(last)) {
|
|
12430
|
+
args[lastIndex] = last - 1;
|
|
12431
|
+
} else if (isBigNumber(last)) {
|
|
12432
|
+
args[lastIndex] = last.minus(1);
|
|
12433
|
+
}
|
|
12434
|
+
try {
|
|
12435
|
+
return concat(...args);
|
|
12436
|
+
} catch (err) {
|
|
12437
|
+
throw errorTransform(err);
|
|
12438
|
+
}
|
|
12439
|
+
}
|
|
12440
|
+
});
|
|
12441
|
+
},
|
|
12442
|
+
{ isTransformFunction: true }
|
|
12443
|
+
);
|
|
12444
|
+
|
|
12445
|
+
// src/transform/cumsum.transform.ts
|
|
12446
|
+
var name26 = "cumsum";
|
|
12447
|
+
var dependencies26 = ["typed", "cumsum"];
|
|
12448
|
+
var createCumSumTransform = /* @__PURE__ */ factory(
|
|
12449
|
+
name26,
|
|
12450
|
+
dependencies26,
|
|
12451
|
+
({ typed, cumsum }) => {
|
|
12452
|
+
return typed(name26, {
|
|
12453
|
+
"...any": function(args) {
|
|
12454
|
+
if (args.length === 2 && isCollection(args[0])) {
|
|
12455
|
+
const dim = args[1];
|
|
12456
|
+
if (isNumber(dim)) {
|
|
12457
|
+
args[1] = dim - 1;
|
|
12458
|
+
} else if (isBigNumber(dim)) {
|
|
12459
|
+
args[1] = dim.minus(1);
|
|
12460
|
+
}
|
|
12461
|
+
}
|
|
12462
|
+
try {
|
|
12463
|
+
return cumsum(...args);
|
|
12464
|
+
} catch (err) {
|
|
12465
|
+
throw errorTransform(err);
|
|
12466
|
+
}
|
|
12467
|
+
}
|
|
12468
|
+
});
|
|
12469
|
+
},
|
|
12470
|
+
{ isTransformFunction: true }
|
|
12471
|
+
);
|
|
12472
|
+
|
|
12473
|
+
// src/transform/utils/dimToZeroBase.ts
|
|
12474
|
+
function dimToZeroBase(dim) {
|
|
12475
|
+
if (isNumber(dim)) {
|
|
12476
|
+
return dim - 1;
|
|
12477
|
+
} else if (isBigNumber(dim)) {
|
|
12478
|
+
return dim.minus(1);
|
|
12479
|
+
} else {
|
|
12480
|
+
return dim;
|
|
12481
|
+
}
|
|
12482
|
+
}
|
|
12483
|
+
function isNumberOrBigNumber(n) {
|
|
12484
|
+
return isNumber(n) || isBigNumber(n);
|
|
12485
|
+
}
|
|
12486
|
+
|
|
12487
|
+
// src/transform/utils/lastDimToZeroBase.ts
|
|
12488
|
+
function lastDimToZeroBase(args) {
|
|
12489
|
+
if (args.length === 2 && isCollection(args[0])) {
|
|
12490
|
+
args = args.slice();
|
|
12491
|
+
const dim = args[1];
|
|
12492
|
+
if (isNumberOrBigNumber(dim)) {
|
|
12493
|
+
args[1] = dimToZeroBase(dim);
|
|
12494
|
+
}
|
|
12495
|
+
}
|
|
12496
|
+
return args;
|
|
12497
|
+
}
|
|
12498
|
+
|
|
12499
|
+
// src/transform/diff.transform.ts
|
|
12500
|
+
var name27 = "diff";
|
|
12501
|
+
var dependencies27 = ["typed", "diff"];
|
|
12502
|
+
var createDiffTransform = /* @__PURE__ */ factory(
|
|
12503
|
+
name27,
|
|
12504
|
+
dependencies27,
|
|
12505
|
+
({ typed, diff }) => {
|
|
12506
|
+
return typed(name27, {
|
|
12507
|
+
"...any": function(args) {
|
|
12508
|
+
args = lastDimToZeroBase(args);
|
|
12509
|
+
try {
|
|
12510
|
+
return diff(...args);
|
|
12511
|
+
} catch (err) {
|
|
12512
|
+
throw errorTransform(err);
|
|
12513
|
+
}
|
|
12514
|
+
}
|
|
12515
|
+
});
|
|
12516
|
+
},
|
|
12517
|
+
{ isTransformFunction: true }
|
|
12518
|
+
);
|
|
12519
|
+
|
|
12520
|
+
// src/transform/utils/compileInlineExpression.ts
|
|
12521
|
+
function compileInlineExpression(expression, math, scope) {
|
|
12522
|
+
const symbol = expression.filter(function(node) {
|
|
12523
|
+
const named = node;
|
|
12524
|
+
return isSymbolNode(node) && !(named.name in math) && !scope.has(named.name);
|
|
12525
|
+
})[0];
|
|
12526
|
+
if (!symbol) {
|
|
12527
|
+
throw new Error(
|
|
12528
|
+
'No undefined variable found in inline expression "' + String(expression) + '"'
|
|
12529
|
+
);
|
|
12530
|
+
}
|
|
12531
|
+
const name47 = symbol.name;
|
|
12532
|
+
const argsScope = /* @__PURE__ */ new Map();
|
|
12533
|
+
const subScope = new PartitionedMap(scope, argsScope, /* @__PURE__ */ new Set([name47]));
|
|
12534
|
+
const eq = expression.compile();
|
|
12535
|
+
return function inlineExpression(x) {
|
|
12536
|
+
argsScope.set(name47, x);
|
|
12537
|
+
return eq.evaluate(subScope);
|
|
12538
|
+
};
|
|
12539
|
+
}
|
|
12540
|
+
|
|
12541
|
+
// src/transform/utils/transformCallback.ts
|
|
12542
|
+
var name28 = "transformCallback";
|
|
12543
|
+
var dependencies28 = ["typed"];
|
|
12544
|
+
var createTransformCallback = /* @__PURE__ */ factory(
|
|
12545
|
+
name28,
|
|
12546
|
+
dependencies28,
|
|
12547
|
+
({ typed }) => {
|
|
12548
|
+
return function(callback, numberOfArrays) {
|
|
12549
|
+
if (typed.isTypedFunction(callback)) {
|
|
12550
|
+
return _transformTypedCallbackFunction(callback, numberOfArrays);
|
|
12551
|
+
} else {
|
|
12552
|
+
const fn = callback;
|
|
12553
|
+
return _transformCallbackFunction(fn, fn.length, numberOfArrays);
|
|
12554
|
+
}
|
|
12555
|
+
};
|
|
12556
|
+
function _transformTypedCallbackFunction(typedFunction, numberOfArrays) {
|
|
12557
|
+
const fn = typedFunction;
|
|
12558
|
+
const signatures = Object.fromEntries(
|
|
12559
|
+
Object.entries(fn.signatures).map(([signature, callbackFunction]) => {
|
|
12560
|
+
const numberOfCallbackInputs = signature.split(",").length;
|
|
12561
|
+
if (typed.isTypedFunction(callbackFunction)) {
|
|
12562
|
+
return [signature, _transformTypedCallbackFunction(callbackFunction, numberOfArrays)];
|
|
12563
|
+
} else {
|
|
12564
|
+
return [
|
|
12565
|
+
signature,
|
|
12566
|
+
_transformCallbackFunction(callbackFunction, numberOfCallbackInputs, numberOfArrays)
|
|
12567
|
+
];
|
|
12568
|
+
}
|
|
12569
|
+
})
|
|
12570
|
+
);
|
|
12571
|
+
if (typeof fn.name === "string") {
|
|
12572
|
+
return typed(fn.name, signatures);
|
|
12573
|
+
} else {
|
|
12574
|
+
return typed(signatures);
|
|
12575
|
+
}
|
|
12576
|
+
}
|
|
12577
|
+
}
|
|
12578
|
+
);
|
|
12579
|
+
function _transformCallbackFunction(callbackFunction, numberOfCallbackInputs, numberOfArrays) {
|
|
12580
|
+
const fn = callbackFunction;
|
|
12581
|
+
if (numberOfCallbackInputs === numberOfArrays) {
|
|
12582
|
+
return callbackFunction;
|
|
12583
|
+
} else if (numberOfCallbackInputs === numberOfArrays + 1) {
|
|
12584
|
+
return function(...args) {
|
|
12585
|
+
const vals = args.slice(0, numberOfArrays);
|
|
12586
|
+
const idx = _transformDims(args[numberOfArrays]);
|
|
12587
|
+
return fn(...vals, idx);
|
|
12588
|
+
};
|
|
12589
|
+
} else if (numberOfCallbackInputs > numberOfArrays + 1) {
|
|
12590
|
+
return function(...args) {
|
|
12591
|
+
const vals = args.slice(0, numberOfArrays);
|
|
12592
|
+
const idx = _transformDims(args[numberOfArrays]);
|
|
12593
|
+
const rest = args.slice(numberOfArrays + 1);
|
|
12594
|
+
return fn(...vals, idx, ...rest);
|
|
12595
|
+
};
|
|
12596
|
+
} else {
|
|
12597
|
+
return callbackFunction;
|
|
12598
|
+
}
|
|
12599
|
+
}
|
|
12600
|
+
function _transformDims(dims) {
|
|
12601
|
+
return dims.map((dim) => dim + 1);
|
|
12602
|
+
}
|
|
12603
|
+
|
|
12604
|
+
// src/transform/filter.transform.ts
|
|
12605
|
+
var name29 = "filter";
|
|
12606
|
+
var dependencies29 = ["typed", "filter"];
|
|
12607
|
+
var createFilterTransform = /* @__PURE__ */ factory(
|
|
12608
|
+
name29,
|
|
12609
|
+
dependencies29,
|
|
12610
|
+
({ typed, filter }) => {
|
|
12611
|
+
function filterTransform(args, math, scope) {
|
|
12612
|
+
const transformCallback = createTransformCallback({ typed });
|
|
12613
|
+
if (args.length === 0) {
|
|
12614
|
+
return filter();
|
|
12615
|
+
}
|
|
12616
|
+
let x = args[0];
|
|
12617
|
+
if (args.length === 1) {
|
|
12618
|
+
return filter(x);
|
|
12619
|
+
}
|
|
12620
|
+
const N = args.length - 1;
|
|
12621
|
+
let callback = args[N];
|
|
12622
|
+
if (x) {
|
|
12623
|
+
x = _compileAndEvaluate(x, scope);
|
|
12624
|
+
}
|
|
12625
|
+
if (callback) {
|
|
12626
|
+
if (isSymbolNode(callback) || isFunctionAssignmentNode(callback)) {
|
|
12627
|
+
callback = _compileAndEvaluate(callback, scope);
|
|
12628
|
+
} else {
|
|
12629
|
+
callback = compileInlineExpression(
|
|
12630
|
+
callback,
|
|
12631
|
+
math,
|
|
12632
|
+
scope
|
|
12633
|
+
);
|
|
12634
|
+
}
|
|
12635
|
+
}
|
|
12636
|
+
return filter(x, transformCallback(callback, N));
|
|
12637
|
+
}
|
|
12638
|
+
filterTransform.rawArgs = true;
|
|
12639
|
+
function _compileAndEvaluate(arg, scope) {
|
|
12640
|
+
return arg.compile().evaluate(scope);
|
|
12641
|
+
}
|
|
12642
|
+
return filterTransform;
|
|
12643
|
+
},
|
|
12644
|
+
{ isTransformFunction: true }
|
|
12645
|
+
);
|
|
12646
|
+
|
|
12647
|
+
// src/transform/forEach.transform.ts
|
|
12648
|
+
var name30 = "forEach";
|
|
12649
|
+
var dependencies30 = ["typed", "forEach"];
|
|
12650
|
+
var createForEachTransform = /* @__PURE__ */ factory(
|
|
12651
|
+
name30,
|
|
12652
|
+
dependencies30,
|
|
12653
|
+
({ typed, forEach: forEach2 }) => {
|
|
12654
|
+
const transformCallback = createTransformCallback({ typed });
|
|
12655
|
+
function forEachTransform(args, math, scope) {
|
|
12656
|
+
if (args.length === 0) {
|
|
12657
|
+
return forEach2();
|
|
12658
|
+
}
|
|
12659
|
+
let x = args[0];
|
|
12660
|
+
if (args.length === 1) {
|
|
12661
|
+
return forEach2(x);
|
|
12662
|
+
}
|
|
12663
|
+
const N = args.length - 1;
|
|
12664
|
+
let callback = args[N];
|
|
12665
|
+
if (x) {
|
|
12666
|
+
x = _compileAndEvaluate(x, scope);
|
|
12667
|
+
}
|
|
12668
|
+
if (callback) {
|
|
12669
|
+
if (isSymbolNode(callback) || isFunctionAssignmentNode(callback)) {
|
|
12670
|
+
callback = _compileAndEvaluate(callback, scope);
|
|
12671
|
+
} else {
|
|
12672
|
+
callback = compileInlineExpression(
|
|
12673
|
+
callback,
|
|
12674
|
+
math,
|
|
12675
|
+
scope
|
|
12676
|
+
);
|
|
12677
|
+
}
|
|
12678
|
+
}
|
|
12679
|
+
return forEach2(x, transformCallback(callback, N));
|
|
12680
|
+
}
|
|
12681
|
+
forEachTransform.rawArgs = true;
|
|
12682
|
+
function _compileAndEvaluate(arg, scope) {
|
|
12683
|
+
return arg.compile().evaluate(scope);
|
|
12684
|
+
}
|
|
12685
|
+
return forEachTransform;
|
|
12686
|
+
},
|
|
12687
|
+
{ isTransformFunction: true }
|
|
12688
|
+
);
|
|
12689
|
+
|
|
12690
|
+
// src/transform/index.transform.ts
|
|
12691
|
+
var name31 = "index";
|
|
12692
|
+
var dependencies31 = ["Index", "getMatrixDataType"];
|
|
12693
|
+
var createIndexTransform = /* @__PURE__ */ factory(
|
|
12694
|
+
name31,
|
|
12695
|
+
dependencies31,
|
|
12696
|
+
({ Index: Index2, getMatrixDataType }) => {
|
|
12697
|
+
return function indexTransform(...args) {
|
|
12698
|
+
const transformedArgs = [];
|
|
12699
|
+
for (let i = 0, ii = args.length; i < ii; i++) {
|
|
12700
|
+
let arg = args[i];
|
|
12701
|
+
if (isRange(arg)) {
|
|
12702
|
+
arg.start--;
|
|
12703
|
+
arg.end -= arg.step > 0 ? 0 : 2;
|
|
12704
|
+
} else if (arg && arg.isSet === true) {
|
|
12705
|
+
arg = arg.map(function(v) {
|
|
12706
|
+
return v - 1;
|
|
12707
|
+
});
|
|
12708
|
+
} else if (isArray(arg) || isMatrix(arg)) {
|
|
12709
|
+
if (getMatrixDataType(arg) !== "boolean") {
|
|
12710
|
+
arg = arg.map(function(v) {
|
|
12711
|
+
return v - 1;
|
|
12712
|
+
});
|
|
12713
|
+
}
|
|
12714
|
+
} else if (isNumber(arg) || isBigInt(arg)) {
|
|
12715
|
+
arg--;
|
|
12716
|
+
} else if (isBigNumber(arg)) {
|
|
12717
|
+
arg = arg.toNumber() - 1;
|
|
12718
|
+
} else if (typeof arg === "string") {
|
|
12719
|
+
} else {
|
|
12720
|
+
throw new TypeError(
|
|
12721
|
+
"Dimension must be an Array, Matrix, number, bigint, string, or Range"
|
|
12722
|
+
);
|
|
12723
|
+
}
|
|
12724
|
+
transformedArgs[i] = arg;
|
|
12725
|
+
}
|
|
12726
|
+
return new Index2(...transformedArgs);
|
|
12727
|
+
};
|
|
12728
|
+
},
|
|
12729
|
+
{ isTransformFunction: true }
|
|
12730
|
+
);
|
|
12731
|
+
|
|
12732
|
+
// src/transform/map.transform.ts
|
|
12733
|
+
var name32 = "map";
|
|
12734
|
+
var dependencies32 = ["typed", "map"];
|
|
12735
|
+
var createMapTransform = /* @__PURE__ */ factory(
|
|
12736
|
+
name32,
|
|
12737
|
+
dependencies32,
|
|
12738
|
+
({ typed, map: map2 }) => {
|
|
12739
|
+
const transformCallback = createTransformCallback({ typed });
|
|
12740
|
+
function mapTransform(args, math, scope) {
|
|
12741
|
+
if (args.length === 0) {
|
|
12742
|
+
return map2();
|
|
12743
|
+
}
|
|
12744
|
+
if (args.length === 1) {
|
|
12745
|
+
return map2(args[0]);
|
|
12746
|
+
}
|
|
12747
|
+
const N = args.length - 1;
|
|
12748
|
+
let X = args.slice(0, N);
|
|
12749
|
+
let callback = args[N];
|
|
12750
|
+
X = X.map((arg) => _compileAndEvaluate(arg, scope));
|
|
12751
|
+
if (callback) {
|
|
12752
|
+
if (isSymbolNode(callback) || isFunctionAssignmentNode(callback)) {
|
|
12753
|
+
callback = _compileAndEvaluate(callback, scope);
|
|
12754
|
+
} else {
|
|
12755
|
+
callback = compileInlineExpression(
|
|
12756
|
+
callback,
|
|
12757
|
+
math,
|
|
12758
|
+
scope
|
|
12759
|
+
);
|
|
12760
|
+
}
|
|
12761
|
+
}
|
|
12762
|
+
return map2(...X, transformCallback(callback, N));
|
|
12763
|
+
function _compileAndEvaluate(arg, scope2) {
|
|
12764
|
+
return arg.compile().evaluate(scope2);
|
|
12765
|
+
}
|
|
12766
|
+
}
|
|
12767
|
+
mapTransform.rawArgs = true;
|
|
12768
|
+
return mapTransform;
|
|
12769
|
+
},
|
|
12770
|
+
{ isTransformFunction: true }
|
|
12771
|
+
);
|
|
12772
|
+
|
|
12773
|
+
// src/transform/mapSlices.transform.ts
|
|
12774
|
+
var name33 = "mapSlices";
|
|
12775
|
+
var dependencies33 = ["typed", "mapSlices"];
|
|
12776
|
+
var createMapSlicesTransform = /* @__PURE__ */ factory(
|
|
12777
|
+
name33,
|
|
12778
|
+
dependencies33,
|
|
12779
|
+
({ typed, mapSlices }) => {
|
|
12780
|
+
return typed("mapSlices", {
|
|
12781
|
+
"...any": function(args) {
|
|
12782
|
+
const dim = args[1];
|
|
12783
|
+
if (isNumber(dim)) {
|
|
12784
|
+
args[1] = dim - 1;
|
|
12785
|
+
} else if (isBigNumber(dim)) {
|
|
12786
|
+
args[1] = dim.minus(1);
|
|
12787
|
+
}
|
|
12788
|
+
try {
|
|
12789
|
+
return mapSlices(...args);
|
|
12790
|
+
} catch (err) {
|
|
12791
|
+
throw errorTransform(err);
|
|
12792
|
+
}
|
|
12793
|
+
}
|
|
12794
|
+
});
|
|
12795
|
+
},
|
|
12796
|
+
{ isTransformFunction: true }
|
|
12797
|
+
);
|
|
12798
|
+
|
|
12799
|
+
// src/transform/max.transform.ts
|
|
12800
|
+
var name34 = "max";
|
|
12801
|
+
var dependencies34 = ["typed", "max"];
|
|
12802
|
+
var createMaxTransform = /* @__PURE__ */ factory(
|
|
12803
|
+
name34,
|
|
12804
|
+
dependencies34,
|
|
12805
|
+
({ typed, max }) => {
|
|
12806
|
+
return typed("max", {
|
|
12807
|
+
"...any": function(args) {
|
|
12808
|
+
args = lastDimToZeroBase(args);
|
|
12809
|
+
try {
|
|
12810
|
+
return max(...args);
|
|
12811
|
+
} catch (err) {
|
|
12812
|
+
throw errorTransform(err);
|
|
12813
|
+
}
|
|
12814
|
+
}
|
|
12815
|
+
});
|
|
12816
|
+
},
|
|
12817
|
+
{ isTransformFunction: true }
|
|
12818
|
+
);
|
|
12819
|
+
|
|
12820
|
+
// src/transform/mean.transform.ts
|
|
12821
|
+
var name35 = "mean";
|
|
12822
|
+
var dependencies35 = ["typed", "mean"];
|
|
12823
|
+
var createMeanTransform = /* @__PURE__ */ factory(
|
|
12824
|
+
name35,
|
|
12825
|
+
dependencies35,
|
|
12826
|
+
({ typed, mean }) => {
|
|
12827
|
+
return typed("mean", {
|
|
12828
|
+
"...any": function(args) {
|
|
12829
|
+
args = lastDimToZeroBase(args);
|
|
12830
|
+
try {
|
|
12831
|
+
return mean(...args);
|
|
12832
|
+
} catch (err) {
|
|
12833
|
+
throw errorTransform(err);
|
|
12834
|
+
}
|
|
12835
|
+
}
|
|
12836
|
+
});
|
|
12837
|
+
},
|
|
12838
|
+
{ isTransformFunction: true }
|
|
12839
|
+
);
|
|
12840
|
+
|
|
12841
|
+
// src/transform/min.transform.ts
|
|
12842
|
+
var name36 = "min";
|
|
12843
|
+
var dependencies36 = ["typed", "min"];
|
|
12844
|
+
var createMinTransform = /* @__PURE__ */ factory(
|
|
12845
|
+
name36,
|
|
12846
|
+
dependencies36,
|
|
12847
|
+
({ typed, min }) => {
|
|
12848
|
+
return typed("min", {
|
|
12849
|
+
"...any": function(args) {
|
|
12850
|
+
args = lastDimToZeroBase(args);
|
|
12851
|
+
try {
|
|
12852
|
+
return min(...args);
|
|
12853
|
+
} catch (err) {
|
|
12854
|
+
throw errorTransform(err);
|
|
12855
|
+
}
|
|
12856
|
+
}
|
|
12857
|
+
});
|
|
12858
|
+
},
|
|
12859
|
+
{ isTransformFunction: true }
|
|
12860
|
+
);
|
|
12861
|
+
|
|
12862
|
+
// src/transform/nullish.transform.ts
|
|
12863
|
+
var name37 = "nullish";
|
|
12864
|
+
var dependencies37 = ["nullish"];
|
|
12865
|
+
var createNullishTransform = /* @__PURE__ */ factory(
|
|
12866
|
+
name37,
|
|
12867
|
+
dependencies37,
|
|
12868
|
+
({ nullish }) => {
|
|
12869
|
+
function nullishTransform(args, _math, scope) {
|
|
12870
|
+
const left = args[0].compile().evaluate(scope);
|
|
12871
|
+
if (!isCollection(left) && left != null && left !== void 0) {
|
|
12872
|
+
return left;
|
|
12873
|
+
}
|
|
12874
|
+
const right = args[1].compile().evaluate(scope);
|
|
12875
|
+
return nullish(left, right);
|
|
12876
|
+
}
|
|
12877
|
+
nullishTransform.rawArgs = true;
|
|
12878
|
+
return nullishTransform;
|
|
12879
|
+
},
|
|
12880
|
+
{ isTransformFunction: true }
|
|
12881
|
+
);
|
|
12882
|
+
|
|
12883
|
+
// src/transform/or.transform.ts
|
|
12884
|
+
var name38 = "or";
|
|
12885
|
+
var dependencies38 = ["or"];
|
|
12886
|
+
var createOrTransform = /* @__PURE__ */ factory(
|
|
12887
|
+
name38,
|
|
12888
|
+
dependencies38,
|
|
12889
|
+
({ or }) => {
|
|
12890
|
+
function orTransform(args, _math, scope) {
|
|
12891
|
+
const condition1 = args[0].compile().evaluate(scope);
|
|
12892
|
+
if (!isCollection(condition1) && or(condition1, false)) {
|
|
12893
|
+
return true;
|
|
12894
|
+
}
|
|
12895
|
+
const condition2 = args[1].compile().evaluate(scope);
|
|
12896
|
+
return or(condition1, condition2);
|
|
12897
|
+
}
|
|
12898
|
+
orTransform.rawArgs = true;
|
|
12899
|
+
return orTransform;
|
|
12900
|
+
},
|
|
12901
|
+
{ isTransformFunction: true }
|
|
12902
|
+
);
|
|
12903
|
+
|
|
12904
|
+
// src/utils/print.ts
|
|
12905
|
+
var printTemplate = /\$([\w.]+)/g;
|
|
12906
|
+
|
|
12907
|
+
// src/transform/print.transform.ts
|
|
12908
|
+
var name39 = "print";
|
|
12909
|
+
var dependencies39 = ["typed", "print"];
|
|
12910
|
+
var createPrintTransform = /* @__PURE__ */ factory(
|
|
12911
|
+
name39,
|
|
12912
|
+
dependencies39,
|
|
12913
|
+
({ typed, print }) => {
|
|
12914
|
+
return typed(name39, {
|
|
12915
|
+
"string, Object | Array": function(template, values) {
|
|
12916
|
+
return print(_convertTemplateToZeroBasedIndex(template), values);
|
|
12917
|
+
},
|
|
12918
|
+
"string, Object | Array, number | Object": function(template, values, options) {
|
|
12919
|
+
return print(_convertTemplateToZeroBasedIndex(template), values, options);
|
|
12920
|
+
}
|
|
12921
|
+
});
|
|
12922
|
+
function _convertTemplateToZeroBasedIndex(template) {
|
|
12923
|
+
return template.replace(printTemplate, (x) => {
|
|
12924
|
+
const parts = x.slice(1).split(".");
|
|
12925
|
+
const result = parts.map(function(part) {
|
|
12926
|
+
if (!isNaN(Number(part)) && part.length > 0) {
|
|
12927
|
+
return parseInt(part) - 1;
|
|
12928
|
+
} else {
|
|
12929
|
+
return part;
|
|
12930
|
+
}
|
|
12931
|
+
});
|
|
12932
|
+
return "$" + result.join(".");
|
|
12933
|
+
});
|
|
12934
|
+
}
|
|
12935
|
+
},
|
|
12936
|
+
{ isTransformFunction: true }
|
|
12937
|
+
);
|
|
12938
|
+
|
|
12939
|
+
// src/transform/quantileSeq.transform.ts
|
|
12940
|
+
var name40 = "quantileSeq";
|
|
12941
|
+
var dependencies40 = ["typed", "quantileSeq"];
|
|
12942
|
+
var createQuantileSeqTransform = /* @__PURE__ */ factory(
|
|
12943
|
+
name40,
|
|
12944
|
+
dependencies40,
|
|
12945
|
+
({ typed, quantileSeq }) => {
|
|
12946
|
+
return typed("quantileSeq", {
|
|
12947
|
+
"Array | Matrix, number | BigNumber": quantileSeq,
|
|
12948
|
+
"Array | Matrix, number | BigNumber, number": (arr, prob, dim) => quantileSeq(arr, prob, dimToZeroBase2(dim)),
|
|
12949
|
+
"Array | Matrix, number | BigNumber, boolean": quantileSeq,
|
|
12950
|
+
"Array | Matrix, number | BigNumber, boolean, number": (arr, prob, sorted, dim) => quantileSeq(arr, prob, sorted, dimToZeroBase2(dim)),
|
|
12951
|
+
"Array | Matrix, Array | Matrix": quantileSeq,
|
|
12952
|
+
"Array | Matrix, Array | Matrix, number": (data, prob, dim) => quantileSeq(data, prob, dimToZeroBase2(dim)),
|
|
12953
|
+
"Array | Matrix, Array | Matrix, boolean": quantileSeq,
|
|
12954
|
+
"Array | Matrix, Array | Matrix, boolean, number": (data, prob, sorted, dim) => quantileSeq(data, prob, sorted, dimToZeroBase2(dim))
|
|
12955
|
+
});
|
|
12956
|
+
function dimToZeroBase2(dim) {
|
|
12957
|
+
return lastDimToZeroBase([[], dim])[1];
|
|
12958
|
+
}
|
|
12959
|
+
},
|
|
12960
|
+
{ isTransformFunction: true }
|
|
12961
|
+
);
|
|
12962
|
+
|
|
12963
|
+
// src/transform/range.transform.ts
|
|
12964
|
+
var name41 = "range";
|
|
12965
|
+
var dependencies41 = ["typed", "range"];
|
|
12966
|
+
var createRangeTransform = /* @__PURE__ */ factory(
|
|
12967
|
+
name41,
|
|
12968
|
+
dependencies41,
|
|
12969
|
+
({ typed, range }) => {
|
|
12970
|
+
return typed("range", {
|
|
12971
|
+
"...any": function(args) {
|
|
12972
|
+
const lastIndex = args.length - 1;
|
|
12973
|
+
const last = args[lastIndex];
|
|
12974
|
+
if (typeof last !== "boolean") {
|
|
12975
|
+
args.push(true);
|
|
12976
|
+
}
|
|
12977
|
+
return range(...args);
|
|
12978
|
+
}
|
|
12979
|
+
});
|
|
12980
|
+
},
|
|
12981
|
+
{ isTransformFunction: true }
|
|
12982
|
+
);
|
|
12983
|
+
|
|
12984
|
+
// src/transform/row.transform.ts
|
|
12985
|
+
var name42 = "row";
|
|
12986
|
+
var dependencies42 = ["typed", "row"];
|
|
12987
|
+
var createRowTransform = /* @__PURE__ */ factory(
|
|
12988
|
+
name42,
|
|
12989
|
+
dependencies42,
|
|
12990
|
+
({ typed, row }) => {
|
|
12991
|
+
return typed("row", {
|
|
12992
|
+
"...any": function(args) {
|
|
12993
|
+
const lastIndex = args.length - 1;
|
|
12994
|
+
const last = args[lastIndex];
|
|
12995
|
+
if (isNumber(last)) {
|
|
12996
|
+
args[lastIndex] = last - 1;
|
|
12997
|
+
}
|
|
12998
|
+
try {
|
|
12999
|
+
return row(...args);
|
|
13000
|
+
} catch (err) {
|
|
13001
|
+
throw errorTransform(err);
|
|
13002
|
+
}
|
|
13003
|
+
}
|
|
13004
|
+
});
|
|
13005
|
+
},
|
|
13006
|
+
{ isTransformFunction: true }
|
|
13007
|
+
);
|
|
13008
|
+
|
|
13009
|
+
// src/transform/std.transform.ts
|
|
13010
|
+
var name43 = "std";
|
|
13011
|
+
var dependencies43 = ["typed", "std"];
|
|
13012
|
+
var createStdTransform = /* @__PURE__ */ factory(
|
|
13013
|
+
name43,
|
|
13014
|
+
dependencies43,
|
|
13015
|
+
({ typed, std }) => {
|
|
13016
|
+
return typed("std", {
|
|
13017
|
+
"...any": function(args) {
|
|
13018
|
+
args = lastDimToZeroBase(args);
|
|
13019
|
+
try {
|
|
13020
|
+
return std(...args);
|
|
13021
|
+
} catch (err) {
|
|
13022
|
+
throw errorTransform(err);
|
|
13023
|
+
}
|
|
13024
|
+
}
|
|
13025
|
+
});
|
|
13026
|
+
},
|
|
13027
|
+
{ isTransformFunction: true }
|
|
13028
|
+
);
|
|
13029
|
+
|
|
13030
|
+
// src/transform/subset.transform.ts
|
|
13031
|
+
var name44 = "subset";
|
|
13032
|
+
var dependencies44 = ["typed", "subset"];
|
|
13033
|
+
var createSubsetTransform = /* @__PURE__ */ factory(
|
|
13034
|
+
name44,
|
|
13035
|
+
dependencies44,
|
|
13036
|
+
({ typed, subset }) => {
|
|
13037
|
+
return typed("subset", {
|
|
13038
|
+
"...any": function(args) {
|
|
13039
|
+
try {
|
|
13040
|
+
return subset(...args);
|
|
13041
|
+
} catch (err) {
|
|
13042
|
+
throw errorTransform(err);
|
|
13043
|
+
}
|
|
13044
|
+
}
|
|
13045
|
+
});
|
|
13046
|
+
},
|
|
13047
|
+
{ isTransformFunction: true }
|
|
13048
|
+
);
|
|
13049
|
+
|
|
13050
|
+
// src/transform/sum.transform.ts
|
|
13051
|
+
var name45 = "sum";
|
|
13052
|
+
var dependencies45 = ["typed", "sum"];
|
|
13053
|
+
var createSumTransform = /* @__PURE__ */ factory(
|
|
13054
|
+
name45,
|
|
13055
|
+
dependencies45,
|
|
13056
|
+
({ typed, sum }) => {
|
|
13057
|
+
return typed(name45, {
|
|
13058
|
+
"...any": function(args) {
|
|
13059
|
+
args = lastDimToZeroBase(args);
|
|
13060
|
+
try {
|
|
13061
|
+
return sum(...args);
|
|
13062
|
+
} catch (err) {
|
|
13063
|
+
throw errorTransform(err);
|
|
13064
|
+
}
|
|
13065
|
+
}
|
|
13066
|
+
});
|
|
13067
|
+
},
|
|
13068
|
+
{ isTransformFunction: true }
|
|
13069
|
+
);
|
|
13070
|
+
|
|
13071
|
+
// src/transform/variance.transform.ts
|
|
13072
|
+
var name46 = "variance";
|
|
13073
|
+
var dependencies46 = ["typed", "variance"];
|
|
13074
|
+
var createVarianceTransform = /* @__PURE__ */ factory(
|
|
13075
|
+
name46,
|
|
13076
|
+
dependencies46,
|
|
13077
|
+
({ typed, variance }) => {
|
|
13078
|
+
return typed(name46, {
|
|
13079
|
+
"...any": function(args) {
|
|
13080
|
+
args = lastDimToZeroBase(args);
|
|
13081
|
+
try {
|
|
13082
|
+
return variance(...args);
|
|
13083
|
+
} catch (err) {
|
|
13084
|
+
throw errorTransform(err);
|
|
13085
|
+
}
|
|
13086
|
+
}
|
|
13087
|
+
});
|
|
13088
|
+
},
|
|
13089
|
+
{ isTransformFunction: true }
|
|
13090
|
+
);
|
|
11241
13091
|
export {
|
|
11242
13092
|
compile,
|
|
11243
13093
|
compileExpression,
|
|
11244
13094
|
createAccessorNode,
|
|
13095
|
+
createAndTransform,
|
|
11245
13096
|
createArrayNode,
|
|
11246
13097
|
createAssignmentNode,
|
|
13098
|
+
createBitAndTransform,
|
|
13099
|
+
createBitOrTransform,
|
|
11247
13100
|
createBlockNode,
|
|
13101
|
+
createColumnTransform,
|
|
13102
|
+
createConcatTransform,
|
|
11248
13103
|
createConditionalNode,
|
|
11249
13104
|
createConstantNode,
|
|
13105
|
+
createCumSumTransform,
|
|
13106
|
+
createDiffTransform,
|
|
11250
13107
|
createEvaluate,
|
|
13108
|
+
createFilterTransform,
|
|
13109
|
+
createForEachTransform,
|
|
11251
13110
|
createFunctionAssignmentNode,
|
|
11252
13111
|
createFunctionNode,
|
|
11253
13112
|
createHelpClass,
|
|
11254
13113
|
createIndexNode,
|
|
13114
|
+
createIndexTransform,
|
|
13115
|
+
createMapSlicesTransform,
|
|
13116
|
+
createMapTransform,
|
|
13117
|
+
createMaxTransform,
|
|
13118
|
+
createMeanTransform,
|
|
13119
|
+
createMinTransform,
|
|
11255
13120
|
createNode,
|
|
13121
|
+
createNullishTransform,
|
|
11256
13122
|
createObjectNode,
|
|
11257
13123
|
createOperatorNode,
|
|
13124
|
+
createOrTransform,
|
|
11258
13125
|
createParenthesisNode,
|
|
11259
13126
|
createParse,
|
|
11260
13127
|
createParser,
|
|
11261
13128
|
createParserClass,
|
|
13129
|
+
createPrintTransform,
|
|
13130
|
+
createQuantileSeqTransform,
|
|
11262
13131
|
createRangeNode,
|
|
13132
|
+
createRangeTransform,
|
|
11263
13133
|
createRelationalNode,
|
|
13134
|
+
createRowTransform,
|
|
13135
|
+
createStdTransform,
|
|
13136
|
+
createSubsetTransform,
|
|
13137
|
+
createSumTransform,
|
|
11264
13138
|
createSymbolNode,
|
|
13139
|
+
createVarianceTransform,
|
|
11265
13140
|
embeddedDocs,
|
|
11266
13141
|
escapeMathML,
|
|
11267
13142
|
getAssociativity,
|