@cortex-js/compute-engine 0.50.1 → 0.50.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 +276 -191
- package/dist/compute-engine.min.esm.js +43 -43
- package/dist/compute-engine.min.umd.js +44 -44
- package/dist/compute-engine.umd.js +276 -191
- 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/constants.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/inequality-bounds.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/init-lazy-refs.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/invisible-operator.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/pattern-utils.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/polynomial-degree.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/polynomials.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/predicates.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/trigonometry.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/type-guards.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/compile-expression.d.ts +1 -1
- package/dist/types/compute-engine/compilation/glsl-target.d.ts +1 -1
- package/dist/types/compute-engine/compilation/gpu-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/interval-wgsl-target.d.ts +1 -1
- package/dist/types/compute-engine/compilation/javascript-target.d.ts +1 -1
- package/dist/types/compute-engine/compilation/python-target.d.ts +1 -1
- package/dist/types/compute-engine/compilation/types.d.ts +1 -1
- package/dist/types/compute-engine/compilation/wgsl-target.d.ts +1 -1
- package/dist/types/compute-engine/cost-function.d.ts +1 -1
- package/dist/types/compute-engine/engine-assumptions.d.ts +1 -1
- package/dist/types/compute-engine/engine-cache.d.ts +1 -1
- package/dist/types/compute-engine/engine-common-symbols.d.ts +1 -1
- package/dist/types/compute-engine/engine-compilation-targets.d.ts +1 -1
- package/dist/types/compute-engine/engine-configuration-lifecycle.d.ts +1 -1
- package/dist/types/compute-engine/engine-declarations.d.ts +1 -1
- package/dist/types/compute-engine/engine-expression-entrypoints.d.ts +1 -1
- package/dist/types/compute-engine/engine-extension-contracts.d.ts +1 -1
- package/dist/types/compute-engine/engine-latex-dictionary-state.d.ts +1 -1
- package/dist/types/compute-engine/engine-library-bootstrap.d.ts +1 -1
- package/dist/types/compute-engine/engine-numeric-configuration.d.ts +1 -1
- package/dist/types/compute-engine/engine-parse-entrypoint.d.ts +1 -1
- package/dist/types/compute-engine/engine-runtime-state.d.ts +1 -1
- package/dist/types/compute-engine/engine-scope.d.ts +1 -1
- package/dist/types/compute-engine/engine-sequences.d.ts +1 -1
- package/dist/types/compute-engine/engine-simplification-rules.d.ts +1 -1
- package/dist/types/compute-engine/engine-startup-coordinator.d.ts +1 -1
- package/dist/types/compute-engine/engine-type-resolver.d.ts +1 -1
- package/dist/types/compute-engine/engine-validation-entrypoints.d.ts +1 -1
- package/dist/types/compute-engine/free-functions.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/dictionary/indexed-types.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/parse-number.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/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.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/type-handlers.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/logic-utils.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-logic.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-definitions.d.ts +1 -1
- package/dist/types/compute-engine/types-engine.d.ts +1 -1
- package/dist/types/compute-engine/types-evaluation.d.ts +1 -1
- package/dist/types/compute-engine/types-expression.d.ts +1 -1
- package/dist/types/compute-engine/types-kernel-evaluation.d.ts +1 -1
- package/dist/types/compute-engine/types-kernel-serialization.d.ts +1 -1
- package/dist/types/compute-engine/types-serialization.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.50.
|
|
1
|
+
/** Compute Engine 0.50.2 */
|
|
2
2
|
|
|
3
3
|
// node_modules/complex-esm/dist/src/complex.js
|
|
4
4
|
var cosh = Math.cosh || function(x) {
|
|
@@ -6558,14 +6558,15 @@ function canonicalInteger(n, exponent) {
|
|
|
6558
6558
|
if (result) return result;
|
|
6559
6559
|
}
|
|
6560
6560
|
const factors = primeFactors(n);
|
|
6561
|
-
let f = 1;
|
|
6562
|
-
let r = 1;
|
|
6561
|
+
let f = BigInt(1);
|
|
6562
|
+
let r = BigInt(1);
|
|
6563
6563
|
for (const k of Object.keys(factors)) {
|
|
6564
|
-
const v = parseInt(k);
|
|
6565
|
-
|
|
6566
|
-
|
|
6564
|
+
const v = BigInt(parseInt(k));
|
|
6565
|
+
const exponentBase = BigInt(exponent);
|
|
6566
|
+
f = f * v ** (BigInt(factors[k]) / exponentBase);
|
|
6567
|
+
r = r * v ** (BigInt(factors[k]) % exponentBase);
|
|
6567
6568
|
}
|
|
6568
|
-
return [f, r];
|
|
6569
|
+
return [Number(f), Number(r)];
|
|
6569
6570
|
}
|
|
6570
6571
|
function gcd(a, b) {
|
|
6571
6572
|
if (a === 0) return b;
|
|
@@ -6576,7 +6577,9 @@ function gcd(a, b) {
|
|
|
6576
6577
|
return a < 0 ? -a : a;
|
|
6577
6578
|
}
|
|
6578
6579
|
function lcm(a, b) {
|
|
6579
|
-
|
|
6580
|
+
if (a === 0 || b === 0) return 0;
|
|
6581
|
+
const res = BigInt(a) * BigInt(b) / BigInt(gcd(a, b));
|
|
6582
|
+
return Number(res);
|
|
6580
6583
|
}
|
|
6581
6584
|
function factorial2(n) {
|
|
6582
6585
|
if (!Number.isInteger(n) || n < 0) return NaN;
|
|
@@ -11043,11 +11046,25 @@ function add2(lhs, rhs) {
|
|
|
11043
11046
|
const bigRhs = [BigInt(rhsNum[0]), BigInt(rhsNum[1])];
|
|
11044
11047
|
return [bigRhs[1] * lhs[0] + bigRhs[0] * lhs[1], bigRhs[1] * lhs[1]];
|
|
11045
11048
|
}
|
|
11046
|
-
|
|
11049
|
+
const n = rhsNum[1] * lhs[0] + rhsNum[0] * lhs[1];
|
|
11050
|
+
const d = rhsNum[1] * lhs[1];
|
|
11051
|
+
if (n <= 9007199254740991 && n >= -9007199254740991 && d <= 9007199254740991)
|
|
11052
|
+
return [n, d];
|
|
11053
|
+
if (!Number.isFinite(n) || !Number.isFinite(d)) return [NaN, 1];
|
|
11054
|
+
return [
|
|
11055
|
+
BigInt(rhsNum[1]) * BigInt(lhs[0]) + BigInt(rhsNum[0]) * BigInt(lhs[1]),
|
|
11056
|
+
BigInt(rhsNum[1]) * BigInt(lhs[1])
|
|
11057
|
+
];
|
|
11047
11058
|
}
|
|
11048
11059
|
function mul2(lhs, rhs) {
|
|
11049
|
-
if (isMachineRational(lhs) && isMachineRational(rhs))
|
|
11050
|
-
|
|
11060
|
+
if (isMachineRational(lhs) && isMachineRational(rhs)) {
|
|
11061
|
+
const n = lhs[0] * rhs[0];
|
|
11062
|
+
const d = lhs[1] * rhs[1];
|
|
11063
|
+
if (n <= 9007199254740991 && n >= -9007199254740991 && d <= 9007199254740991)
|
|
11064
|
+
return [n, d];
|
|
11065
|
+
if (!Number.isFinite(n) || !Number.isFinite(d)) return [NaN, 1];
|
|
11066
|
+
return [BigInt(lhs[0]) * BigInt(rhs[0]), BigInt(lhs[1]) * BigInt(rhs[1])];
|
|
11067
|
+
}
|
|
11051
11068
|
if (isMachineRational(lhs))
|
|
11052
11069
|
return [
|
|
11053
11070
|
BigInt(lhs[0]) * rhs[0],
|
|
@@ -14728,8 +14745,7 @@ var ExactNumericValue = class _ExactNumericValue extends NumericValue {
|
|
|
14728
14745
|
}
|
|
14729
14746
|
if (this.radical >= 4) {
|
|
14730
14747
|
const [factor3, root2] = canonicalInteger(this.radical, 2);
|
|
14731
|
-
if (
|
|
14732
|
-
else this.rational = mul2(this.rational, [factor3, 1]);
|
|
14748
|
+
if (factor3 !== 1) this.rational = mul2(this.rational, [factor3, 1]);
|
|
14733
14749
|
this.radical = root2;
|
|
14734
14750
|
}
|
|
14735
14751
|
this.rational = reducedRational(this.rational);
|
|
@@ -14780,7 +14796,10 @@ var ExactNumericValue = class _ExactNumericValue extends NumericValue {
|
|
|
14780
14796
|
if (this.isOne) return this;
|
|
14781
14797
|
if (this.isNegativeOne) return this;
|
|
14782
14798
|
return this.clone({
|
|
14783
|
-
rational:
|
|
14799
|
+
rational: mul2(
|
|
14800
|
+
[BigInt(this.rational[1]), BigInt(1)],
|
|
14801
|
+
inverse([BigInt(this.rational[0]) * BigInt(this.radical), BigInt(1)])
|
|
14802
|
+
),
|
|
14784
14803
|
radical: this.radical
|
|
14785
14804
|
});
|
|
14786
14805
|
}
|
|
@@ -14789,10 +14808,7 @@ var ExactNumericValue = class _ExactNumericValue extends NumericValue {
|
|
|
14789
14808
|
if (other === 0) return this;
|
|
14790
14809
|
if (Number.isInteger(other) && this.radical === 1)
|
|
14791
14810
|
return this.clone({
|
|
14792
|
-
rational:
|
|
14793
|
-
this.rational[0] + BigInt(other) * this.rational[1],
|
|
14794
|
-
this.rational[1]
|
|
14795
|
-
]
|
|
14811
|
+
rational: add2(this.rational, [other, 1])
|
|
14796
14812
|
});
|
|
14797
14813
|
return this.factory(this.bignumRe).add(other);
|
|
14798
14814
|
}
|
|
@@ -14821,7 +14837,7 @@ var ExactNumericValue = class _ExactNumericValue extends NumericValue {
|
|
|
14821
14837
|
if (typeof other === "number") {
|
|
14822
14838
|
if (Number.isInteger(other))
|
|
14823
14839
|
return this.clone({
|
|
14824
|
-
rational:
|
|
14840
|
+
rational: mul2(this.rational, [other, 1]),
|
|
14825
14841
|
radical: this.radical
|
|
14826
14842
|
});
|
|
14827
14843
|
return this.factory(this.bignumRe).mul(other);
|
|
@@ -14844,9 +14860,12 @@ var ExactNumericValue = class _ExactNumericValue extends NumericValue {
|
|
|
14844
14860
|
if (this.isOne) return other;
|
|
14845
14861
|
if (this.isNegativeOne) return other.neg();
|
|
14846
14862
|
if (!(other instanceof _ExactNumericValue)) return other.mul(this);
|
|
14863
|
+
const radical = BigInt(this.radical) * BigInt(other.radical);
|
|
14864
|
+
if (radical > BigInt(SMALL_INTEGER))
|
|
14865
|
+
return this.factory(this.bignumRe).mul(other);
|
|
14847
14866
|
return this.clone({
|
|
14848
14867
|
rational: mul2(this.rational, other.rational),
|
|
14849
|
-
radical:
|
|
14868
|
+
radical: Number(radical)
|
|
14850
14869
|
});
|
|
14851
14870
|
}
|
|
14852
14871
|
div(other) {
|
|
@@ -14855,7 +14874,7 @@ var ExactNumericValue = class _ExactNumericValue extends NumericValue {
|
|
|
14855
14874
|
if (other === -1) return this.neg();
|
|
14856
14875
|
if (other === 0) return this.clone(NaN);
|
|
14857
14876
|
return this.clone({
|
|
14858
|
-
rational:
|
|
14877
|
+
rational: mul2(this.rational, [1, other]),
|
|
14859
14878
|
radical: this.radical
|
|
14860
14879
|
});
|
|
14861
14880
|
}
|
|
@@ -14870,18 +14889,14 @@ var ExactNumericValue = class _ExactNumericValue extends NumericValue {
|
|
|
14870
14889
|
if (!(other instanceof _ExactNumericValue))
|
|
14871
14890
|
return this.factory(this.bignumRe).div(other);
|
|
14872
14891
|
if (other.im !== 0) return this.factory(this.bignumRe).div(other);
|
|
14873
|
-
|
|
14874
|
-
|
|
14875
|
-
|
|
14876
|
-
|
|
14877
|
-
|
|
14878
|
-
|
|
14879
|
-
|
|
14880
|
-
|
|
14881
|
-
BigInt(other.rational[0]) * BigInt(other.radical)
|
|
14882
|
-
]);
|
|
14883
|
-
}
|
|
14884
|
-
return this.clone({ rational, radical: this.radical * other.radical });
|
|
14892
|
+
const rational = mul2(this.rational, [
|
|
14893
|
+
BigInt(other.rational[1]),
|
|
14894
|
+
BigInt(other.rational[0]) * BigInt(other.radical)
|
|
14895
|
+
]);
|
|
14896
|
+
const radical = BigInt(this.radical) * BigInt(other.radical);
|
|
14897
|
+
if (radical > BigInt(SMALL_INTEGER))
|
|
14898
|
+
return this.factory(this.bignumRe).div(other);
|
|
14899
|
+
return this.clone({ rational, radical: Number(radical) });
|
|
14885
14900
|
}
|
|
14886
14901
|
pow(exponent) {
|
|
14887
14902
|
console.assert(!Array.isArray(exponent));
|
|
@@ -14927,26 +14942,31 @@ var ExactNumericValue = class _ExactNumericValue extends NumericValue {
|
|
|
14927
14942
|
if (this.sign < 0) {
|
|
14928
14943
|
if (Number.isInteger(exponent)) {
|
|
14929
14944
|
const sign3 = exponent % 2 === 0 ? 1 : -1;
|
|
14945
|
+
const bigExp = BigInt(exponent);
|
|
14946
|
+
const radical = BigInt(this.radical) ** bigExp;
|
|
14947
|
+
if (radical > BigInt(SMALL_INTEGER))
|
|
14948
|
+
return this.factory(this.bignumRe).pow(exponent);
|
|
14930
14949
|
return this.clone({
|
|
14931
|
-
rational:
|
|
14932
|
-
sign3 * (-this.rational[0]) **
|
|
14933
|
-
this.rational[1] **
|
|
14934
|
-
] : [
|
|
14935
|
-
BigInt(sign3) * (-this.rational[0]) ** BigInt(exponent),
|
|
14936
|
-
this.rational[1] ** BigInt(exponent)
|
|
14950
|
+
rational: [
|
|
14951
|
+
BigInt(sign3) * (-BigInt(this.rational[0])) ** bigExp,
|
|
14952
|
+
BigInt(this.rational[1]) ** bigExp
|
|
14937
14953
|
],
|
|
14938
|
-
radical:
|
|
14954
|
+
radical: Number(radical)
|
|
14939
14955
|
});
|
|
14940
14956
|
}
|
|
14941
14957
|
return this.factory({ im: (-this.re) ** exponent });
|
|
14942
14958
|
} else {
|
|
14943
14959
|
if (Number.isInteger(exponent)) {
|
|
14960
|
+
const bigExp = BigInt(exponent);
|
|
14961
|
+
const radical = BigInt(this.radical) ** bigExp;
|
|
14962
|
+
if (radical > BigInt(SMALL_INTEGER))
|
|
14963
|
+
return this.factory(this.bignumRe).pow(exponent);
|
|
14944
14964
|
return this.clone({
|
|
14945
|
-
rational:
|
|
14946
|
-
BigInt(this.rational[0]) **
|
|
14947
|
-
this.rational[1] **
|
|
14965
|
+
rational: [
|
|
14966
|
+
BigInt(this.rational[0]) ** bigExp,
|
|
14967
|
+
BigInt(this.rational[1]) ** bigExp
|
|
14948
14968
|
],
|
|
14949
|
-
radical:
|
|
14969
|
+
radical: Number(radical)
|
|
14950
14970
|
});
|
|
14951
14971
|
}
|
|
14952
14972
|
}
|
|
@@ -21924,11 +21944,15 @@ function canonicalIndexingSet(expr) {
|
|
|
21924
21944
|
function canonicalBigop(bigOp2, body, indexingSets, scope) {
|
|
21925
21945
|
const ce = body.engine;
|
|
21926
21946
|
ce.pushScope(scope);
|
|
21927
|
-
|
|
21928
|
-
|
|
21929
|
-
|
|
21930
|
-
|
|
21931
|
-
|
|
21947
|
+
let indexes;
|
|
21948
|
+
try {
|
|
21949
|
+
indexes = indexingSets.map(
|
|
21950
|
+
(x) => canonicalIndexingSet(x) ?? ce.error("missing")
|
|
21951
|
+
);
|
|
21952
|
+
body = body?.canonical ?? ce.error("missing");
|
|
21953
|
+
} finally {
|
|
21954
|
+
ce.popScope();
|
|
21955
|
+
}
|
|
21932
21956
|
if (body.isCollection) {
|
|
21933
21957
|
if (bigOp2 === "Sum") return ce.box(["Reduce", body, "Add", 0]);
|
|
21934
21958
|
return ce.box(["Reduce", body, "Multiply", 1]);
|
|
@@ -22230,7 +22254,11 @@ var ARITHMETIC_LIBRARY = [
|
|
|
22230
22254
|
for (const x of rest) result = canonicalDivide(result, x);
|
|
22231
22255
|
return result;
|
|
22232
22256
|
},
|
|
22233
|
-
evaluate: ([num, den]) =>
|
|
22257
|
+
evaluate: ([num, den], { numericApproximation: numericApproximation2 }) => {
|
|
22258
|
+
const res = num.div(den);
|
|
22259
|
+
if (numericApproximation2 && res.operator !== "Divide") return res.N();
|
|
22260
|
+
return res;
|
|
22261
|
+
}
|
|
22234
22262
|
},
|
|
22235
22263
|
Exp: {
|
|
22236
22264
|
wikidata: "Q168698",
|
|
@@ -23413,11 +23441,12 @@ var ARITHMETIC_LIBRARY = [
|
|
|
23413
23441
|
canonical: ([body, ...bounds], { scope }) => canonicalBigop("Product", body, bounds, scope),
|
|
23414
23442
|
evaluate: (ops, options) => {
|
|
23415
23443
|
const ce = options.engine;
|
|
23444
|
+
const numericApproximation2 = options.numericApproximation;
|
|
23416
23445
|
const result = run(
|
|
23417
23446
|
reduceBigOp(
|
|
23418
23447
|
ops[0],
|
|
23419
23448
|
ops.slice(1),
|
|
23420
|
-
(acc, x) => acc.mul(x.evaluate(
|
|
23449
|
+
(acc, x) => acc.mul(x.evaluate({ numericApproximation: numericApproximation2 })),
|
|
23421
23450
|
ce.One
|
|
23422
23451
|
),
|
|
23423
23452
|
ce._timeRemaining
|
|
@@ -23425,15 +23454,16 @@ var ARITHMETIC_LIBRARY = [
|
|
|
23425
23454
|
if (result === NON_ENUMERABLE_DOMAIN) {
|
|
23426
23455
|
return void 0;
|
|
23427
23456
|
}
|
|
23428
|
-
return result?.evaluate() ?? ce.NaN;
|
|
23457
|
+
return result?.evaluate({ numericApproximation: numericApproximation2 }) ?? ce.NaN;
|
|
23429
23458
|
},
|
|
23430
23459
|
evaluateAsync: async (ops, options) => {
|
|
23431
23460
|
const ce = options.engine;
|
|
23461
|
+
const numericApproximation2 = options.numericApproximation;
|
|
23432
23462
|
const result = await runAsync(
|
|
23433
23463
|
reduceBigOp(
|
|
23434
23464
|
ops[0],
|
|
23435
23465
|
ops.slice(1),
|
|
23436
|
-
(acc, x) => acc.mul(x.evaluate(
|
|
23466
|
+
(acc, x) => acc.mul(x.evaluate({ numericApproximation: numericApproximation2 })),
|
|
23437
23467
|
ce.One
|
|
23438
23468
|
),
|
|
23439
23469
|
ce._timeRemaining,
|
|
@@ -23442,7 +23472,7 @@ var ARITHMETIC_LIBRARY = [
|
|
|
23442
23472
|
if (result === NON_ENUMERABLE_DOMAIN) {
|
|
23443
23473
|
return void 0;
|
|
23444
23474
|
}
|
|
23445
|
-
return result?.evaluate() ?? ce.NaN;
|
|
23475
|
+
return result?.evaluate({ numericApproximation: numericApproximation2 }) ?? ce.NaN;
|
|
23446
23476
|
}
|
|
23447
23477
|
},
|
|
23448
23478
|
Sum: {
|
|
@@ -23454,12 +23484,12 @@ var ARITHMETIC_LIBRARY = [
|
|
|
23454
23484
|
lazy: true,
|
|
23455
23485
|
signature: "((number) -> number, bounds:tuple+) -> number",
|
|
23456
23486
|
canonical: ([body, ...bounds], { scope }) => canonicalBigop("Sum", body, bounds, scope),
|
|
23457
|
-
evaluate: ([body, ...indexes], { engine }) => {
|
|
23487
|
+
evaluate: ([body, ...indexes], { engine, numericApproximation: numericApproximation2 }) => {
|
|
23458
23488
|
const result = run(
|
|
23459
23489
|
reduceBigOp(
|
|
23460
23490
|
body,
|
|
23461
23491
|
indexes,
|
|
23462
|
-
(acc, x) => acc.add(x.evaluate()),
|
|
23492
|
+
(acc, x) => acc.add(x.evaluate({ numericApproximation: numericApproximation2 })),
|
|
23463
23493
|
engine.Zero
|
|
23464
23494
|
),
|
|
23465
23495
|
engine._timeRemaining
|
|
@@ -23467,14 +23497,14 @@ var ARITHMETIC_LIBRARY = [
|
|
|
23467
23497
|
if (result === NON_ENUMERABLE_DOMAIN) {
|
|
23468
23498
|
return void 0;
|
|
23469
23499
|
}
|
|
23470
|
-
return result?.evaluate() ?? engine.NaN;
|
|
23500
|
+
return result?.evaluate({ numericApproximation: numericApproximation2 }) ?? engine.NaN;
|
|
23471
23501
|
},
|
|
23472
|
-
evaluateAsync: async (xs, { engine, signal }) => {
|
|
23502
|
+
evaluateAsync: async (xs, { engine, signal, numericApproximation: numericApproximation2 }) => {
|
|
23473
23503
|
const result = await runAsync(
|
|
23474
23504
|
reduceBigOp(
|
|
23475
23505
|
xs[0],
|
|
23476
23506
|
xs.slice(1),
|
|
23477
|
-
(acc, x) => acc.add(x.evaluate()),
|
|
23507
|
+
(acc, x) => acc.add(x.evaluate({ numericApproximation: numericApproximation2 })),
|
|
23478
23508
|
engine.Zero
|
|
23479
23509
|
),
|
|
23480
23510
|
engine._timeRemaining,
|
|
@@ -23483,7 +23513,7 @@ var ARITHMETIC_LIBRARY = [
|
|
|
23483
23513
|
if (result === NON_ENUMERABLE_DOMAIN) {
|
|
23484
23514
|
return void 0;
|
|
23485
23515
|
}
|
|
23486
|
-
return result?.evaluate() ?? engine.NaN;
|
|
23516
|
+
return result?.evaluate({ numericApproximation: numericApproximation2 }) ?? engine.NaN;
|
|
23487
23517
|
}
|
|
23488
23518
|
}
|
|
23489
23519
|
}
|
|
@@ -24193,60 +24223,62 @@ function parseRule(ce, rule, options) {
|
|
|
24193
24223
|
if (systemScope) {
|
|
24194
24224
|
ce.pushScope({ parent: systemScope, bindings: /* @__PURE__ */ new Map() });
|
|
24195
24225
|
}
|
|
24196
|
-
|
|
24197
|
-
|
|
24198
|
-
|
|
24199
|
-
|
|
24200
|
-
|
|
24201
|
-
|
|
24202
|
-
|
|
24203
|
-
`Invalid rule "${rule}"
|
|
24226
|
+
let expr;
|
|
24227
|
+
try {
|
|
24228
|
+
expr = ce.parse(rule);
|
|
24229
|
+
ce.latexDictionary = previousDictionary;
|
|
24230
|
+
if (!expr.isValid || expr.operator !== "Rule") {
|
|
24231
|
+
throw new Error(
|
|
24232
|
+
`Invalid rule "${rule}"
|
|
24204
24233
|
| ${dewildcard(expr).toString()}
|
|
24205
24234
|
| A rule should be of the form:
|
|
24206
24235
|
| <match> -> <replace>; <condition>`
|
|
24207
|
-
|
|
24208
|
-
}
|
|
24209
|
-
if (!isFunction2(expr)) {
|
|
24210
|
-
if (systemScope) {
|
|
24211
|
-
ce.popScope();
|
|
24236
|
+
);
|
|
24212
24237
|
}
|
|
24213
|
-
|
|
24214
|
-
|
|
24215
|
-
|
|
24216
|
-
|
|
24217
|
-
|
|
24218
|
-
|
|
24219
|
-
|
|
24220
|
-
|
|
24221
|
-
|
|
24222
|
-
|
|
24223
|
-
|
|
24224
|
-
|
|
24225
|
-
|
|
24226
|
-
throw new Error(
|
|
24227
|
-
`Invalid rule "${rule}"
|
|
24238
|
+
if (!isFunction2(expr)) {
|
|
24239
|
+
throw new Error(`Invalid rule "${rule}"`);
|
|
24240
|
+
}
|
|
24241
|
+
const [match_, replace_, condition] = expr.ops;
|
|
24242
|
+
let match2 = match_;
|
|
24243
|
+
let replace2 = replace_;
|
|
24244
|
+
if (canonical2) {
|
|
24245
|
+
match2 = match2.canonical;
|
|
24246
|
+
replace2 = replace2.canonical;
|
|
24247
|
+
}
|
|
24248
|
+
if (!includesWildcards(replace2, match2))
|
|
24249
|
+
throw new Error(
|
|
24250
|
+
`Invalid rule "${rule}"
|
|
24228
24251
|
| The replace expression contains wildcards not present in the match expression`
|
|
24229
|
-
|
|
24230
|
-
|
|
24231
|
-
throw new Error(
|
|
24232
|
-
`Invalid rule "${rule}"
|
|
24233
|
-
| The match and replace expressions are the same.
|
|
24234
|
-
| This may be because the rule is not necessary due to canonical simplification`
|
|
24235
|
-
);
|
|
24236
|
-
}
|
|
24237
|
-
let condFn = void 0;
|
|
24238
|
-
if (condition !== void 0) {
|
|
24239
|
-
if (!includesWildcards(condition, match2))
|
|
24252
|
+
);
|
|
24253
|
+
if (match2.isSame(replace2)) {
|
|
24240
24254
|
throw new Error(
|
|
24241
24255
|
`Invalid rule "${rule}"
|
|
24242
|
-
| The
|
|
24256
|
+
| The match and replace expressions are the same.
|
|
24257
|
+
| This may be because the rule is not necessary due to canonical simplification`
|
|
24243
24258
|
);
|
|
24244
|
-
|
|
24245
|
-
|
|
24246
|
-
|
|
24247
|
-
|
|
24259
|
+
}
|
|
24260
|
+
let condFn = void 0;
|
|
24261
|
+
if (condition !== void 0) {
|
|
24262
|
+
if (!includesWildcards(condition, match2))
|
|
24263
|
+
throw new Error(
|
|
24264
|
+
`Invalid rule "${rule}"
|
|
24265
|
+
| The condition expression contains wildcards not present in the match expression`
|
|
24266
|
+
);
|
|
24267
|
+
condFn = (sub3) => {
|
|
24268
|
+
const evaluated = condition.subs(sub3).canonical.evaluate();
|
|
24269
|
+
return isSymbol2(evaluated) && evaluated.symbol === "True";
|
|
24270
|
+
};
|
|
24271
|
+
}
|
|
24272
|
+
return boxRule(
|
|
24273
|
+
ce,
|
|
24274
|
+
{ match: match2, replace: replace2, condition: condFn, id: rule },
|
|
24275
|
+
options
|
|
24276
|
+
);
|
|
24277
|
+
} finally {
|
|
24278
|
+
if (systemScope) {
|
|
24279
|
+
ce.popScope();
|
|
24280
|
+
}
|
|
24248
24281
|
}
|
|
24249
|
-
return boxRule(ce, { match: match2, replace: replace2, condition: condFn, id: rule }, options);
|
|
24250
24282
|
}
|
|
24251
24283
|
function boxRule(ce, rule, options) {
|
|
24252
24284
|
if (rule === void 0 || rule === null)
|
|
@@ -24300,12 +24332,17 @@ function boxRule(ce, rule, options) {
|
|
|
24300
24332
|
} else {
|
|
24301
24333
|
ce.pushScope();
|
|
24302
24334
|
}
|
|
24303
|
-
|
|
24304
|
-
|
|
24305
|
-
|
|
24306
|
-
|
|
24307
|
-
|
|
24308
|
-
|
|
24335
|
+
let matchExpr;
|
|
24336
|
+
let replaceExpr;
|
|
24337
|
+
try {
|
|
24338
|
+
matchExpr = parseRulePart(ce, match2, {
|
|
24339
|
+
canonical: false,
|
|
24340
|
+
autoWildcard: false
|
|
24341
|
+
});
|
|
24342
|
+
replaceExpr = typeof replace2 === "function" ? replace2 : parseRulePart(ce, replace2, options);
|
|
24343
|
+
} finally {
|
|
24344
|
+
ce.popScope();
|
|
24345
|
+
}
|
|
24309
24346
|
if (!id) {
|
|
24310
24347
|
if (typeof match2 === "string") id = match2;
|
|
24311
24348
|
else id = JSON.stringify(match2, void 0, 4);
|
|
@@ -24326,7 +24363,7 @@ function boxRule(ce, rule, options) {
|
|
|
24326
24363
|
| the match expression is not valid: ${matchExpr.toString()}`
|
|
24327
24364
|
);
|
|
24328
24365
|
}
|
|
24329
|
-
if (replaceExpr && !replaceExpr.isValid) {
|
|
24366
|
+
if (replaceExpr && typeof replaceExpr !== "function" && !replaceExpr.isValid) {
|
|
24330
24367
|
throw new Error(
|
|
24331
24368
|
`Invalid rule ${id ?? JSON.stringify(rule, void 0, 4)}
|
|
24332
24369
|
| The replace expression is not valid: ${replaceExpr?.toString()}`
|
|
@@ -24369,6 +24406,7 @@ ${e.message}
|
|
|
24369
24406
|
return { rules };
|
|
24370
24407
|
}
|
|
24371
24408
|
function applyRule(rule, expr, substitution, options) {
|
|
24409
|
+
if (!rule) return null;
|
|
24372
24410
|
let canonical2 = options?.canonical ?? (expr.isCanonical || expr.isStructural);
|
|
24373
24411
|
let operandsMatched = false;
|
|
24374
24412
|
if (isFunction2(expr) && options?.recursive) {
|
|
@@ -25392,8 +25430,12 @@ function solveNestedSqrtEquation(expr, variable) {
|
|
|
25392
25430
|
const uEquation = substitutedArg.sub(aSquared).simplify();
|
|
25393
25431
|
ce.pushScope();
|
|
25394
25432
|
ce.declare(uSymbolName, { type: "real" });
|
|
25395
|
-
|
|
25396
|
-
|
|
25433
|
+
let uSolutions;
|
|
25434
|
+
try {
|
|
25435
|
+
uSolutions = findUnivariateRoots(uEquation, uSymbolName);
|
|
25436
|
+
} finally {
|
|
25437
|
+
ce.popScope();
|
|
25438
|
+
}
|
|
25397
25439
|
if (uSolutions.length === 0) return null;
|
|
25398
25440
|
const xSolutions = [];
|
|
25399
25441
|
for (const uVal of uSolutions) {
|
|
@@ -25430,40 +25472,44 @@ function findUnivariateRoots(expr, x) {
|
|
|
25430
25472
|
const rules = ce.getRuleSet("solve-univariate");
|
|
25431
25473
|
let exprs = [expr.subs({ [x]: "_x" }, { canonical: false })];
|
|
25432
25474
|
ce.pushScope();
|
|
25433
|
-
|
|
25434
|
-
|
|
25435
|
-
|
|
25436
|
-
(
|
|
25437
|
-
expr2,
|
|
25438
|
-
rules,
|
|
25439
|
-
{ _x: ce.symbol("_x") },
|
|
25440
|
-
{ useVariations: true, canonical: true }
|
|
25441
|
-
)
|
|
25442
|
-
);
|
|
25443
|
-
if (result.length === 0) {
|
|
25444
|
-
exprs = exprs.flatMap((expr2) => harmonize(expr2));
|
|
25445
|
-
result = exprs.flatMap(
|
|
25446
|
-
(expr2) => matchAnyRules(
|
|
25447
|
-
expr2,
|
|
25448
|
-
rules,
|
|
25449
|
-
{ _x: ce.symbol(x) },
|
|
25450
|
-
{ useVariations: true, canonical: true }
|
|
25451
|
-
)
|
|
25452
|
-
);
|
|
25453
|
-
}
|
|
25454
|
-
if (result.length === 0) {
|
|
25455
|
-
exprs = exprs.flatMap((expr2) => expand2(expr2.canonical)).filter((x2) => x2 !== null);
|
|
25456
|
-
exprs = exprs.flatMap((expr2) => harmonize(expr2));
|
|
25475
|
+
let result = [];
|
|
25476
|
+
try {
|
|
25477
|
+
const varType = ce.symbol(x).type.type;
|
|
25478
|
+
ce.declare("_x", typeof varType === "string" ? varType : "number");
|
|
25457
25479
|
result = exprs.flatMap(
|
|
25458
25480
|
(expr2) => matchAnyRules(
|
|
25459
25481
|
expr2,
|
|
25460
25482
|
rules,
|
|
25461
|
-
{ _x: ce.symbol(
|
|
25483
|
+
{ _x: ce.symbol("_x") },
|
|
25462
25484
|
{ useVariations: true, canonical: true }
|
|
25463
25485
|
)
|
|
25464
25486
|
);
|
|
25487
|
+
if (result.length === 0) {
|
|
25488
|
+
exprs = exprs.flatMap((expr2) => harmonize(expr2));
|
|
25489
|
+
result = exprs.flatMap(
|
|
25490
|
+
(expr2) => matchAnyRules(
|
|
25491
|
+
expr2,
|
|
25492
|
+
rules,
|
|
25493
|
+
{ _x: ce.symbol(x) },
|
|
25494
|
+
{ useVariations: true, canonical: true }
|
|
25495
|
+
)
|
|
25496
|
+
);
|
|
25497
|
+
}
|
|
25498
|
+
if (result.length === 0) {
|
|
25499
|
+
exprs = exprs.flatMap((expr2) => expand2(expr2.canonical)).filter((x2) => x2 !== null);
|
|
25500
|
+
exprs = exprs.flatMap((expr2) => harmonize(expr2));
|
|
25501
|
+
result = exprs.flatMap(
|
|
25502
|
+
(expr2) => matchAnyRules(
|
|
25503
|
+
expr2,
|
|
25504
|
+
rules,
|
|
25505
|
+
{ _x: ce.symbol(x) },
|
|
25506
|
+
{ useVariations: true, canonical: true }
|
|
25507
|
+
)
|
|
25508
|
+
);
|
|
25509
|
+
}
|
|
25510
|
+
} finally {
|
|
25511
|
+
ce.popScope();
|
|
25465
25512
|
}
|
|
25466
|
-
ce.popScope();
|
|
25467
25513
|
const validatedRoots = validateRoots(
|
|
25468
25514
|
originalExpr,
|
|
25469
25515
|
x,
|
|
@@ -34588,9 +34634,12 @@ var STATISTICS_LIBRARY = [
|
|
|
34588
34634
|
signature: "((collection|number)+) -> number",
|
|
34589
34635
|
type: () => "finite_real",
|
|
34590
34636
|
description: "The most frequently occurring value in the collection.",
|
|
34591
|
-
evaluate: (ops, { engine }) =>
|
|
34592
|
-
|
|
34593
|
-
|
|
34637
|
+
evaluate: (ops, { engine, numericApproximation: numericApproximation2 }) => {
|
|
34638
|
+
const xs = ops.map((x) => x.evaluate({ numericApproximation: numericApproximation2 }));
|
|
34639
|
+
return engine.number(
|
|
34640
|
+
bignumPreferred(engine) ? bigMean(engine.bignum.bind(engine), flattenBigScalars(xs)) : mean(flattenScalars(xs))
|
|
34641
|
+
);
|
|
34642
|
+
}
|
|
34594
34643
|
},
|
|
34595
34644
|
Median: {
|
|
34596
34645
|
complexity: 1200,
|
|
@@ -34599,30 +34648,39 @@ var STATISTICS_LIBRARY = [
|
|
|
34599
34648
|
type: () => "finite_real",
|
|
34600
34649
|
description: "The most frequently occurring value in the collection.",
|
|
34601
34650
|
examples: ["Mode([1, 2, 2, 3]) // Returns 2"],
|
|
34602
|
-
evaluate: (ops, { engine }) =>
|
|
34603
|
-
|
|
34604
|
-
|
|
34651
|
+
evaluate: (ops, { engine, numericApproximation: numericApproximation2 }) => {
|
|
34652
|
+
const xs = ops.map((x) => x.evaluate({ numericApproximation: numericApproximation2 }));
|
|
34653
|
+
return engine.number(
|
|
34654
|
+
bignumPreferred(engine) ? bigMedian(flattenBigScalars(xs)) : median(flattenScalars(xs))
|
|
34655
|
+
);
|
|
34656
|
+
}
|
|
34605
34657
|
},
|
|
34606
34658
|
Variance: {
|
|
34607
34659
|
complexity: 1200,
|
|
34608
34660
|
broadcastable: false,
|
|
34609
34661
|
signature: "((collection|number)+) -> number",
|
|
34610
34662
|
type: () => "finite_real",
|
|
34611
|
-
evaluate: (ops, { engine }) =>
|
|
34612
|
-
|
|
34613
|
-
|
|
34663
|
+
evaluate: (ops, { engine, numericApproximation: numericApproximation2 }) => {
|
|
34664
|
+
const xs = ops.map((x) => x.evaluate({ numericApproximation: numericApproximation2 }));
|
|
34665
|
+
return engine.number(
|
|
34666
|
+
bignumPreferred(engine) ? bigVariance(engine.bignum.bind(engine), flattenBigScalars(xs)) : variance(flattenScalars(xs))
|
|
34667
|
+
);
|
|
34668
|
+
}
|
|
34614
34669
|
},
|
|
34615
34670
|
PopulationVariance: {
|
|
34616
34671
|
complexity: 1200,
|
|
34617
34672
|
broadcastable: false,
|
|
34618
34673
|
signature: "((collection|number)+) -> number",
|
|
34619
34674
|
type: () => "finite_real",
|
|
34620
|
-
evaluate: (ops, { engine }) =>
|
|
34621
|
-
|
|
34622
|
-
|
|
34623
|
-
|
|
34624
|
-
|
|
34625
|
-
|
|
34675
|
+
evaluate: (ops, { engine, numericApproximation: numericApproximation2 }) => {
|
|
34676
|
+
const xs = ops.map((x) => x.evaluate({ numericApproximation: numericApproximation2 }));
|
|
34677
|
+
return engine.number(
|
|
34678
|
+
bignumPreferred(engine) ? bigPopulationVariance(
|
|
34679
|
+
engine.bignum.bind(engine),
|
|
34680
|
+
flattenBigScalars(xs)
|
|
34681
|
+
) : populationVariance(flattenScalars(xs))
|
|
34682
|
+
);
|
|
34683
|
+
}
|
|
34626
34684
|
},
|
|
34627
34685
|
StandardDeviation: {
|
|
34628
34686
|
complexity: 1200,
|
|
@@ -34630,12 +34688,15 @@ var STATISTICS_LIBRARY = [
|
|
|
34630
34688
|
description: "Sample Standard Deviation of a collection of numbers.",
|
|
34631
34689
|
signature: "((collection|number)+) -> number",
|
|
34632
34690
|
type: () => "finite_real",
|
|
34633
|
-
evaluate: (ops, { engine }) =>
|
|
34634
|
-
|
|
34635
|
-
|
|
34636
|
-
|
|
34637
|
-
|
|
34638
|
-
|
|
34691
|
+
evaluate: (ops, { engine, numericApproximation: numericApproximation2 }) => {
|
|
34692
|
+
const xs = ops.map((x) => x.evaluate({ numericApproximation: numericApproximation2 }));
|
|
34693
|
+
return engine.number(
|
|
34694
|
+
bignumPreferred(engine) ? bigVariance(
|
|
34695
|
+
engine.bignum.bind(engine),
|
|
34696
|
+
flattenBigScalars(xs)
|
|
34697
|
+
).sqrt() : Math.sqrt(variance(flattenScalars(xs)))
|
|
34698
|
+
);
|
|
34699
|
+
}
|
|
34639
34700
|
},
|
|
34640
34701
|
PopulationStandardDeviation: {
|
|
34641
34702
|
complexity: 1200,
|
|
@@ -34643,47 +34704,60 @@ var STATISTICS_LIBRARY = [
|
|
|
34643
34704
|
description: "Population Standard Deviation of a collection of numbers.",
|
|
34644
34705
|
signature: "((collection|number)+) -> number",
|
|
34645
34706
|
type: () => "finite_real",
|
|
34646
|
-
evaluate: (ops, { engine }) =>
|
|
34647
|
-
|
|
34648
|
-
|
|
34649
|
-
|
|
34650
|
-
|
|
34651
|
-
|
|
34707
|
+
evaluate: (ops, { engine, numericApproximation: numericApproximation2 }) => {
|
|
34708
|
+
const xs = ops.map((x) => x.evaluate({ numericApproximation: numericApproximation2 }));
|
|
34709
|
+
return engine.number(
|
|
34710
|
+
bignumPreferred(engine) ? bigPopulationVariance(
|
|
34711
|
+
engine.bignum.bind(engine),
|
|
34712
|
+
flattenBigScalars(xs)
|
|
34713
|
+
).sqrt() : Math.sqrt(populationVariance(flattenScalars(xs)))
|
|
34714
|
+
);
|
|
34715
|
+
}
|
|
34652
34716
|
},
|
|
34653
34717
|
Kurtosis: {
|
|
34654
34718
|
complexity: 1200,
|
|
34655
34719
|
broadcastable: false,
|
|
34656
34720
|
signature: "((collection|number)+) -> number",
|
|
34657
34721
|
type: () => "finite_real",
|
|
34658
|
-
evaluate: (ops, { engine }) =>
|
|
34659
|
-
|
|
34660
|
-
|
|
34722
|
+
evaluate: (ops, { engine, numericApproximation: numericApproximation2 }) => {
|
|
34723
|
+
const xs = ops.map((x) => x.evaluate({ numericApproximation: numericApproximation2 }));
|
|
34724
|
+
return engine.number(
|
|
34725
|
+
bignumPreferred(engine) ? bigKurtosis(engine.bignum.bind(engine), flattenBigScalars(xs)) : kurtosis(flattenScalars(xs))
|
|
34726
|
+
);
|
|
34727
|
+
}
|
|
34661
34728
|
},
|
|
34662
34729
|
Skewness: {
|
|
34663
34730
|
complexity: 1200,
|
|
34664
34731
|
broadcastable: false,
|
|
34665
34732
|
signature: "((collection|number)+) -> number",
|
|
34666
34733
|
type: () => "finite_real",
|
|
34667
|
-
evaluate: (ops, { engine }) =>
|
|
34668
|
-
|
|
34669
|
-
|
|
34734
|
+
evaluate: (ops, { engine, numericApproximation: numericApproximation2 }) => {
|
|
34735
|
+
const xs = ops.map((x) => x.evaluate({ numericApproximation: numericApproximation2 }));
|
|
34736
|
+
return engine.number(
|
|
34737
|
+
bignumPreferred(engine) ? bigSkewness(engine.bignum.bind(engine), flattenBigScalars(xs)) : skewness(flattenScalars(xs))
|
|
34738
|
+
);
|
|
34739
|
+
}
|
|
34670
34740
|
},
|
|
34671
34741
|
Mode: {
|
|
34672
34742
|
complexity: 1200,
|
|
34673
34743
|
broadcastable: false,
|
|
34674
34744
|
signature: "((collection|number)+) -> number",
|
|
34675
34745
|
type: () => "finite_real",
|
|
34676
|
-
evaluate: (ops, { engine }) =>
|
|
34677
|
-
|
|
34678
|
-
|
|
34746
|
+
evaluate: (ops, { engine, numericApproximation: numericApproximation2 }) => {
|
|
34747
|
+
const xs = ops.map((x) => x.evaluate({ numericApproximation: numericApproximation2 }));
|
|
34748
|
+
return engine.number(
|
|
34749
|
+
bignumPreferred(engine) ? bigMode(engine.bignum.bind(engine), flattenBigScalars(xs)) : mode(flattenScalars(xs))
|
|
34750
|
+
);
|
|
34751
|
+
}
|
|
34679
34752
|
},
|
|
34680
34753
|
Quartiles: {
|
|
34681
34754
|
complexity: 1200,
|
|
34682
34755
|
broadcastable: false,
|
|
34683
34756
|
signature: "((collection|number)+) -> tuple<mid:number, lower:number, upper:number>",
|
|
34684
34757
|
examples: ["Quartiles([1, 2, 3, 4, 5]) // Returns (3, 2, 4)"],
|
|
34685
|
-
evaluate: (ops, { engine }) => {
|
|
34686
|
-
const
|
|
34758
|
+
evaluate: (ops, { engine, numericApproximation: numericApproximation2 }) => {
|
|
34759
|
+
const xs = ops.map((x) => x.evaluate({ numericApproximation: numericApproximation2 }));
|
|
34760
|
+
const [mid, lower, upper] = (bignumPreferred(engine) ? bigQuartiles(flattenBigScalars(xs)) : quartiles(flattenScalars(xs))).map((v) => engine.number(v));
|
|
34687
34761
|
return engine.tuple(mid, lower, upper);
|
|
34688
34762
|
}
|
|
34689
34763
|
},
|
|
@@ -34692,9 +34766,12 @@ var STATISTICS_LIBRARY = [
|
|
|
34692
34766
|
broadcastable: false,
|
|
34693
34767
|
signature: "((collection|number)+) -> number",
|
|
34694
34768
|
type: () => "finite_real",
|
|
34695
|
-
evaluate: (ops, { engine }) =>
|
|
34696
|
-
|
|
34697
|
-
|
|
34769
|
+
evaluate: (ops, { engine, numericApproximation: numericApproximation2 }) => {
|
|
34770
|
+
const xs = ops.map((x) => x.evaluate({ numericApproximation: numericApproximation2 }));
|
|
34771
|
+
return engine.number(
|
|
34772
|
+
bignumPreferred(engine) ? bigInterquartileRange(flattenBigScalars(xs)) : interquartileRange(flattenScalars(xs))
|
|
34773
|
+
);
|
|
34774
|
+
}
|
|
34698
34775
|
},
|
|
34699
34776
|
Histogram: {
|
|
34700
34777
|
description: "Compute a histogram of the values in a collection. Returns a list of (bin start, count) tuples.",
|
|
@@ -42318,12 +42395,16 @@ var BoxedFunction = class extends _BoxedExpression {
|
|
|
42318
42395
|
this.engine.context.values[k] = v;
|
|
42319
42396
|
}
|
|
42320
42397
|
}
|
|
42321
|
-
|
|
42322
|
-
|
|
42323
|
-
|
|
42324
|
-
|
|
42325
|
-
|
|
42326
|
-
|
|
42398
|
+
let evalResult;
|
|
42399
|
+
try {
|
|
42400
|
+
evalResult = def.evaluate?.(tail, {
|
|
42401
|
+
numericApproximation: numericApproximation2,
|
|
42402
|
+
engine: this.engine,
|
|
42403
|
+
materialization
|
|
42404
|
+
});
|
|
42405
|
+
} finally {
|
|
42406
|
+
if (isScoped) this.engine._popEvalContext();
|
|
42407
|
+
}
|
|
42327
42408
|
return evalResult ?? this.engine.function(this._operator, tail);
|
|
42328
42409
|
};
|
|
42329
42410
|
}
|
|
@@ -47446,9 +47527,13 @@ function assignFn(ce, arg1, arg2) {
|
|
|
47446
47527
|
const def = ce.lookupDefinition(id);
|
|
47447
47528
|
if (isOperatorDef(def)) {
|
|
47448
47529
|
const value2 = assignValueAsValue(ce, arg2);
|
|
47449
|
-
if (value2
|
|
47530
|
+
if (value2 !== void 0) {
|
|
47531
|
+
updateDef(ce, id, def, { value: value2 });
|
|
47532
|
+
ce._setSymbolValue(id, value2);
|
|
47533
|
+
return ce;
|
|
47534
|
+
}
|
|
47450
47535
|
const fnDef2 = assignValueAsOperatorDef(ce, arg2);
|
|
47451
|
-
if (!fnDef2) throw Error(`
|
|
47536
|
+
if (!fnDef2) throw Error(`Invalid definition for symbol "${id}"`);
|
|
47452
47537
|
updateDef(ce, id, def, fnDef2);
|
|
47453
47538
|
return ce;
|
|
47454
47539
|
}
|
|
@@ -61033,10 +61118,10 @@ var ComputeEngine = class _ComputeEngine {
|
|
|
61033
61118
|
_setComputeEngineClass(ComputeEngine);
|
|
61034
61119
|
|
|
61035
61120
|
// src/compute-engine.ts
|
|
61036
|
-
var version = "0.50.
|
|
61121
|
+
var version = "0.50.2";
|
|
61037
61122
|
globalThis[Symbol.for("io.cortexjs.compute-engine")] = {
|
|
61038
61123
|
ComputeEngine: ComputeEngine.prototype.constructor,
|
|
61039
|
-
version: "0.50.
|
|
61124
|
+
version: "0.50.2"
|
|
61040
61125
|
};
|
|
61041
61126
|
export {
|
|
61042
61127
|
BaseCompiler,
|