@cortex-js/compute-engine 0.35.1 → 0.35.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 +101 -54
- package/dist/compute-engine.min.esm.js +40 -40
- package/dist/compute-engine.min.umd.js +40 -40
- package/dist/compute-engine.umd.js +101 -54
- package/dist/math-json.esm.js +2 -2
- package/dist/math-json.min.esm.js +2 -2
- package/dist/math-json.min.umd.js +2 -2
- package/dist/math-json.umd.js +2 -2
- package/dist/types/common/ansi-codes.d.ts +1 -1
- package/dist/types/common/configuration-change.d.ts +1 -1
- package/dist/types/common/fuzzy-string-match.d.ts +1 -1
- package/dist/types/common/grapheme-splitter.d.ts +1 -1
- package/dist/types/common/interruptible.d.ts +1 -1
- package/dist/types/common/one-of.d.ts +1 -1
- package/dist/types/common/signals.d.ts +1 -1
- package/dist/types/common/type/ast-nodes.d.ts +1 -1
- package/dist/types/common/type/boxed-type.d.ts +1 -1
- package/dist/types/common/type/lexer.d.ts +1 -1
- package/dist/types/common/type/parse.d.ts +1 -1
- package/dist/types/common/type/parser.d.ts +1 -1
- package/dist/types/common/type/primitive.d.ts +1 -1
- package/dist/types/common/type/reduce.d.ts +1 -1
- package/dist/types/common/type/serialize.d.ts +1 -1
- package/dist/types/common/type/subtype.d.ts +1 -1
- package/dist/types/common/type/type-builder.d.ts +1 -1
- package/dist/types/common/type/types.d.ts +1 -1
- package/dist/types/common/type/utils.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/apply.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/arithmetic-add.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/arithmetic-mul-div.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/arithmetic-power.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/ascii-math.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-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-operator-definition.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.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-tensor.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-value-definition.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/cache.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/canonical-utils.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/canonical.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/compare.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/expand.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/factor.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/flatten.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/hold.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/match.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/negate.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/numerics.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/order.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/polynomials.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/product.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/rules.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/serialize.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/sgn.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/simplify.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/solve-linear-system.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/solve.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/terms.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/trigonometry.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/compilation/base-compiler.d.ts +1 -1
- package/dist/types/compute-engine/compilation/glsl-target.d.ts +1 -1
- package/dist/types/compute-engine/compilation/interval-glsl-target.d.ts +1 -1
- package/dist/types/compute-engine/compilation/interval-javascript-target.d.ts +1 -1
- package/dist/types/compute-engine/compilation/javascript-target.d.ts +1 -1
- package/dist/types/compute-engine/compilation/types.d.ts +1 -1
- package/dist/types/compute-engine/cost-function.d.ts +1 -1
- package/dist/types/compute-engine/function-utils.d.ts +1 -1
- package/dist/types/compute-engine/global-types.d.ts +1 -1
- package/dist/types/compute-engine/index.d.ts +1 -1
- package/dist/types/compute-engine/interval/arithmetic.d.ts +1 -1
- package/dist/types/compute-engine/interval/comparison.d.ts +1 -1
- package/dist/types/compute-engine/interval/elementary.d.ts +1 -1
- package/dist/types/compute-engine/interval/index.d.ts +1 -1
- package/dist/types/compute-engine/interval/trigonometric.d.ts +1 -1
- package/dist/types/compute-engine/interval/types.d.ts +1 -1
- package/dist/types/compute-engine/interval/util.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 +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-linear-algebra.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-relational-operators.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/parse-symbol.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/parse.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/latex-syntax/types.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/utils.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/combinatorics.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/invisible-operator.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-analysis.d.ts +1 -1
- package/dist/types/compute-engine/library/logic-utils.d.ts +1 -1
- package/dist/types/compute-engine/library/logic.d.ts +1 -1
- package/dist/types/compute-engine/library/number-theory.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/numeric-value/big-numeric-value.d.ts +1 -1
- package/dist/types/compute-engine/numeric-value/exact-numeric-value.d.ts +1 -1
- package/dist/types/compute-engine/numeric-value/machine-numeric-value.d.ts +1 -1
- package/dist/types/compute-engine/numeric-value/types.d.ts +1 -1
- package/dist/types/compute-engine/numerics/bigint.d.ts +1 -1
- package/dist/types/compute-engine/numerics/expression.d.ts +1 -1
- package/dist/types/compute-engine/numerics/interval.d.ts +1 -1
- package/dist/types/compute-engine/numerics/monte-carlo.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/numerics/special-functions.d.ts +1 -1
- package/dist/types/compute-engine/numerics/statistics.d.ts +1 -1
- package/dist/types/compute-engine/numerics/strings.d.ts +1 -1
- package/dist/types/compute-engine/numerics/types.d.ts +1 -1
- package/dist/types/compute-engine/oeis.d.ts +1 -1
- package/dist/types/compute-engine/sequence.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/antiderivative.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/derivative.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/distribute.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/fu-cost.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/fu-transforms.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/fu.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-abs.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-divide.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-hyperbolic.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-infinity.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-log.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-power.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-product.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-rules.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-sum.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-trig.d.ts +1 -1
- package/dist/types/compute-engine/tensor/tensor-fields.d.ts +1 -1
- package/dist/types/compute-engine/tensor/tensors.d.ts +1 -1
- package/dist/types/compute-engine/types.d.ts +1 -1
- package/dist/types/compute-engine.d.ts +1 -1
- package/dist/types/math-json/symbols.d.ts +1 -1
- package/dist/types/math-json/types.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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Compute Engine 0.35.
|
|
1
|
+
/** Compute Engine 0.35.2 */
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
@@ -5441,15 +5441,14 @@ function bigint(a) {
|
|
|
5441
5441
|
}
|
|
5442
5442
|
if (a instanceof Decimal) {
|
|
5443
5443
|
if (!a.isInteger()) return null;
|
|
5444
|
-
return
|
|
5444
|
+
return BigInt(a.toFixed(0));
|
|
5445
5445
|
}
|
|
5446
5446
|
let s = a.toLowerCase();
|
|
5447
|
-
const m = s.match(
|
|
5447
|
+
const m = s.match(/^([+-]?[0-9]+)e([+-]?[0-9]+)$/);
|
|
5448
5448
|
if (m) {
|
|
5449
|
-
const exp3 = parseInt(m[
|
|
5450
|
-
|
|
5451
|
-
|
|
5452
|
-
s = (m[1] ?? "") + (m[2] ?? "") + "0".repeat(pad);
|
|
5449
|
+
const exp3 = parseInt(m[2]);
|
|
5450
|
+
if (exp3 < 0) return null;
|
|
5451
|
+
s = m[1] + "0".repeat(exp3);
|
|
5453
5452
|
}
|
|
5454
5453
|
const i = s.indexOf(".");
|
|
5455
5454
|
if (i >= 0) return null;
|
|
@@ -9760,6 +9759,23 @@ function serializeScientificNotationNumber(valString, options, expMultiple = 1)
|
|
|
9760
9759
|
if (!m) return serializeAutoNotationNumber(valString, options);
|
|
9761
9760
|
let exponent = parseInt(m[2]);
|
|
9762
9761
|
let mantissa = m[1];
|
|
9762
|
+
{
|
|
9763
|
+
const signMatch = mantissa.match(/^(-?)/);
|
|
9764
|
+
const sign3 = signMatch ? signMatch[1] : "";
|
|
9765
|
+
const unsigned = sign3 ? mantissa.substring(1) : mantissa;
|
|
9766
|
+
const parts = unsigned.match(/^(\d+)(?:\.(\d*))?$/);
|
|
9767
|
+
if (parts) {
|
|
9768
|
+
let whole = parts[1];
|
|
9769
|
+
let fraction = parts[2] ?? "";
|
|
9770
|
+
if (whole.length > 1) {
|
|
9771
|
+
fraction = whole.slice(1) + fraction;
|
|
9772
|
+
exponent += whole.length - 1;
|
|
9773
|
+
whole = whole[0];
|
|
9774
|
+
}
|
|
9775
|
+
mantissa = sign3 + whole;
|
|
9776
|
+
if (fraction) mantissa += "." + fraction;
|
|
9777
|
+
}
|
|
9778
|
+
}
|
|
9763
9779
|
if (Math.abs(exponent) % expMultiple !== 0) {
|
|
9764
9780
|
const adjust = exponent > 0 ? exponent % expMultiple : -((expMultiple + exponent) % expMultiple);
|
|
9765
9781
|
exponent = exponent >= 0 ? exponent - adjust : exponent + adjust;
|
|
@@ -11718,7 +11734,8 @@ var init_exact_numeric_value = __esm({
|
|
|
11718
11734
|
}
|
|
11719
11735
|
} else {
|
|
11720
11736
|
console.assert(isSubtype(value.type, "integer"));
|
|
11721
|
-
|
|
11737
|
+
const intValue = BigInt(value.bignumRe.toFixed(0));
|
|
11738
|
+
rationalSum = add2(rationalSum, [intValue, BigInt(1)]);
|
|
11722
11739
|
}
|
|
11723
11740
|
}
|
|
11724
11741
|
if (isZero(rationalSum) && radicals.length === 0) {
|
|
@@ -12084,11 +12101,14 @@ function canonicalDivide(op1, op2) {
|
|
|
12084
12101
|
const ce = op1.engine;
|
|
12085
12102
|
if (!op1.isValid || !op2.isValid) return ce._fn("Divide", [op1, op2]);
|
|
12086
12103
|
if (op1.isNaN || op2.isNaN) return ce.NaN;
|
|
12087
|
-
const op2IsConstantExpression = op2.
|
|
12104
|
+
const op2IsConstantExpression = op2.unknowns.length === 0 && !op2.isNumberLiteral;
|
|
12088
12105
|
if (op2.is(0)) return op1.is(0) ? ce.NaN : ce.ComplexInfinity;
|
|
12089
12106
|
if (op1.is(0) && op2.isFinite !== false) {
|
|
12090
12107
|
if (op2IsConstantExpression)
|
|
12091
|
-
return ce.
|
|
12108
|
+
return ce.function("Divide", [op1, op2], {
|
|
12109
|
+
canonical: false,
|
|
12110
|
+
structural: true
|
|
12111
|
+
});
|
|
12092
12112
|
return ce.Zero;
|
|
12093
12113
|
}
|
|
12094
12114
|
if (op2.isInfinity) return op1.isInfinity ? ce.NaN : ce.Zero;
|
|
@@ -12097,7 +12117,10 @@ function canonicalDivide(op1, op2) {
|
|
|
12097
12117
|
return ce.One;
|
|
12098
12118
|
if (op1.isSame(op2)) {
|
|
12099
12119
|
if (op2IsConstantExpression)
|
|
12100
|
-
return ce.
|
|
12120
|
+
return ce.function("Divide", [op1, op2], {
|
|
12121
|
+
canonical: false,
|
|
12122
|
+
structural: true
|
|
12123
|
+
});
|
|
12101
12124
|
return ce.One;
|
|
12102
12125
|
}
|
|
12103
12126
|
}
|
|
@@ -15248,7 +15271,7 @@ function asRadical(expr) {
|
|
|
15248
15271
|
}
|
|
15249
15272
|
function canonicalPower(a, b) {
|
|
15250
15273
|
const ce = a.engine;
|
|
15251
|
-
const fullyCanonical = a.isCanonical && b.isCanonical;
|
|
15274
|
+
const fullyCanonical = (a.isCanonical || a.isStructural) && (b.isCanonical || b.isStructural);
|
|
15252
15275
|
const unchanged = () => ce._fn("Power", [a, b], { canonical: fullyCanonical });
|
|
15253
15276
|
if (a.operator === "Power") {
|
|
15254
15277
|
const [base, aPow] = a.ops;
|
|
@@ -15294,7 +15317,7 @@ function canonicalPower(a, b) {
|
|
|
15294
15317
|
if (a.is(-1)) return ce.NegativeOne;
|
|
15295
15318
|
if (a.is(1)) return ce.One;
|
|
15296
15319
|
}
|
|
15297
|
-
if (!a.isCanonical)
|
|
15320
|
+
if (!(a.isCanonical || a.isStructural))
|
|
15298
15321
|
return ce._fn("Power", [a, ce.number(-1)], { canonical: false });
|
|
15299
15322
|
return a.inv();
|
|
15300
15323
|
}
|
|
@@ -15350,10 +15373,10 @@ function canonicalPower(a, b) {
|
|
|
15350
15373
|
}
|
|
15351
15374
|
}
|
|
15352
15375
|
if (b.is(0.5))
|
|
15353
|
-
return a.isCanonical ? canonicalRoot(a, 2) : ce._fn("Sqrt", [a], { canonical: false });
|
|
15376
|
+
return a.isCanonical || a.isStructural ? canonicalRoot(a, 2) : ce._fn("Sqrt", [a], { canonical: false });
|
|
15354
15377
|
const r = asRational(b);
|
|
15355
15378
|
if (r !== void 0 && r[0] === 1 && r[1] !== 1)
|
|
15356
|
-
return a.isCanonical ? canonicalRoot(a, ce.number(r[1])) : ce._fn("Root", [a, ce.number(r[1])], { canonical: false });
|
|
15379
|
+
return a.isCanonical || a.isStructural ? canonicalRoot(a, ce.number(r[1])) : ce._fn("Root", [a, ce.number(r[1])], { canonical: false });
|
|
15357
15380
|
return unchanged();
|
|
15358
15381
|
}
|
|
15359
15382
|
function canonicalRoot(a, b) {
|
|
@@ -15372,14 +15395,14 @@ function canonicalRoot(a, b) {
|
|
|
15372
15395
|
if (v.numericValue.isExact) return v;
|
|
15373
15396
|
}
|
|
15374
15397
|
}
|
|
15375
|
-
return ce._fn("Sqrt", [a], { canonical: a.isCanonical });
|
|
15398
|
+
return ce._fn("Sqrt", [a], { canonical: a.isCanonical || a.isStructural });
|
|
15376
15399
|
}
|
|
15377
15400
|
return ce._fn("Root", [a, typeof b === "number" ? ce.number(b) : b], {
|
|
15378
|
-
canonical: a.isCanonical && (typeof b === "number" || b.isCanonical)
|
|
15401
|
+
canonical: (a.isCanonical || a.isStructural) && (typeof b === "number" || b.isCanonical || b.isStructural)
|
|
15379
15402
|
});
|
|
15380
15403
|
}
|
|
15381
15404
|
function pow2(x, exp3, { numericApproximation }) {
|
|
15382
|
-
if (!x.isCanonical || typeof exp3 !== "number" && !exp3.isCanonical)
|
|
15405
|
+
if (!(x.isCanonical || x.isStructural) || typeof exp3 !== "number" && !(exp3.isCanonical || exp3.isStructural))
|
|
15383
15406
|
return x.engine._fn("Power", [x, x.engine.box(exp3)], { canonical: false });
|
|
15384
15407
|
if (numericApproximation) {
|
|
15385
15408
|
if (x.isNumberLiteral) {
|
|
@@ -15475,7 +15498,7 @@ function pow2(x, exp3, { numericApproximation }) {
|
|
|
15475
15498
|
return ce._fn("Power", [x, ce.box(exp3)]);
|
|
15476
15499
|
}
|
|
15477
15500
|
function root(a, b, { numericApproximation }) {
|
|
15478
|
-
if (!a.isCanonical || !b.isCanonical)
|
|
15501
|
+
if (!(a.isCanonical || a.isStructural) || !(b.isCanonical || b.isStructural))
|
|
15479
15502
|
return a.engine._fn("Root", [a, b], { canonical: false });
|
|
15480
15503
|
if (numericApproximation) {
|
|
15481
15504
|
if (a.isNumberLiteral && b.isNumberLiteral) {
|
|
@@ -15681,7 +15704,7 @@ function order(a, b) {
|
|
|
15681
15704
|
return (a.complexity ?? DEFAULT_COMPLEXITY) - (b.complexity ?? DEFAULT_COMPLEXITY);
|
|
15682
15705
|
}
|
|
15683
15706
|
function canonicalOrder(expr, { recursive = false }) {
|
|
15684
|
-
if (expr.isCanonical || !expr.ops) return expr;
|
|
15707
|
+
if (expr.isCanonical || expr.isStructural || !expr.ops) return expr;
|
|
15685
15708
|
let ops = expr.ops;
|
|
15686
15709
|
if (recursive) ops = ops.map((x) => canonicalOrder(x, { recursive }));
|
|
15687
15710
|
ops = sortOperands(expr.operator, ops);
|
|
@@ -23795,6 +23818,24 @@ var init_utils5 = __esm({
|
|
|
23795
23818
|
});
|
|
23796
23819
|
|
|
23797
23820
|
// src/compute-engine/boxed-expression/validate.ts
|
|
23821
|
+
function typeCouldBeCollection(type2) {
|
|
23822
|
+
if (typeof type2 === "string") {
|
|
23823
|
+
return type2 === "collection" || type2 === "indexed_collection" || type2 === "list" || type2 === "set" || type2 === "tuple" || type2 === "any";
|
|
23824
|
+
}
|
|
23825
|
+
if (type2.kind === "list" || type2.kind === "set" || type2.kind === "tuple")
|
|
23826
|
+
return true;
|
|
23827
|
+
if (type2.kind === "union") return type2.types.some((t) => typeCouldBeCollection(t));
|
|
23828
|
+
return false;
|
|
23829
|
+
}
|
|
23830
|
+
function typeCouldBeNumericCollection(type2) {
|
|
23831
|
+
if (typeof type2 === "string") {
|
|
23832
|
+
return type2 === "list" || type2 === "set" || type2 === "collection" || type2 === "indexed_collection";
|
|
23833
|
+
}
|
|
23834
|
+
if (type2.kind === "list" || type2.kind === "set") return true;
|
|
23835
|
+
if (type2.kind === "union")
|
|
23836
|
+
return type2.types.some((t) => typeCouldBeNumericCollection(t));
|
|
23837
|
+
return false;
|
|
23838
|
+
}
|
|
23798
23839
|
function checkArity(ce, ops, count) {
|
|
23799
23840
|
ops = flatten(ops);
|
|
23800
23841
|
if (!ce.strict) return ops;
|
|
@@ -23844,7 +23885,9 @@ function checkNumericArgs(ce, ops, options) {
|
|
|
23844
23885
|
xs.push(op);
|
|
23845
23886
|
} else if (op.symbol && !ce.lookupDefinition(op.symbol)) {
|
|
23846
23887
|
xs.push(op);
|
|
23847
|
-
} else if (op.type.isUnknown) {
|
|
23888
|
+
} else if (op.type.isUnknown || op.type.type === "any") {
|
|
23889
|
+
xs.push(op);
|
|
23890
|
+
} else if (typeCouldBeNumericCollection(op.type.type)) {
|
|
23848
23891
|
xs.push(op);
|
|
23849
23892
|
} else if (isBoxedTensor(op)) {
|
|
23850
23893
|
xs.push(op);
|
|
@@ -23928,11 +23971,11 @@ function validateArguments(ce, ops, signature, lazy, threadable) {
|
|
|
23928
23971
|
isValid = false;
|
|
23929
23972
|
continue;
|
|
23930
23973
|
}
|
|
23931
|
-
if (op.type.isUnknown) {
|
|
23974
|
+
if (op.type.isUnknown || op.type.type === "any") {
|
|
23932
23975
|
result.push(op);
|
|
23933
23976
|
continue;
|
|
23934
23977
|
}
|
|
23935
|
-
if (threadable && isFiniteIndexedCollection(op)) {
|
|
23978
|
+
if (threadable && (isFiniteIndexedCollection(op) || typeCouldBeCollection(op.type.type))) {
|
|
23936
23979
|
result.push(op);
|
|
23937
23980
|
continue;
|
|
23938
23981
|
}
|
|
@@ -23967,12 +24010,12 @@ function validateArguments(ce, ops, signature, lazy, threadable) {
|
|
|
23967
24010
|
i += 1;
|
|
23968
24011
|
continue;
|
|
23969
24012
|
}
|
|
23970
|
-
if (op.type.isUnknown) {
|
|
24013
|
+
if (op.type.isUnknown || op.type.type === "any") {
|
|
23971
24014
|
result.push(op);
|
|
23972
24015
|
i += 1;
|
|
23973
24016
|
continue;
|
|
23974
24017
|
}
|
|
23975
|
-
if (threadable && isFiniteIndexedCollection(op)) {
|
|
24018
|
+
if (threadable && (isFiniteIndexedCollection(op) || typeCouldBeCollection(op.type.type))) {
|
|
23976
24019
|
result.push(op);
|
|
23977
24020
|
i += 1;
|
|
23978
24021
|
continue;
|
|
@@ -24005,11 +24048,11 @@ function validateArguments(ce, ops, signature, lazy, threadable) {
|
|
|
24005
24048
|
isValid = false;
|
|
24006
24049
|
continue;
|
|
24007
24050
|
}
|
|
24008
|
-
if (op.type.isUnknown) {
|
|
24051
|
+
if (op.type.isUnknown || op.type.type === "any") {
|
|
24009
24052
|
result.push(op);
|
|
24010
24053
|
continue;
|
|
24011
24054
|
}
|
|
24012
|
-
if (threadable && isFiniteIndexedCollection(op)) {
|
|
24055
|
+
if (threadable && (isFiniteIndexedCollection(op) || typeCouldBeCollection(op.type.type))) {
|
|
24013
24056
|
result.push(op);
|
|
24014
24057
|
continue;
|
|
24015
24058
|
}
|
|
@@ -24039,20 +24082,22 @@ function validateArguments(ce, ops, signature, lazy, threadable) {
|
|
|
24039
24082
|
i = 0;
|
|
24040
24083
|
for (const param of params) {
|
|
24041
24084
|
if (!lazy) {
|
|
24042
|
-
if (!threadable || !isFiniteIndexedCollection(ops[i]))
|
|
24085
|
+
if (!threadable || !isFiniteIndexedCollection(ops[i]) && !typeCouldBeCollection(ops[i].type.type))
|
|
24043
24086
|
ops[i].infer(param);
|
|
24044
24087
|
}
|
|
24045
24088
|
i += 1;
|
|
24046
24089
|
}
|
|
24047
24090
|
for (const param of optParams) {
|
|
24048
24091
|
if (!ops[i]) break;
|
|
24049
|
-
if (!threadable || !isFiniteIndexedCollection(ops[i])
|
|
24092
|
+
if (!threadable || !isFiniteIndexedCollection(ops[i]) && !typeCouldBeCollection(ops[i].type.type))
|
|
24093
|
+
ops[i]?.infer(param);
|
|
24050
24094
|
i += 1;
|
|
24051
24095
|
}
|
|
24052
24096
|
if (varParam) {
|
|
24053
24097
|
for (const op of ops.slice(i)) {
|
|
24054
24098
|
if (!lazy) {
|
|
24055
|
-
if (!threadable || !isFiniteIndexedCollection(op)
|
|
24099
|
+
if (!threadable || !isFiniteIndexedCollection(op) && !typeCouldBeCollection(op.type.type))
|
|
24100
|
+
op.infer(varParam);
|
|
24056
24101
|
}
|
|
24057
24102
|
i += 1;
|
|
24058
24103
|
}
|
|
@@ -35464,6 +35509,12 @@ function canonicalForm(expr, forms, scope) {
|
|
|
35464
35509
|
throw Error("Invalid canonical form");
|
|
35465
35510
|
}
|
|
35466
35511
|
}
|
|
35512
|
+
if (expr.isFunctionExpression && expr.isCanonical) {
|
|
35513
|
+
expr = expr.engine.function(expr.operator, [...expr.ops], {
|
|
35514
|
+
canonical: false,
|
|
35515
|
+
structural: true
|
|
35516
|
+
});
|
|
35517
|
+
}
|
|
35467
35518
|
return expr;
|
|
35468
35519
|
}
|
|
35469
35520
|
function flattenForm(expr) {
|
|
@@ -35545,10 +35596,7 @@ function multiplyForm(expr) {
|
|
|
35545
35596
|
if (!expr.ops) return expr;
|
|
35546
35597
|
const ops = expr.ops.map(multiplyForm);
|
|
35547
35598
|
if (expr.operator === "Multiply")
|
|
35548
|
-
return canonicalMultiply(
|
|
35549
|
-
expr.engine,
|
|
35550
|
-
ops.map((x) => x.canonical)
|
|
35551
|
-
);
|
|
35599
|
+
return canonicalMultiply(expr.engine, ops);
|
|
35552
35600
|
if (expr.operator === "Negate")
|
|
35553
35601
|
return canonicalMultiply(expr.engine, [ops[0], expr.engine.NegativeOne]);
|
|
35554
35602
|
return expr;
|
|
@@ -45682,7 +45730,7 @@ var BoxedFunction = class extends _BoxedExpression {
|
|
|
45682
45730
|
return void 0;
|
|
45683
45731
|
}
|
|
45684
45732
|
get isCanonical() {
|
|
45685
|
-
return this._def !== void 0 && this._def !== null;
|
|
45733
|
+
return this._def !== void 0 && this._def !== null && !this._isStructural;
|
|
45686
45734
|
}
|
|
45687
45735
|
get isPure() {
|
|
45688
45736
|
if (this._isPure !== void 0) return this._isPure;
|
|
@@ -45849,7 +45897,7 @@ var BoxedFunction = class extends _BoxedExpression {
|
|
|
45849
45897
|
subs(sub3, options) {
|
|
45850
45898
|
options ??= { canonical: void 0 };
|
|
45851
45899
|
if (options.canonical === void 0)
|
|
45852
|
-
options = { canonical: this.isCanonical };
|
|
45900
|
+
options = { canonical: this.isCanonical || this.isStructural };
|
|
45853
45901
|
const ops = this._ops.map((x) => x.subs(sub3, options));
|
|
45854
45902
|
if (!ops.every((x) => x.isValid))
|
|
45855
45903
|
return this.engine.function(this._operator, ops, { canonical: false });
|
|
@@ -45921,7 +45969,7 @@ var BoxedFunction = class extends _BoxedExpression {
|
|
|
45921
45969
|
return this.numeratorDenominator[1];
|
|
45922
45970
|
}
|
|
45923
45971
|
get numeratorDenominator() {
|
|
45924
|
-
if (!this.isCanonical) return [this, this.engine.One];
|
|
45972
|
+
if (!(this.isCanonical || this.isStructural)) return [this, this.engine.One];
|
|
45925
45973
|
if (this.isNumber !== true)
|
|
45926
45974
|
return [this.engine.Nothing, this.engine.Nothing];
|
|
45927
45975
|
const operator2 = this.operator;
|
|
@@ -45959,11 +46007,11 @@ var BoxedFunction = class extends _BoxedExpression {
|
|
|
45959
46007
|
// ALGEBRAIC OPERATIONS
|
|
45960
46008
|
//
|
|
45961
46009
|
neg() {
|
|
45962
|
-
if (!this.isCanonical) throw new Error("Not canonical");
|
|
46010
|
+
if (!(this.isCanonical || this.isStructural)) throw new Error("Not canonical");
|
|
45963
46011
|
return negate(this);
|
|
45964
46012
|
}
|
|
45965
46013
|
inv() {
|
|
45966
|
-
if (!this.isCanonical) throw new Error("Not canonical");
|
|
46014
|
+
if (!(this.isCanonical || this.isStructural)) throw new Error("Not canonical");
|
|
45967
46015
|
if (this.isOne) return this;
|
|
45968
46016
|
if (this.isNegativeOne) return this;
|
|
45969
46017
|
if (this.operator === "Sqrt") return this.op1.inv().sqrt();
|
|
@@ -45984,7 +46032,7 @@ var BoxedFunction = class extends _BoxedExpression {
|
|
|
45984
46032
|
return this.engine._fn("Divide", [this.engine.One, this]);
|
|
45985
46033
|
}
|
|
45986
46034
|
abs() {
|
|
45987
|
-
if (!this.isCanonical) throw new Error("Not canonical");
|
|
46035
|
+
if (!(this.isCanonical || this.isStructural)) throw new Error("Not canonical");
|
|
45988
46036
|
if (this.operator === "Abs" || this.operator === "Negate") return this;
|
|
45989
46037
|
if (this.isNonNegative) return this;
|
|
45990
46038
|
if (this.isNonPositive) return this.neg();
|
|
@@ -45992,11 +46040,11 @@ var BoxedFunction = class extends _BoxedExpression {
|
|
|
45992
46040
|
}
|
|
45993
46041
|
add(rhs) {
|
|
45994
46042
|
if (rhs === 0) return this;
|
|
45995
|
-
if (!this.isCanonical) throw new Error("Not canonical");
|
|
46043
|
+
if (!(this.isCanonical || this.isStructural)) throw new Error("Not canonical");
|
|
45996
46044
|
return add3(this, this.engine.box(rhs));
|
|
45997
46045
|
}
|
|
45998
46046
|
mul(rhs) {
|
|
45999
|
-
if (!this.isCanonical) throw new Error("Not canonical");
|
|
46047
|
+
if (!(this.isCanonical || this.isStructural)) throw new Error("Not canonical");
|
|
46000
46048
|
if (rhs === 0) return this.engine.Zero;
|
|
46001
46049
|
if (rhs === 1) return this;
|
|
46002
46050
|
if (rhs === -1) return this.neg();
|
|
@@ -46008,14 +46056,14 @@ var BoxedFunction = class extends _BoxedExpression {
|
|
|
46008
46056
|
return mul3(this, this.engine.box(rhs));
|
|
46009
46057
|
}
|
|
46010
46058
|
div(rhs) {
|
|
46011
|
-
if (!this.isCanonical) throw new Error("Not canonical");
|
|
46059
|
+
if (!(this.isCanonical || this.isStructural)) throw new Error("Not canonical");
|
|
46012
46060
|
return div2(this, rhs);
|
|
46013
46061
|
}
|
|
46014
46062
|
pow(exp3) {
|
|
46015
46063
|
return pow2(this, exp3, { numericApproximation: false });
|
|
46016
46064
|
}
|
|
46017
46065
|
root(exp3) {
|
|
46018
|
-
if (!this.isCanonical || typeof exp3 !== "number" && !exp3.isCanonical)
|
|
46066
|
+
if (!(this.isCanonical || this.isStructural) || typeof exp3 !== "number" && !(exp3.isCanonical || exp3.isStructural))
|
|
46019
46067
|
throw new Error("Not canonical");
|
|
46020
46068
|
const e = typeof exp3 === "number" ? exp3 : exp3.im === 0 ? exp3.re : void 0;
|
|
46021
46069
|
if (e === 0) return this.engine.NaN;
|
|
@@ -46074,7 +46122,7 @@ var BoxedFunction = class extends _BoxedExpression {
|
|
|
46074
46122
|
}
|
|
46075
46123
|
ln(semiBase) {
|
|
46076
46124
|
const base = semiBase ? this.engine.box(semiBase) : void 0;
|
|
46077
|
-
if (!this.isCanonical) throw new Error("Not canonical");
|
|
46125
|
+
if (!(this.isCanonical || this.isStructural)) throw new Error("Not canonical");
|
|
46078
46126
|
if (this.is(0)) return this.engine.NegativeInfinity;
|
|
46079
46127
|
if (this.operator === "Exp") {
|
|
46080
46128
|
if (!base) return this.op1;
|
|
@@ -46107,7 +46155,7 @@ var BoxedFunction = class extends _BoxedExpression {
|
|
|
46107
46155
|
return this.engine._fn("Ln", [this]);
|
|
46108
46156
|
}
|
|
46109
46157
|
get complexity() {
|
|
46110
|
-
if (!this.isCanonical) return void 0;
|
|
46158
|
+
if (!(this.isCanonical || this.isStructural)) return void 0;
|
|
46111
46159
|
return this.operatorDefinition?.complexity ?? DEFAULT_COMPLEXITY;
|
|
46112
46160
|
}
|
|
46113
46161
|
get baseDefinition() {
|
|
@@ -54694,12 +54742,11 @@ var ComputeEngine = class _ComputeEngine {
|
|
|
54694
54742
|
bignum
|
|
54695
54743
|
);
|
|
54696
54744
|
if (value instanceof Decimal) {
|
|
54697
|
-
if (value.isInteger() && value.e <= MAX_BIGINT_DIGITS)
|
|
54698
|
-
|
|
54699
|
-
|
|
54700
|
-
makeNumericValue,
|
|
54701
|
-
|
|
54702
|
-
);
|
|
54745
|
+
if (value.isInteger() && value.e <= MAX_BIGINT_DIGITS) {
|
|
54746
|
+
const n = bigint(value.toString());
|
|
54747
|
+
if (n !== null)
|
|
54748
|
+
return new ExactNumericValue(n, makeNumericValue, bignum);
|
|
54749
|
+
}
|
|
54703
54750
|
return makeNumericValue(value);
|
|
54704
54751
|
}
|
|
54705
54752
|
if (value instanceof Complex) {
|
|
@@ -55765,10 +55812,10 @@ function defToString(name, def, v) {
|
|
|
55765
55812
|
// src/compute-engine.ts
|
|
55766
55813
|
init_types6();
|
|
55767
55814
|
init_base_compiler();
|
|
55768
|
-
var version = "0.35.
|
|
55815
|
+
var version = "0.35.2";
|
|
55769
55816
|
globalThis[Symbol.for("io.cortexjs.compute-engine")] = {
|
|
55770
55817
|
ComputeEngine: ComputeEngine.prototype.constructor,
|
|
55771
|
-
version: "0.35.
|
|
55818
|
+
version: "0.35.2"
|
|
55772
55819
|
};
|
|
55773
55820
|
export {
|
|
55774
55821
|
BaseCompiler,
|