@cortex-js/compute-engine 0.57.0 → 0.59.0
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/README.md +4 -0
- package/dist/compile.esm.js +2376 -501
- package/dist/compile.min.esm.js +316 -68
- package/dist/compile.min.umd.cjs +316 -68
- package/dist/compile.umd.cjs +2376 -501
- package/dist/compute-engine.esm.js +15717 -12444
- package/dist/compute-engine.min.esm.js +331 -83
- package/dist/compute-engine.min.umd.cjs +330 -82
- package/dist/compute-engine.umd.cjs +15717 -12444
- package/dist/core.esm.js +15716 -12443
- package/dist/core.min.esm.js +329 -81
- package/dist/core.min.umd.cjs +329 -81
- package/dist/core.umd.cjs +15716 -12443
- package/dist/identities.esm.js +1921 -0
- package/dist/identities.min.esm.js +2 -0
- package/dist/identities.min.umd.cjs +4 -0
- package/dist/identities.umd.cjs +1946 -0
- package/dist/interval.esm.js +779 -339
- package/dist/interval.min.esm.js +8 -8
- package/dist/interval.min.umd.cjs +8 -8
- package/dist/interval.umd.cjs +779 -339
- package/dist/latex-syntax.esm.js +971 -608
- package/dist/latex-syntax.min.esm.js +7 -7
- package/dist/latex-syntax.min.umd.cjs +7 -7
- package/dist/latex-syntax.umd.cjs +971 -608
- package/dist/math-json.esm.js +8 -12
- package/dist/math-json.min.esm.js +2 -2
- package/dist/math-json.min.umd.cjs +2 -2
- package/dist/math-json.umd.cjs +8 -12
- package/dist/numerics.esm.js +1382 -226
- package/dist/numerics.min.esm.js +16 -5
- package/dist/numerics.min.umd.cjs +16 -5
- package/dist/numerics.umd.cjs +1382 -226
- package/dist/types/big-decimal/big-decimal.d.ts +1 -1
- package/dist/types/big-decimal/index.d.ts +1 -1
- package/dist/types/big-decimal/transcendentals.d.ts +1 -1
- package/dist/types/big-decimal/utils.d.ts +1 -1
- 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 -208
- package/dist/types/common/type/parser.d.ts +124 -2
- package/dist/types/common/type/primitive.d.ts +5 -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 +18 -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/compile.d.ts +1 -1
- package/dist/types/compute-engine/assume.d.ts +13 -6
- package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +3 -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 +7 -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 +3 -3
- 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/constraint-subject.d.ts +140 -0
- 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 +34 -12
- 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/rule-index.d.ts +112 -0
- package/dist/types/compute-engine/boxed-expression/rules.d.ts +2 -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/stochastic-equal.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 +8 -1
- package/dist/types/compute-engine/compilation/compile-expression.d.ts +1 -1
- package/dist/types/compute-engine/compilation/constant-folding.d.ts +16 -1
- package/dist/types/compute-engine/compilation/glsl-target.d.ts +1 -1
- package/dist/types/compute-engine/compilation/gpu-target.d.ts +58 -5
- package/dist/types/compute-engine/compilation/interval-javascript-target.d.ts +4 -4
- 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-library-bootstrap.d.ts +1 -1
- package/dist/types/compute-engine/engine-numeric-configuration.d.ts +1 -1
- package/dist/types/compute-engine/engine-runtime-state.d.ts +4 -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 +10 -2
- 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/fungrim/loader.d.ts +13 -0
- package/dist/types/compute-engine/fungrim/types.d.ts +160 -0
- package/dist/types/compute-engine/global-types.d.ts +1 -1
- package/dist/types/compute-engine/index.d.ts +63 -2
- 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 +10 -2
- package/dist/types/compute-engine/interval/index.d.ts +2 -2
- 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/default-dictionary.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-colors.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-units.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 +4 -1
- package/dist/types/compute-engine/latex-syntax/latex-syntax.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 +3 -2
- package/dist/types/compute-engine/latex-syntax/serialize-dms.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +1 -11
- 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/colors.d.ts +1 -1
- package/dist/types/compute-engine/library/combinatorics.d.ts +1 -1
- package/dist/types/compute-engine/library/complex.d.ts +13 -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/fractals.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/quantity-arithmetic.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 +27 -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/unit-data.d.ts +1 -1
- package/dist/types/compute-engine/library/units.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 +7 -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/bernoulli.d.ts +39 -0
- 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/linear-algebra.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 +12 -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/random.d.ts +23 -0
- 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 +78 -10
- 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/numerics/unit-data.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-factorial.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 +3 -3
- package/dist/types/compute-engine/types-definitions.d.ts +1 -1
- package/dist/types/compute-engine/types-engine.d.ts +52 -3
- package/dist/types/compute-engine/types-evaluation.d.ts +1 -1
- package/dist/types/compute-engine/types-expression.d.ts +85 -14
- package/dist/types/compute-engine/types-kernel-evaluation.d.ts +32 -1
- package/dist/types/compute-engine/types-kernel-serialization.d.ts +45 -3
- 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/core.d.ts +1 -1
- package/dist/types/identities.d.ts +3 -0
- package/dist/types/interval.d.ts +1 -1
- package/dist/types/latex-syntax.d.ts +2 -2
- 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/dist/types/numerics.d.ts +1 -1
- package/package.json +9 -3
package/dist/interval.umd.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Interval 0.
|
|
1
|
+
/** Interval 0.59.0 */
|
|
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.Interval = {}));})(this, (function (exports) { 'use strict';
|
|
3
3
|
var Interval = (() => {
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
@@ -236,9 +236,18 @@ var Interval = (() => {
|
|
|
236
236
|
return ok({ lo: -xVal.hi, hi: -xVal.lo });
|
|
237
237
|
}
|
|
238
238
|
function _mul(a, b) {
|
|
239
|
-
const products = [
|
|
239
|
+
const products = [
|
|
240
|
+
_prod(a.lo, b.lo),
|
|
241
|
+
_prod(a.lo, b.hi),
|
|
242
|
+
_prod(a.hi, b.lo),
|
|
243
|
+
_prod(a.hi, b.hi)
|
|
244
|
+
];
|
|
240
245
|
return { lo: Math.min(...products), hi: Math.max(...products) };
|
|
241
246
|
}
|
|
247
|
+
function _prod(x, y) {
|
|
248
|
+
if (x === 0 || y === 0) return 0;
|
|
249
|
+
return x * y;
|
|
250
|
+
}
|
|
242
251
|
function mul(a, b) {
|
|
243
252
|
const unwrapped = unwrapOrPropagate(a, b);
|
|
244
253
|
if (!Array.isArray(unwrapped)) return unwrapped;
|
|
@@ -403,6 +412,7 @@ var Interval = (() => {
|
|
|
403
412
|
return sum;
|
|
404
413
|
}
|
|
405
414
|
function fpln(x, scale) {
|
|
415
|
+
if (x <= 0n) throw new RangeError("fpln: input must be positive");
|
|
406
416
|
if (x === scale) return 0n;
|
|
407
417
|
const xNum = Number(x);
|
|
408
418
|
const scaleNum = Number(scale);
|
|
@@ -1052,9 +1062,11 @@ var Interval = (() => {
|
|
|
1052
1062
|
if (Number.isFinite(thisExp) && Number.isFinite(otherExp)) {
|
|
1053
1063
|
if (other.significand === 0n) return _BigDecimal.NAN;
|
|
1054
1064
|
if (this.significand === 0n) return fromRaw(0n, 0);
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
);
|
|
1065
|
+
const ediff = thisExp - otherExp;
|
|
1066
|
+
const num = ediff >= 0 ? this.significand * pow10(ediff) : this.significand;
|
|
1067
|
+
const den = ediff >= 0 ? other.significand : other.significand * pow10(-ediff);
|
|
1068
|
+
const q = num / den;
|
|
1069
|
+
return this.sub(fromRaw(q, 0).mul(other));
|
|
1058
1070
|
}
|
|
1059
1071
|
if (thisExp !== thisExp || otherExp !== otherExp) return _BigDecimal.NAN;
|
|
1060
1072
|
if (!Number.isFinite(thisExp)) return _BigDecimal.NAN;
|
|
@@ -1099,7 +1111,10 @@ var Interval = (() => {
|
|
|
1099
1111
|
return this.pow(n.neg()).inv();
|
|
1100
1112
|
}
|
|
1101
1113
|
const absSig = this.significand < 0n ? -this.significand : this.significand;
|
|
1102
|
-
const
|
|
1114
|
+
const sigDigits = bigintDigits(absSig);
|
|
1115
|
+
const dropped = sigDigits > 15 ? sigDigits - 15 : 0;
|
|
1116
|
+
const lead = dropped > 0 ? Number(absSig / 10n ** BigInt(dropped)) : Number(absSig);
|
|
1117
|
+
const thisLog10 = Math.log10(lead) + dropped + this.exponent;
|
|
1103
1118
|
const resultLog10 = Number(expValue) * thisLog10;
|
|
1104
1119
|
if (resultLog10 > 9e15) {
|
|
1105
1120
|
return this.significand < 0n && expValue % 2n !== 0n ? _BigDecimal.NEGATIVE_INFINITY : _BigDecimal.POSITIVE_INFINITY;
|
|
@@ -1132,7 +1147,19 @@ var Interval = (() => {
|
|
|
1132
1147
|
return _BigDecimal.POSITIVE_INFINITY;
|
|
1133
1148
|
}
|
|
1134
1149
|
if (this.significand < 0n) return _BigDecimal.NAN;
|
|
1135
|
-
|
|
1150
|
+
const baseSig = this.significand;
|
|
1151
|
+
const decExpBase = this.exponent + bigintDigits(baseSig) - 1;
|
|
1152
|
+
const nSig = n.significand < 0n ? -n.significand : n.significand;
|
|
1153
|
+
const decExpN = n.exponent + bigintDigits(nSig) - 1;
|
|
1154
|
+
const argMag = decExpN + Math.log10(Math.abs(decExpBase) * 2.303 + 3) + 1;
|
|
1155
|
+
const extra = Math.min(20, Math.max(2, Math.ceil(argMag) + 2));
|
|
1156
|
+
const savedPrec = _BigDecimal.precision;
|
|
1157
|
+
_BigDecimal.precision = savedPrec + extra;
|
|
1158
|
+
try {
|
|
1159
|
+
return n.mul(this.ln()).exp().toPrecision(savedPrec);
|
|
1160
|
+
} finally {
|
|
1161
|
+
_BigDecimal.precision = savedPrec;
|
|
1162
|
+
}
|
|
1136
1163
|
}
|
|
1137
1164
|
// ---------- Conversion methods ----------
|
|
1138
1165
|
/** Convert to a JavaScript number. May lose precision for large values. */
|
|
@@ -1373,6 +1400,20 @@ var Interval = (() => {
|
|
|
1373
1400
|
const sig = negative ? -absFp : absFp;
|
|
1374
1401
|
return fromRaw(sig, resultExp);
|
|
1375
1402
|
}
|
|
1403
|
+
function decimalExponent(x) {
|
|
1404
|
+
const sig = x.significand < 0n ? -x.significand : x.significand;
|
|
1405
|
+
return x.exponent + bigintDigits(sig) - 1;
|
|
1406
|
+
}
|
|
1407
|
+
var MAX_SAFE_EXPONENT = BigInt(Number.MAX_SAFE_INTEGER);
|
|
1408
|
+
var _ln10Fp = null;
|
|
1409
|
+
var _ln10Scale = null;
|
|
1410
|
+
function ln10Fixed(scale) {
|
|
1411
|
+
if (_ln10Scale !== scale) {
|
|
1412
|
+
_ln10Fp = fpln(10n * scale, scale);
|
|
1413
|
+
_ln10Scale = scale;
|
|
1414
|
+
}
|
|
1415
|
+
return _ln10Fp;
|
|
1416
|
+
}
|
|
1376
1417
|
BigDecimal.prototype.sqrt = function() {
|
|
1377
1418
|
if (this.isNaN()) return BigDecimal.NAN;
|
|
1378
1419
|
if (this.isZero()) return BigDecimal.ZERO;
|
|
@@ -1383,9 +1424,13 @@ var Interval = (() => {
|
|
|
1383
1424
|
if (this.significand < 0n) return BigDecimal.NAN;
|
|
1384
1425
|
const targetPrec = BigDecimal.precision;
|
|
1385
1426
|
const workingPrec = targetPrec + 10;
|
|
1386
|
-
const
|
|
1427
|
+
const e = decimalExponent(this);
|
|
1428
|
+
const k = Math.floor(e / 2);
|
|
1429
|
+
const m = fromRaw(this.significand, this.exponent - 2 * k);
|
|
1430
|
+
const [fp, scale] = toFixedPoint(m, workingPrec);
|
|
1387
1431
|
const sqrtFp = fpsqrt(fp, scale);
|
|
1388
|
-
|
|
1432
|
+
const root = fromFixedPoint(sqrtFp, scale, targetPrec);
|
|
1433
|
+
return fromRaw(root.significand, root.exponent + k);
|
|
1389
1434
|
};
|
|
1390
1435
|
BigDecimal.prototype.cbrt = function() {
|
|
1391
1436
|
if (this.isNaN()) return BigDecimal.NAN;
|
|
@@ -1399,10 +1444,13 @@ var Interval = (() => {
|
|
|
1399
1444
|
}
|
|
1400
1445
|
const targetPrec = BigDecimal.precision;
|
|
1401
1446
|
const workingPrec = targetPrec + 10;
|
|
1402
|
-
const
|
|
1447
|
+
const e = decimalExponent(this);
|
|
1448
|
+
const k = Math.floor(e / 3);
|
|
1449
|
+
const m = fromRaw(this.significand, this.exponent - 3 * k);
|
|
1450
|
+
const [fp, scale] = toFixedPoint(m, workingPrec);
|
|
1403
1451
|
const C = fp * scale * scale;
|
|
1404
1452
|
let x;
|
|
1405
|
-
const numVal =
|
|
1453
|
+
const numVal = m.toNumber();
|
|
1406
1454
|
const scaleNum = Number(scale);
|
|
1407
1455
|
if (Number.isFinite(numVal) && numVal > 0 && Number.isFinite(scaleNum)) {
|
|
1408
1456
|
const approx = Math.cbrt(numVal);
|
|
@@ -1431,7 +1479,8 @@ var Interval = (() => {
|
|
|
1431
1479
|
const diffNext = bigintAbs(next * next * next - C);
|
|
1432
1480
|
if (diffNext < diffX) x = next;
|
|
1433
1481
|
}
|
|
1434
|
-
|
|
1482
|
+
const root = fromFixedPoint(x, scale, targetPrec);
|
|
1483
|
+
return fromRaw(root.significand, root.exponent + k);
|
|
1435
1484
|
};
|
|
1436
1485
|
BigDecimal.sqrt = function(x) {
|
|
1437
1486
|
return x.sqrt();
|
|
@@ -1446,11 +1495,27 @@ var Interval = (() => {
|
|
|
1446
1495
|
return BigDecimal.ZERO;
|
|
1447
1496
|
}
|
|
1448
1497
|
if (this.isZero()) return BigDecimal.ONE;
|
|
1498
|
+
if (decimalExponent(this) >= 17)
|
|
1499
|
+
return this.significand > 0n ? BigDecimal.POSITIVE_INFINITY : BigDecimal.ZERO;
|
|
1449
1500
|
const targetPrec = BigDecimal.precision;
|
|
1450
|
-
const
|
|
1451
|
-
const
|
|
1452
|
-
const
|
|
1453
|
-
|
|
1501
|
+
const absSig = this.significand < 0n ? -this.significand : this.significand;
|
|
1502
|
+
const magnitude = Math.max(0, this.exponent + bigintDigits(absSig));
|
|
1503
|
+
const workingPrec = targetPrec + 20 + magnitude;
|
|
1504
|
+
const [xFp, scale] = toFixedPoint(this, workingPrec);
|
|
1505
|
+
const l10 = ln10Fixed(scale);
|
|
1506
|
+
let k = xFp / l10;
|
|
1507
|
+
let rFp = xFp - k * l10;
|
|
1508
|
+
if (rFp < 0n) {
|
|
1509
|
+
k -= 1n;
|
|
1510
|
+
rFp += l10;
|
|
1511
|
+
}
|
|
1512
|
+
if (k > MAX_SAFE_EXPONENT || k < -MAX_SAFE_EXPONENT)
|
|
1513
|
+
return k > 0n ? BigDecimal.POSITIVE_INFINITY : BigDecimal.ZERO;
|
|
1514
|
+
const expR = fromFixedPoint(fpexp(rFp, scale), scale, targetPrec);
|
|
1515
|
+
const newExp = expR.exponent + Number(k);
|
|
1516
|
+
if (!Number.isSafeInteger(newExp))
|
|
1517
|
+
return k > 0n ? BigDecimal.POSITIVE_INFINITY : BigDecimal.ZERO;
|
|
1518
|
+
return fromRaw(expR.significand, newExp);
|
|
1454
1519
|
};
|
|
1455
1520
|
BigDecimal.prototype.ln = function() {
|
|
1456
1521
|
if (this.isNaN()) return BigDecimal.NAN;
|
|
@@ -1462,10 +1527,16 @@ var Interval = (() => {
|
|
|
1462
1527
|
if (this.significand < 0n) return BigDecimal.NAN;
|
|
1463
1528
|
if (this.eq(1)) return BigDecimal.ZERO;
|
|
1464
1529
|
const targetPrec = BigDecimal.precision;
|
|
1465
|
-
const
|
|
1466
|
-
const
|
|
1467
|
-
const
|
|
1468
|
-
|
|
1530
|
+
const sig = this.significand;
|
|
1531
|
+
const digits = bigintDigits(sig);
|
|
1532
|
+
const e = this.exponent + digits - 1;
|
|
1533
|
+
const m = fromRaw(sig, -(digits - 1));
|
|
1534
|
+
const eDigits = Math.abs(e).toString().length;
|
|
1535
|
+
const workingPrec = targetPrec + 20 + eDigits;
|
|
1536
|
+
const [mFp, scale] = toFixedPoint(m, workingPrec);
|
|
1537
|
+
const l10 = ln10Fixed(scale);
|
|
1538
|
+
const resultFp = fpln(mFp, scale) + BigInt(e) * l10;
|
|
1539
|
+
return fromFixedPoint(resultFp, scale, targetPrec);
|
|
1469
1540
|
};
|
|
1470
1541
|
BigDecimal.prototype.log = function(base) {
|
|
1471
1542
|
const b = base instanceof BigDecimal ? base : new BigDecimal(base);
|
|
@@ -1485,7 +1556,10 @@ var Interval = (() => {
|
|
|
1485
1556
|
if (!this.isFinite()) return BigDecimal.NAN;
|
|
1486
1557
|
if (this.isZero()) return BigDecimal.ZERO;
|
|
1487
1558
|
const targetPrec = BigDecimal.precision;
|
|
1488
|
-
const
|
|
1559
|
+
const e = decimalExponent(this);
|
|
1560
|
+
if (e < 0 && -2 * e >= targetPrec + 4) return this.toPrecision(targetPrec);
|
|
1561
|
+
const workingPrec = targetPrec + 15 + (e < 0 ? -e : 0);
|
|
1562
|
+
if (e > PI_DIGITS.length - workingPrec - 30) return BigDecimal.NAN;
|
|
1489
1563
|
const [fp, scale] = toFixedPoint(this, workingPrec);
|
|
1490
1564
|
const [sinFp] = fpsincos(fp, scale);
|
|
1491
1565
|
return fromFixedPoint(sinFp, scale, targetPrec);
|
|
@@ -1496,6 +1570,8 @@ var Interval = (() => {
|
|
|
1496
1570
|
if (this.isZero()) return BigDecimal.ONE;
|
|
1497
1571
|
const targetPrec = BigDecimal.precision;
|
|
1498
1572
|
const workingPrec = targetPrec + 15;
|
|
1573
|
+
const e = decimalExponent(this);
|
|
1574
|
+
if (e > PI_DIGITS.length - workingPrec - 30) return BigDecimal.NAN;
|
|
1499
1575
|
const [fp, scale] = toFixedPoint(this, workingPrec);
|
|
1500
1576
|
const [, cosFp] = fpsincos(fp, scale);
|
|
1501
1577
|
return fromFixedPoint(cosFp, scale, targetPrec);
|
|
@@ -1505,7 +1581,10 @@ var Interval = (() => {
|
|
|
1505
1581
|
if (!this.isFinite()) return BigDecimal.NAN;
|
|
1506
1582
|
if (this.isZero()) return BigDecimal.ZERO;
|
|
1507
1583
|
const targetPrec = BigDecimal.precision;
|
|
1508
|
-
const
|
|
1584
|
+
const e = decimalExponent(this);
|
|
1585
|
+
if (e < 0 && -2 * e >= targetPrec + 4) return this.toPrecision(targetPrec);
|
|
1586
|
+
const workingPrec = targetPrec + 15 + (e < 0 ? -e : 0);
|
|
1587
|
+
if (e > PI_DIGITS.length - workingPrec - 30) return BigDecimal.NAN;
|
|
1509
1588
|
const [fp, scale] = toFixedPoint(this, workingPrec);
|
|
1510
1589
|
const [sinFp, cosFp] = fpsincos(fp, scale);
|
|
1511
1590
|
if (cosFp === 0n) {
|
|
@@ -1523,7 +1602,9 @@ var Interval = (() => {
|
|
|
1523
1602
|
return piHalf.neg();
|
|
1524
1603
|
}
|
|
1525
1604
|
const targetPrec = BigDecimal.precision;
|
|
1526
|
-
const
|
|
1605
|
+
const e = decimalExponent(this);
|
|
1606
|
+
if (e < 0 && -2 * e >= targetPrec + 4) return this.toPrecision(targetPrec);
|
|
1607
|
+
const workingPrec = targetPrec + 15 + (e < 0 ? -e : 0);
|
|
1527
1608
|
const [fp, scale] = toFixedPoint(this, workingPrec);
|
|
1528
1609
|
const atanFp = fpatan(fp, scale);
|
|
1529
1610
|
return fromFixedPoint(atanFp, scale, targetPrec);
|
|
@@ -1540,7 +1621,9 @@ var Interval = (() => {
|
|
|
1540
1621
|
return this.significand > 0n ? piHalf : piHalf.neg();
|
|
1541
1622
|
}
|
|
1542
1623
|
const targetPrec = BigDecimal.precision;
|
|
1543
|
-
const
|
|
1624
|
+
const e = decimalExponent(this);
|
|
1625
|
+
if (e < 0 && -2 * e >= targetPrec + 4) return this.toPrecision(targetPrec);
|
|
1626
|
+
const workingPrec = targetPrec + 20 + (e < 0 ? -e : 0);
|
|
1544
1627
|
const [xFp, scale] = toFixedPoint(this, workingPrec);
|
|
1545
1628
|
const x2 = fpmul(xFp, xFp, scale);
|
|
1546
1629
|
const oneMinusX2 = scale - x2;
|
|
@@ -1603,6 +1686,23 @@ var Interval = (() => {
|
|
|
1603
1686
|
if (this.significand > 0n) return BigDecimal.POSITIVE_INFINITY;
|
|
1604
1687
|
return BigDecimal.NEGATIVE_INFINITY;
|
|
1605
1688
|
}
|
|
1689
|
+
const targetPrec = BigDecimal.precision;
|
|
1690
|
+
const e = decimalExponent(this);
|
|
1691
|
+
if (e < 0) {
|
|
1692
|
+
if (-2 * e >= targetPrec + 4) return this.toPrecision(targetPrec);
|
|
1693
|
+
const saved = BigDecimal.precision;
|
|
1694
|
+
BigDecimal.precision = targetPrec - e + 5;
|
|
1695
|
+
try {
|
|
1696
|
+
const expX2 = this.exp();
|
|
1697
|
+
return expX2.sub(expX2.inv()).div(BigDecimal.TWO).toPrecision(targetPrec);
|
|
1698
|
+
} finally {
|
|
1699
|
+
BigDecimal.precision = saved;
|
|
1700
|
+
}
|
|
1701
|
+
}
|
|
1702
|
+
if (Math.abs(this.toNumber()) > 1.16 * (targetPrec + 3)) {
|
|
1703
|
+
const h = this.abs().exp().div(BigDecimal.TWO);
|
|
1704
|
+
return this.significand > 0n ? h : h.neg();
|
|
1705
|
+
}
|
|
1606
1706
|
const expX = this.exp();
|
|
1607
1707
|
const expNegX = expX.inv();
|
|
1608
1708
|
return expX.sub(expNegX).div(BigDecimal.TWO);
|
|
@@ -1613,6 +1713,9 @@ var Interval = (() => {
|
|
|
1613
1713
|
if (!this.isFinite()) {
|
|
1614
1714
|
return BigDecimal.POSITIVE_INFINITY;
|
|
1615
1715
|
}
|
|
1716
|
+
const targetPrec = BigDecimal.precision;
|
|
1717
|
+
if (Math.abs(this.toNumber()) > 1.16 * (targetPrec + 3))
|
|
1718
|
+
return this.abs().exp().div(BigDecimal.TWO);
|
|
1616
1719
|
const expX = this.exp();
|
|
1617
1720
|
const expNegX = expX.inv();
|
|
1618
1721
|
return expX.add(expNegX).div(BigDecimal.TWO);
|
|
@@ -1624,6 +1727,21 @@ var Interval = (() => {
|
|
|
1624
1727
|
if (this.significand > 0n) return BigDecimal.ONE;
|
|
1625
1728
|
return BigDecimal.NEGATIVE_ONE;
|
|
1626
1729
|
}
|
|
1730
|
+
const targetPrec = BigDecimal.precision;
|
|
1731
|
+
const e = decimalExponent(this);
|
|
1732
|
+
if (e < 0) {
|
|
1733
|
+
if (-2 * e >= targetPrec + 4) return this.toPrecision(targetPrec);
|
|
1734
|
+
const saved = BigDecimal.precision;
|
|
1735
|
+
BigDecimal.precision = targetPrec - e + 5;
|
|
1736
|
+
try {
|
|
1737
|
+
const exp2x2 = this.mul(BigDecimal.TWO).exp();
|
|
1738
|
+
return exp2x2.sub(BigDecimal.ONE).div(exp2x2.add(BigDecimal.ONE)).toPrecision(targetPrec);
|
|
1739
|
+
} finally {
|
|
1740
|
+
BigDecimal.precision = saved;
|
|
1741
|
+
}
|
|
1742
|
+
}
|
|
1743
|
+
if (Math.abs(this.toNumber()) > 1.16 * (targetPrec + 3))
|
|
1744
|
+
return this.significand > 0n ? BigDecimal.ONE : BigDecimal.NEGATIVE_ONE;
|
|
1627
1745
|
const exp2x = this.mul(BigDecimal.TWO).exp();
|
|
1628
1746
|
return exp2x.sub(BigDecimal.ONE).div(exp2x.add(BigDecimal.ONE));
|
|
1629
1747
|
};
|
|
@@ -1669,9 +1787,14 @@ var Interval = (() => {
|
|
|
1669
1787
|
];
|
|
1670
1788
|
function gammaln(z) {
|
|
1671
1789
|
if (z < 0) return NaN;
|
|
1790
|
+
let shift = 0;
|
|
1791
|
+
while (z < 10) {
|
|
1792
|
+
shift += Math.log(z);
|
|
1793
|
+
z += 1;
|
|
1794
|
+
}
|
|
1672
1795
|
const pi = Math.PI;
|
|
1673
1796
|
const z3 = z * z * z;
|
|
1674
|
-
return z * Math.log(z) - z - 0.5 * Math.log(z) + 0.5 * Math.log(2 * pi) + 1 / (12 * z) - 1 / (360 * z3) + 1 / (1260 * z3 * z * z);
|
|
1797
|
+
return z * Math.log(z) - z - 0.5 * Math.log(z) + 0.5 * Math.log(2 * pi) + 1 / (12 * z) - 1 / (360 * z3) + 1 / (1260 * z3 * z * z) - shift;
|
|
1675
1798
|
}
|
|
1676
1799
|
function gamma(z) {
|
|
1677
1800
|
if (z < 0.5) return Math.PI / (Math.sin(Math.PI * z) * gamma(1 - z));
|
|
@@ -1683,20 +1806,43 @@ var Interval = (() => {
|
|
|
1683
1806
|
return Math.sqrt(2 * Math.PI) * Math.pow(t, z + 0.5) * Math.exp(-t) * x;
|
|
1684
1807
|
}
|
|
1685
1808
|
function erfc(x) {
|
|
1686
|
-
|
|
1809
|
+
if (Number.isNaN(x)) return NaN;
|
|
1810
|
+
if (!Number.isFinite(x)) return x > 0 ? 0 : 2;
|
|
1811
|
+
if (x < 0) return 2 - erfc(-x);
|
|
1812
|
+
if (x < 2) return 1 - erf(x);
|
|
1813
|
+
const tiny = 1e-300;
|
|
1814
|
+
let f = x === 0 ? tiny : x;
|
|
1815
|
+
let c = f;
|
|
1816
|
+
let d = 0;
|
|
1817
|
+
for (let k = 1; k <= 500; k++) {
|
|
1818
|
+
const a = k / 2;
|
|
1819
|
+
d = x + a * d;
|
|
1820
|
+
if (d === 0) d = tiny;
|
|
1821
|
+
d = 1 / d;
|
|
1822
|
+
c = x + a / c;
|
|
1823
|
+
if (c === 0) c = tiny;
|
|
1824
|
+
const delta = c * d;
|
|
1825
|
+
f *= delta;
|
|
1826
|
+
if (Math.abs(delta - 1) < 1e-17) break;
|
|
1827
|
+
}
|
|
1828
|
+
return Math.exp(-x * x) / (Math.sqrt(Math.PI) * f);
|
|
1687
1829
|
}
|
|
1688
1830
|
function erf(x) {
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
const a4 = -1.453152027;
|
|
1693
|
-
const a5 = 1.061405429;
|
|
1694
|
-
const p = 0.3275911;
|
|
1831
|
+
if (Number.isNaN(x)) return NaN;
|
|
1832
|
+
if (x === 0) return 0;
|
|
1833
|
+
if (!Number.isFinite(x)) return x > 0 ? 1 : -1;
|
|
1695
1834
|
const sign2 = x < 0 ? -1 : 1;
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
const
|
|
1699
|
-
|
|
1835
|
+
const ax = Math.abs(x);
|
|
1836
|
+
if (ax >= 6) return sign2;
|
|
1837
|
+
const x2 = ax * ax;
|
|
1838
|
+
let term = ax;
|
|
1839
|
+
let sum = ax;
|
|
1840
|
+
for (let n = 1; n < 200; n++) {
|
|
1841
|
+
term *= 2 * x2 / (2 * n + 1);
|
|
1842
|
+
sum += term;
|
|
1843
|
+
if (term < sum * 1e-18) break;
|
|
1844
|
+
}
|
|
1845
|
+
return sign2 * (2 / Math.sqrt(Math.PI)) * Math.exp(-x2) * sum;
|
|
1700
1846
|
}
|
|
1701
1847
|
var BERNOULLI_2K = [
|
|
1702
1848
|
1 / 6,
|
|
@@ -1823,7 +1969,7 @@ var Interval = (() => {
|
|
|
1823
1969
|
const t = x2 * x2;
|
|
1824
1970
|
return sign2 * x * x2 * polevl(t, SN) / polevl(t, SD);
|
|
1825
1971
|
}
|
|
1826
|
-
if (x <
|
|
1972
|
+
if (x < 36974) {
|
|
1827
1973
|
const x2 = x * x;
|
|
1828
1974
|
const t = Math.PI * x2;
|
|
1829
1975
|
const u = 1 / (t * t);
|
|
@@ -1848,7 +1994,7 @@ var Interval = (() => {
|
|
|
1848
1994
|
const t = x2 * x2;
|
|
1849
1995
|
return sign2 * x * polevl(t, CN) / polevl(t, CD);
|
|
1850
1996
|
}
|
|
1851
|
-
if (x <
|
|
1997
|
+
if (x < 36974) {
|
|
1852
1998
|
const x2 = x * x;
|
|
1853
1999
|
const t = Math.PI * x2;
|
|
1854
2000
|
const u = 1 / (t * t);
|
|
@@ -1890,7 +2036,8 @@ var Interval = (() => {
|
|
|
1890
2036
|
}
|
|
1891
2037
|
function lcm(a, b) {
|
|
1892
2038
|
if (a === 0 || b === 0) return 0;
|
|
1893
|
-
|
|
2039
|
+
let res = BigInt(a) * BigInt(b) / BigInt(gcd(a, b));
|
|
2040
|
+
if (res < 0n) res = -res;
|
|
1894
2041
|
return Number(res);
|
|
1895
2042
|
}
|
|
1896
2043
|
function factorial(n) {
|
|
@@ -3256,172 +3403,23 @@ var Interval = (() => {
|
|
|
3256
3403
|
"error",
|
|
3257
3404
|
...EXPRESSION_TYPES
|
|
3258
3405
|
];
|
|
3406
|
+
var NUMERIC_TYPES_SET = new Set(
|
|
3407
|
+
NUMERIC_TYPES
|
|
3408
|
+
);
|
|
3409
|
+
var COLLECTION_TYPES_SET = new Set(
|
|
3410
|
+
COLLECTION_TYPES
|
|
3411
|
+
);
|
|
3412
|
+
var SCALAR_TYPES_SET = new Set(
|
|
3413
|
+
SCALAR_TYPES
|
|
3414
|
+
);
|
|
3415
|
+
var PRIMITIVE_TYPES_SET = new Set(
|
|
3416
|
+
PRIMITIVE_TYPES
|
|
3417
|
+
);
|
|
3259
3418
|
function isValidType(t) {
|
|
3260
|
-
if (typeof t === "string")
|
|
3261
|
-
return PRIMITIVE_TYPES.includes(t);
|
|
3419
|
+
if (typeof t === "string") return PRIMITIVE_TYPES_SET.has(t);
|
|
3262
3420
|
if (typeof t !== "object") return false;
|
|
3263
3421
|
if (!("kind" in t)) return false;
|
|
3264
|
-
return t.kind === "signature" || t.kind === "union" || t.kind === "intersection" || t.kind === "negation" || t.kind === "tuple" || t.kind === "list" || t.kind === "record" || t.kind === "dictionary" || t.kind === "set" || t.kind === "
|
|
3265
|
-
}
|
|
3266
|
-
|
|
3267
|
-
// src/common/type/serialize.ts
|
|
3268
|
-
var NEGATION_PRECEDENCE = 3;
|
|
3269
|
-
var UNION_PRECEDENCE = 1;
|
|
3270
|
-
var INTERSECTION_PRECEDENCE = 2;
|
|
3271
|
-
var LIST_PRECEDENCE = 4;
|
|
3272
|
-
var RECORD_PRECEDENCE = 5;
|
|
3273
|
-
var DICTIONARY_PRECEDENCE = 6;
|
|
3274
|
-
var SET_PRECEDENCE = 7;
|
|
3275
|
-
var COLLECTION_PRECEDENCE = 8;
|
|
3276
|
-
var TUPLE_PRECEDENCE = 9;
|
|
3277
|
-
var SIGNATURE_PRECEDENCE = 10;
|
|
3278
|
-
var VALUE_PRECEDENCE = 11;
|
|
3279
|
-
function typeToString(type, precedence = 0) {
|
|
3280
|
-
if (typeof type === "string") return type;
|
|
3281
|
-
let result = "";
|
|
3282
|
-
switch (type.kind) {
|
|
3283
|
-
case "value":
|
|
3284
|
-
if (typeof type.value === "string") result = `"${type.value}"`;
|
|
3285
|
-
else if (typeof type.value === "boolean")
|
|
3286
|
-
result = type.value ? "true" : "false";
|
|
3287
|
-
else result = type.value.toString();
|
|
3288
|
-
break;
|
|
3289
|
-
case "reference":
|
|
3290
|
-
result = type.name;
|
|
3291
|
-
break;
|
|
3292
|
-
case "negation":
|
|
3293
|
-
result = `!${typeToString(type.type, NEGATION_PRECEDENCE)}`;
|
|
3294
|
-
break;
|
|
3295
|
-
case "union":
|
|
3296
|
-
result = type.types.map((t) => typeToString(t, UNION_PRECEDENCE)).join(" | ");
|
|
3297
|
-
break;
|
|
3298
|
-
case "intersection":
|
|
3299
|
-
result = type.types.map((t) => typeToString(t, INTERSECTION_PRECEDENCE)).join(" & ");
|
|
3300
|
-
break;
|
|
3301
|
-
case "expression":
|
|
3302
|
-
result = `expression<${symbolName(type.operator)}>`;
|
|
3303
|
-
break;
|
|
3304
|
-
case "symbol":
|
|
3305
|
-
result = `symbol<${symbolName(type.name)}>`;
|
|
3306
|
-
break;
|
|
3307
|
-
case "numeric":
|
|
3308
|
-
if (Number.isFinite(type.lower) && Number.isFinite(type.upper)) {
|
|
3309
|
-
result = `${type.type}<${type.lower}..${type.upper}>`;
|
|
3310
|
-
} else if (Number.isFinite(type.lower)) {
|
|
3311
|
-
result = `${type.type}<${type.lower}..>`;
|
|
3312
|
-
} else if (Number.isFinite(type.upper)) {
|
|
3313
|
-
result = `${type.type}<..${type.upper}>`;
|
|
3314
|
-
} else {
|
|
3315
|
-
result = `${type.type}`;
|
|
3316
|
-
}
|
|
3317
|
-
break;
|
|
3318
|
-
case "list":
|
|
3319
|
-
if (type.dimensions && typeof type.elements === "string" && NUMERIC_TYPES.includes(type.elements)) {
|
|
3320
|
-
if (type.dimensions === void 0) {
|
|
3321
|
-
if (type.elements === "number") result = "tensor";
|
|
3322
|
-
} else if (type.dimensions.length === 1) {
|
|
3323
|
-
if (type.elements === "number") {
|
|
3324
|
-
if (type.dimensions[0] < 0) result = "vector";
|
|
3325
|
-
else result = `vector<${type.dimensions[0]}>`;
|
|
3326
|
-
} else {
|
|
3327
|
-
if (type.dimensions[0] < 0)
|
|
3328
|
-
result = `vector<${typeToString(type.elements)}>`;
|
|
3329
|
-
else
|
|
3330
|
-
result = `vector<${typeToString(type.elements)}^${type.dimensions[0]}>`;
|
|
3331
|
-
}
|
|
3332
|
-
} else if (type.dimensions.length === 2) {
|
|
3333
|
-
const dims = type.dimensions;
|
|
3334
|
-
if (type.elements === "number") {
|
|
3335
|
-
if (dims[0] < 0 && dims[1] < 0) result = "matrix";
|
|
3336
|
-
else result = `matrix<${dims[0]}x${dims[1]}>`;
|
|
3337
|
-
} else {
|
|
3338
|
-
if (dims[0] < 0 && dims[1] < 0)
|
|
3339
|
-
result = `matrix<${typeToString(type.elements)}>`;
|
|
3340
|
-
else
|
|
3341
|
-
result = `matrix<${typeToString(type.elements)}^(${dims[0]}x${dims[1]})>`;
|
|
3342
|
-
}
|
|
3343
|
-
}
|
|
3344
|
-
}
|
|
3345
|
-
if (!result) {
|
|
3346
|
-
const dimensions = type.dimensions ? type.dimensions.length === 1 ? `^${type.dimensions[0].toString()}` : `^(${type.dimensions.join("x")})` : "";
|
|
3347
|
-
result = `list<${typeToString(type.elements)}${dimensions}>`;
|
|
3348
|
-
}
|
|
3349
|
-
break;
|
|
3350
|
-
case "record":
|
|
3351
|
-
const elements = Object.entries(type.elements).map(([key, value]) => `${key}: ${typeToString(value)}`).join(", ");
|
|
3352
|
-
result = `record<${elements}>`;
|
|
3353
|
-
break;
|
|
3354
|
-
case "dictionary":
|
|
3355
|
-
result = `dictionary<${typeToString(type.values)}>`;
|
|
3356
|
-
break;
|
|
3357
|
-
case "set":
|
|
3358
|
-
result = `set<${typeToString(type.elements)}>`;
|
|
3359
|
-
break;
|
|
3360
|
-
case "collection":
|
|
3361
|
-
result = `collection<${typeToString(type.elements)}>`;
|
|
3362
|
-
break;
|
|
3363
|
-
case "indexed_collection":
|
|
3364
|
-
result = `indexed_collection<${typeToString(type.elements)}>`;
|
|
3365
|
-
break;
|
|
3366
|
-
case "tuple":
|
|
3367
|
-
if (type.elements.length === 0) result = "tuple";
|
|
3368
|
-
else if (type.elements.length === 1) {
|
|
3369
|
-
const [el] = type.elements;
|
|
3370
|
-
result = `tuple<${namedElement(el)}>`;
|
|
3371
|
-
} else {
|
|
3372
|
-
result = "tuple<" + type.elements.map((el) => namedElement(el)).join(", ") + ">";
|
|
3373
|
-
}
|
|
3374
|
-
break;
|
|
3375
|
-
case "signature":
|
|
3376
|
-
const args = type.args ? type.args.map((arg) => namedElement(arg)).join(", ") : "";
|
|
3377
|
-
const optArgs = type.optArgs ? type.optArgs.map((arg) => namedElement(arg) + "?").join(", ") : "";
|
|
3378
|
-
const varArg = type.variadicArg ? type.variadicMin === 0 ? `${namedElement(type.variadicArg)}*` : `${namedElement(type.variadicArg)}+` : "";
|
|
3379
|
-
const argsList = [args, optArgs, varArg].filter((s) => s).join(", ");
|
|
3380
|
-
result = `(${argsList}) -> ${typeToString(type.result)}`;
|
|
3381
|
-
break;
|
|
3382
|
-
default:
|
|
3383
|
-
result = "error";
|
|
3384
|
-
}
|
|
3385
|
-
if (precedence > 0 && precedence > getPrecedence(type.kind))
|
|
3386
|
-
return `(${result})`;
|
|
3387
|
-
return result;
|
|
3388
|
-
}
|
|
3389
|
-
function namedElement(el) {
|
|
3390
|
-
if (el.name) return `${el.name}: ${typeToString(el.type)}`;
|
|
3391
|
-
return typeToString(el.type);
|
|
3392
|
-
}
|
|
3393
|
-
function symbolName(name) {
|
|
3394
|
-
if (/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(name)) return name;
|
|
3395
|
-
return `\`${name}\``;
|
|
3396
|
-
}
|
|
3397
|
-
function getPrecedence(kind) {
|
|
3398
|
-
switch (kind) {
|
|
3399
|
-
case "negation":
|
|
3400
|
-
return NEGATION_PRECEDENCE;
|
|
3401
|
-
case "union":
|
|
3402
|
-
return UNION_PRECEDENCE;
|
|
3403
|
-
case "intersection":
|
|
3404
|
-
return INTERSECTION_PRECEDENCE;
|
|
3405
|
-
case "list":
|
|
3406
|
-
return LIST_PRECEDENCE;
|
|
3407
|
-
case "record":
|
|
3408
|
-
return RECORD_PRECEDENCE;
|
|
3409
|
-
case "dictionary":
|
|
3410
|
-
return DICTIONARY_PRECEDENCE;
|
|
3411
|
-
case "set":
|
|
3412
|
-
return SET_PRECEDENCE;
|
|
3413
|
-
case "collection":
|
|
3414
|
-
case "indexed_collection":
|
|
3415
|
-
return COLLECTION_PRECEDENCE;
|
|
3416
|
-
case "tuple":
|
|
3417
|
-
return TUPLE_PRECEDENCE;
|
|
3418
|
-
case "signature":
|
|
3419
|
-
return SIGNATURE_PRECEDENCE;
|
|
3420
|
-
case "value":
|
|
3421
|
-
return VALUE_PRECEDENCE;
|
|
3422
|
-
default:
|
|
3423
|
-
return 0;
|
|
3424
|
-
}
|
|
3422
|
+
return t.kind === "signature" || t.kind === "union" || t.kind === "intersection" || t.kind === "negation" || t.kind === "value" || t.kind === "tuple" || t.kind === "list" || t.kind === "record" || t.kind === "dictionary" || t.kind === "set" || t.kind === "symbol" || t.kind === "expression" || t.kind === "numeric" || t.kind === "collection" || t.kind === "indexed_collection" || t.kind === "reference";
|
|
3425
3423
|
}
|
|
3426
3424
|
|
|
3427
3425
|
// src/common/type/lexer.ts
|
|
@@ -4131,19 +4129,13 @@ var Interval = (() => {
|
|
|
4131
4129
|
);
|
|
4132
4130
|
let dimensions;
|
|
4133
4131
|
if (this.match("<")) {
|
|
4134
|
-
dimensions = this.
|
|
4135
|
-
if (!dimensions) {
|
|
4136
|
-
dimensions = this.parseDimensions();
|
|
4137
|
-
}
|
|
4132
|
+
dimensions = this.parseDimensions();
|
|
4138
4133
|
if (!dimensions) {
|
|
4139
4134
|
const type = this.parseUnionType();
|
|
4140
4135
|
if (type) {
|
|
4141
4136
|
elementType = type;
|
|
4142
4137
|
if (this.match("^")) {
|
|
4143
|
-
dimensions = this.
|
|
4144
|
-
if (!dimensions) {
|
|
4145
|
-
dimensions = this.parseDimensions();
|
|
4146
|
-
}
|
|
4138
|
+
dimensions = this.parseCaretDimensions();
|
|
4147
4139
|
}
|
|
4148
4140
|
}
|
|
4149
4141
|
}
|
|
@@ -4184,19 +4176,13 @@ var Interval = (() => {
|
|
|
4184
4176
|
);
|
|
4185
4177
|
let dimensions;
|
|
4186
4178
|
if (this.match("<")) {
|
|
4187
|
-
dimensions = this.
|
|
4188
|
-
if (!dimensions) {
|
|
4189
|
-
dimensions = this.parseDimensions();
|
|
4190
|
-
}
|
|
4179
|
+
dimensions = this.parseDimensions();
|
|
4191
4180
|
if (!dimensions) {
|
|
4192
4181
|
const type = this.parseUnionType();
|
|
4193
4182
|
if (type) {
|
|
4194
4183
|
elementType = type;
|
|
4195
4184
|
if (this.match("^")) {
|
|
4196
|
-
dimensions = this.
|
|
4197
|
-
if (!dimensions) {
|
|
4198
|
-
dimensions = this.parseDimensions();
|
|
4199
|
-
}
|
|
4185
|
+
dimensions = this.parseCaretDimensions();
|
|
4200
4186
|
}
|
|
4201
4187
|
}
|
|
4202
4188
|
}
|
|
@@ -4227,16 +4213,30 @@ var Interval = (() => {
|
|
|
4227
4213
|
return this.createNode("tensor", { elementType });
|
|
4228
4214
|
}
|
|
4229
4215
|
parseDimensions() {
|
|
4230
|
-
const dimensions = [];
|
|
4231
4216
|
const firstDim = this.parseDimension();
|
|
4232
4217
|
if (!firstDim) return void 0;
|
|
4233
|
-
dimensions
|
|
4234
|
-
|
|
4235
|
-
const
|
|
4236
|
-
if (
|
|
4237
|
-
this.
|
|
4218
|
+
const dimensions = [firstDim];
|
|
4219
|
+
for (; ; ) {
|
|
4220
|
+
const tok = this.current;
|
|
4221
|
+
if (tok.type === "IDENTIFIER" && /^(x\d+)+$/.test(tok.value)) {
|
|
4222
|
+
this.advance();
|
|
4223
|
+
for (const m of tok.value.match(/x(\d+)/g))
|
|
4224
|
+
dimensions.push(
|
|
4225
|
+
this.createNode("dimension", {
|
|
4226
|
+
size: parseInt(m.slice(1))
|
|
4227
|
+
})
|
|
4228
|
+
);
|
|
4229
|
+
} else if (tok.type === "IDENTIFIER" && tok.value === "x") {
|
|
4230
|
+
const next = this.lexer.peekToken();
|
|
4231
|
+
if (next.type !== "NUMBER_LITERAL" && next.type !== "?")
|
|
4232
|
+
this.error(
|
|
4233
|
+
"Expected a positive integer literal or `?` after x. For example: `2x3` or `2x?`"
|
|
4234
|
+
);
|
|
4235
|
+
this.advance();
|
|
4236
|
+
dimensions.push(this.parseDimension());
|
|
4237
|
+
} else {
|
|
4238
|
+
break;
|
|
4238
4239
|
}
|
|
4239
|
-
dimensions.push(dim);
|
|
4240
4240
|
}
|
|
4241
4241
|
return dimensions;
|
|
4242
4242
|
}
|
|
@@ -4250,35 +4250,11 @@ var Interval = (() => {
|
|
|
4250
4250
|
}
|
|
4251
4251
|
return void 0;
|
|
4252
4252
|
}
|
|
4253
|
-
|
|
4254
|
-
|
|
4255
|
-
|
|
4256
|
-
|
|
4257
|
-
|
|
4258
|
-
this.createNode("dimension", { size: firstDim })
|
|
4259
|
-
);
|
|
4260
|
-
if (this.current.type === "IDENTIFIER" && this.current.value.startsWith("x")) {
|
|
4261
|
-
const dimString = this.current.value;
|
|
4262
|
-
const matches = dimString.match(/x(\d+)/g);
|
|
4263
|
-
if (matches && matches.join("") === dimString) {
|
|
4264
|
-
this.advance();
|
|
4265
|
-
for (const match of matches) {
|
|
4266
|
-
const dimValue = parseInt(match.substring(1));
|
|
4267
|
-
dimensions.push(
|
|
4268
|
-
this.createNode("dimension", { size: dimValue })
|
|
4269
|
-
);
|
|
4270
|
-
}
|
|
4271
|
-
} else if (dimString === "x" || dimString.startsWith("x")) {
|
|
4272
|
-
this.error(
|
|
4273
|
-
"Expected a positive integer literal or `?` after x. For example: `2x3` or `2x?`"
|
|
4274
|
-
);
|
|
4275
|
-
}
|
|
4276
|
-
}
|
|
4277
|
-
if (dimensions.length > 1) {
|
|
4278
|
-
return dimensions;
|
|
4279
|
-
}
|
|
4280
|
-
}
|
|
4281
|
-
return void 0;
|
|
4253
|
+
parseCaretDimensions() {
|
|
4254
|
+
const paren = this.match("(");
|
|
4255
|
+
const dimensions = this.parseDimensions();
|
|
4256
|
+
if (paren) this.expect(")");
|
|
4257
|
+
return dimensions;
|
|
4282
4258
|
}
|
|
4283
4259
|
parseTupleType() {
|
|
4284
4260
|
if (this.current.type === "IDENTIFIER" && this.current.value === "tuple") {
|
|
@@ -4463,6 +4439,18 @@ var Interval = (() => {
|
|
|
4463
4439
|
this.expect("..");
|
|
4464
4440
|
const upperBound = this.parseValue();
|
|
4465
4441
|
this.expect(">");
|
|
4442
|
+
const lower = lowerBound?.value ?? -Infinity;
|
|
4443
|
+
const upper = upperBound?.value ?? Infinity;
|
|
4444
|
+
if (Number.isNaN(lower) || Number.isNaN(upper))
|
|
4445
|
+
this.error(
|
|
4446
|
+
"Invalid numeric type",
|
|
4447
|
+
"Lower and upper bounds must be valid numbers"
|
|
4448
|
+
);
|
|
4449
|
+
if (lower > upper)
|
|
4450
|
+
this.error(
|
|
4451
|
+
`Invalid range: ${lower}..${upper}`,
|
|
4452
|
+
"The lower bound must be less than the upper bound"
|
|
4453
|
+
);
|
|
4466
4454
|
return this.createNode("numeric", {
|
|
4467
4455
|
baseType,
|
|
4468
4456
|
lowerBound,
|
|
@@ -4477,7 +4465,7 @@ var Interval = (() => {
|
|
|
4477
4465
|
parsePrimitiveType() {
|
|
4478
4466
|
if (this.current.type === "IDENTIFIER") {
|
|
4479
4467
|
const name = this.current.value;
|
|
4480
|
-
if (
|
|
4468
|
+
if (PRIMITIVE_TYPES_SET.has(name)) {
|
|
4481
4469
|
this.advance();
|
|
4482
4470
|
return this.createNode("primitive", { name });
|
|
4483
4471
|
}
|
|
@@ -4811,14 +4799,32 @@ var Interval = (() => {
|
|
|
4811
4799
|
}
|
|
4812
4800
|
|
|
4813
4801
|
// src/common/type/parse.ts
|
|
4802
|
+
var TYPE_CACHE = /* @__PURE__ */ new Map();
|
|
4803
|
+
var TYPE_CACHE_MAX_SIZE = 2048;
|
|
4804
|
+
function deepFreeze(obj) {
|
|
4805
|
+
if (obj === null || typeof obj !== "object") return obj;
|
|
4806
|
+
if (Object.isFrozen(obj)) return obj;
|
|
4807
|
+
Object.freeze(obj);
|
|
4808
|
+
for (const value of Object.values(obj)) deepFreeze(value);
|
|
4809
|
+
return obj;
|
|
4810
|
+
}
|
|
4814
4811
|
function parseType(s, typeResolver) {
|
|
4815
4812
|
if (s === void 0) return void 0;
|
|
4816
4813
|
if (isValidType(s)) return s;
|
|
4817
4814
|
if (typeof s !== "string") return void 0;
|
|
4815
|
+
const cacheable = typeResolver === void 0;
|
|
4816
|
+
if (cacheable) {
|
|
4817
|
+
const cached = TYPE_CACHE.get(s);
|
|
4818
|
+
if (cached !== void 0) return cached;
|
|
4819
|
+
}
|
|
4818
4820
|
try {
|
|
4819
4821
|
const parser = new Parser(s, { typeResolver });
|
|
4820
4822
|
const ast = parser.parseType();
|
|
4821
4823
|
const type = buildTypeFromAST(ast, typeResolver);
|
|
4824
|
+
if (cacheable) {
|
|
4825
|
+
if (TYPE_CACHE.size >= TYPE_CACHE_MAX_SIZE) TYPE_CACHE.clear();
|
|
4826
|
+
TYPE_CACHE.set(s, deepFreeze(type));
|
|
4827
|
+
}
|
|
4822
4828
|
return type;
|
|
4823
4829
|
} catch (error) {
|
|
4824
4830
|
throw new Error(
|
|
@@ -4893,19 +4899,36 @@ var Interval = (() => {
|
|
|
4893
4899
|
color: [],
|
|
4894
4900
|
expression: EXPRESSION_TYPES
|
|
4895
4901
|
};
|
|
4902
|
+
var PRIMITIVE_SUBTYPES_CLOSURE = (() => {
|
|
4903
|
+
const closure = {};
|
|
4904
|
+
const closeOver = (t) => {
|
|
4905
|
+
if (closure[t]) return closure[t];
|
|
4906
|
+
const result = /* @__PURE__ */ new Set([t]);
|
|
4907
|
+
closure[t] = result;
|
|
4908
|
+
for (const sub2 of PRIMITIVE_SUBTYPES[t]) {
|
|
4909
|
+
if (sub2 === t) continue;
|
|
4910
|
+
for (const s of closeOver(sub2)) result.add(s);
|
|
4911
|
+
}
|
|
4912
|
+
return result;
|
|
4913
|
+
};
|
|
4914
|
+
for (const t of Object.keys(PRIMITIVE_SUBTYPES))
|
|
4915
|
+
closeOver(t);
|
|
4916
|
+
return closure;
|
|
4917
|
+
})();
|
|
4896
4918
|
function isPrimitiveSubtype(lhs, rhs) {
|
|
4897
4919
|
if (rhs === "any") return true;
|
|
4898
4920
|
if (lhs === "never") return true;
|
|
4899
4921
|
if (lhs === "unknown" || rhs === "unknown") return false;
|
|
4900
4922
|
if (lhs === rhs) return true;
|
|
4901
|
-
return
|
|
4923
|
+
return PRIMITIVE_SUBTYPES_CLOSURE[rhs].has(lhs);
|
|
4902
4924
|
}
|
|
4903
4925
|
function isSubtype(lhs, rhs) {
|
|
4904
|
-
if (typeof lhs === "string" && !
|
|
4926
|
+
if (typeof lhs === "string" && !PRIMITIVE_TYPES_SET.has(lhs))
|
|
4905
4927
|
lhs = parseType(lhs);
|
|
4906
|
-
if (typeof rhs === "string" && !
|
|
4928
|
+
if (typeof rhs === "string" && !PRIMITIVE_TYPES_SET.has(rhs))
|
|
4907
4929
|
rhs = parseType(rhs);
|
|
4908
4930
|
if (rhs === "any") return true;
|
|
4931
|
+
if (lhs === "never") return true;
|
|
4909
4932
|
if (rhs === "never") return false;
|
|
4910
4933
|
if (rhs === "error") return lhs === "error";
|
|
4911
4934
|
if (rhs === "nothing") return lhs === "nothing";
|
|
@@ -4920,7 +4943,7 @@ var Interval = (() => {
|
|
|
4920
4943
|
if (typeof lhs.value === "number") {
|
|
4921
4944
|
if (Number.isInteger(lhs.value))
|
|
4922
4945
|
return isPrimitiveSubtype("integer", rhs);
|
|
4923
|
-
return isPrimitiveSubtype("
|
|
4946
|
+
return isPrimitiveSubtype("real", rhs);
|
|
4924
4947
|
}
|
|
4925
4948
|
if (typeof lhs.value === "boolean")
|
|
4926
4949
|
return isPrimitiveSubtype("boolean", rhs);
|
|
@@ -5150,7 +5173,7 @@ var Interval = (() => {
|
|
|
5150
5173
|
}
|
|
5151
5174
|
function isNumeric(type) {
|
|
5152
5175
|
if (typeof type === "string")
|
|
5153
|
-
return
|
|
5176
|
+
return NUMERIC_TYPES_SET.has(type);
|
|
5154
5177
|
if (type.kind === "value") return typeof type.value === "number";
|
|
5155
5178
|
if (type.kind === "numeric") return true;
|
|
5156
5179
|
return false;
|
|
@@ -5158,7 +5181,7 @@ var Interval = (() => {
|
|
|
5158
5181
|
function isScalar(type) {
|
|
5159
5182
|
if (isNumeric(type)) return true;
|
|
5160
5183
|
if (typeof type === "string")
|
|
5161
|
-
return
|
|
5184
|
+
return SCALAR_TYPES_SET.has(type);
|
|
5162
5185
|
if (type.kind === "value")
|
|
5163
5186
|
return ["string", "boolean", "number"].includes(typeof type.value);
|
|
5164
5187
|
return false;
|
|
@@ -5166,7 +5189,7 @@ var Interval = (() => {
|
|
|
5166
5189
|
function isCollection(type) {
|
|
5167
5190
|
if (isIndexedCollection(type)) return true;
|
|
5168
5191
|
if (typeof type === "string")
|
|
5169
|
-
return
|
|
5192
|
+
return COLLECTION_TYPES_SET.has(type);
|
|
5170
5193
|
return ["collection", "set", "record", "dictionary"].includes(type.kind);
|
|
5171
5194
|
}
|
|
5172
5195
|
function isIndexedCollection(type) {
|
|
@@ -5205,7 +5228,7 @@ var Interval = (() => {
|
|
|
5205
5228
|
if (b === "unknown") return a;
|
|
5206
5229
|
if (isSubtype(a, b)) return a;
|
|
5207
5230
|
if (isSubtype(b, a)) return b;
|
|
5208
|
-
return
|
|
5231
|
+
return "never";
|
|
5209
5232
|
}
|
|
5210
5233
|
function widen2(a, b) {
|
|
5211
5234
|
if (a === b) return a;
|
|
@@ -5218,7 +5241,43 @@ var Interval = (() => {
|
|
|
5218
5241
|
if (b === "nothing") return a;
|
|
5219
5242
|
if (isSubtype(a, b)) return b;
|
|
5220
5243
|
if (isSubtype(b, a)) return a;
|
|
5221
|
-
|
|
5244
|
+
const sup = superType(a, b);
|
|
5245
|
+
if (LOSSY_SUPERTYPE.has(sup)) return unionTypes(a, b);
|
|
5246
|
+
return sup;
|
|
5247
|
+
}
|
|
5248
|
+
var LOSSY_SUPERTYPE = /* @__PURE__ */ new Set([
|
|
5249
|
+
"scalar",
|
|
5250
|
+
"value",
|
|
5251
|
+
"function",
|
|
5252
|
+
"expression",
|
|
5253
|
+
"collection",
|
|
5254
|
+
"indexed_collection",
|
|
5255
|
+
"list",
|
|
5256
|
+
"set",
|
|
5257
|
+
"tuple",
|
|
5258
|
+
"record",
|
|
5259
|
+
"dictionary",
|
|
5260
|
+
"map",
|
|
5261
|
+
"any"
|
|
5262
|
+
]);
|
|
5263
|
+
function unionTypes(a, b) {
|
|
5264
|
+
const members = [];
|
|
5265
|
+
const keys = /* @__PURE__ */ new Set();
|
|
5266
|
+
const push = (t) => {
|
|
5267
|
+
if (typeof t === "object" && t.kind === "union") {
|
|
5268
|
+
for (const m of t.types) push(m);
|
|
5269
|
+
return;
|
|
5270
|
+
}
|
|
5271
|
+
const key = typeof t === "string" ? t : JSON.stringify(t);
|
|
5272
|
+
if (!keys.has(key)) {
|
|
5273
|
+
keys.add(key);
|
|
5274
|
+
members.push(t);
|
|
5275
|
+
}
|
|
5276
|
+
};
|
|
5277
|
+
push(a);
|
|
5278
|
+
push(b);
|
|
5279
|
+
if (members.length === 1) return members[0];
|
|
5280
|
+
return { kind: "union", types: members };
|
|
5222
5281
|
}
|
|
5223
5282
|
function narrow(...types) {
|
|
5224
5283
|
if (types.length === 0) return "nothing";
|
|
@@ -5230,6 +5289,32 @@ var Interval = (() => {
|
|
|
5230
5289
|
if (types.length === 1) return types[0];
|
|
5231
5290
|
return types.reduce((a, b) => widen2(a, b));
|
|
5232
5291
|
}
|
|
5292
|
+
var SUPERTYPE_PROBE_ORDER = [
|
|
5293
|
+
"non_finite_number",
|
|
5294
|
+
"finite_integer",
|
|
5295
|
+
"integer",
|
|
5296
|
+
"finite_rational",
|
|
5297
|
+
"rational",
|
|
5298
|
+
"finite_real",
|
|
5299
|
+
"real",
|
|
5300
|
+
"imaginary",
|
|
5301
|
+
"finite_complex",
|
|
5302
|
+
"complex",
|
|
5303
|
+
"finite_number",
|
|
5304
|
+
"number",
|
|
5305
|
+
"list",
|
|
5306
|
+
"record",
|
|
5307
|
+
"dictionary",
|
|
5308
|
+
"set",
|
|
5309
|
+
"tuple",
|
|
5310
|
+
"indexed_collection",
|
|
5311
|
+
"collection",
|
|
5312
|
+
"scalar",
|
|
5313
|
+
"value",
|
|
5314
|
+
"function",
|
|
5315
|
+
"expression"
|
|
5316
|
+
];
|
|
5317
|
+
var PRIMITIVE_SUPERTYPE_CACHE = /* @__PURE__ */ new Map();
|
|
5233
5318
|
function superType(a, b) {
|
|
5234
5319
|
if (a === b) return a;
|
|
5235
5320
|
if (a === "any" || b === "any") return "any";
|
|
@@ -5239,34 +5324,185 @@ var Interval = (() => {
|
|
|
5239
5324
|
if (b === "unknown") return a;
|
|
5240
5325
|
if (a === "nothing") return b;
|
|
5241
5326
|
if (b === "nothing") return a;
|
|
5242
|
-
if (
|
|
5243
|
-
|
|
5244
|
-
|
|
5245
|
-
|
|
5246
|
-
|
|
5247
|
-
|
|
5248
|
-
|
|
5249
|
-
|
|
5250
|
-
|
|
5251
|
-
|
|
5252
|
-
|
|
5253
|
-
|
|
5254
|
-
|
|
5255
|
-
|
|
5256
|
-
|
|
5257
|
-
|
|
5258
|
-
|
|
5259
|
-
|
|
5260
|
-
if (commonSupertype(a, b, "collection")) return "collection";
|
|
5261
|
-
if (commonSupertype(a, b, "scalar")) return "scalar";
|
|
5262
|
-
if (commonSupertype(a, b, "value")) return "value";
|
|
5263
|
-
if (commonSupertype(a, b, "function")) return "function";
|
|
5264
|
-
if (commonSupertype(a, b, "expression")) return "expression";
|
|
5327
|
+
if (typeof a === "string" && typeof b === "string") {
|
|
5328
|
+
const key = a < b ? `${a}|${b}` : `${b}|${a}`;
|
|
5329
|
+
let result = PRIMITIVE_SUPERTYPE_CACHE.get(key);
|
|
5330
|
+
if (result === void 0) {
|
|
5331
|
+
result = "any";
|
|
5332
|
+
for (const ancestor of SUPERTYPE_PROBE_ORDER) {
|
|
5333
|
+
const subtypes = PRIMITIVE_SUBTYPES_CLOSURE[ancestor];
|
|
5334
|
+
if (subtypes.has(a) && subtypes.has(b)) {
|
|
5335
|
+
result = ancestor;
|
|
5336
|
+
break;
|
|
5337
|
+
}
|
|
5338
|
+
}
|
|
5339
|
+
PRIMITIVE_SUPERTYPE_CACHE.set(key, result);
|
|
5340
|
+
}
|
|
5341
|
+
return result;
|
|
5342
|
+
}
|
|
5343
|
+
for (const ancestor of SUPERTYPE_PROBE_ORDER)
|
|
5344
|
+
if (isSubtype(a, ancestor) && isSubtype(b, ancestor)) return ancestor;
|
|
5265
5345
|
return "any";
|
|
5266
5346
|
}
|
|
5267
|
-
|
|
5268
|
-
|
|
5269
|
-
|
|
5347
|
+
|
|
5348
|
+
// src/common/type/serialize.ts
|
|
5349
|
+
var NEGATION_PRECEDENCE = 3;
|
|
5350
|
+
var UNION_PRECEDENCE = 1;
|
|
5351
|
+
var INTERSECTION_PRECEDENCE = 2;
|
|
5352
|
+
var LIST_PRECEDENCE = 4;
|
|
5353
|
+
var RECORD_PRECEDENCE = 5;
|
|
5354
|
+
var DICTIONARY_PRECEDENCE = 6;
|
|
5355
|
+
var SET_PRECEDENCE = 7;
|
|
5356
|
+
var COLLECTION_PRECEDENCE = 8;
|
|
5357
|
+
var TUPLE_PRECEDENCE = 9;
|
|
5358
|
+
var SIGNATURE_PRECEDENCE = 10;
|
|
5359
|
+
var VALUE_PRECEDENCE = 11;
|
|
5360
|
+
function typeToString(type, precedence = 0) {
|
|
5361
|
+
if (typeof type === "string") return type;
|
|
5362
|
+
let result = "";
|
|
5363
|
+
switch (type.kind) {
|
|
5364
|
+
case "value":
|
|
5365
|
+
if (typeof type.value === "string") result = `"${type.value}"`;
|
|
5366
|
+
else if (typeof type.value === "boolean")
|
|
5367
|
+
result = type.value ? "true" : "false";
|
|
5368
|
+
else result = type.value.toString();
|
|
5369
|
+
break;
|
|
5370
|
+
case "reference":
|
|
5371
|
+
result = type.name;
|
|
5372
|
+
break;
|
|
5373
|
+
case "negation":
|
|
5374
|
+
result = `!${typeToString(type.type, NEGATION_PRECEDENCE)}`;
|
|
5375
|
+
break;
|
|
5376
|
+
case "union":
|
|
5377
|
+
result = type.types.map((t) => typeToString(t, UNION_PRECEDENCE)).join(" | ");
|
|
5378
|
+
break;
|
|
5379
|
+
case "intersection":
|
|
5380
|
+
result = type.types.map((t) => typeToString(t, INTERSECTION_PRECEDENCE)).join(" & ");
|
|
5381
|
+
break;
|
|
5382
|
+
case "expression":
|
|
5383
|
+
result = `expression<${symbolName(type.operator)}>`;
|
|
5384
|
+
break;
|
|
5385
|
+
case "symbol":
|
|
5386
|
+
result = `symbol<${symbolName(type.name)}>`;
|
|
5387
|
+
break;
|
|
5388
|
+
case "numeric":
|
|
5389
|
+
if (Number.isFinite(type.lower) && Number.isFinite(type.upper)) {
|
|
5390
|
+
result = `${type.type}<${type.lower}..${type.upper}>`;
|
|
5391
|
+
} else if (Number.isFinite(type.lower)) {
|
|
5392
|
+
result = `${type.type}<${type.lower}..>`;
|
|
5393
|
+
} else if (Number.isFinite(type.upper)) {
|
|
5394
|
+
result = `${type.type}<..${type.upper}>`;
|
|
5395
|
+
} else {
|
|
5396
|
+
result = `${type.type}`;
|
|
5397
|
+
}
|
|
5398
|
+
break;
|
|
5399
|
+
case "list":
|
|
5400
|
+
if (type.dimensions && typeof type.elements === "string" && NUMERIC_TYPES_SET.has(type.elements)) {
|
|
5401
|
+
if (type.dimensions === void 0) {
|
|
5402
|
+
if (type.elements === "number") result = "tensor";
|
|
5403
|
+
} else if (type.dimensions.length === 1) {
|
|
5404
|
+
if (type.elements === "number") {
|
|
5405
|
+
if (type.dimensions[0] < 0) result = "vector";
|
|
5406
|
+
else result = `vector<${type.dimensions[0]}>`;
|
|
5407
|
+
} else {
|
|
5408
|
+
if (type.dimensions[0] < 0)
|
|
5409
|
+
result = `vector<${typeToString(type.elements)}>`;
|
|
5410
|
+
else
|
|
5411
|
+
result = `vector<${typeToString(type.elements)}^${type.dimensions[0]}>`;
|
|
5412
|
+
}
|
|
5413
|
+
} else if (type.dimensions.length === 2) {
|
|
5414
|
+
const dims = type.dimensions;
|
|
5415
|
+
if (type.elements === "number") {
|
|
5416
|
+
if (dims[0] < 0 && dims[1] < 0) result = "matrix";
|
|
5417
|
+
else result = `matrix<${dims[0]}x${dims[1]}>`;
|
|
5418
|
+
} else {
|
|
5419
|
+
if (dims[0] < 0 && dims[1] < 0)
|
|
5420
|
+
result = `matrix<${typeToString(type.elements)}>`;
|
|
5421
|
+
else
|
|
5422
|
+
result = `matrix<${typeToString(type.elements)}^(${dims[0]}x${dims[1]})>`;
|
|
5423
|
+
}
|
|
5424
|
+
}
|
|
5425
|
+
}
|
|
5426
|
+
if (!result) {
|
|
5427
|
+
const dimensions = type.dimensions ? type.dimensions.length === 1 ? `^${type.dimensions[0].toString()}` : `^(${type.dimensions.join("x")})` : "";
|
|
5428
|
+
result = `list<${typeToString(type.elements)}${dimensions}>`;
|
|
5429
|
+
}
|
|
5430
|
+
break;
|
|
5431
|
+
case "record":
|
|
5432
|
+
const elements = Object.entries(type.elements).map(([key, value]) => `${key}: ${typeToString(value)}`).join(", ");
|
|
5433
|
+
result = `record<${elements}>`;
|
|
5434
|
+
break;
|
|
5435
|
+
case "dictionary":
|
|
5436
|
+
result = `dictionary<${typeToString(type.values)}>`;
|
|
5437
|
+
break;
|
|
5438
|
+
case "set":
|
|
5439
|
+
result = `set<${typeToString(type.elements)}>`;
|
|
5440
|
+
break;
|
|
5441
|
+
case "collection":
|
|
5442
|
+
result = `collection<${typeToString(type.elements)}>`;
|
|
5443
|
+
break;
|
|
5444
|
+
case "indexed_collection":
|
|
5445
|
+
result = `indexed_collection<${typeToString(type.elements)}>`;
|
|
5446
|
+
break;
|
|
5447
|
+
case "tuple":
|
|
5448
|
+
if (type.elements.length === 0) result = "tuple";
|
|
5449
|
+
else if (type.elements.length === 1) {
|
|
5450
|
+
const [el] = type.elements;
|
|
5451
|
+
result = `tuple<${namedElement(el)}>`;
|
|
5452
|
+
} else {
|
|
5453
|
+
result = "tuple<" + type.elements.map((el) => namedElement(el)).join(", ") + ">";
|
|
5454
|
+
}
|
|
5455
|
+
break;
|
|
5456
|
+
case "signature":
|
|
5457
|
+
const args = type.args ? type.args.map((arg) => namedElement(arg)).join(", ") : "";
|
|
5458
|
+
const optArgs = type.optArgs ? type.optArgs.map((arg) => namedElement(arg) + "?").join(", ") : "";
|
|
5459
|
+
const varArg = type.variadicArg ? type.variadicMin === 0 ? `${namedElement(type.variadicArg)}*` : `${namedElement(type.variadicArg)}+` : "";
|
|
5460
|
+
const argsList = [args, optArgs, varArg].filter((s) => s).join(", ");
|
|
5461
|
+
result = `(${argsList}) -> ${typeToString(type.result)}`;
|
|
5462
|
+
break;
|
|
5463
|
+
default:
|
|
5464
|
+
result = "error";
|
|
5465
|
+
}
|
|
5466
|
+
if (precedence > 0 && precedence > getPrecedence(type.kind))
|
|
5467
|
+
return `(${result})`;
|
|
5468
|
+
return result;
|
|
5469
|
+
}
|
|
5470
|
+
function namedElement(el) {
|
|
5471
|
+
if (el.name) return `${el.name}: ${typeToString(el.type)}`;
|
|
5472
|
+
return typeToString(el.type);
|
|
5473
|
+
}
|
|
5474
|
+
function symbolName(name) {
|
|
5475
|
+
if (/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(name)) return name;
|
|
5476
|
+
return `\`${name}\``;
|
|
5477
|
+
}
|
|
5478
|
+
function getPrecedence(kind) {
|
|
5479
|
+
switch (kind) {
|
|
5480
|
+
case "negation":
|
|
5481
|
+
return NEGATION_PRECEDENCE;
|
|
5482
|
+
case "union":
|
|
5483
|
+
return UNION_PRECEDENCE;
|
|
5484
|
+
case "intersection":
|
|
5485
|
+
return INTERSECTION_PRECEDENCE;
|
|
5486
|
+
case "list":
|
|
5487
|
+
return LIST_PRECEDENCE;
|
|
5488
|
+
case "record":
|
|
5489
|
+
return RECORD_PRECEDENCE;
|
|
5490
|
+
case "dictionary":
|
|
5491
|
+
return DICTIONARY_PRECEDENCE;
|
|
5492
|
+
case "set":
|
|
5493
|
+
return SET_PRECEDENCE;
|
|
5494
|
+
case "collection":
|
|
5495
|
+
case "indexed_collection":
|
|
5496
|
+
return COLLECTION_PRECEDENCE;
|
|
5497
|
+
case "tuple":
|
|
5498
|
+
return TUPLE_PRECEDENCE;
|
|
5499
|
+
case "signature":
|
|
5500
|
+
return SIGNATURE_PRECEDENCE;
|
|
5501
|
+
case "value":
|
|
5502
|
+
return VALUE_PRECEDENCE;
|
|
5503
|
+
default:
|
|
5504
|
+
return 0;
|
|
5505
|
+
}
|
|
5270
5506
|
}
|
|
5271
5507
|
|
|
5272
5508
|
// src/common/type/boxed-type.ts
|
|
@@ -5326,6 +5562,12 @@ var Interval = (() => {
|
|
|
5326
5562
|
}
|
|
5327
5563
|
};
|
|
5328
5564
|
|
|
5565
|
+
// src/compute-engine/boxed-expression/constraint-subject.ts
|
|
5566
|
+
var EMPTY_FACT_INDEX = Object.freeze({
|
|
5567
|
+
bySubject: /* @__PURE__ */ new Map(),
|
|
5568
|
+
membership: /* @__PURE__ */ new Map()
|
|
5569
|
+
});
|
|
5570
|
+
|
|
5329
5571
|
// src/compute-engine/boxed-expression/stochastic-equal.ts
|
|
5330
5572
|
var WELL_KNOWN_POINTS = [
|
|
5331
5573
|
0,
|
|
@@ -5431,12 +5673,14 @@ var Interval = (() => {
|
|
|
5431
5673
|
if (expr === null) return null;
|
|
5432
5674
|
if (isDictionaryObject(expr)) return expr;
|
|
5433
5675
|
const kv = keyValuePair(expr);
|
|
5434
|
-
if (kv)
|
|
5676
|
+
if (kv)
|
|
5677
|
+
return {
|
|
5678
|
+
dict: { [kv[0]]: expressionToDictionaryValue(kv[1]) ?? "Nothing" }
|
|
5679
|
+
};
|
|
5435
5680
|
if (operator(expr) === "Dictionary") {
|
|
5436
5681
|
const dict = {};
|
|
5437
|
-
const
|
|
5438
|
-
|
|
5439
|
-
const kv2 = keyValuePair(ops[i]);
|
|
5682
|
+
for (const op of operands(expr)) {
|
|
5683
|
+
const kv2 = keyValuePair(op);
|
|
5440
5684
|
if (kv2) {
|
|
5441
5685
|
dict[kv2[0]] = expressionToDictionaryValue(kv2[1]) ?? "Nothing";
|
|
5442
5686
|
}
|
|
@@ -6374,15 +6618,16 @@ var Interval = (() => {
|
|
|
6374
6618
|
precedence: ASSIGNMENT_PRECEDENCE,
|
|
6375
6619
|
parse: parseAssign
|
|
6376
6620
|
},
|
|
6377
|
-
// General colon operator (type annotation, mapping notation)
|
|
6378
|
-
// Precedence below
|
|
6379
|
-
// and below arrows (270) so
|
|
6621
|
+
// General colon operator (type annotation, mapping notation, Desmos piecewise)
|
|
6622
|
+
// Precedence below comparisons (245) so `cond : val` (Desmos compact piecewise)
|
|
6623
|
+
// parses as `Colon(cond, val)`, and below arrows (270) so
|
|
6624
|
+
// `f: A \to B` parses as `Colon(f, To(A, B))`.
|
|
6380
6625
|
{
|
|
6381
6626
|
name: "Colon",
|
|
6382
6627
|
latexTrigger: ":",
|
|
6383
6628
|
kind: "infix",
|
|
6384
6629
|
associativity: "right",
|
|
6385
|
-
precedence:
|
|
6630
|
+
precedence: 240,
|
|
6386
6631
|
serialize: (serializer, expr) => joinLatex([
|
|
6387
6632
|
serializer.serialize(operand(expr, 1)),
|
|
6388
6633
|
"\\colon",
|
|
@@ -6393,7 +6638,7 @@ var Interval = (() => {
|
|
|
6393
6638
|
latexTrigger: "\\colon",
|
|
6394
6639
|
kind: "infix",
|
|
6395
6640
|
associativity: "right",
|
|
6396
|
-
precedence:
|
|
6641
|
+
precedence: 240,
|
|
6397
6642
|
parse: "Colon"
|
|
6398
6643
|
},
|
|
6399
6644
|
{
|
|
@@ -7369,6 +7614,7 @@ var Interval = (() => {
|
|
|
7369
7614
|
}
|
|
7370
7615
|
}
|
|
7371
7616
|
if (!variable) return null;
|
|
7617
|
+
if (symbol(variable) === null) return null;
|
|
7372
7618
|
parser.skipSpace();
|
|
7373
7619
|
const fn = parser.parseExpression({ minPrec: 740 });
|
|
7374
7620
|
if (!fn) return null;
|
|
@@ -7555,7 +7801,7 @@ var Interval = (() => {
|
|
|
7555
7801
|
if (runs.length === 1) body = runs[0];
|
|
7556
7802
|
else {
|
|
7557
7803
|
if (runs.every((x) => stringValue(x) !== null))
|
|
7558
|
-
body = "'" + runs.map((x) => stringValue(x)).join() + "'";
|
|
7804
|
+
body = "'" + runs.map((x) => stringValue(x)).join("") + "'";
|
|
7559
7805
|
else body = ["Text", ...runs];
|
|
7560
7806
|
}
|
|
7561
7807
|
return style ? ["Annotated", body, dictionaryFromEntries(style)] : body;
|
|
@@ -7963,7 +8209,10 @@ var Interval = (() => {
|
|
|
7963
8209
|
p.skipVisualSpace();
|
|
7964
8210
|
const isComma = p.peek === ",";
|
|
7965
8211
|
p.index = saved;
|
|
7966
|
-
return
|
|
8212
|
+
if (isComma) return true;
|
|
8213
|
+
if (peekKeyword(p, "where")) return true;
|
|
8214
|
+
if (peekKeyword(p, "with")) return true;
|
|
8215
|
+
return false;
|
|
7967
8216
|
}
|
|
7968
8217
|
};
|
|
7969
8218
|
const elements = [];
|
|
@@ -8004,6 +8253,25 @@ var Interval = (() => {
|
|
|
8004
8253
|
parser.skipVisualSpace();
|
|
8005
8254
|
} while (parser.match(","));
|
|
8006
8255
|
if (bindings.length === 0) return null;
|
|
8256
|
+
const forStart = parser.index;
|
|
8257
|
+
if (matchKeyword(parser, "for")) {
|
|
8258
|
+
const loop = parseForComprehension(parser, lhs, until);
|
|
8259
|
+
if (loop) {
|
|
8260
|
+
const block2 = [];
|
|
8261
|
+
for (const b of bindings) {
|
|
8262
|
+
const normalized = normalizeLocalAssign(b);
|
|
8263
|
+
if (operator(normalized) === "Assign") {
|
|
8264
|
+
block2.push(["Declare", operand(normalized, 1)]);
|
|
8265
|
+
block2.push(normalized);
|
|
8266
|
+
} else {
|
|
8267
|
+
block2.push(normalized);
|
|
8268
|
+
}
|
|
8269
|
+
}
|
|
8270
|
+
block2.push(loop);
|
|
8271
|
+
return ["Block", ...block2];
|
|
8272
|
+
}
|
|
8273
|
+
parser.index = forStart;
|
|
8274
|
+
}
|
|
8007
8275
|
const block = [];
|
|
8008
8276
|
for (const b of bindings) {
|
|
8009
8277
|
const normalized = normalizeLocalAssign(b);
|
|
@@ -8217,6 +8485,17 @@ var Interval = (() => {
|
|
|
8217
8485
|
const upperExpr = openRight ? ["Open", upper] : upper;
|
|
8218
8486
|
return ["Interval", lowerExpr, upperExpr];
|
|
8219
8487
|
}
|
|
8488
|
+
var COMPARISON_HEADS = /* @__PURE__ */ new Set([
|
|
8489
|
+
"Less",
|
|
8490
|
+
"LessEqual",
|
|
8491
|
+
"Greater",
|
|
8492
|
+
"GreaterEqual",
|
|
8493
|
+
"Equal",
|
|
8494
|
+
"NotEqual",
|
|
8495
|
+
"And",
|
|
8496
|
+
"Or",
|
|
8497
|
+
"Not"
|
|
8498
|
+
]);
|
|
8220
8499
|
var DEFINITIONS_SETS = [
|
|
8221
8500
|
//
|
|
8222
8501
|
// Constants
|
|
@@ -8475,18 +8754,58 @@ var Interval = (() => {
|
|
|
8475
8754
|
closeTrigger: "}",
|
|
8476
8755
|
parse: (_parser, body) => {
|
|
8477
8756
|
if (isEmptySequence(body)) return "EmptySet";
|
|
8757
|
+
if (operator(body) == "Delimiter" && stringValue(operand(body, 2)) === ",") {
|
|
8758
|
+
body = operand(body, 1);
|
|
8759
|
+
}
|
|
8478
8760
|
const h = operator(body);
|
|
8479
|
-
if (h === "Divides"
|
|
8761
|
+
if (h === "Divides") {
|
|
8480
8762
|
const expr = operand(body, 1);
|
|
8481
8763
|
const condition = operand(body, 2);
|
|
8482
8764
|
if (expr !== null && condition !== null)
|
|
8483
8765
|
return ["Set", expr, ["Condition", condition]];
|
|
8484
8766
|
}
|
|
8485
|
-
if (
|
|
8486
|
-
|
|
8767
|
+
if (h === "Colon") {
|
|
8768
|
+
const lhs = operand(body, 1);
|
|
8769
|
+
const rhs = operand(body, 2);
|
|
8770
|
+
if (lhs !== null && rhs !== null) {
|
|
8771
|
+
const lhsOp = operator(lhs);
|
|
8772
|
+
if (lhsOp !== null && COMPARISON_HEADS.has(lhsOp)) {
|
|
8773
|
+
return ["Which", lhs, rhs];
|
|
8774
|
+
}
|
|
8775
|
+
return ["Set", lhs, ["Condition", rhs]];
|
|
8776
|
+
}
|
|
8487
8777
|
}
|
|
8488
|
-
if (
|
|
8489
|
-
|
|
8778
|
+
if (h === "Sequence") {
|
|
8779
|
+
const elements = operands(body);
|
|
8780
|
+
const colonElements = elements.filter((el) => operator(el) === "Colon");
|
|
8781
|
+
const allPiecewise = colonElements.length > 0 && colonElements.every((el) => {
|
|
8782
|
+
const lhs = operand(el, 1);
|
|
8783
|
+
const lhsOp = lhs !== null ? operator(lhs) : null;
|
|
8784
|
+
return lhsOp !== null && COMPARISON_HEADS.has(lhsOp);
|
|
8785
|
+
});
|
|
8786
|
+
if (allPiecewise) {
|
|
8787
|
+
const whichOps = [];
|
|
8788
|
+
for (let i = 0; i < elements.length; i++) {
|
|
8789
|
+
const el = elements[i];
|
|
8790
|
+
if (operator(el) === "Colon") {
|
|
8791
|
+
const cond = operand(el, 1);
|
|
8792
|
+
const val = operand(el, 2);
|
|
8793
|
+
if (cond === null || val === null) {
|
|
8794
|
+
return ["Set", ...elements];
|
|
8795
|
+
}
|
|
8796
|
+
whichOps.push(cond, val);
|
|
8797
|
+
} else {
|
|
8798
|
+
if (i !== elements.length - 1) {
|
|
8799
|
+
return ["Set", ...elements];
|
|
8800
|
+
}
|
|
8801
|
+
whichOps.push("True", el);
|
|
8802
|
+
}
|
|
8803
|
+
}
|
|
8804
|
+
return ["Which", ...whichOps];
|
|
8805
|
+
}
|
|
8806
|
+
return ["Set", ...elements];
|
|
8807
|
+
}
|
|
8808
|
+
return ["Set", body];
|
|
8490
8809
|
},
|
|
8491
8810
|
serialize: (serializer, expr) => {
|
|
8492
8811
|
if (nops(expr) === 2 && operator(operand(expr, 2)) === "Condition") {
|
|
@@ -9015,6 +9334,8 @@ var Interval = (() => {
|
|
|
9015
9334
|
const h = operator(arg);
|
|
9016
9335
|
if (prevWasNumber && (h === "Divide" || h === "Rational")) {
|
|
9017
9336
|
result = latexTemplate(serializer.options.multiply, result, term);
|
|
9337
|
+
} else if (/^\d/.test(term)) {
|
|
9338
|
+
result = latexTemplate(serializer.options.multiply, result, term);
|
|
9018
9339
|
} else if (!serializer.options.invisibleMultiply) {
|
|
9019
9340
|
result = joinLatex([result, term]);
|
|
9020
9341
|
} else {
|
|
@@ -10460,7 +10781,9 @@ var Interval = (() => {
|
|
|
10460
10781
|
minPrec: MULTIPLICATION_PRECEDENCE,
|
|
10461
10782
|
condition: (parser2) => trigCommands[parser2.peek] || (until?.condition?.(parser2) ?? false)
|
|
10462
10783
|
});
|
|
10463
|
-
const
|
|
10784
|
+
const isTwoArgArctan = args?.length === 2 && (fn === "Arctan" || Array.isArray(fn) && fn[0] === "InverseFunction" && fn[1] === "Tan");
|
|
10785
|
+
const head = isTwoArgArctan ? "Arctan2" : fn;
|
|
10786
|
+
const appliedFn = args === null ? fn : typeof head === "string" ? [head, ...args] : ["Apply", head, ...args];
|
|
10464
10787
|
return sup === null ? appliedFn : ["Power", appliedFn, sup];
|
|
10465
10788
|
};
|
|
10466
10789
|
}
|
|
@@ -12583,10 +12906,17 @@ var Interval = (() => {
|
|
|
12583
12906
|
// The capitalized library entries already exist; these are pure parse
|
|
12584
12907
|
// aliases so the lowercase names don't land in `unsupported-operator`.
|
|
12585
12908
|
// ---------------------------------------------------------------------------
|
|
12909
|
+
{ latexTrigger: "\\operatorname{count}", parse: "Length" },
|
|
12586
12910
|
{ latexTrigger: "\\operatorname{random}", parse: "Random" },
|
|
12587
12911
|
{ latexTrigger: "\\operatorname{shuffle}", parse: "Shuffle" },
|
|
12588
12912
|
{ latexTrigger: "\\operatorname{repeat}", parse: "Repeat" },
|
|
12589
12913
|
{ latexTrigger: "\\operatorname{join}", parse: "Join" },
|
|
12914
|
+
{ latexTrigger: "\\operatorname{range}", parse: "Range" },
|
|
12915
|
+
// Note: `\operatorname{with}` (Desmos's local-binding clause) is intentionally
|
|
12916
|
+
// NOT registered here. Use the math-notation equivalent `\operatorname{where}`
|
|
12917
|
+
// (with `\coloneq` for bindings), or register `with` as a custom dictionary
|
|
12918
|
+
// entry at the integration layer — see the "Desmos-Specific Syntax — Prefer
|
|
12919
|
+
// Custom LaTeX Dictionary" section in COMPUTE_ENGINE.md for a worked example.
|
|
12590
12920
|
// ---------------------------------------------------------------------------
|
|
12591
12921
|
// Geometric primitive heads. Registered as known typed heads so consumers
|
|
12592
12922
|
// can branch on the operator name; CE itself doesn't render them. The
|
|
@@ -12739,6 +13069,30 @@ var Interval = (() => {
|
|
|
12739
13069
|
var SOME_EMOJI = new RegExp(`(?:${POSSIBLE_EMOJI})+`, "u");
|
|
12740
13070
|
var EMOJIS = new RegExp(`^(?:${POSSIBLE_EMOJI})+$`, "u");
|
|
12741
13071
|
|
|
13072
|
+
// src/compute-engine/latex-syntax/parse.ts
|
|
13073
|
+
var PARSE_TOKEN_EXCLUDED = /* @__PURE__ */ new Set([
|
|
13074
|
+
...'!"#$%&(),/;:?@[]\\`|~'.split(""),
|
|
13075
|
+
"\\left",
|
|
13076
|
+
"\\bigl",
|
|
13077
|
+
"\\mleft"
|
|
13078
|
+
]);
|
|
13079
|
+
var TEX_UNIT_TOKENS = [
|
|
13080
|
+
"pt",
|
|
13081
|
+
"em",
|
|
13082
|
+
"mu",
|
|
13083
|
+
"ex",
|
|
13084
|
+
"mm",
|
|
13085
|
+
"cm",
|
|
13086
|
+
"in",
|
|
13087
|
+
"bp",
|
|
13088
|
+
"sp",
|
|
13089
|
+
"dd",
|
|
13090
|
+
"cc",
|
|
13091
|
+
"pc",
|
|
13092
|
+
"nc",
|
|
13093
|
+
"nd"
|
|
13094
|
+
].map((unit) => [...unit]);
|
|
13095
|
+
|
|
12742
13096
|
// src/compute-engine/boxed-expression/expand.ts
|
|
12743
13097
|
var binomials = [
|
|
12744
13098
|
[1],
|
|
@@ -13040,6 +13394,7 @@ var Interval = (() => {
|
|
|
13040
13394
|
const period = Math.abs(
|
|
13041
13395
|
bVal.lo === bVal.hi ? bVal.lo : Math.max(Math.abs(bVal.lo), Math.abs(bVal.hi))
|
|
13042
13396
|
);
|
|
13397
|
+
const divisorNegative = bVal.hi < 0;
|
|
13043
13398
|
const flo = Math.floor(aVal.lo / period);
|
|
13044
13399
|
const fhi = Math.floor(aVal.hi / period);
|
|
13045
13400
|
if (flo !== fhi) {
|
|
@@ -13047,6 +13402,11 @@ var Interval = (() => {
|
|
|
13047
13402
|
}
|
|
13048
13403
|
const modLo = aVal.lo - period * flo;
|
|
13049
13404
|
const modHi = aVal.hi - period * flo;
|
|
13405
|
+
if (divisorNegative) {
|
|
13406
|
+
if (modLo === 0)
|
|
13407
|
+
return { kind: "singular", at: aVal.lo, continuity: "right" };
|
|
13408
|
+
return ok({ lo: modLo - period, hi: modHi - period });
|
|
13409
|
+
}
|
|
13050
13410
|
return ok({ lo: Math.min(modLo, modHi), hi: Math.max(modLo, modHi) });
|
|
13051
13411
|
}
|
|
13052
13412
|
function remainder(a, b) {
|
|
@@ -13078,6 +13438,23 @@ var Interval = (() => {
|
|
|
13078
13438
|
const [xVal] = unwrapped;
|
|
13079
13439
|
return _gamma(xVal);
|
|
13080
13440
|
}
|
|
13441
|
+
var GAMMA_NEG_EXTREMA_X = [
|
|
13442
|
+
-0.504083008264455,
|
|
13443
|
+
-1.573498473162391,
|
|
13444
|
+
-2.610720868444145,
|
|
13445
|
+
-3.635293366436901,
|
|
13446
|
+
-4.653163765628266,
|
|
13447
|
+
-5.667162441556885,
|
|
13448
|
+
-6.678418213073426,
|
|
13449
|
+
-7.687788325031709,
|
|
13450
|
+
-8.695764163640956,
|
|
13451
|
+
-9.702672540001863
|
|
13452
|
+
];
|
|
13453
|
+
function gammaNegStripExtremum(lo) {
|
|
13454
|
+
const n = Math.floor(lo);
|
|
13455
|
+
const idx = -n - 1;
|
|
13456
|
+
return idx >= 0 && idx < GAMMA_NEG_EXTREMA_X.length ? GAMMA_NEG_EXTREMA_X[idx] : null;
|
|
13457
|
+
}
|
|
13081
13458
|
function _gamma(x) {
|
|
13082
13459
|
if (x.hi >= 0 && x.lo <= 0) {
|
|
13083
13460
|
return { kind: "singular", at: 0 };
|
|
@@ -13090,7 +13467,21 @@ var Interval = (() => {
|
|
|
13090
13467
|
}
|
|
13091
13468
|
const gLo = gamma(x.lo);
|
|
13092
13469
|
const gHi = gamma(x.hi);
|
|
13093
|
-
|
|
13470
|
+
let lo = Math.min(gLo, gHi);
|
|
13471
|
+
let hi = Math.max(gLo, gHi);
|
|
13472
|
+
const xStar = gammaNegStripExtremum(x.lo);
|
|
13473
|
+
if (xStar !== null) {
|
|
13474
|
+
if (xStar >= x.lo && xStar <= x.hi) {
|
|
13475
|
+
const g = gamma(xStar);
|
|
13476
|
+
lo = Math.min(lo, g);
|
|
13477
|
+
hi = Math.max(hi, g);
|
|
13478
|
+
}
|
|
13479
|
+
} else {
|
|
13480
|
+
const stripEven = Math.floor(x.lo) % 2 === 0;
|
|
13481
|
+
if (stripEven) lo = Math.min(lo, 0);
|
|
13482
|
+
else hi = Math.max(hi, 0);
|
|
13483
|
+
}
|
|
13484
|
+
return ok({ lo, hi });
|
|
13094
13485
|
}
|
|
13095
13486
|
if (x.lo >= GAMMA_MIN_X) {
|
|
13096
13487
|
return ok({ lo: gamma(x.lo), hi: gamma(x.hi) });
|
|
@@ -13121,7 +13512,15 @@ var Interval = (() => {
|
|
|
13121
13512
|
}
|
|
13122
13513
|
const gLo = gammaln(x.lo);
|
|
13123
13514
|
const gHi = gammaln(x.hi);
|
|
13124
|
-
|
|
13515
|
+
let lo = Math.min(gLo, gHi);
|
|
13516
|
+
const hi = Math.max(gLo, gHi);
|
|
13517
|
+
const xStar = gammaNegStripExtremum(x.lo);
|
|
13518
|
+
if (xStar !== null) {
|
|
13519
|
+
if (xStar >= x.lo && xStar <= x.hi) lo = Math.min(lo, gammaln(xStar));
|
|
13520
|
+
} else {
|
|
13521
|
+
lo = -Infinity;
|
|
13522
|
+
}
|
|
13523
|
+
return ok({ lo, hi });
|
|
13125
13524
|
}
|
|
13126
13525
|
return ok({ lo: gammaln(x.lo), hi: gammaln(x.hi) });
|
|
13127
13526
|
}
|
|
@@ -13147,6 +13546,33 @@ var Interval = (() => {
|
|
|
13147
13546
|
return ok({ lo: Math.min(fLo, fHi), hi: Math.max(fLo, fHi) });
|
|
13148
13547
|
return ok({ lo: fLo, hi: fHi });
|
|
13149
13548
|
}
|
|
13549
|
+
var MAX_INT_ENUM_POINTS = 4096;
|
|
13550
|
+
function integerPoints(lo, hi, cap) {
|
|
13551
|
+
const a = Math.round(lo);
|
|
13552
|
+
const b = Math.round(hi);
|
|
13553
|
+
if (!Number.isFinite(a) || !Number.isFinite(b)) return null;
|
|
13554
|
+
if (b - a + 1 > cap) return null;
|
|
13555
|
+
const out = [];
|
|
13556
|
+
for (let i = a; i <= b; i++) out.push(i);
|
|
13557
|
+
return out;
|
|
13558
|
+
}
|
|
13559
|
+
function enumerateInteger2(a, b, f) {
|
|
13560
|
+
const xs = integerPoints(a.lo, a.hi, MAX_INT_ENUM_POINTS);
|
|
13561
|
+
const ys = integerPoints(b.lo, b.hi, MAX_INT_ENUM_POINTS);
|
|
13562
|
+
if (!xs || !ys || xs.length * ys.length > MAX_INT_ENUM_POINTS) return null;
|
|
13563
|
+
let lo = Infinity;
|
|
13564
|
+
let hi = -Infinity;
|
|
13565
|
+
for (const x of xs)
|
|
13566
|
+
for (const y of ys) {
|
|
13567
|
+
const v = f(x, y);
|
|
13568
|
+
if (Number.isFinite(v)) {
|
|
13569
|
+
if (v < lo) lo = v;
|
|
13570
|
+
if (v > hi) hi = v;
|
|
13571
|
+
}
|
|
13572
|
+
}
|
|
13573
|
+
if (lo === Infinity) return null;
|
|
13574
|
+
return ok({ lo, hi });
|
|
13575
|
+
}
|
|
13150
13576
|
function binomial(n, k) {
|
|
13151
13577
|
const uN = unwrapOrPropagate(n);
|
|
13152
13578
|
if (!Array.isArray(uN)) return uN;
|
|
@@ -13154,13 +13580,10 @@ var Interval = (() => {
|
|
|
13154
13580
|
if (!Array.isArray(uK)) return uK;
|
|
13155
13581
|
const [nVal] = uN;
|
|
13156
13582
|
const [kVal] = uK;
|
|
13157
|
-
const
|
|
13158
|
-
|
|
13159
|
-
|
|
13160
|
-
|
|
13161
|
-
choose(Math.round(nVal.hi), Math.round(kVal.hi))
|
|
13162
|
-
];
|
|
13163
|
-
return ok({ lo: Math.min(...vals), hi: Math.max(...vals) });
|
|
13583
|
+
const enumerated = enumerateInteger2(nVal, kVal, choose);
|
|
13584
|
+
if (enumerated) return enumerated;
|
|
13585
|
+
const nMax = Math.round(nVal.hi);
|
|
13586
|
+
return ok({ lo: 0, hi: choose(nMax, Math.floor(nMax / 2)) });
|
|
13164
13587
|
}
|
|
13165
13588
|
function gcd3(a, b) {
|
|
13166
13589
|
const uA = unwrapOrPropagate(a);
|
|
@@ -13169,13 +13592,15 @@ var Interval = (() => {
|
|
|
13169
13592
|
if (!Array.isArray(uB)) return uB;
|
|
13170
13593
|
const [aVal] = uA;
|
|
13171
13594
|
const [bVal] = uB;
|
|
13172
|
-
const
|
|
13173
|
-
|
|
13174
|
-
|
|
13175
|
-
|
|
13176
|
-
|
|
13177
|
-
|
|
13178
|
-
|
|
13595
|
+
const enumerated = enumerateInteger2(aVal, bVal, gcd);
|
|
13596
|
+
if (enumerated) return enumerated;
|
|
13597
|
+
const m = Math.max(
|
|
13598
|
+
Math.abs(Math.round(aVal.lo)),
|
|
13599
|
+
Math.abs(Math.round(aVal.hi)),
|
|
13600
|
+
Math.abs(Math.round(bVal.lo)),
|
|
13601
|
+
Math.abs(Math.round(bVal.hi))
|
|
13602
|
+
);
|
|
13603
|
+
return ok({ lo: 0, hi: m });
|
|
13179
13604
|
}
|
|
13180
13605
|
function lcm3(a, b) {
|
|
13181
13606
|
const uA = unwrapOrPropagate(a);
|
|
@@ -13184,13 +13609,11 @@ var Interval = (() => {
|
|
|
13184
13609
|
if (!Array.isArray(uB)) return uB;
|
|
13185
13610
|
const [aVal] = uA;
|
|
13186
13611
|
const [bVal] = uB;
|
|
13187
|
-
const
|
|
13188
|
-
|
|
13189
|
-
|
|
13190
|
-
|
|
13191
|
-
|
|
13192
|
-
];
|
|
13193
|
-
return ok({ lo: Math.min(...vals), hi: Math.max(...vals) });
|
|
13612
|
+
const enumerated = enumerateInteger2(aVal, bVal, lcm);
|
|
13613
|
+
if (enumerated) return enumerated;
|
|
13614
|
+
const ma = Math.max(Math.abs(Math.round(aVal.lo)), Math.abs(Math.round(aVal.hi)));
|
|
13615
|
+
const mb = Math.max(Math.abs(Math.round(bVal.lo)), Math.abs(Math.round(bVal.hi)));
|
|
13616
|
+
return ok({ lo: 0, hi: ma * mb });
|
|
13194
13617
|
}
|
|
13195
13618
|
function chop2(x) {
|
|
13196
13619
|
const unwrapped = unwrapOrPropagate(x);
|
|
@@ -13582,7 +14005,6 @@ var Interval = (() => {
|
|
|
13582
14005
|
29.8116,
|
|
13583
14006
|
32.95639
|
|
13584
14007
|
];
|
|
13585
|
-
var SINC_GLOBAL_LO = -0.21724;
|
|
13586
14008
|
function sinc(x) {
|
|
13587
14009
|
const unwrapped = unwrapOrPropagate(x);
|
|
13588
14010
|
if (!Array.isArray(unwrapped)) return unwrapped;
|
|
@@ -13603,8 +14025,14 @@ var Interval = (() => {
|
|
|
13603
14025
|
if (e >= xVal.lo && e <= xVal.hi) update(sincVal(e));
|
|
13604
14026
|
if (-e >= xVal.lo && -e <= xVal.hi) update(sincVal(-e));
|
|
13605
14027
|
}
|
|
13606
|
-
|
|
13607
|
-
|
|
14028
|
+
let minBeyondAbs = Infinity;
|
|
14029
|
+
if (xVal.hi > lastExtremum)
|
|
14030
|
+
minBeyondAbs = Math.min(minBeyondAbs, Math.max(xVal.lo, lastExtremum));
|
|
14031
|
+
if (xVal.lo < -lastExtremum)
|
|
14032
|
+
minBeyondAbs = Math.min(minBeyondAbs, -Math.min(xVal.hi, -lastExtremum));
|
|
14033
|
+
if (Number.isFinite(minBeyondAbs) && minBeyondAbs > 0) {
|
|
14034
|
+
update(1 / minBeyondAbs);
|
|
14035
|
+
update(-1 / minBeyondAbs);
|
|
13608
14036
|
}
|
|
13609
14037
|
return ok({ lo, hi });
|
|
13610
14038
|
}
|
|
@@ -13630,8 +14058,21 @@ var Interval = (() => {
|
|
|
13630
14058
|
if (e >= xVal.lo && e <= xVal.hi) update(fresnelS(e));
|
|
13631
14059
|
if (-e >= xVal.lo && -e <= xVal.hi) update(fresnelS(-e));
|
|
13632
14060
|
}
|
|
14061
|
+
fresnelConvergenceBound(xVal, FRESNEL_S_EXTREMA, fresnelS, update);
|
|
13633
14062
|
return ok({ lo, hi });
|
|
13634
14063
|
}
|
|
14064
|
+
function fresnelConvergenceBound(xVal, extrema, scalar, update) {
|
|
14065
|
+
const lastE = extrema[extrema.length - 1];
|
|
14066
|
+
const amp = Math.abs(scalar(lastE) - 0.5);
|
|
14067
|
+
if (xVal.hi > lastE) {
|
|
14068
|
+
update(0.5 + amp);
|
|
14069
|
+
update(0.5 - amp);
|
|
14070
|
+
}
|
|
14071
|
+
if (xVal.lo < -lastE) {
|
|
14072
|
+
update(-0.5 - amp);
|
|
14073
|
+
update(-0.5 + amp);
|
|
14074
|
+
}
|
|
14075
|
+
}
|
|
13635
14076
|
function fresnelC2(x) {
|
|
13636
14077
|
const unwrapped = unwrapOrPropagate(x);
|
|
13637
14078
|
if (!Array.isArray(unwrapped)) return unwrapped;
|
|
@@ -13648,6 +14089,7 @@ var Interval = (() => {
|
|
|
13648
14089
|
if (e >= xVal.lo && e <= xVal.hi) update(fresnelC(e));
|
|
13649
14090
|
if (-e >= xVal.lo && -e <= xVal.hi) update(fresnelC(-e));
|
|
13650
14091
|
}
|
|
14092
|
+
fresnelConvergenceBound(xVal, FRESNEL_C_EXTREMA, fresnelC, update);
|
|
13651
14093
|
return ok({ lo, hi });
|
|
13652
14094
|
}
|
|
13653
14095
|
|
|
@@ -13755,11 +14197,9 @@ var Interval = (() => {
|
|
|
13755
14197
|
const unwrapped = unwrapOrPropagate(x, lo, hi);
|
|
13756
14198
|
if (!Array.isArray(unwrapped)) return unwrapped;
|
|
13757
14199
|
const [xVal, loVal, hiVal] = unwrapped;
|
|
13758
|
-
const
|
|
13759
|
-
const
|
|
13760
|
-
|
|
13761
|
-
return { kind: "empty" };
|
|
13762
|
-
}
|
|
14200
|
+
const lowered = { lo: Math.max(xVal.lo, loVal.lo), hi: Math.max(xVal.hi, loVal.hi) };
|
|
14201
|
+
const resultLo = Math.min(lowered.lo, hiVal.lo);
|
|
14202
|
+
const resultHi = Math.min(lowered.hi, hiVal.hi);
|
|
13763
14203
|
return { kind: "interval", value: { lo: resultLo, hi: resultHi } };
|
|
13764
14204
|
}
|
|
13765
14205
|
|
|
@@ -13865,7 +14305,7 @@ var Interval = (() => {
|
|
|
13865
14305
|
};
|
|
13866
14306
|
|
|
13867
14307
|
// src/interval.ts
|
|
13868
|
-
var version = "0.
|
|
14308
|
+
var version = "0.59.0";
|
|
13869
14309
|
return __toCommonJS(interval_exports);
|
|
13870
14310
|
})();
|
|
13871
14311
|
/*! Bundled license information:
|