@cortex-js/compute-engine 0.12.4 → 0.12.5
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 +94 -60
- package/dist/compute-engine.js +94 -60
- package/dist/compute-engine.min.esm.js +94 -60
- package/dist/compute-engine.min.js +94 -60
- 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/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 +2 -2
- 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/compute-engine.d.ts +4 -2
- 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/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-core.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-inequalities.d.ts +1 -1
- 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-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 +4 -2
- package/dist/types/compute-engine/latex-syntax/public.d.ts +2 -2
- 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/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/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/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/public.d.ts +5 -3
- 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/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 +1 -1
- package/dist/types/math-json.d.ts +2 -2
- package/package.json +1 -1
package/dist/compute-engine.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** CortexJS Compute Engine 0.12.
|
|
1
|
+
/** CortexJS Compute Engine 0.12.5 */
|
|
2
2
|
(function(global,factory){typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'],factory):(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ComputeEngine = {}));})(this, (function (exports) { 'use strict';
|
|
3
3
|
var ComputeEngine = (() => {
|
|
4
4
|
var __create = Object.create;
|
|
@@ -4608,6 +4608,15 @@ var ComputeEngine = (() => {
|
|
|
4608
4608
|
parse: "ExponentialE",
|
|
4609
4609
|
serialize: "\\exponentialE"
|
|
4610
4610
|
},
|
|
4611
|
+
{
|
|
4612
|
+
kind: "function",
|
|
4613
|
+
trigger: "exp",
|
|
4614
|
+
parse: (parser) => ["Exp", ...parser.matchArguments("enclosure") ?? []]
|
|
4615
|
+
},
|
|
4616
|
+
{
|
|
4617
|
+
trigger: "\\exp",
|
|
4618
|
+
parse: (parser) => ["Exp", ...parser.matchArguments("enclosure") ?? []]
|
|
4619
|
+
},
|
|
4611
4620
|
{
|
|
4612
4621
|
name: "ImaginaryUnit",
|
|
4613
4622
|
trigger: ["\\imaginaryI"]
|
|
@@ -4731,11 +4740,12 @@ var ComputeEngine = (() => {
|
|
|
4731
4740
|
},
|
|
4732
4741
|
{
|
|
4733
4742
|
name: "Exp",
|
|
4734
|
-
serialize: (serializer, expr) =>
|
|
4735
|
-
|
|
4736
|
-
|
|
4737
|
-
|
|
4738
|
-
|
|
4743
|
+
serialize: (serializer, expr) => {
|
|
4744
|
+
const op12 = op(expr, 1);
|
|
4745
|
+
if (symbol(op12) || machineValue(op12) !== null)
|
|
4746
|
+
return joinLatex(["\\exponentialE^{", serializer.serialize(op12)]);
|
|
4747
|
+
return joinLatex(["\\exp", serializer.wrap(missingIfEmpty(op12))]);
|
|
4748
|
+
}
|
|
4739
4749
|
},
|
|
4740
4750
|
{
|
|
4741
4751
|
name: "Factorial",
|
|
@@ -4912,7 +4922,31 @@ var ComputeEngine = (() => {
|
|
|
4912
4922
|
trigger: ["\\pm"],
|
|
4913
4923
|
kind: "infix",
|
|
4914
4924
|
associativity: "both",
|
|
4915
|
-
precedence: 270
|
|
4925
|
+
precedence: 270,
|
|
4926
|
+
serialize: (serializer, expr) => {
|
|
4927
|
+
const op12 = op(expr, 1);
|
|
4928
|
+
if (op12 === null)
|
|
4929
|
+
return "\\pm";
|
|
4930
|
+
if (nops(expr) === 1)
|
|
4931
|
+
return joinLatex(["\\pm", serializer.serialize(op12)]);
|
|
4932
|
+
const op22 = op(expr, 2);
|
|
4933
|
+
return joinLatex([
|
|
4934
|
+
serializer.serialize(op12),
|
|
4935
|
+
"\\pm",
|
|
4936
|
+
serializer.serialize(op22)
|
|
4937
|
+
]);
|
|
4938
|
+
}
|
|
4939
|
+
},
|
|
4940
|
+
{
|
|
4941
|
+
trigger: ["\\pm"],
|
|
4942
|
+
kind: "prefix",
|
|
4943
|
+
precedence: 270,
|
|
4944
|
+
parse: (parser, terminator) => {
|
|
4945
|
+
if (270 < terminator.minPrec)
|
|
4946
|
+
return null;
|
|
4947
|
+
const rhs = parser.matchExpression({ ...terminator, minPrec: 400 });
|
|
4948
|
+
return ["PlusMinus", missingIfEmpty(rhs)];
|
|
4949
|
+
}
|
|
4916
4950
|
},
|
|
4917
4951
|
{
|
|
4918
4952
|
name: "Power",
|
|
@@ -5641,7 +5675,7 @@ var ComputeEngine = (() => {
|
|
|
5641
5675
|
kind: "infix",
|
|
5642
5676
|
associativity: "right",
|
|
5643
5677
|
precedence: 241,
|
|
5644
|
-
parse: "
|
|
5678
|
+
parse: "LessEqual"
|
|
5645
5679
|
},
|
|
5646
5680
|
{
|
|
5647
5681
|
trigger: ["\\leqslant"],
|
|
@@ -7425,7 +7459,7 @@ var ComputeEngine = (() => {
|
|
|
7425
7459
|
message: [
|
|
7426
7460
|
"invalid-dictionary-entry",
|
|
7427
7461
|
indexedEntry.name,
|
|
7428
|
-
"Duplicate definition"
|
|
7462
|
+
"Duplicate definition. The name must be unique, but a trigger can be used by multiple definitions."
|
|
7429
7463
|
]
|
|
7430
7464
|
});
|
|
7431
7465
|
}
|
|
@@ -8722,6 +8756,8 @@ var ComputeEngine = (() => {
|
|
|
8722
8756
|
* - 'enclosure' : will look for an argument inside an enclosure (open/close fence)
|
|
8723
8757
|
* - 'implicit': either an expression inside a pair of `()`, or just a product
|
|
8724
8758
|
* (i.e. we interpret `\cos 2x + 1` as `\cos(2x) + 1`)
|
|
8759
|
+
*
|
|
8760
|
+
* This returns an array of arguments, or null if there is no match.
|
|
8725
8761
|
*/
|
|
8726
8762
|
matchArguments(kind, until) {
|
|
8727
8763
|
if (!kind)
|
|
@@ -8730,23 +8766,15 @@ var ComputeEngine = (() => {
|
|
|
8730
8766
|
return null;
|
|
8731
8767
|
const savedIndex = this.index;
|
|
8732
8768
|
const group = this.matchEnclosure();
|
|
8733
|
-
if (kind === "enclosure"
|
|
8734
|
-
|
|
8735
|
-
return ops(op(group, 1)) ?? [];
|
|
8736
|
-
return [op(group, 1) ?? ["Sequence"]];
|
|
8737
|
-
}
|
|
8769
|
+
if (kind === "enclosure")
|
|
8770
|
+
return getSequence(group) ?? [];
|
|
8738
8771
|
if (kind === "implicit") {
|
|
8739
|
-
if (head(group) === "Delimiter")
|
|
8740
|
-
|
|
8741
|
-
return getSequence(group) ?? [];
|
|
8742
|
-
return [op(group, 1) ?? ["Sequence"]];
|
|
8743
|
-
}
|
|
8772
|
+
if (head(group) === "Delimiter")
|
|
8773
|
+
return getSequence(group) ?? [];
|
|
8744
8774
|
if (group !== null)
|
|
8745
8775
|
return [group];
|
|
8746
8776
|
const primary = this.matchExpression({ ...until, minPrec: 390 });
|
|
8747
|
-
|
|
8748
|
-
return [primary];
|
|
8749
|
-
return null;
|
|
8777
|
+
return primary === null ? null : [primary];
|
|
8750
8778
|
}
|
|
8751
8779
|
this.index = savedIndex;
|
|
8752
8780
|
return null;
|
|
@@ -8766,7 +8794,7 @@ var ComputeEngine = (() => {
|
|
|
8766
8794
|
fn = pf;
|
|
8767
8795
|
} while (true);
|
|
8768
8796
|
const seq = this.matchArguments("enclosure");
|
|
8769
|
-
return seq ? [fn, ...seq] :
|
|
8797
|
+
return seq ? [fn, ...seq] : fn;
|
|
8770
8798
|
}
|
|
8771
8799
|
/** A prime suffix is a sequence of `'`, `\prime` or `\doubleprime`
|
|
8772
8800
|
* after a function or in a superscript.
|
|
@@ -9175,7 +9203,7 @@ var ComputeEngine = (() => {
|
|
|
9175
9203
|
this.index = index;
|
|
9176
9204
|
return result;
|
|
9177
9205
|
}
|
|
9178
|
-
matchPostfix(lhs) {
|
|
9206
|
+
matchPostfix(lhs, until) {
|
|
9179
9207
|
console.assert(lhs !== null);
|
|
9180
9208
|
if (lhs === null)
|
|
9181
9209
|
return null;
|
|
@@ -9185,7 +9213,7 @@ var ComputeEngine = (() => {
|
|
|
9185
9213
|
const start = this.index;
|
|
9186
9214
|
for (const [def, n] of defs) {
|
|
9187
9215
|
this.index = start + n;
|
|
9188
|
-
const result = def.parse(this, lhs);
|
|
9216
|
+
const result = def.parse(this, lhs, until);
|
|
9189
9217
|
if (result !== null)
|
|
9190
9218
|
return result;
|
|
9191
9219
|
}
|
|
@@ -9531,7 +9559,7 @@ var ComputeEngine = (() => {
|
|
|
9531
9559
|
let postfix = null;
|
|
9532
9560
|
let index = this.index;
|
|
9533
9561
|
do {
|
|
9534
|
-
postfix = this.matchPostfix(result);
|
|
9562
|
+
postfix = this.matchPostfix(result, until);
|
|
9535
9563
|
result = postfix ?? result;
|
|
9536
9564
|
if (this.index === index && postfix !== null) {
|
|
9537
9565
|
console.assert(this.index !== index, "No token consumed");
|
|
@@ -15392,7 +15420,7 @@ var ComputeEngine = (() => {
|
|
|
15392
15420
|
const ce = expr.engine;
|
|
15393
15421
|
if (expr.op1.head === "Negate") {
|
|
15394
15422
|
const sign2 = exp2 % 2 === 0 ? 1 : -1;
|
|
15395
|
-
const result2 = expandMultinomial(ce.
|
|
15423
|
+
const result2 = expandMultinomial(ce.pow(expr.op1.op1, expr.op2));
|
|
15396
15424
|
if (result2 === null)
|
|
15397
15425
|
return null;
|
|
15398
15426
|
if (sign2 > 0)
|
|
@@ -15617,15 +15645,14 @@ var ComputeEngine = (() => {
|
|
|
15617
15645
|
const sols = findUnivariateRoots(proposition, lhs2);
|
|
15618
15646
|
if (sols.length === 0) {
|
|
15619
15647
|
ce.assumptions.set(
|
|
15620
|
-
ce.
|
|
15621
|
-
"Equal",
|
|
15648
|
+
ce.fn("Equal", [
|
|
15622
15649
|
ce.add([proposition.op1.canonical, ce.neg(proposition.op2.canonical)]).simplify(),
|
|
15623
15650
|
0
|
|
15624
15651
|
]),
|
|
15625
15652
|
true
|
|
15626
15653
|
);
|
|
15627
15654
|
}
|
|
15628
|
-
const val = sols.length === 1 ? sols[0] : ce.
|
|
15655
|
+
const val = sols.length === 1 ? sols[0] : ce.fn("List", sols);
|
|
15629
15656
|
const def = ce.lookupSymbol(lhs2);
|
|
15630
15657
|
if (!def) {
|
|
15631
15658
|
ce.defineSymbol(lhs2, { value: val });
|
|
@@ -16607,7 +16634,6 @@ var ComputeEngine = (() => {
|
|
|
16607
16634
|
return result;
|
|
16608
16635
|
}
|
|
16609
16636
|
solve(vars) {
|
|
16610
|
-
console.log("solve this:", this.toString());
|
|
16611
16637
|
if (vars.length !== 1)
|
|
16612
16638
|
return null;
|
|
16613
16639
|
const roots = findUnivariateRoots(this.simplify(), vars[0]);
|
|
@@ -16686,6 +16712,8 @@ var ComputeEngine = (() => {
|
|
|
16686
16712
|
xs.push(y);
|
|
16687
16713
|
}
|
|
16688
16714
|
}
|
|
16715
|
+
if (!xs.every((x) => x.isValid))
|
|
16716
|
+
return new BoxedFunction(ce, head2, xs, { metadata, canonical: false });
|
|
16689
16717
|
const sig = def.signature;
|
|
16690
16718
|
if (sig.canonical) {
|
|
16691
16719
|
try {
|
|
@@ -16716,21 +16744,22 @@ var ComputeEngine = (() => {
|
|
|
16716
16744
|
return new BoxedFunction(ce, head2, xs, { metadata, def, canonical: true });
|
|
16717
16745
|
}
|
|
16718
16746
|
function apply(fn, args) {
|
|
16747
|
+
const ce = fn.engine;
|
|
16719
16748
|
if (fn.head !== "Lambda")
|
|
16720
|
-
return
|
|
16749
|
+
return ce._fn(fn.evaluate(), args);
|
|
16721
16750
|
const subs2 = {
|
|
16722
|
-
"__":
|
|
16723
|
-
"_#":
|
|
16751
|
+
"__": ce.tuple(args),
|
|
16752
|
+
"_#": ce.number(args.length)
|
|
16724
16753
|
};
|
|
16725
16754
|
let n = 1;
|
|
16726
16755
|
for (const op3 of args)
|
|
16727
16756
|
subs2[`_${n++}`] = op3;
|
|
16728
16757
|
subs2["_"] = subs2["_1"];
|
|
16729
|
-
const savedContext =
|
|
16730
|
-
|
|
16731
|
-
const result = fn.subs(subs2)
|
|
16732
|
-
|
|
16733
|
-
return result;
|
|
16758
|
+
const savedContext = ce.context;
|
|
16759
|
+
ce.context = fn.scope ?? null;
|
|
16760
|
+
const result = fn.subs(subs2);
|
|
16761
|
+
ce.context = savedContext;
|
|
16762
|
+
return result.op1.evaluate();
|
|
16734
16763
|
}
|
|
16735
16764
|
function holdMap(xs, skip, associativeHead, f) {
|
|
16736
16765
|
if (xs.length === 0)
|
|
@@ -18845,7 +18874,7 @@ var ComputeEngine = (() => {
|
|
|
18845
18874
|
return ce._NEGATIVE_INFINITY;
|
|
18846
18875
|
if (ops2.length === 1)
|
|
18847
18876
|
return ops2[0];
|
|
18848
|
-
return ce.
|
|
18877
|
+
return ce.fn("Max", ops2);
|
|
18849
18878
|
},
|
|
18850
18879
|
evaluate: (ce, ops2) => {
|
|
18851
18880
|
if (ops2.length === 0)
|
|
@@ -18874,7 +18903,7 @@ var ComputeEngine = (() => {
|
|
|
18874
18903
|
return ce._NEGATIVE_INFINITY;
|
|
18875
18904
|
if (ops2.length === 1)
|
|
18876
18905
|
return ops2[0];
|
|
18877
|
-
return ce.
|
|
18906
|
+
return ce.fn("Min", ops2);
|
|
18878
18907
|
},
|
|
18879
18908
|
evaluate: (ce, ops2) => {
|
|
18880
18909
|
if (ops2.length === 0)
|
|
@@ -19215,7 +19244,7 @@ var ComputeEngine = (() => {
|
|
|
19215
19244
|
e: {
|
|
19216
19245
|
domain: "TranscendentalNumber",
|
|
19217
19246
|
constant: true,
|
|
19218
|
-
holdUntil: "
|
|
19247
|
+
holdUntil: "N",
|
|
19219
19248
|
value: "ExponentialE"
|
|
19220
19249
|
},
|
|
19221
19250
|
i: {
|
|
@@ -19241,14 +19270,13 @@ var ComputeEngine = (() => {
|
|
|
19241
19270
|
},
|
|
19242
19271
|
Half: {
|
|
19243
19272
|
constant: true,
|
|
19244
|
-
holdUntil: "
|
|
19273
|
+
holdUntil: "evaluate",
|
|
19245
19274
|
value: ["Rational", 1, 2]
|
|
19246
19275
|
},
|
|
19247
19276
|
ImaginaryUnit: {
|
|
19248
19277
|
domain: "ImaginaryNumber",
|
|
19249
19278
|
constant: true,
|
|
19250
|
-
holdUntil: "
|
|
19251
|
-
// @todo maybe?
|
|
19279
|
+
holdUntil: "never",
|
|
19252
19280
|
wikidata: "Q193796",
|
|
19253
19281
|
flags: { imaginary: true },
|
|
19254
19282
|
value: ["Complex", 0, 1]
|
|
@@ -20076,8 +20104,7 @@ var ComputeEngine = (() => {
|
|
|
20076
20104
|
signature: {
|
|
20077
20105
|
domain: ["Function", ["Maybe", ["Sequence", "Anything"]], "String"],
|
|
20078
20106
|
evaluate: (ce, ops2) => {
|
|
20079
|
-
return ce.
|
|
20080
|
-
"Latex",
|
|
20107
|
+
return ce.fn("Latex", [
|
|
20081
20108
|
ce.string(tokensToString(ops2.map((x) => x.string ?? x.latex)))
|
|
20082
20109
|
]);
|
|
20083
20110
|
}
|
|
@@ -20100,7 +20127,7 @@ var ComputeEngine = (() => {
|
|
|
20100
20127
|
hold: "all",
|
|
20101
20128
|
signature: {
|
|
20102
20129
|
domain: ["Function", ["Maybe", ["Sequence", "Anything"]], "String"],
|
|
20103
|
-
evaluate: (ce, ops2) => ce.
|
|
20130
|
+
evaluate: (ce, ops2) => ce.fn("Latex", [ce.string(joinLatex(ops2.map((x) => x.latex)))])
|
|
20104
20131
|
}
|
|
20105
20132
|
},
|
|
20106
20133
|
SplitAsLatexTokens: {
|
|
@@ -20937,13 +20964,13 @@ var ComputeEngine = (() => {
|
|
|
20937
20964
|
"Number"
|
|
20938
20965
|
]);
|
|
20939
20966
|
if (ops2.length !== 1)
|
|
20940
|
-
return ce.
|
|
20967
|
+
return ce.fn("Degrees", ops2, { canonical: false });
|
|
20941
20968
|
const arg = ops2[0];
|
|
20942
20969
|
if (arg.numericValue === null || !arg.isValid)
|
|
20943
|
-
return ce.
|
|
20970
|
+
return ce.fn("Degrees", ops2, { canonical: false });
|
|
20944
20971
|
return ce.div(ce.mul([arg, ce.symbol("Pi")]), ce.number(180));
|
|
20945
20972
|
},
|
|
20946
|
-
evaluate: (ce, ops2) => ce.mul([ops2[0], ce.
|
|
20973
|
+
evaluate: (ce, ops2) => ce.mul([ops2[0], ce.div(ce.symbol("Pi"), ce.number(180))])
|
|
20947
20974
|
}
|
|
20948
20975
|
},
|
|
20949
20976
|
Hypot: {
|
|
@@ -21463,6 +21490,8 @@ var ComputeEngine = (() => {
|
|
|
21463
21490
|
]
|
|
21464
21491
|
};
|
|
21465
21492
|
function constructibleValues(ce, head2, x) {
|
|
21493
|
+
if (!x)
|
|
21494
|
+
return void 0;
|
|
21466
21495
|
const specialValues = ce.cache(
|
|
21467
21496
|
"constructible-trigonometric-values",
|
|
21468
21497
|
() => {
|
|
@@ -21539,6 +21568,8 @@ var ComputeEngine = (() => {
|
|
|
21539
21568
|
return newHead ? ce.symbol(newHead) : void 0;
|
|
21540
21569
|
}
|
|
21541
21570
|
function evalTrig(ce, mode, head2, op3) {
|
|
21571
|
+
if (!op3)
|
|
21572
|
+
return void 0;
|
|
21542
21573
|
if (mode === "evaluate") {
|
|
21543
21574
|
const result = constructibleValues(ce, head2, op3)?.evaluate();
|
|
21544
21575
|
if (result)
|
|
@@ -21736,7 +21767,7 @@ var ComputeEngine = (() => {
|
|
|
21736
21767
|
this._flags = def.flags ? normalizeFlags(def.flags) : void 0;
|
|
21737
21768
|
this._domain = def.domain ? ce.domain(def.domain) : void 0;
|
|
21738
21769
|
this.constant = def.constant ?? false;
|
|
21739
|
-
this.holdUntil = def.holdUntil ?? "
|
|
21770
|
+
this.holdUntil = def.holdUntil ?? "evaluate";
|
|
21740
21771
|
if (this.constant) {
|
|
21741
21772
|
this._defValue = def.value;
|
|
21742
21773
|
this._value = null;
|
|
@@ -23392,17 +23423,20 @@ ${JSON.stringify(entry)}`
|
|
|
23392
23423
|
}
|
|
23393
23424
|
simplify(options) {
|
|
23394
23425
|
const def = this.symbolDefinition;
|
|
23395
|
-
if (
|
|
23426
|
+
if (def?.holdUntil === "simplify" && def.value)
|
|
23396
23427
|
return def.value.simplify(options);
|
|
23397
23428
|
return options?.rules ? this.replace(options.rules) ?? this : this;
|
|
23398
23429
|
}
|
|
23399
23430
|
evaluate(options) {
|
|
23400
23431
|
const def = this.symbolDefinition;
|
|
23401
|
-
if (def
|
|
23402
|
-
return def
|
|
23432
|
+
if (def && (def.holdUntil === "simplify" || def.holdUntil === "evaluate"))
|
|
23433
|
+
return def.value?.evaluate(options) ?? this;
|
|
23403
23434
|
return this;
|
|
23404
23435
|
}
|
|
23405
23436
|
N(options) {
|
|
23437
|
+
const def = this.symbolDefinition;
|
|
23438
|
+
if (def && def.holdUntil === "never")
|
|
23439
|
+
return this;
|
|
23406
23440
|
return this.symbolDefinition?.value?.N(options) ?? this;
|
|
23407
23441
|
}
|
|
23408
23442
|
replace(rules, options) {
|
|
@@ -23815,7 +23849,7 @@ ${JSON.stringify(entry)}`
|
|
|
23815
23849
|
precision: this.precision,
|
|
23816
23850
|
avoidExponentsInRange: [-6, this.precision],
|
|
23817
23851
|
onError: (err) => {
|
|
23818
|
-
throw new Error(err[0].message
|
|
23852
|
+
throw new Error(JSON.stringify(err[0].message));
|
|
23819
23853
|
}
|
|
23820
23854
|
});
|
|
23821
23855
|
return this._latexSyntax;
|
|
@@ -24079,8 +24113,8 @@ ${JSON.stringify(entry)}`
|
|
|
24079
24113
|
const bxs = xs;
|
|
24080
24114
|
return bxs.every((x) => x.isCanonical) ? bxs : bxs.map((x) => x.canonical);
|
|
24081
24115
|
}
|
|
24082
|
-
fn(head2, ops2,
|
|
24083
|
-
return boxFunction(this, head2, ops2, {
|
|
24116
|
+
fn(head2, ops2, options) {
|
|
24117
|
+
return boxFunction(this, head2, ops2, options ?? { canonical: true });
|
|
24084
24118
|
}
|
|
24085
24119
|
/** @internal */
|
|
24086
24120
|
_fn(head2, ops2, metadata) {
|
|
@@ -24494,10 +24528,10 @@ ${JSON.stringify(entry)}`
|
|
|
24494
24528
|
};
|
|
24495
24529
|
|
|
24496
24530
|
// src/compute-engine.ts
|
|
24497
|
-
var version = "0.12.
|
|
24531
|
+
var version = "0.12.5";
|
|
24498
24532
|
globalThis[Symbol.for("io.cortexjs.compute-engine")] = {
|
|
24499
24533
|
ComputeEngine: ComputeEngine.prototype.constructor,
|
|
24500
|
-
version: "0.12.
|
|
24534
|
+
version: "0.12.5"
|
|
24501
24535
|
};
|
|
24502
24536
|
return __toCommonJS(compute_engine_exports);
|
|
24503
24537
|
})();
|