@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
|
(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 __defProp = Object.defineProperty;
|
|
@@ -5443,15 +5443,14 @@ var ComputeEngine = (() => {
|
|
|
5443
5443
|
}
|
|
5444
5444
|
if (a instanceof Decimal) {
|
|
5445
5445
|
if (!a.isInteger()) return null;
|
|
5446
|
-
return
|
|
5446
|
+
return BigInt(a.toFixed(0));
|
|
5447
5447
|
}
|
|
5448
5448
|
let s = a.toLowerCase();
|
|
5449
|
-
const m = s.match(
|
|
5449
|
+
const m = s.match(/^([+-]?[0-9]+)e([+-]?[0-9]+)$/);
|
|
5450
5450
|
if (m) {
|
|
5451
|
-
const exp3 = parseInt(m[
|
|
5452
|
-
|
|
5453
|
-
|
|
5454
|
-
s = (m[1] ?? "") + (m[2] ?? "") + "0".repeat(pad);
|
|
5451
|
+
const exp3 = parseInt(m[2]);
|
|
5452
|
+
if (exp3 < 0) return null;
|
|
5453
|
+
s = m[1] + "0".repeat(exp3);
|
|
5455
5454
|
}
|
|
5456
5455
|
const i = s.indexOf(".");
|
|
5457
5456
|
if (i >= 0) return null;
|
|
@@ -9762,6 +9761,23 @@ var ComputeEngine = (() => {
|
|
|
9762
9761
|
if (!m) return serializeAutoNotationNumber(valString, options);
|
|
9763
9762
|
let exponent = parseInt(m[2]);
|
|
9764
9763
|
let mantissa = m[1];
|
|
9764
|
+
{
|
|
9765
|
+
const signMatch = mantissa.match(/^(-?)/);
|
|
9766
|
+
const sign3 = signMatch ? signMatch[1] : "";
|
|
9767
|
+
const unsigned = sign3 ? mantissa.substring(1) : mantissa;
|
|
9768
|
+
const parts = unsigned.match(/^(\d+)(?:\.(\d*))?$/);
|
|
9769
|
+
if (parts) {
|
|
9770
|
+
let whole = parts[1];
|
|
9771
|
+
let fraction = parts[2] ?? "";
|
|
9772
|
+
if (whole.length > 1) {
|
|
9773
|
+
fraction = whole.slice(1) + fraction;
|
|
9774
|
+
exponent += whole.length - 1;
|
|
9775
|
+
whole = whole[0];
|
|
9776
|
+
}
|
|
9777
|
+
mantissa = sign3 + whole;
|
|
9778
|
+
if (fraction) mantissa += "." + fraction;
|
|
9779
|
+
}
|
|
9780
|
+
}
|
|
9765
9781
|
if (Math.abs(exponent) % expMultiple !== 0) {
|
|
9766
9782
|
const adjust = exponent > 0 ? exponent % expMultiple : -((expMultiple + exponent) % expMultiple);
|
|
9767
9783
|
exponent = exponent >= 0 ? exponent - adjust : exponent + adjust;
|
|
@@ -11720,7 +11736,8 @@ var ComputeEngine = (() => {
|
|
|
11720
11736
|
}
|
|
11721
11737
|
} else {
|
|
11722
11738
|
console.assert(isSubtype(value.type, "integer"));
|
|
11723
|
-
|
|
11739
|
+
const intValue = BigInt(value.bignumRe.toFixed(0));
|
|
11740
|
+
rationalSum = add2(rationalSum, [intValue, BigInt(1)]);
|
|
11724
11741
|
}
|
|
11725
11742
|
}
|
|
11726
11743
|
if (isZero(rationalSum) && radicals.length === 0) {
|
|
@@ -12086,11 +12103,14 @@ var ComputeEngine = (() => {
|
|
|
12086
12103
|
const ce = op1.engine;
|
|
12087
12104
|
if (!op1.isValid || !op2.isValid) return ce._fn("Divide", [op1, op2]);
|
|
12088
12105
|
if (op1.isNaN || op2.isNaN) return ce.NaN;
|
|
12089
|
-
const op2IsConstantExpression = op2.
|
|
12106
|
+
const op2IsConstantExpression = op2.unknowns.length === 0 && !op2.isNumberLiteral;
|
|
12090
12107
|
if (op2.is(0)) return op1.is(0) ? ce.NaN : ce.ComplexInfinity;
|
|
12091
12108
|
if (op1.is(0) && op2.isFinite !== false) {
|
|
12092
12109
|
if (op2IsConstantExpression)
|
|
12093
|
-
return ce.
|
|
12110
|
+
return ce.function("Divide", [op1, op2], {
|
|
12111
|
+
canonical: false,
|
|
12112
|
+
structural: true
|
|
12113
|
+
});
|
|
12094
12114
|
return ce.Zero;
|
|
12095
12115
|
}
|
|
12096
12116
|
if (op2.isInfinity) return op1.isInfinity ? ce.NaN : ce.Zero;
|
|
@@ -12099,7 +12119,10 @@ var ComputeEngine = (() => {
|
|
|
12099
12119
|
return ce.One;
|
|
12100
12120
|
if (op1.isSame(op2)) {
|
|
12101
12121
|
if (op2IsConstantExpression)
|
|
12102
|
-
return ce.
|
|
12122
|
+
return ce.function("Divide", [op1, op2], {
|
|
12123
|
+
canonical: false,
|
|
12124
|
+
structural: true
|
|
12125
|
+
});
|
|
12103
12126
|
return ce.One;
|
|
12104
12127
|
}
|
|
12105
12128
|
}
|
|
@@ -15250,7 +15273,7 @@ var ComputeEngine = (() => {
|
|
|
15250
15273
|
}
|
|
15251
15274
|
function canonicalPower(a, b) {
|
|
15252
15275
|
const ce = a.engine;
|
|
15253
|
-
const fullyCanonical = a.isCanonical && b.isCanonical;
|
|
15276
|
+
const fullyCanonical = (a.isCanonical || a.isStructural) && (b.isCanonical || b.isStructural);
|
|
15254
15277
|
const unchanged = () => ce._fn("Power", [a, b], { canonical: fullyCanonical });
|
|
15255
15278
|
if (a.operator === "Power") {
|
|
15256
15279
|
const [base, aPow] = a.ops;
|
|
@@ -15296,7 +15319,7 @@ var ComputeEngine = (() => {
|
|
|
15296
15319
|
if (a.is(-1)) return ce.NegativeOne;
|
|
15297
15320
|
if (a.is(1)) return ce.One;
|
|
15298
15321
|
}
|
|
15299
|
-
if (!a.isCanonical)
|
|
15322
|
+
if (!(a.isCanonical || a.isStructural))
|
|
15300
15323
|
return ce._fn("Power", [a, ce.number(-1)], { canonical: false });
|
|
15301
15324
|
return a.inv();
|
|
15302
15325
|
}
|
|
@@ -15352,10 +15375,10 @@ var ComputeEngine = (() => {
|
|
|
15352
15375
|
}
|
|
15353
15376
|
}
|
|
15354
15377
|
if (b.is(0.5))
|
|
15355
|
-
return a.isCanonical ? canonicalRoot(a, 2) : ce._fn("Sqrt", [a], { canonical: false });
|
|
15378
|
+
return a.isCanonical || a.isStructural ? canonicalRoot(a, 2) : ce._fn("Sqrt", [a], { canonical: false });
|
|
15356
15379
|
const r = asRational(b);
|
|
15357
15380
|
if (r !== void 0 && r[0] === 1 && r[1] !== 1)
|
|
15358
|
-
return a.isCanonical ? canonicalRoot(a, ce.number(r[1])) : ce._fn("Root", [a, ce.number(r[1])], { canonical: false });
|
|
15381
|
+
return a.isCanonical || a.isStructural ? canonicalRoot(a, ce.number(r[1])) : ce._fn("Root", [a, ce.number(r[1])], { canonical: false });
|
|
15359
15382
|
return unchanged();
|
|
15360
15383
|
}
|
|
15361
15384
|
function canonicalRoot(a, b) {
|
|
@@ -15374,14 +15397,14 @@ var ComputeEngine = (() => {
|
|
|
15374
15397
|
if (v.numericValue.isExact) return v;
|
|
15375
15398
|
}
|
|
15376
15399
|
}
|
|
15377
|
-
return ce._fn("Sqrt", [a], { canonical: a.isCanonical });
|
|
15400
|
+
return ce._fn("Sqrt", [a], { canonical: a.isCanonical || a.isStructural });
|
|
15378
15401
|
}
|
|
15379
15402
|
return ce._fn("Root", [a, typeof b === "number" ? ce.number(b) : b], {
|
|
15380
|
-
canonical: a.isCanonical && (typeof b === "number" || b.isCanonical)
|
|
15403
|
+
canonical: (a.isCanonical || a.isStructural) && (typeof b === "number" || b.isCanonical || b.isStructural)
|
|
15381
15404
|
});
|
|
15382
15405
|
}
|
|
15383
15406
|
function pow2(x, exp3, { numericApproximation }) {
|
|
15384
|
-
if (!x.isCanonical || typeof exp3 !== "number" && !exp3.isCanonical)
|
|
15407
|
+
if (!(x.isCanonical || x.isStructural) || typeof exp3 !== "number" && !(exp3.isCanonical || exp3.isStructural))
|
|
15385
15408
|
return x.engine._fn("Power", [x, x.engine.box(exp3)], { canonical: false });
|
|
15386
15409
|
if (numericApproximation) {
|
|
15387
15410
|
if (x.isNumberLiteral) {
|
|
@@ -15477,7 +15500,7 @@ var ComputeEngine = (() => {
|
|
|
15477
15500
|
return ce._fn("Power", [x, ce.box(exp3)]);
|
|
15478
15501
|
}
|
|
15479
15502
|
function root(a, b, { numericApproximation }) {
|
|
15480
|
-
if (!a.isCanonical || !b.isCanonical)
|
|
15503
|
+
if (!(a.isCanonical || a.isStructural) || !(b.isCanonical || b.isStructural))
|
|
15481
15504
|
return a.engine._fn("Root", [a, b], { canonical: false });
|
|
15482
15505
|
if (numericApproximation) {
|
|
15483
15506
|
if (a.isNumberLiteral && b.isNumberLiteral) {
|
|
@@ -15683,7 +15706,7 @@ var ComputeEngine = (() => {
|
|
|
15683
15706
|
return (a.complexity ?? DEFAULT_COMPLEXITY) - (b.complexity ?? DEFAULT_COMPLEXITY);
|
|
15684
15707
|
}
|
|
15685
15708
|
function canonicalOrder(expr, { recursive = false }) {
|
|
15686
|
-
if (expr.isCanonical || !expr.ops) return expr;
|
|
15709
|
+
if (expr.isCanonical || expr.isStructural || !expr.ops) return expr;
|
|
15687
15710
|
let ops = expr.ops;
|
|
15688
15711
|
if (recursive) ops = ops.map((x) => canonicalOrder(x, { recursive }));
|
|
15689
15712
|
ops = sortOperands(expr.operator, ops);
|
|
@@ -23797,6 +23820,24 @@ ${e.message}`);
|
|
|
23797
23820
|
});
|
|
23798
23821
|
|
|
23799
23822
|
// src/compute-engine/boxed-expression/validate.ts
|
|
23823
|
+
function typeCouldBeCollection(type2) {
|
|
23824
|
+
if (typeof type2 === "string") {
|
|
23825
|
+
return type2 === "collection" || type2 === "indexed_collection" || type2 === "list" || type2 === "set" || type2 === "tuple" || type2 === "any";
|
|
23826
|
+
}
|
|
23827
|
+
if (type2.kind === "list" || type2.kind === "set" || type2.kind === "tuple")
|
|
23828
|
+
return true;
|
|
23829
|
+
if (type2.kind === "union") return type2.types.some((t) => typeCouldBeCollection(t));
|
|
23830
|
+
return false;
|
|
23831
|
+
}
|
|
23832
|
+
function typeCouldBeNumericCollection(type2) {
|
|
23833
|
+
if (typeof type2 === "string") {
|
|
23834
|
+
return type2 === "list" || type2 === "set" || type2 === "collection" || type2 === "indexed_collection";
|
|
23835
|
+
}
|
|
23836
|
+
if (type2.kind === "list" || type2.kind === "set") return true;
|
|
23837
|
+
if (type2.kind === "union")
|
|
23838
|
+
return type2.types.some((t) => typeCouldBeNumericCollection(t));
|
|
23839
|
+
return false;
|
|
23840
|
+
}
|
|
23800
23841
|
function checkArity(ce, ops, count) {
|
|
23801
23842
|
ops = flatten(ops);
|
|
23802
23843
|
if (!ce.strict) return ops;
|
|
@@ -23846,7 +23887,9 @@ ${e.message}`);
|
|
|
23846
23887
|
xs.push(op);
|
|
23847
23888
|
} else if (op.symbol && !ce.lookupDefinition(op.symbol)) {
|
|
23848
23889
|
xs.push(op);
|
|
23849
|
-
} else if (op.type.isUnknown) {
|
|
23890
|
+
} else if (op.type.isUnknown || op.type.type === "any") {
|
|
23891
|
+
xs.push(op);
|
|
23892
|
+
} else if (typeCouldBeNumericCollection(op.type.type)) {
|
|
23850
23893
|
xs.push(op);
|
|
23851
23894
|
} else if (isBoxedTensor(op)) {
|
|
23852
23895
|
xs.push(op);
|
|
@@ -23930,11 +23973,11 @@ ${e.message}`);
|
|
|
23930
23973
|
isValid = false;
|
|
23931
23974
|
continue;
|
|
23932
23975
|
}
|
|
23933
|
-
if (op.type.isUnknown) {
|
|
23976
|
+
if (op.type.isUnknown || op.type.type === "any") {
|
|
23934
23977
|
result.push(op);
|
|
23935
23978
|
continue;
|
|
23936
23979
|
}
|
|
23937
|
-
if (threadable && isFiniteIndexedCollection(op)) {
|
|
23980
|
+
if (threadable && (isFiniteIndexedCollection(op) || typeCouldBeCollection(op.type.type))) {
|
|
23938
23981
|
result.push(op);
|
|
23939
23982
|
continue;
|
|
23940
23983
|
}
|
|
@@ -23969,12 +24012,12 @@ ${e.message}`);
|
|
|
23969
24012
|
i += 1;
|
|
23970
24013
|
continue;
|
|
23971
24014
|
}
|
|
23972
|
-
if (op.type.isUnknown) {
|
|
24015
|
+
if (op.type.isUnknown || op.type.type === "any") {
|
|
23973
24016
|
result.push(op);
|
|
23974
24017
|
i += 1;
|
|
23975
24018
|
continue;
|
|
23976
24019
|
}
|
|
23977
|
-
if (threadable && isFiniteIndexedCollection(op)) {
|
|
24020
|
+
if (threadable && (isFiniteIndexedCollection(op) || typeCouldBeCollection(op.type.type))) {
|
|
23978
24021
|
result.push(op);
|
|
23979
24022
|
i += 1;
|
|
23980
24023
|
continue;
|
|
@@ -24007,11 +24050,11 @@ ${e.message}`);
|
|
|
24007
24050
|
isValid = false;
|
|
24008
24051
|
continue;
|
|
24009
24052
|
}
|
|
24010
|
-
if (op.type.isUnknown) {
|
|
24053
|
+
if (op.type.isUnknown || op.type.type === "any") {
|
|
24011
24054
|
result.push(op);
|
|
24012
24055
|
continue;
|
|
24013
24056
|
}
|
|
24014
|
-
if (threadable && isFiniteIndexedCollection(op)) {
|
|
24057
|
+
if (threadable && (isFiniteIndexedCollection(op) || typeCouldBeCollection(op.type.type))) {
|
|
24015
24058
|
result.push(op);
|
|
24016
24059
|
continue;
|
|
24017
24060
|
}
|
|
@@ -24041,20 +24084,22 @@ ${e.message}`);
|
|
|
24041
24084
|
i = 0;
|
|
24042
24085
|
for (const param of params) {
|
|
24043
24086
|
if (!lazy) {
|
|
24044
|
-
if (!threadable || !isFiniteIndexedCollection(ops[i]))
|
|
24087
|
+
if (!threadable || !isFiniteIndexedCollection(ops[i]) && !typeCouldBeCollection(ops[i].type.type))
|
|
24045
24088
|
ops[i].infer(param);
|
|
24046
24089
|
}
|
|
24047
24090
|
i += 1;
|
|
24048
24091
|
}
|
|
24049
24092
|
for (const param of optParams) {
|
|
24050
24093
|
if (!ops[i]) break;
|
|
24051
|
-
if (!threadable || !isFiniteIndexedCollection(ops[i])
|
|
24094
|
+
if (!threadable || !isFiniteIndexedCollection(ops[i]) && !typeCouldBeCollection(ops[i].type.type))
|
|
24095
|
+
ops[i]?.infer(param);
|
|
24052
24096
|
i += 1;
|
|
24053
24097
|
}
|
|
24054
24098
|
if (varParam) {
|
|
24055
24099
|
for (const op of ops.slice(i)) {
|
|
24056
24100
|
if (!lazy) {
|
|
24057
|
-
if (!threadable || !isFiniteIndexedCollection(op)
|
|
24101
|
+
if (!threadable || !isFiniteIndexedCollection(op) && !typeCouldBeCollection(op.type.type))
|
|
24102
|
+
op.infer(varParam);
|
|
24058
24103
|
}
|
|
24059
24104
|
i += 1;
|
|
24060
24105
|
}
|
|
@@ -35478,6 +35523,12 @@ ${lines.join("\n")}`;
|
|
|
35478
35523
|
throw Error("Invalid canonical form");
|
|
35479
35524
|
}
|
|
35480
35525
|
}
|
|
35526
|
+
if (expr.isFunctionExpression && expr.isCanonical) {
|
|
35527
|
+
expr = expr.engine.function(expr.operator, [...expr.ops], {
|
|
35528
|
+
canonical: false,
|
|
35529
|
+
structural: true
|
|
35530
|
+
});
|
|
35531
|
+
}
|
|
35481
35532
|
return expr;
|
|
35482
35533
|
}
|
|
35483
35534
|
function flattenForm(expr) {
|
|
@@ -35559,10 +35610,7 @@ ${lines.join("\n")}`;
|
|
|
35559
35610
|
if (!expr.ops) return expr;
|
|
35560
35611
|
const ops = expr.ops.map(multiplyForm);
|
|
35561
35612
|
if (expr.operator === "Multiply")
|
|
35562
|
-
return canonicalMultiply(
|
|
35563
|
-
expr.engine,
|
|
35564
|
-
ops.map((x) => x.canonical)
|
|
35565
|
-
);
|
|
35613
|
+
return canonicalMultiply(expr.engine, ops);
|
|
35566
35614
|
if (expr.operator === "Negate")
|
|
35567
35615
|
return canonicalMultiply(expr.engine, [ops[0], expr.engine.NegativeOne]);
|
|
35568
35616
|
return expr;
|
|
@@ -45696,7 +45744,7 @@ Error in definition of "${name}"`,
|
|
|
45696
45744
|
return void 0;
|
|
45697
45745
|
}
|
|
45698
45746
|
get isCanonical() {
|
|
45699
|
-
return this._def !== void 0 && this._def !== null;
|
|
45747
|
+
return this._def !== void 0 && this._def !== null && !this._isStructural;
|
|
45700
45748
|
}
|
|
45701
45749
|
get isPure() {
|
|
45702
45750
|
if (this._isPure !== void 0) return this._isPure;
|
|
@@ -45863,7 +45911,7 @@ Error in definition of "${name}"`,
|
|
|
45863
45911
|
subs(sub3, options) {
|
|
45864
45912
|
options ??= { canonical: void 0 };
|
|
45865
45913
|
if (options.canonical === void 0)
|
|
45866
|
-
options = { canonical: this.isCanonical };
|
|
45914
|
+
options = { canonical: this.isCanonical || this.isStructural };
|
|
45867
45915
|
const ops = this._ops.map((x) => x.subs(sub3, options));
|
|
45868
45916
|
if (!ops.every((x) => x.isValid))
|
|
45869
45917
|
return this.engine.function(this._operator, ops, { canonical: false });
|
|
@@ -45935,7 +45983,7 @@ Error in definition of "${name}"`,
|
|
|
45935
45983
|
return this.numeratorDenominator[1];
|
|
45936
45984
|
}
|
|
45937
45985
|
get numeratorDenominator() {
|
|
45938
|
-
if (!this.isCanonical) return [this, this.engine.One];
|
|
45986
|
+
if (!(this.isCanonical || this.isStructural)) return [this, this.engine.One];
|
|
45939
45987
|
if (this.isNumber !== true)
|
|
45940
45988
|
return [this.engine.Nothing, this.engine.Nothing];
|
|
45941
45989
|
const operator2 = this.operator;
|
|
@@ -45973,11 +46021,11 @@ Error in definition of "${name}"`,
|
|
|
45973
46021
|
// ALGEBRAIC OPERATIONS
|
|
45974
46022
|
//
|
|
45975
46023
|
neg() {
|
|
45976
|
-
if (!this.isCanonical) throw new Error("Not canonical");
|
|
46024
|
+
if (!(this.isCanonical || this.isStructural)) throw new Error("Not canonical");
|
|
45977
46025
|
return negate(this);
|
|
45978
46026
|
}
|
|
45979
46027
|
inv() {
|
|
45980
|
-
if (!this.isCanonical) throw new Error("Not canonical");
|
|
46028
|
+
if (!(this.isCanonical || this.isStructural)) throw new Error("Not canonical");
|
|
45981
46029
|
if (this.isOne) return this;
|
|
45982
46030
|
if (this.isNegativeOne) return this;
|
|
45983
46031
|
if (this.operator === "Sqrt") return this.op1.inv().sqrt();
|
|
@@ -45998,7 +46046,7 @@ Error in definition of "${name}"`,
|
|
|
45998
46046
|
return this.engine._fn("Divide", [this.engine.One, this]);
|
|
45999
46047
|
}
|
|
46000
46048
|
abs() {
|
|
46001
|
-
if (!this.isCanonical) throw new Error("Not canonical");
|
|
46049
|
+
if (!(this.isCanonical || this.isStructural)) throw new Error("Not canonical");
|
|
46002
46050
|
if (this.operator === "Abs" || this.operator === "Negate") return this;
|
|
46003
46051
|
if (this.isNonNegative) return this;
|
|
46004
46052
|
if (this.isNonPositive) return this.neg();
|
|
@@ -46006,11 +46054,11 @@ Error in definition of "${name}"`,
|
|
|
46006
46054
|
}
|
|
46007
46055
|
add(rhs) {
|
|
46008
46056
|
if (rhs === 0) return this;
|
|
46009
|
-
if (!this.isCanonical) throw new Error("Not canonical");
|
|
46057
|
+
if (!(this.isCanonical || this.isStructural)) throw new Error("Not canonical");
|
|
46010
46058
|
return add3(this, this.engine.box(rhs));
|
|
46011
46059
|
}
|
|
46012
46060
|
mul(rhs) {
|
|
46013
|
-
if (!this.isCanonical) throw new Error("Not canonical");
|
|
46061
|
+
if (!(this.isCanonical || this.isStructural)) throw new Error("Not canonical");
|
|
46014
46062
|
if (rhs === 0) return this.engine.Zero;
|
|
46015
46063
|
if (rhs === 1) return this;
|
|
46016
46064
|
if (rhs === -1) return this.neg();
|
|
@@ -46022,14 +46070,14 @@ Error in definition of "${name}"`,
|
|
|
46022
46070
|
return mul3(this, this.engine.box(rhs));
|
|
46023
46071
|
}
|
|
46024
46072
|
div(rhs) {
|
|
46025
|
-
if (!this.isCanonical) throw new Error("Not canonical");
|
|
46073
|
+
if (!(this.isCanonical || this.isStructural)) throw new Error("Not canonical");
|
|
46026
46074
|
return div2(this, rhs);
|
|
46027
46075
|
}
|
|
46028
46076
|
pow(exp3) {
|
|
46029
46077
|
return pow2(this, exp3, { numericApproximation: false });
|
|
46030
46078
|
}
|
|
46031
46079
|
root(exp3) {
|
|
46032
|
-
if (!this.isCanonical || typeof exp3 !== "number" && !exp3.isCanonical)
|
|
46080
|
+
if (!(this.isCanonical || this.isStructural) || typeof exp3 !== "number" && !(exp3.isCanonical || exp3.isStructural))
|
|
46033
46081
|
throw new Error("Not canonical");
|
|
46034
46082
|
const e = typeof exp3 === "number" ? exp3 : exp3.im === 0 ? exp3.re : void 0;
|
|
46035
46083
|
if (e === 0) return this.engine.NaN;
|
|
@@ -46088,7 +46136,7 @@ Error in definition of "${name}"`,
|
|
|
46088
46136
|
}
|
|
46089
46137
|
ln(semiBase) {
|
|
46090
46138
|
const base = semiBase ? this.engine.box(semiBase) : void 0;
|
|
46091
|
-
if (!this.isCanonical) throw new Error("Not canonical");
|
|
46139
|
+
if (!(this.isCanonical || this.isStructural)) throw new Error("Not canonical");
|
|
46092
46140
|
if (this.is(0)) return this.engine.NegativeInfinity;
|
|
46093
46141
|
if (this.operator === "Exp") {
|
|
46094
46142
|
if (!base) return this.op1;
|
|
@@ -46121,7 +46169,7 @@ Error in definition of "${name}"`,
|
|
|
46121
46169
|
return this.engine._fn("Ln", [this]);
|
|
46122
46170
|
}
|
|
46123
46171
|
get complexity() {
|
|
46124
|
-
if (!this.isCanonical) return void 0;
|
|
46172
|
+
if (!(this.isCanonical || this.isStructural)) return void 0;
|
|
46125
46173
|
return this.operatorDefinition?.complexity ?? DEFAULT_COMPLEXITY;
|
|
46126
46174
|
}
|
|
46127
46175
|
get baseDefinition() {
|
|
@@ -54708,12 +54756,11 @@ IntervalResult ${functionName}(${params}) {
|
|
|
54708
54756
|
bignum
|
|
54709
54757
|
);
|
|
54710
54758
|
if (value instanceof Decimal) {
|
|
54711
|
-
if (value.isInteger() && value.e <= MAX_BIGINT_DIGITS)
|
|
54712
|
-
|
|
54713
|
-
|
|
54714
|
-
makeNumericValue,
|
|
54715
|
-
|
|
54716
|
-
);
|
|
54759
|
+
if (value.isInteger() && value.e <= MAX_BIGINT_DIGITS) {
|
|
54760
|
+
const n = bigint(value.toString());
|
|
54761
|
+
if (n !== null)
|
|
54762
|
+
return new ExactNumericValue(n, makeNumericValue, bignum);
|
|
54763
|
+
}
|
|
54717
54764
|
return makeNumericValue(value);
|
|
54718
54765
|
}
|
|
54719
54766
|
if (value instanceof Complex) {
|
|
@@ -55779,10 +55826,10 @@ IntervalResult ${functionName}(${params}) {
|
|
|
55779
55826
|
// src/compute-engine.ts
|
|
55780
55827
|
init_types6();
|
|
55781
55828
|
init_base_compiler();
|
|
55782
|
-
var version = "0.35.
|
|
55829
|
+
var version = "0.35.2";
|
|
55783
55830
|
globalThis[Symbol.for("io.cortexjs.compute-engine")] = {
|
|
55784
55831
|
ComputeEngine: ComputeEngine.prototype.constructor,
|
|
55785
|
-
version: "0.35.
|
|
55832
|
+
version: "0.35.2"
|
|
55786
55833
|
};
|
|
55787
55834
|
return __toCommonJS(compute_engine_exports);
|
|
55788
55835
|
})();
|
package/dist/math-json.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Compute Engine 0.35.
|
|
1
|
+
/** Compute Engine 0.35.2 */
|
|
2
2
|
|
|
3
3
|
// src/math-json/utils.ts
|
|
4
4
|
function isNumberObject(expr) {
|
|
@@ -115,7 +115,7 @@ function expressionToDictionaryValue(expr) {
|
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
// src/math-json.ts
|
|
118
|
-
var version = "0.35.
|
|
118
|
+
var version = "0.35.2";
|
|
119
119
|
export {
|
|
120
120
|
dictionaryFromExpression,
|
|
121
121
|
isFunctionObject,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/** Compute Engine 0.35.
|
|
2
|
-
function d(n){return n!==null&&typeof n=="object"&&"num"in n}function s(n){return n!==null&&typeof n=="object"&&"sym"in n}function a(n){return n!==null&&typeof n=="object"&&"str"in n}function m(n){return n!==null&&typeof n=="object"&&"dict"in n&&typeof n.dict=="object"&&!Array.isArray(n.dict)&&n.dict!==null}function u(n){return n!==null&&typeof n=="object"&&"fn"in n&&Array.isArray(n.fn)&&n.fn.length>0&&typeof n.fn[0]=="string"}function c(n){return n==null?null:typeof n=="object"&&"str"in n?n.str:typeof n!="string"?null:n.length>=2&&n.at(0)==="'"&&n.at(-1)==="'"?n.substring(1,n.length-1):M(n)||b(n)?null:n}function l(n){return Array.isArray(n)?n[0]:n==null?"":u(n)?n.fn[0]:""}function y(n){return Array.isArray(n)?n.slice(1):n!==void 0&&u(n)?n.fn.slice(1):[]}function E(n,t){return Array.isArray(n)?n[t]??null:n===null||!u(n)?null:n.fn[t]??null}function h(n){return n==null?0:Array.isArray(n)?Math.max(0,n.length-1):u(n)?Math.max(0,n.fn.length-1):0}function g(n){return typeof n=="string"&&b(n)?n.length>=2&&n.at(0)==="`"&&n.at(-1)==="`"?n.slice(1,-1):n:n==null?null:s(n)?n.sym:null}function f(n){let t=l(n);if(t==="KeyValuePair"||t==="Tuple"||t==="Pair"){let[i,r]=y(n),e=c(i);return e?[e,r??"Nothing"]:null}return null}function j(n){if(n===null)return null;if(m(n))return n;let t=f(n);if(t)return{[t[0]]:t[1]};if(l(n)==="Dictionary"){let i={},r=y(n);for(let e=1;e<h(n);e++){let o=f(r[e]);o&&(i[o[0]]=A(o[1])??"Nothing")}return{dict:i}}return null}function O(n,t){let i=null;if(Array.isArray(n)&&(i=n),u(n)&&(i=n.fn),i===null)return[];let r=1,e=[];for(;r<i.length;)e.push(t(i[r])),r+=1;return e}function M(n){return/^(nan|oo|\+oo|-oo|infinity|\+infinity|-infinity)$/i.test(n)||/^[+-]?(0|[1-9][0-9]*)(\.[0-9]+)?(\([0-9]+\))?([eE][+-]?[0-9]+)?$/.test(n)}function b(n){return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(n)||n.length>=2&&n[0]==="`"&&n[n.length-1]==="`"}function A(n){return n==null?null:a(n)?n.str:d(n)?parseFloat(n.num):s(n)?n.sym:typeof n=="string"||typeof n=="number"?n:Array.isArray(n)?{fn:n}:n}var S="0.35.
|
|
1
|
+
/** Compute Engine 0.35.2 */
|
|
2
|
+
function d(n){return n!==null&&typeof n=="object"&&"num"in n}function s(n){return n!==null&&typeof n=="object"&&"sym"in n}function a(n){return n!==null&&typeof n=="object"&&"str"in n}function m(n){return n!==null&&typeof n=="object"&&"dict"in n&&typeof n.dict=="object"&&!Array.isArray(n.dict)&&n.dict!==null}function u(n){return n!==null&&typeof n=="object"&&"fn"in n&&Array.isArray(n.fn)&&n.fn.length>0&&typeof n.fn[0]=="string"}function c(n){return n==null?null:typeof n=="object"&&"str"in n?n.str:typeof n!="string"?null:n.length>=2&&n.at(0)==="'"&&n.at(-1)==="'"?n.substring(1,n.length-1):M(n)||b(n)?null:n}function l(n){return Array.isArray(n)?n[0]:n==null?"":u(n)?n.fn[0]:""}function y(n){return Array.isArray(n)?n.slice(1):n!==void 0&&u(n)?n.fn.slice(1):[]}function E(n,t){return Array.isArray(n)?n[t]??null:n===null||!u(n)?null:n.fn[t]??null}function h(n){return n==null?0:Array.isArray(n)?Math.max(0,n.length-1):u(n)?Math.max(0,n.fn.length-1):0}function g(n){return typeof n=="string"&&b(n)?n.length>=2&&n.at(0)==="`"&&n.at(-1)==="`"?n.slice(1,-1):n:n==null?null:s(n)?n.sym:null}function f(n){let t=l(n);if(t==="KeyValuePair"||t==="Tuple"||t==="Pair"){let[i,r]=y(n),e=c(i);return e?[e,r??"Nothing"]:null}return null}function j(n){if(n===null)return null;if(m(n))return n;let t=f(n);if(t)return{[t[0]]:t[1]};if(l(n)==="Dictionary"){let i={},r=y(n);for(let e=1;e<h(n);e++){let o=f(r[e]);o&&(i[o[0]]=A(o[1])??"Nothing")}return{dict:i}}return null}function O(n,t){let i=null;if(Array.isArray(n)&&(i=n),u(n)&&(i=n.fn),i===null)return[];let r=1,e=[];for(;r<i.length;)e.push(t(i[r])),r+=1;return e}function M(n){return/^(nan|oo|\+oo|-oo|infinity|\+infinity|-infinity)$/i.test(n)||/^[+-]?(0|[1-9][0-9]*)(\.[0-9]+)?(\([0-9]+\))?([eE][+-]?[0-9]+)?$/.test(n)}function b(n){return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(n)||n.length>=2&&n[0]==="`"&&n[n.length-1]==="`"}function A(n){return n==null?null:a(n)?n.str:d(n)?parseFloat(n.num):s(n)?n.sym:typeof n=="string"||typeof n=="number"?n:Array.isArray(n)?{fn:n}:n}var S="0.35.2";export{j as dictionaryFromExpression,u as isFunctionObject,a as isStringObject,s as isSymbolObject,O as mapArgs,E as operand,l as operator,c as stringValue,g as symbol,S as version};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** MathJSON 0.35.
|
|
1
|
+
/** MathJSON 0.35.2 */
|
|
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.MathJson = {}));})(this, (function (exports) { 'use strict';
|
|
3
|
-
var MathJson=(()=>{var f=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var M=Object.prototype.hasOwnProperty;var A=(n,t)=>{for(var i in t)f(n,i,{get:t[i],enumerable:!0})},J=(n,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of O(t))!M.call(n,e)&&e!==i&&f(n,e,{get:()=>t[e],enumerable:!(r=j(t,e))||r.enumerable});return n};var S=n=>J(f({},"__esModule",{value:!0}),n);var T={};A(T,{dictionaryFromExpression:()=>E,isFunctionObject:()=>u,isStringObject:()=>a,isSymbolObject:()=>o,mapArgs:()=>h,operand:()=>d,operator:()=>s,stringValue:()=>c,symbol:()=>m,version:()=>V});function N(n){return n!==null&&typeof n=="object"&&"num"in n}function o(n){return n!==null&&typeof n=="object"&&"sym"in n}function a(n){return n!==null&&typeof n=="object"&&"str"in n}function p(n){return n!==null&&typeof n=="object"&&"dict"in n&&typeof n.dict=="object"&&!Array.isArray(n.dict)&&n.dict!==null}function u(n){return n!==null&&typeof n=="object"&&"fn"in n&&Array.isArray(n.fn)&&n.fn.length>0&&typeof n.fn[0]=="string"}function c(n){return n==null?null:typeof n=="object"&&"str"in n?n.str:typeof n!="string"?null:n.length>=2&&n.at(0)==="'"&&n.at(-1)==="'"?n.substring(1,n.length-1):k(n)||g(n)?null:n}function s(n){return Array.isArray(n)?n[0]:n==null?"":u(n)?n.fn[0]:""}function b(n){return Array.isArray(n)?n.slice(1):n!==void 0&&u(n)?n.fn.slice(1):[]}function d(n,t){return Array.isArray(n)?n[t]??null:n===null||!u(n)?null:n.fn[t]??null}function D(n){return n==null?0:Array.isArray(n)?Math.max(0,n.length-1):u(n)?Math.max(0,n.fn.length-1):0}function m(n){return typeof n=="string"&&g(n)?n.length>=2&&n.at(0)==="`"&&n.at(-1)==="`"?n.slice(1,-1):n:n==null?null:o(n)?n.sym:null}function y(n){let t=s(n);if(t==="KeyValuePair"||t==="Tuple"||t==="Pair"){let[i,r]=b(n),e=c(i);return e?[e,r??"Nothing"]:null}return null}function E(n){if(n===null)return null;if(p(n))return n;let t=y(n);if(t)return{[t[0]]:t[1]};if(s(n)==="Dictionary"){let i={},r=b(n);for(let e=1;e<D(n);e++){let l=y(r[e]);l&&(i[l[0]]=F(l[1])??"Nothing")}return{dict:i}}return null}function h(n,t){let i=null;if(Array.isArray(n)&&(i=n),u(n)&&(i=n.fn),i===null)return[];let r=1,e=[];for(;r<i.length;)e.push(t(i[r])),r+=1;return e}function k(n){return/^(nan|oo|\+oo|-oo|infinity|\+infinity|-infinity)$/i.test(n)||/^[+-]?(0|[1-9][0-9]*)(\.[0-9]+)?(\([0-9]+\))?([eE][+-]?[0-9]+)?$/.test(n)}function g(n){return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(n)||n.length>=2&&n[0]==="`"&&n[n.length-1]==="`"}function F(n){return n==null?null:a(n)?n.str:N(n)?parseFloat(n.num):o(n)?n.sym:typeof n=="string"||typeof n=="number"?n:Array.isArray(n)?{fn:n}:n}var V="0.35.
|
|
3
|
+
var MathJson=(()=>{var f=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var M=Object.prototype.hasOwnProperty;var A=(n,t)=>{for(var i in t)f(n,i,{get:t[i],enumerable:!0})},J=(n,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of O(t))!M.call(n,e)&&e!==i&&f(n,e,{get:()=>t[e],enumerable:!(r=j(t,e))||r.enumerable});return n};var S=n=>J(f({},"__esModule",{value:!0}),n);var T={};A(T,{dictionaryFromExpression:()=>E,isFunctionObject:()=>u,isStringObject:()=>a,isSymbolObject:()=>o,mapArgs:()=>h,operand:()=>d,operator:()=>s,stringValue:()=>c,symbol:()=>m,version:()=>V});function N(n){return n!==null&&typeof n=="object"&&"num"in n}function o(n){return n!==null&&typeof n=="object"&&"sym"in n}function a(n){return n!==null&&typeof n=="object"&&"str"in n}function p(n){return n!==null&&typeof n=="object"&&"dict"in n&&typeof n.dict=="object"&&!Array.isArray(n.dict)&&n.dict!==null}function u(n){return n!==null&&typeof n=="object"&&"fn"in n&&Array.isArray(n.fn)&&n.fn.length>0&&typeof n.fn[0]=="string"}function c(n){return n==null?null:typeof n=="object"&&"str"in n?n.str:typeof n!="string"?null:n.length>=2&&n.at(0)==="'"&&n.at(-1)==="'"?n.substring(1,n.length-1):k(n)||g(n)?null:n}function s(n){return Array.isArray(n)?n[0]:n==null?"":u(n)?n.fn[0]:""}function b(n){return Array.isArray(n)?n.slice(1):n!==void 0&&u(n)?n.fn.slice(1):[]}function d(n,t){return Array.isArray(n)?n[t]??null:n===null||!u(n)?null:n.fn[t]??null}function D(n){return n==null?0:Array.isArray(n)?Math.max(0,n.length-1):u(n)?Math.max(0,n.fn.length-1):0}function m(n){return typeof n=="string"&&g(n)?n.length>=2&&n.at(0)==="`"&&n.at(-1)==="`"?n.slice(1,-1):n:n==null?null:o(n)?n.sym:null}function y(n){let t=s(n);if(t==="KeyValuePair"||t==="Tuple"||t==="Pair"){let[i,r]=b(n),e=c(i);return e?[e,r??"Nothing"]:null}return null}function E(n){if(n===null)return null;if(p(n))return n;let t=y(n);if(t)return{[t[0]]:t[1]};if(s(n)==="Dictionary"){let i={},r=b(n);for(let e=1;e<D(n);e++){let l=y(r[e]);l&&(i[l[0]]=F(l[1])??"Nothing")}return{dict:i}}return null}function h(n,t){let i=null;if(Array.isArray(n)&&(i=n),u(n)&&(i=n.fn),i===null)return[];let r=1,e=[];for(;r<i.length;)e.push(t(i[r])),r+=1;return e}function k(n){return/^(nan|oo|\+oo|-oo|infinity|\+infinity|-infinity)$/i.test(n)||/^[+-]?(0|[1-9][0-9]*)(\.[0-9]+)?(\([0-9]+\))?([eE][+-]?[0-9]+)?$/.test(n)}function g(n){return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(n)||n.length>=2&&n[0]==="`"&&n[n.length-1]==="`"}function F(n){return n==null?null:a(n)?n.str:N(n)?parseFloat(n.num):o(n)?n.sym:typeof n=="string"||typeof n=="number"?n:Array.isArray(n)?{fn:n}:n}var V="0.35.2";return S(T);})();
|
|
4
4
|
Object.assign(exports, MathJson); Object.defineProperty(exports, '__esModule', { value: true });}));
|
package/dist/math-json.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** MathJSON 0.35.
|
|
1
|
+
/** MathJSON 0.35.2 */
|
|
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.MathJson = {}));})(this, (function (exports) { 'use strict';
|
|
3
3
|
var MathJson = (() => {
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
@@ -149,7 +149,7 @@ var MathJson = (() => {
|
|
|
149
149
|
}
|
|
150
150
|
|
|
151
151
|
// src/math-json.ts
|
|
152
|
-
var version = "0.35.
|
|
152
|
+
var version = "0.35.2";
|
|
153
153
|
return __toCommonJS(math_json_exports);
|
|
154
154
|
})();
|
|
155
155
|
Object.assign(exports, MathJson); Object.defineProperty(exports, '__esModule', { value: true });}));
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.35.
|
|
1
|
+
/* 0.35.2 */
|
|
2
2
|
export declare function fuzzyStringMatch(invalidWord: string, validWords: string[]): string | null;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.35.
|
|
1
|
+
/* 0.35.2 */
|
|
2
2
|
export type RuntimeSignalCode = 'timeout' | 'out-of-memory' | 'recursion-depth-exceeded' | 'iteration-limit-exceeded';
|
|
3
3
|
/** @category Error Handling */
|
|
4
4
|
export type SignalCode = RuntimeSignalCode | ('invalid-name' | 'expected-predicate' | 'expected-symbol' | 'operator-requires-one-operand' | 'postfix-operator-requires-one-operand' | 'prefix-operator-requires-one-operand' | 'unbalanced-symbols' | 'expected-argument' | 'unexpected-command' | 'cyclic-definition' | 'invalid-supersets' | 'expected-supersets' | 'unknown-domain' | 'duplicate-wikidata' | 'invalid-dictionary-entry' | 'syntax-error');
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.35.
|
|
1
|
+
/* 0.35.2 */
|
|
2
2
|
export declare function typeToString(type: Type, precedence?: number): string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.35.
|
|
1
|
+
/* 0.35.2 */
|
|
2
2
|
import { Decimal } from 'decimal.js';
|
|
3
3
|
import type { BoxedExpression } from '../global-types';
|
|
4
4
|
export declare function apply(expr: BoxedExpression, fn: (x: number) => number | Complex, bigFn?: (x: Decimal) => Decimal | Complex | number, complexFn?: (x: Complex) => number | Complex): BoxedExpression | undefined;
|