@cortex-js/compute-engine 0.20.0 → 0.20.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/compute-engine.esm.js +274 -209
- package/dist/compute-engine.js +274 -209
- package/dist/compute-engine.min.esm.js +10 -10
- package/dist/compute-engine.min.js +10 -10
- package/dist/math-json.esm.js +2 -2
- package/dist/math-json.js +2 -2
- package/dist/math-json.min.esm.js +2 -2
- package/dist/math-json.min.js +2 -2
- package/dist/types/common/ansi-codes.d.ts +1 -1
- package/dist/types/common/grapheme-splitter.d.ts +1 -1
- package/dist/types/common/signals.d.ts +1 -1
- package/dist/types/common/utils.d.ts +1 -1
- package/dist/types/compute-engine/assume.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/box.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-domain.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-function-definition.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-symbol-definition.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/order.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/serialize.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/utils.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/validate.d.ts +1 -1
- package/dist/types/compute-engine/collection-utils.d.ts +1 -1
- package/dist/types/compute-engine/compile.d.ts +1 -1
- package/dist/types/compute-engine/compute-engine.d.ts +1 -1
- package/dist/types/compute-engine/cost-function.d.ts +1 -1
- package/dist/types/compute-engine/domain-utils.d.ts +1 -1
- package/dist/types/compute-engine/function-utils.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-algebra.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-arithmetic.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-calculus.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-complex.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-core.d.ts +2 -2
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-inequalities.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-linear-algebra.d.ts +2 -0
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-logic.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-other.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-sets.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-statistics.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-symbols.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-trigonometry.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/latex-syntax.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/parse-identifier.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/parse.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/public.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/serializer-style.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/serializer.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +1 -1
- package/dist/types/compute-engine/library/arithmetic-add.d.ts +1 -1
- package/dist/types/compute-engine/library/arithmetic-divide.d.ts +1 -1
- package/dist/types/compute-engine/library/arithmetic-multiply.d.ts +1 -1
- package/dist/types/compute-engine/library/arithmetic-power.d.ts +1 -1
- package/dist/types/compute-engine/library/arithmetic.d.ts +1 -1
- package/dist/types/compute-engine/library/calculus.d.ts +1 -1
- package/dist/types/compute-engine/library/collections.d.ts +1 -1
- package/dist/types/compute-engine/library/complex.d.ts +1 -1
- package/dist/types/compute-engine/library/control-structures.d.ts +1 -1
- package/dist/types/compute-engine/library/core.d.ts +1 -1
- package/dist/types/compute-engine/library/domains.d.ts +1 -1
- package/dist/types/compute-engine/library/library.d.ts +1 -1
- package/dist/types/compute-engine/library/linear-algebra.d.ts +1 -1
- package/dist/types/compute-engine/library/logic.d.ts +1 -1
- package/dist/types/compute-engine/library/polynomials.d.ts +1 -1
- package/dist/types/compute-engine/library/random-expression.d.ts +1 -1
- package/dist/types/compute-engine/library/relational-operator.d.ts +1 -1
- package/dist/types/compute-engine/library/sets.d.ts +1 -1
- package/dist/types/compute-engine/library/statistics.d.ts +1 -1
- package/dist/types/compute-engine/library/trigonometry.d.ts +1 -1
- package/dist/types/compute-engine/library/utils.d.ts +1 -1
- package/dist/types/compute-engine/numerics/numeric-bigint.d.ts +1 -1
- package/dist/types/compute-engine/numerics/numeric-bignum.d.ts +1 -1
- package/dist/types/compute-engine/numerics/numeric-complex.d.ts +1 -1
- package/dist/types/compute-engine/numerics/numeric.d.ts +1 -1
- package/dist/types/compute-engine/numerics/primes.d.ts +1 -1
- package/dist/types/compute-engine/numerics/rationals.d.ts +1 -1
- package/dist/types/compute-engine/numerics/richardson.d.ts +1 -1
- package/dist/types/compute-engine/public.d.ts +1 -1
- package/dist/types/compute-engine/rules.d.ts +1 -1
- package/dist/types/compute-engine/simplify-rules.d.ts +1 -1
- package/dist/types/compute-engine/solve.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/derivative.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/expand.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/flatten.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/negate.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/polynomials.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/product.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/sum.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/utils.d.ts +1 -1
- package/dist/types/compute-engine.d.ts +2 -2
- package/dist/types/math-json/math-json-format.d.ts +1 -1
- package/dist/types/math-json/utils.d.ts +2 -1
- package/dist/types/math-json.d.ts +2 -2
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** CortexJS Compute Engine 0.20.
|
|
1
|
+
/** CortexJS Compute Engine 0.20.2 */
|
|
2
2
|
var __create = Object.create;
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -3950,6 +3950,13 @@ function nops(expr) {
|
|
|
3950
3950
|
return Math.max(0, expr.fn.length - 1);
|
|
3951
3951
|
return 0;
|
|
3952
3952
|
}
|
|
3953
|
+
function unhold(expr) {
|
|
3954
|
+
if (expr === null || expr === void 0)
|
|
3955
|
+
return null;
|
|
3956
|
+
if (head(expr) === "Hold")
|
|
3957
|
+
return op(expr, 1);
|
|
3958
|
+
return expr;
|
|
3959
|
+
}
|
|
3953
3960
|
function symbol(expr) {
|
|
3954
3961
|
if (expr === null || expr === void 0)
|
|
3955
3962
|
return null;
|
|
@@ -5366,16 +5373,14 @@ var DEFINITIONS_CORE = [
|
|
|
5366
5373
|
lhs = op(lhs, 1) ?? "Nothing";
|
|
5367
5374
|
if (head(lhs) === "Sequence") {
|
|
5368
5375
|
for (const x of ops(lhs) ?? []) {
|
|
5369
|
-
if (symbol(x))
|
|
5370
|
-
params.push(symbol(x));
|
|
5371
|
-
else
|
|
5376
|
+
if (!symbol(x))
|
|
5372
5377
|
return null;
|
|
5378
|
+
params.push(symbol(x));
|
|
5373
5379
|
}
|
|
5374
5380
|
} else {
|
|
5375
|
-
if (symbol(lhs))
|
|
5376
|
-
params = [symbol(lhs)];
|
|
5377
|
-
else
|
|
5381
|
+
if (!symbol(lhs))
|
|
5378
5382
|
return null;
|
|
5383
|
+
params = [symbol(lhs)];
|
|
5379
5384
|
}
|
|
5380
5385
|
let rhs = parser.parseExpression({ minPrec: ARROW_PRECEDENCE }) ?? "Nothing";
|
|
5381
5386
|
if (head(rhs) === "Delimiter")
|
|
@@ -5448,8 +5453,23 @@ var DEFINITIONS_CORE = [
|
|
|
5448
5453
|
// return ['Assign', lhs, rhs];
|
|
5449
5454
|
// },
|
|
5450
5455
|
serialize: (serializer, expr) => {
|
|
5456
|
+
const id = unhold(op(expr, 1));
|
|
5457
|
+
if (head(op(expr, 2)) === "Function") {
|
|
5458
|
+
const op_2 = op(expr, 2);
|
|
5459
|
+
const body = unhold(op(op_2, 1));
|
|
5460
|
+
const args = ops(op_2)?.slice(1) ?? [];
|
|
5461
|
+
return joinLatex([
|
|
5462
|
+
serializer.serialize(id),
|
|
5463
|
+
serializer.wrapString(
|
|
5464
|
+
args.map((x) => serializer.serialize(x)).join(", "),
|
|
5465
|
+
serializer.options.applyFunctionStyle(expr, serializer.level)
|
|
5466
|
+
),
|
|
5467
|
+
"\\coloneq",
|
|
5468
|
+
serializer.serialize(body)
|
|
5469
|
+
]);
|
|
5470
|
+
}
|
|
5451
5471
|
return joinLatex([
|
|
5452
|
-
serializer.serialize(
|
|
5472
|
+
serializer.serialize(id),
|
|
5453
5473
|
"\\coloneq",
|
|
5454
5474
|
serializer.serialize(op(expr, 2))
|
|
5455
5475
|
]);
|
|
@@ -5555,107 +5575,6 @@ var DEFINITIONS_CORE = [
|
|
|
5555
5575
|
return serializer.wrapString(body, style, open + close);
|
|
5556
5576
|
}
|
|
5557
5577
|
},
|
|
5558
|
-
// The first argument is the matrix data.
|
|
5559
|
-
// The second, optional, argument are the delimiters.
|
|
5560
|
-
// The third, optional, argument is the column specification.
|
|
5561
|
-
{
|
|
5562
|
-
name: "Matrix",
|
|
5563
|
-
// https://ctan.math.illinois.edu/macros/latex/required/tools/array.pdf
|
|
5564
|
-
serialize: (serializer, expr) => {
|
|
5565
|
-
const body = op(expr, 1);
|
|
5566
|
-
const delims = op(expr, 2) ?? "()";
|
|
5567
|
-
let columns = "";
|
|
5568
|
-
if (op(expr, 3) !== null) {
|
|
5569
|
-
const colsSpec = stringValue(op(expr, 3)) ?? "";
|
|
5570
|
-
for (const c of colsSpec) {
|
|
5571
|
-
if (c === "<")
|
|
5572
|
-
columns += "l";
|
|
5573
|
-
else if (c === ">")
|
|
5574
|
-
columns += "r";
|
|
5575
|
-
else if (c === "=")
|
|
5576
|
-
columns += "c";
|
|
5577
|
-
else if (c === "|")
|
|
5578
|
-
columns += "|";
|
|
5579
|
-
else if (c === ":")
|
|
5580
|
-
columns += ":";
|
|
5581
|
-
}
|
|
5582
|
-
}
|
|
5583
|
-
let [open, close] = ["", ""];
|
|
5584
|
-
if (typeof delims === "string" && delims.length === 2)
|
|
5585
|
-
[open, close] = delims;
|
|
5586
|
-
const rows = [];
|
|
5587
|
-
for (const row of ops(body) ?? []) {
|
|
5588
|
-
const cells = [];
|
|
5589
|
-
for (const cell of ops(row) ?? [])
|
|
5590
|
-
cells.push(serializer.serialize(cell));
|
|
5591
|
-
rows.push(cells.join(" & "));
|
|
5592
|
-
}
|
|
5593
|
-
const tabular = rows.join("\\\\\n");
|
|
5594
|
-
const optColumns = columns.length > 0 ? `[${columns}]` : "";
|
|
5595
|
-
if (open === "(" && close === ")")
|
|
5596
|
-
return joinLatex([
|
|
5597
|
-
"\\begin{pmatrix}",
|
|
5598
|
-
optColumns,
|
|
5599
|
-
tabular,
|
|
5600
|
-
"\\end{pmatrix}"
|
|
5601
|
-
]);
|
|
5602
|
-
if (open === "[" && close === "]")
|
|
5603
|
-
return joinLatex([
|
|
5604
|
-
"\\begin{bmatrix}",
|
|
5605
|
-
optColumns,
|
|
5606
|
-
tabular,
|
|
5607
|
-
"\\end{bmatrix}"
|
|
5608
|
-
]);
|
|
5609
|
-
if (open === "{" && close === "}")
|
|
5610
|
-
return joinLatex([
|
|
5611
|
-
"\\begin{Bmatrix}",
|
|
5612
|
-
optColumns,
|
|
5613
|
-
tabular,
|
|
5614
|
-
"\\end{Bmatrix}"
|
|
5615
|
-
]);
|
|
5616
|
-
if (open === "|" && close === "|")
|
|
5617
|
-
return joinLatex([
|
|
5618
|
-
"\\begin{vmatrix}",
|
|
5619
|
-
optColumns,
|
|
5620
|
-
tabular,
|
|
5621
|
-
"\\end{vmatrix}"
|
|
5622
|
-
]);
|
|
5623
|
-
if (open === "\u2016" && close === "\u2016")
|
|
5624
|
-
return joinLatex([
|
|
5625
|
-
"\\begin{Vmatrix}",
|
|
5626
|
-
optColumns,
|
|
5627
|
-
tabular,
|
|
5628
|
-
"\\end{Vmatrix}"
|
|
5629
|
-
]);
|
|
5630
|
-
if (open === "{" && close === ".")
|
|
5631
|
-
return joinLatex([
|
|
5632
|
-
"\\begin{dcases}",
|
|
5633
|
-
optColumns,
|
|
5634
|
-
tabular,
|
|
5635
|
-
"\\end{dcases}"
|
|
5636
|
-
]);
|
|
5637
|
-
if (open === "." && close === "}")
|
|
5638
|
-
return joinLatex([
|
|
5639
|
-
"\\begin{rcases}",
|
|
5640
|
-
optColumns,
|
|
5641
|
-
tabular,
|
|
5642
|
-
"\\end{rcases}"
|
|
5643
|
-
]);
|
|
5644
|
-
if (columns || open !== "." || close !== ".") {
|
|
5645
|
-
return joinLatex([
|
|
5646
|
-
"\\left",
|
|
5647
|
-
DELIMITERS_SHORTHAND[open] ?? open,
|
|
5648
|
-
"\\begin{array}",
|
|
5649
|
-
`{${columns}}`,
|
|
5650
|
-
tabular,
|
|
5651
|
-
"\\end{array}",
|
|
5652
|
-
"\\right",
|
|
5653
|
-
DELIMITERS_SHORTHAND[close] ?? close
|
|
5654
|
-
]);
|
|
5655
|
-
}
|
|
5656
|
-
return joinLatex(["\\begin{matrix}", tabular, "\\end{matrix}"]);
|
|
5657
|
-
}
|
|
5658
|
-
},
|
|
5659
5578
|
{
|
|
5660
5579
|
name: "Domain",
|
|
5661
5580
|
serialize: (serializer, expr) => {
|
|
@@ -6296,11 +6215,11 @@ var DELIMITERS_SHORTHAND = {
|
|
|
6296
6215
|
"(": "(",
|
|
6297
6216
|
")": ")",
|
|
6298
6217
|
"[": "\\lbrack",
|
|
6218
|
+
"]": "\\rbrack",
|
|
6299
6219
|
"\u27E6": "\\llbrack",
|
|
6300
6220
|
// U+27E6 MATHEMATICAL LEFT WHITE SQUARE BRACKET
|
|
6301
6221
|
"\u27E7": "\\rrbrack",
|
|
6302
6222
|
// U+27E7 MATHEMATICAL RIGHT WHITE SQUARE BRACKET
|
|
6303
|
-
"]": "\\rbrack",
|
|
6304
6223
|
"{": "\\lbrace",
|
|
6305
6224
|
"}": "\\rbrace",
|
|
6306
6225
|
"<": "\\langle",
|
|
@@ -6347,6 +6266,16 @@ function parseAssign(parser, lhs) {
|
|
|
6347
6266
|
}
|
|
6348
6267
|
return ["Assign", fn, ["Function", rhs2, ...args ?? []]];
|
|
6349
6268
|
}
|
|
6269
|
+
if (typeof head(lhs) === "string") {
|
|
6270
|
+
const fn = head(lhs);
|
|
6271
|
+
const args = ops(lhs) ?? [];
|
|
6272
|
+
const rhs2 = parser.parseExpression({ minPrec: 0 });
|
|
6273
|
+
if (rhs2 === null) {
|
|
6274
|
+
parser.index = index;
|
|
6275
|
+
return null;
|
|
6276
|
+
}
|
|
6277
|
+
return ["Assign", fn, ["Function", rhs2, ...args]];
|
|
6278
|
+
}
|
|
6350
6279
|
if (!symbol(lhs))
|
|
6351
6280
|
return null;
|
|
6352
6281
|
const rhs = parser.parseExpression({ minPrec: 0 });
|
|
@@ -6757,6 +6686,111 @@ var DEFINITIONS_INEQUALITIES = [
|
|
|
6757
6686
|
}
|
|
6758
6687
|
];
|
|
6759
6688
|
|
|
6689
|
+
// src/compute-engine/latex-syntax/dictionary/definitions-linear-algebra.ts
|
|
6690
|
+
var DEFINITIONS_LINEAR_ALGEBRA = [
|
|
6691
|
+
// The first argument is the matrix data.
|
|
6692
|
+
// The second, optional, argument are the delimiters.
|
|
6693
|
+
// The third, optional, argument is the column specification.
|
|
6694
|
+
{
|
|
6695
|
+
name: "Matrix",
|
|
6696
|
+
// https://ctan.math.illinois.edu/macros/latex/required/tools/array.pdf
|
|
6697
|
+
serialize: (serializer, expr) => {
|
|
6698
|
+
const body = op(expr, 1);
|
|
6699
|
+
const delims = op(expr, 2) ?? "()";
|
|
6700
|
+
let columns = "";
|
|
6701
|
+
if (op(expr, 3) !== null) {
|
|
6702
|
+
const colsSpec = stringValue(op(expr, 3)) ?? "";
|
|
6703
|
+
for (const c of colsSpec) {
|
|
6704
|
+
if (c === "<")
|
|
6705
|
+
columns += "l";
|
|
6706
|
+
else if (c === ">")
|
|
6707
|
+
columns += "r";
|
|
6708
|
+
else if (c === "=")
|
|
6709
|
+
columns += "c";
|
|
6710
|
+
else if (c === "|")
|
|
6711
|
+
columns += "|";
|
|
6712
|
+
else if (c === ":")
|
|
6713
|
+
columns += ":";
|
|
6714
|
+
}
|
|
6715
|
+
}
|
|
6716
|
+
let [open, close] = ["", ""];
|
|
6717
|
+
if (typeof delims === "string" && delims.length === 2)
|
|
6718
|
+
[open, close] = delims;
|
|
6719
|
+
const rows = [];
|
|
6720
|
+
for (const row of ops(body) ?? []) {
|
|
6721
|
+
const cells = [];
|
|
6722
|
+
for (const cell of ops(row) ?? [])
|
|
6723
|
+
cells.push(serializer.serialize(cell));
|
|
6724
|
+
rows.push(cells.join(" & "));
|
|
6725
|
+
}
|
|
6726
|
+
const tabular = rows.join("\\\\\n");
|
|
6727
|
+
const optColumns = columns.length > 0 ? `[${columns}]` : "";
|
|
6728
|
+
if (open === "(" && close === ")")
|
|
6729
|
+
return joinLatex([
|
|
6730
|
+
"\\begin{pmatrix}",
|
|
6731
|
+
optColumns,
|
|
6732
|
+
tabular,
|
|
6733
|
+
"\\end{pmatrix}"
|
|
6734
|
+
]);
|
|
6735
|
+
if (open === "[" && close === "]")
|
|
6736
|
+
return joinLatex([
|
|
6737
|
+
"\\begin{bmatrix}",
|
|
6738
|
+
optColumns,
|
|
6739
|
+
tabular,
|
|
6740
|
+
"\\end{bmatrix}"
|
|
6741
|
+
]);
|
|
6742
|
+
if (open === "{" && close === "}")
|
|
6743
|
+
return joinLatex([
|
|
6744
|
+
"\\begin{Bmatrix}",
|
|
6745
|
+
optColumns,
|
|
6746
|
+
tabular,
|
|
6747
|
+
"\\end{Bmatrix}"
|
|
6748
|
+
]);
|
|
6749
|
+
if (open === "|" && close === "|")
|
|
6750
|
+
return joinLatex([
|
|
6751
|
+
"\\begin{vmatrix}",
|
|
6752
|
+
optColumns,
|
|
6753
|
+
tabular,
|
|
6754
|
+
"\\end{vmatrix}"
|
|
6755
|
+
]);
|
|
6756
|
+
if (open === "\u2016" && close === "\u2016")
|
|
6757
|
+
return joinLatex([
|
|
6758
|
+
"\\begin{Vmatrix}",
|
|
6759
|
+
optColumns,
|
|
6760
|
+
tabular,
|
|
6761
|
+
"\\end{Vmatrix}"
|
|
6762
|
+
]);
|
|
6763
|
+
if (open === "{" && close === ".")
|
|
6764
|
+
return joinLatex([
|
|
6765
|
+
"\\begin{dcases}",
|
|
6766
|
+
optColumns,
|
|
6767
|
+
tabular,
|
|
6768
|
+
"\\end{dcases}"
|
|
6769
|
+
]);
|
|
6770
|
+
if (open === "." && close === "}")
|
|
6771
|
+
return joinLatex([
|
|
6772
|
+
"\\begin{rcases}",
|
|
6773
|
+
optColumns,
|
|
6774
|
+
tabular,
|
|
6775
|
+
"\\end{rcases}"
|
|
6776
|
+
]);
|
|
6777
|
+
if (columns || open !== "." || close !== ".") {
|
|
6778
|
+
return joinLatex([
|
|
6779
|
+
"\\left",
|
|
6780
|
+
DELIMITERS_SHORTHAND[open] ?? open,
|
|
6781
|
+
"\\begin{array}",
|
|
6782
|
+
`{${columns}}`,
|
|
6783
|
+
tabular,
|
|
6784
|
+
"\\end{array}",
|
|
6785
|
+
"\\right",
|
|
6786
|
+
DELIMITERS_SHORTHAND[close] ?? close
|
|
6787
|
+
]);
|
|
6788
|
+
}
|
|
6789
|
+
return joinLatex(["\\begin{matrix}", tabular, "\\end{matrix}"]);
|
|
6790
|
+
}
|
|
6791
|
+
}
|
|
6792
|
+
];
|
|
6793
|
+
|
|
6760
6794
|
// src/compute-engine/latex-syntax/dictionary/definitions-logic.ts
|
|
6761
6795
|
var DEFINITIONS_LOGIC = [
|
|
6762
6796
|
// Constants
|
|
@@ -8798,25 +8832,26 @@ function isValidEntry(entry, onError) {
|
|
|
8798
8832
|
return true;
|
|
8799
8833
|
}
|
|
8800
8834
|
var DEFAULT_LATEX_DICTIONARY = {
|
|
8801
|
-
algebra: DEFINITIONS_ALGEBRA,
|
|
8802
|
-
arithmetic: DEFINITIONS_ARITHMETIC,
|
|
8803
|
-
calculus: DEFINITIONS_CALCULUS,
|
|
8804
|
-
complex: DEFINITIONS_COMPLEX,
|
|
8805
|
-
core: DEFINITIONS_CORE,
|
|
8806
|
-
|
|
8807
|
-
|
|
8808
|
-
|
|
8809
|
-
|
|
8835
|
+
"algebra": DEFINITIONS_ALGEBRA,
|
|
8836
|
+
"arithmetic": DEFINITIONS_ARITHMETIC,
|
|
8837
|
+
"calculus": DEFINITIONS_CALCULUS,
|
|
8838
|
+
"complex": DEFINITIONS_COMPLEX,
|
|
8839
|
+
"core": DEFINITIONS_CORE,
|
|
8840
|
+
"linear-algebra": DEFINITIONS_LINEAR_ALGEBRA,
|
|
8841
|
+
"logic": DEFINITIONS_LOGIC,
|
|
8842
|
+
"relop": DEFINITIONS_INEQUALITIES,
|
|
8843
|
+
"other": DEFINITIONS_OTHERS,
|
|
8844
|
+
"physics": [
|
|
8810
8845
|
{
|
|
8811
8846
|
name: "mu0",
|
|
8812
8847
|
kind: "symbol",
|
|
8813
8848
|
latexTrigger: "\\mu_0"
|
|
8814
8849
|
}
|
|
8815
8850
|
],
|
|
8816
|
-
sets: DEFINITIONS_SETS,
|
|
8817
|
-
statistics: DEFINITIONS_STATISTICS,
|
|
8818
|
-
symbols: DEFINITIONS_SYMBOLS,
|
|
8819
|
-
trigonometry: DEFINITIONS_TRIGONOMETRY
|
|
8851
|
+
"sets": DEFINITIONS_SETS,
|
|
8852
|
+
"statistics": DEFINITIONS_STATISTICS,
|
|
8853
|
+
"symbols": DEFINITIONS_SYMBOLS,
|
|
8854
|
+
"trigonometry": DEFINITIONS_TRIGONOMETRY
|
|
8820
8855
|
};
|
|
8821
8856
|
|
|
8822
8857
|
// src/compute-engine/latex-syntax/parse-identifier.ts
|
|
@@ -15138,7 +15173,7 @@ function compileExpr(h, args, prec, target) {
|
|
|
15138
15173
|
}
|
|
15139
15174
|
if (h === "Function") {
|
|
15140
15175
|
const params = args.slice(1).map((x) => x.symbol);
|
|
15141
|
-
return `((${params.join(", ")}) => ${compile(args[0], {
|
|
15176
|
+
return `((${params.join(", ")}) => ${compile(args[0].canonical, {
|
|
15142
15177
|
...target,
|
|
15143
15178
|
var: (id) => params.includes(id) ? id : target.var(id)
|
|
15144
15179
|
})})`;
|
|
@@ -17749,7 +17784,7 @@ var SIMPLIFY_RULES = [];
|
|
|
17749
17784
|
// src/compute-engine/function-utils.ts
|
|
17750
17785
|
function canonicalFunctionExpression(expr) {
|
|
17751
17786
|
if (expr.head === "N" && typeof expr.op1.head === "string") {
|
|
17752
|
-
const newHead = {
|
|
17787
|
+
const newHead = { Integrate: "NIntegrate", Limit: "NLimit" }[expr.op1.head];
|
|
17753
17788
|
if (newHead)
|
|
17754
17789
|
expr = expr.engine._fn(newHead, expr.op1.ops);
|
|
17755
17790
|
}
|
|
@@ -18220,6 +18255,11 @@ var BoxedFunction = class _BoxedFunction extends _BoxedExpression {
|
|
|
18220
18255
|
evaluate(options) {
|
|
18221
18256
|
if (!this.isValid)
|
|
18222
18257
|
return this;
|
|
18258
|
+
if (options?.numericMode) {
|
|
18259
|
+
const h = this.head;
|
|
18260
|
+
if (h === "Integrate" || h === "Limit")
|
|
18261
|
+
return this.engine.box(["N", this], { canonical: true }).evaluate(options);
|
|
18262
|
+
}
|
|
18223
18263
|
if (!this.isCanonical) {
|
|
18224
18264
|
this.engine.pushScope();
|
|
18225
18265
|
const canonical2 = this.canonical;
|
|
@@ -21050,71 +21090,6 @@ var ARITHMETIC_LIBRARY = [
|
|
|
21050
21090
|
evaluate: (ce, ops2) => evalSummation(ce, ops2[0], ops2[1], "evaluate"),
|
|
21051
21091
|
N: (ce, ops2) => evalSummation(ce, ops2[0], ops2[1], "N")
|
|
21052
21092
|
}
|
|
21053
|
-
},
|
|
21054
|
-
// Limits
|
|
21055
|
-
Limit: {
|
|
21056
|
-
description: "Limit of a function",
|
|
21057
|
-
complexity: 5e3,
|
|
21058
|
-
hold: "all",
|
|
21059
|
-
threadable: false,
|
|
21060
|
-
signature: {
|
|
21061
|
-
domain: [
|
|
21062
|
-
"FunctionOf",
|
|
21063
|
-
"Anything",
|
|
21064
|
-
"Numbers",
|
|
21065
|
-
["OptArg", "Numbers"],
|
|
21066
|
-
"Numbers"
|
|
21067
|
-
],
|
|
21068
|
-
N: (ce, ops2) => {
|
|
21069
|
-
const [f, x, dir] = ops2;
|
|
21070
|
-
const target = asFloat(x.N());
|
|
21071
|
-
if (target === null)
|
|
21072
|
-
return void 0;
|
|
21073
|
-
const fn = applicable(f);
|
|
21074
|
-
return ce.number(
|
|
21075
|
-
limit(
|
|
21076
|
-
(x2) => {
|
|
21077
|
-
const y = fn([ce.number(x2)])?.value;
|
|
21078
|
-
return typeof y === "number" ? y : Number.NaN;
|
|
21079
|
-
},
|
|
21080
|
-
target,
|
|
21081
|
-
dir ? asFloat(dir) ?? 1 : 1
|
|
21082
|
-
)
|
|
21083
|
-
);
|
|
21084
|
-
}
|
|
21085
|
-
}
|
|
21086
|
-
},
|
|
21087
|
-
NLimit: {
|
|
21088
|
-
description: "Numerical approximation of the limit of a function",
|
|
21089
|
-
complexity: 5e3,
|
|
21090
|
-
hold: "all",
|
|
21091
|
-
threadable: false,
|
|
21092
|
-
signature: {
|
|
21093
|
-
domain: [
|
|
21094
|
-
"FunctionOf",
|
|
21095
|
-
"Anything",
|
|
21096
|
-
"Numbers",
|
|
21097
|
-
["OptArg", "Numbers"],
|
|
21098
|
-
"Numbers"
|
|
21099
|
-
],
|
|
21100
|
-
evaluate: (ce, ops2) => {
|
|
21101
|
-
const [f, x, dir] = ops2;
|
|
21102
|
-
const target = asFloat(x.N());
|
|
21103
|
-
if (target === null)
|
|
21104
|
-
return void 0;
|
|
21105
|
-
const fn = applicable(f);
|
|
21106
|
-
return ce.number(
|
|
21107
|
-
limit(
|
|
21108
|
-
(x2) => {
|
|
21109
|
-
const y = fn([ce.number(x2)])?.value;
|
|
21110
|
-
return typeof y === "number" ? y : Number.NaN;
|
|
21111
|
-
},
|
|
21112
|
-
target,
|
|
21113
|
-
dir ? asFloat(dir) ?? 1 : 1
|
|
21114
|
-
)
|
|
21115
|
-
);
|
|
21116
|
-
}
|
|
21117
|
-
}
|
|
21118
21093
|
}
|
|
21119
21094
|
},
|
|
21120
21095
|
//
|
|
@@ -21785,6 +21760,73 @@ var CALCULUS_LIBRARY = [
|
|
|
21785
21760
|
}
|
|
21786
21761
|
}
|
|
21787
21762
|
}
|
|
21763
|
+
},
|
|
21764
|
+
{
|
|
21765
|
+
// Limits
|
|
21766
|
+
Limit: {
|
|
21767
|
+
description: "Limit of a function",
|
|
21768
|
+
complexity: 5e3,
|
|
21769
|
+
hold: "all",
|
|
21770
|
+
threadable: false,
|
|
21771
|
+
signature: {
|
|
21772
|
+
domain: [
|
|
21773
|
+
"FunctionOf",
|
|
21774
|
+
"Anything",
|
|
21775
|
+
"Numbers",
|
|
21776
|
+
["OptArg", "Numbers"],
|
|
21777
|
+
"Numbers"
|
|
21778
|
+
],
|
|
21779
|
+
N: (ce, ops2) => {
|
|
21780
|
+
const [f, x, dir] = ops2;
|
|
21781
|
+
const target = asFloat(x.N());
|
|
21782
|
+
if (target === null)
|
|
21783
|
+
return void 0;
|
|
21784
|
+
const fn = applicable(f);
|
|
21785
|
+
return ce.number(
|
|
21786
|
+
limit(
|
|
21787
|
+
(x2) => {
|
|
21788
|
+
const y = fn([ce.number(x2)])?.value;
|
|
21789
|
+
return typeof y === "number" ? y : Number.NaN;
|
|
21790
|
+
},
|
|
21791
|
+
target,
|
|
21792
|
+
dir ? asFloat(dir) ?? 1 : 1
|
|
21793
|
+
)
|
|
21794
|
+
);
|
|
21795
|
+
}
|
|
21796
|
+
}
|
|
21797
|
+
},
|
|
21798
|
+
NLimit: {
|
|
21799
|
+
description: "Numerical approximation of the limit of a function",
|
|
21800
|
+
complexity: 5e3,
|
|
21801
|
+
hold: "all",
|
|
21802
|
+
threadable: false,
|
|
21803
|
+
signature: {
|
|
21804
|
+
domain: [
|
|
21805
|
+
"FunctionOf",
|
|
21806
|
+
"Anything",
|
|
21807
|
+
"Numbers",
|
|
21808
|
+
["OptArg", "Numbers"],
|
|
21809
|
+
"Numbers"
|
|
21810
|
+
],
|
|
21811
|
+
evaluate: (ce, ops2) => {
|
|
21812
|
+
const [f, x, dir] = ops2;
|
|
21813
|
+
const target = asFloat(x.N());
|
|
21814
|
+
if (target === null)
|
|
21815
|
+
return void 0;
|
|
21816
|
+
const fn = applicable(f);
|
|
21817
|
+
return ce.number(
|
|
21818
|
+
limit(
|
|
21819
|
+
(x2) => {
|
|
21820
|
+
const y = fn([ce.number(x2)])?.value;
|
|
21821
|
+
return typeof y === "number" ? y : Number.NaN;
|
|
21822
|
+
},
|
|
21823
|
+
target,
|
|
21824
|
+
dir ? asFloat(dir) ?? 1 : 1
|
|
21825
|
+
)
|
|
21826
|
+
);
|
|
21827
|
+
}
|
|
21828
|
+
}
|
|
21829
|
+
}
|
|
21788
21830
|
}
|
|
21789
21831
|
];
|
|
21790
21832
|
|
|
@@ -23142,18 +23184,6 @@ var CORE_LIBRARY = [
|
|
|
23142
23184
|
}
|
|
23143
23185
|
}
|
|
23144
23186
|
},
|
|
23145
|
-
Matrix: {
|
|
23146
|
-
complexity: 9e3,
|
|
23147
|
-
hold: "all",
|
|
23148
|
-
signature: {
|
|
23149
|
-
params: ["Lists"],
|
|
23150
|
-
optParams: ["Strings", "Strings"],
|
|
23151
|
-
result: "Lists",
|
|
23152
|
-
canonical: canonicalMatrix,
|
|
23153
|
-
evaluate: (_ce, ops2) => ops2[0].evaluate(),
|
|
23154
|
-
N: (_ce, ops2) => ops2[0].N()
|
|
23155
|
-
}
|
|
23156
|
-
},
|
|
23157
23187
|
Error: {
|
|
23158
23188
|
/**
|
|
23159
23189
|
* - The first argument is either a string or an `["ErrorCode"]`
|
|
@@ -23305,7 +23335,7 @@ var CORE_LIBRARY = [
|
|
|
23305
23335
|
if (!op12.symbol)
|
|
23306
23336
|
return null;
|
|
23307
23337
|
const op22 = args[1];
|
|
23308
|
-
return ce._fn("Assign", [
|
|
23338
|
+
return ce._fn("Assign", [op12, op22]);
|
|
23309
23339
|
},
|
|
23310
23340
|
evaluate: (ce, ops2) => {
|
|
23311
23341
|
const op12 = ops2[0];
|
|
@@ -23401,7 +23431,27 @@ var CORE_LIBRARY = [
|
|
|
23401
23431
|
signature: {
|
|
23402
23432
|
domain: ["FunctionOf", "Anything", "Anything"],
|
|
23403
23433
|
result: (_ce, ops2) => ops2[0].domain,
|
|
23404
|
-
canonical: (ce, ops2) =>
|
|
23434
|
+
canonical: (ce, ops2) => {
|
|
23435
|
+
if (ops2.length !== 1)
|
|
23436
|
+
return ce._fn("N", checkArity(ce, ops2, 1));
|
|
23437
|
+
const h = ops2[0].head;
|
|
23438
|
+
if (h === "N")
|
|
23439
|
+
return ops2[0].canonical;
|
|
23440
|
+
if (h === "Integrate") {
|
|
23441
|
+
const [index, lower, upper] = normalizeLimits(ops2[0].op2);
|
|
23442
|
+
if (!index || lower === void 0 || upper === void 0)
|
|
23443
|
+
return null;
|
|
23444
|
+
const fn = ops2[0].op1;
|
|
23445
|
+
return ce._fn("NIntegrate", [
|
|
23446
|
+
ce.box(["Function", fn, index]),
|
|
23447
|
+
ce.number(lower),
|
|
23448
|
+
ce.number(upper)
|
|
23449
|
+
]);
|
|
23450
|
+
}
|
|
23451
|
+
if (h === "Limit")
|
|
23452
|
+
return ce._fn("NLimit", ops2[0].ops);
|
|
23453
|
+
return ce._fn("N", ops2);
|
|
23454
|
+
},
|
|
23405
23455
|
evaluate: (_ce, ops2) => ops2[0].N()
|
|
23406
23456
|
}
|
|
23407
23457
|
},
|
|
@@ -23644,6 +23694,24 @@ function canonicalInvisibleOperator(ce, ops2) {
|
|
|
23644
23694
|
return ce._fn("Multiply", flattenOps(ops2, "Multiply"));
|
|
23645
23695
|
return ce._fn("Tuple", ops2);
|
|
23646
23696
|
}
|
|
23697
|
+
|
|
23698
|
+
// src/compute-engine/library/linear-algebra.ts
|
|
23699
|
+
var LINEAR_ALGEBRA_LIBRARY = [
|
|
23700
|
+
{
|
|
23701
|
+
Matrix: {
|
|
23702
|
+
complexity: 9e3,
|
|
23703
|
+
hold: "all",
|
|
23704
|
+
signature: {
|
|
23705
|
+
params: ["Lists"],
|
|
23706
|
+
optParams: ["Strings", "Strings"],
|
|
23707
|
+
result: "Lists",
|
|
23708
|
+
canonical: canonicalMatrix,
|
|
23709
|
+
evaluate: (_ce, ops2) => ops2[0].evaluate(),
|
|
23710
|
+
N: (_ce, ops2) => ops2[0].N()
|
|
23711
|
+
}
|
|
23712
|
+
}
|
|
23713
|
+
}
|
|
23714
|
+
];
|
|
23647
23715
|
function canonicalMatrix(ce, ops2) {
|
|
23648
23716
|
if (ops2.length === 0)
|
|
23649
23717
|
return ce._fn("Matrix", []);
|
|
@@ -23659,9 +23727,6 @@ function canonicalMatrix(ce, ops2) {
|
|
|
23659
23727
|
return ce._fn("Matrix", [body]);
|
|
23660
23728
|
}
|
|
23661
23729
|
|
|
23662
|
-
// src/compute-engine/library/linear-algebra.ts
|
|
23663
|
-
var LINEAR_ALGEBRA_LIBRARY = [];
|
|
23664
|
-
|
|
23665
23730
|
// src/compute-engine/library/logic.ts
|
|
23666
23731
|
var LOGIC_LIBRARY = {
|
|
23667
23732
|
True: { wikidata: "Q16751793", domain: "Booleans", constant: true },
|
|
@@ -28783,10 +28848,10 @@ function isFunctionValue(value) {
|
|
|
28783
28848
|
}
|
|
28784
28849
|
|
|
28785
28850
|
// src/compute-engine.ts
|
|
28786
|
-
var version = "0.20.
|
|
28851
|
+
var version = "0.20.2";
|
|
28787
28852
|
globalThis[Symbol.for("io.cortexjs.compute-engine")] = {
|
|
28788
28853
|
ComputeEngine: ComputeEngine.prototype.constructor,
|
|
28789
|
-
version: "0.20.
|
|
28854
|
+
version: "0.20.2"
|
|
28790
28855
|
};
|
|
28791
28856
|
export {
|
|
28792
28857
|
ADDITION_PRECEDENCE,
|