@cortex-js/compute-engine 0.35.0 → 0.35.1

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.
Files changed (177) hide show
  1. package/dist/compute-engine.esm.js +507 -150
  2. package/dist/compute-engine.min.esm.js +233 -38
  3. package/dist/compute-engine.min.umd.js +233 -38
  4. package/dist/compute-engine.umd.js +507 -150
  5. package/dist/math-json.esm.js +2 -2
  6. package/dist/math-json.min.esm.js +2 -2
  7. package/dist/math-json.min.umd.js +2 -2
  8. package/dist/math-json.umd.js +2 -2
  9. package/dist/types/common/ansi-codes.d.ts +1 -1
  10. package/dist/types/common/configuration-change.d.ts +1 -1
  11. package/dist/types/common/fuzzy-string-match.d.ts +1 -1
  12. package/dist/types/common/grapheme-splitter.d.ts +1 -1
  13. package/dist/types/common/interruptible.d.ts +1 -1
  14. package/dist/types/common/one-of.d.ts +1 -1
  15. package/dist/types/common/signals.d.ts +1 -1
  16. package/dist/types/common/type/ast-nodes.d.ts +1 -1
  17. package/dist/types/common/type/boxed-type.d.ts +1 -1
  18. package/dist/types/common/type/lexer.d.ts +1 -1
  19. package/dist/types/common/type/parse.d.ts +1 -1
  20. package/dist/types/common/type/parser.d.ts +1 -1
  21. package/dist/types/common/type/primitive.d.ts +1 -1
  22. package/dist/types/common/type/reduce.d.ts +1 -1
  23. package/dist/types/common/type/serialize.d.ts +1 -1
  24. package/dist/types/common/type/subtype.d.ts +1 -1
  25. package/dist/types/common/type/type-builder.d.ts +1 -1
  26. package/dist/types/common/type/types.d.ts +1 -1
  27. package/dist/types/common/type/utils.d.ts +1 -1
  28. package/dist/types/common/utils.d.ts +1 -1
  29. package/dist/types/compute-engine/assume.d.ts +1 -1
  30. package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +1 -1
  31. package/dist/types/compute-engine/boxed-expression/apply.d.ts +1 -1
  32. package/dist/types/compute-engine/boxed-expression/arithmetic-add.d.ts +1 -1
  33. package/dist/types/compute-engine/boxed-expression/arithmetic-mul-div.d.ts +1 -1
  34. package/dist/types/compute-engine/boxed-expression/arithmetic-power.d.ts +1 -1
  35. package/dist/types/compute-engine/boxed-expression/ascii-math.d.ts +1 -1
  36. package/dist/types/compute-engine/boxed-expression/box.d.ts +1 -1
  37. package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +1 -1
  38. package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +1 -1
  39. package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +1 -1
  40. package/dist/types/compute-engine/boxed-expression/boxed-operator-definition.d.ts +1 -1
  41. package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +1 -1
  42. package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +1 -1
  43. package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +1 -1
  44. package/dist/types/compute-engine/boxed-expression/boxed-tensor.d.ts +1 -1
  45. package/dist/types/compute-engine/boxed-expression/boxed-value-definition.d.ts +1 -1
  46. package/dist/types/compute-engine/boxed-expression/cache.d.ts +1 -1
  47. package/dist/types/compute-engine/boxed-expression/canonical-utils.d.ts +1 -1
  48. package/dist/types/compute-engine/boxed-expression/canonical.d.ts +1 -1
  49. package/dist/types/compute-engine/boxed-expression/compare.d.ts +1 -1
  50. package/dist/types/compute-engine/boxed-expression/expand.d.ts +1 -1
  51. package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +1 -1
  52. package/dist/types/compute-engine/boxed-expression/factor.d.ts +1 -1
  53. package/dist/types/compute-engine/boxed-expression/flatten.d.ts +1 -1
  54. package/dist/types/compute-engine/boxed-expression/hold.d.ts +1 -1
  55. package/dist/types/compute-engine/boxed-expression/match.d.ts +1 -1
  56. package/dist/types/compute-engine/boxed-expression/negate.d.ts +1 -1
  57. package/dist/types/compute-engine/boxed-expression/numerics.d.ts +1 -1
  58. package/dist/types/compute-engine/boxed-expression/order.d.ts +1 -1
  59. package/dist/types/compute-engine/boxed-expression/polynomials.d.ts +1 -1
  60. package/dist/types/compute-engine/boxed-expression/product.d.ts +1 -1
  61. package/dist/types/compute-engine/boxed-expression/rules.d.ts +1 -1
  62. package/dist/types/compute-engine/boxed-expression/serialize.d.ts +1 -1
  63. package/dist/types/compute-engine/boxed-expression/sgn.d.ts +1 -1
  64. package/dist/types/compute-engine/boxed-expression/simplify.d.ts +1 -1
  65. package/dist/types/compute-engine/boxed-expression/solve-linear-system.d.ts +1 -1
  66. package/dist/types/compute-engine/boxed-expression/solve.d.ts +1 -1
  67. package/dist/types/compute-engine/boxed-expression/terms.d.ts +1 -1
  68. package/dist/types/compute-engine/boxed-expression/trigonometry.d.ts +1 -1
  69. package/dist/types/compute-engine/boxed-expression/utils.d.ts +1 -1
  70. package/dist/types/compute-engine/boxed-expression/validate.d.ts +1 -1
  71. package/dist/types/compute-engine/collection-utils.d.ts +1 -1
  72. package/dist/types/compute-engine/compilation/base-compiler.d.ts +1 -1
  73. package/dist/types/compute-engine/compilation/glsl-target.d.ts +1 -1
  74. package/dist/types/compute-engine/compilation/interval-glsl-target.d.ts +1 -1
  75. package/dist/types/compute-engine/compilation/interval-javascript-target.d.ts +1 -1
  76. package/dist/types/compute-engine/compilation/javascript-target.d.ts +1 -1
  77. package/dist/types/compute-engine/compilation/types.d.ts +1 -1
  78. package/dist/types/compute-engine/cost-function.d.ts +1 -1
  79. package/dist/types/compute-engine/function-utils.d.ts +1 -1
  80. package/dist/types/compute-engine/global-types.d.ts +1 -1
  81. package/dist/types/compute-engine/index.d.ts +1 -1
  82. package/dist/types/compute-engine/interval/arithmetic.d.ts +1 -1
  83. package/dist/types/compute-engine/interval/comparison.d.ts +9 -9
  84. package/dist/types/compute-engine/interval/elementary.d.ts +14 -14
  85. package/dist/types/compute-engine/interval/index.d.ts +1 -1
  86. package/dist/types/compute-engine/interval/trigonometric.d.ts +17 -17
  87. package/dist/types/compute-engine/interval/types.d.ts +1 -1
  88. package/dist/types/compute-engine/interval/util.d.ts +1 -1
  89. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-algebra.d.ts +1 -1
  90. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-arithmetic.d.ts +1 -1
  91. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-calculus.d.ts +1 -1
  92. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-complex.d.ts +1 -1
  93. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-core.d.ts +1 -1
  94. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-linear-algebra.d.ts +1 -1
  95. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-logic.d.ts +1 -1
  96. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-other.d.ts +1 -1
  97. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-relational-operators.d.ts +1 -1
  98. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-sets.d.ts +1 -1
  99. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-statistics.d.ts +1 -1
  100. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-symbols.d.ts +1 -1
  101. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-trigonometry.d.ts +1 -1
  102. package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +1 -1
  103. package/dist/types/compute-engine/latex-syntax/parse-symbol.d.ts +1 -1
  104. package/dist/types/compute-engine/latex-syntax/parse.d.ts +1 -1
  105. package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +1 -1
  106. package/dist/types/compute-engine/latex-syntax/serializer-style.d.ts +1 -1
  107. package/dist/types/compute-engine/latex-syntax/serializer.d.ts +1 -1
  108. package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +1 -1
  109. package/dist/types/compute-engine/latex-syntax/types.d.ts +1 -1
  110. package/dist/types/compute-engine/latex-syntax/utils.d.ts +1 -1
  111. package/dist/types/compute-engine/library/arithmetic.d.ts +1 -1
  112. package/dist/types/compute-engine/library/calculus.d.ts +1 -1
  113. package/dist/types/compute-engine/library/collections.d.ts +1 -1
  114. package/dist/types/compute-engine/library/combinatorics.d.ts +1 -1
  115. package/dist/types/compute-engine/library/complex.d.ts +1 -1
  116. package/dist/types/compute-engine/library/control-structures.d.ts +1 -1
  117. package/dist/types/compute-engine/library/core.d.ts +1 -1
  118. package/dist/types/compute-engine/library/invisible-operator.d.ts +1 -1
  119. package/dist/types/compute-engine/library/library.d.ts +1 -1
  120. package/dist/types/compute-engine/library/linear-algebra.d.ts +1 -1
  121. package/dist/types/compute-engine/library/logic-analysis.d.ts +1 -1
  122. package/dist/types/compute-engine/library/logic-utils.d.ts +1 -1
  123. package/dist/types/compute-engine/library/logic.d.ts +1 -1
  124. package/dist/types/compute-engine/library/number-theory.d.ts +1 -1
  125. package/dist/types/compute-engine/library/polynomials.d.ts +1 -1
  126. package/dist/types/compute-engine/library/random-expression.d.ts +1 -1
  127. package/dist/types/compute-engine/library/relational-operator.d.ts +1 -1
  128. package/dist/types/compute-engine/library/sets.d.ts +1 -1
  129. package/dist/types/compute-engine/library/statistics.d.ts +1 -1
  130. package/dist/types/compute-engine/library/trigonometry.d.ts +1 -1
  131. package/dist/types/compute-engine/library/utils.d.ts +1 -1
  132. package/dist/types/compute-engine/numeric-value/big-numeric-value.d.ts +1 -1
  133. package/dist/types/compute-engine/numeric-value/exact-numeric-value.d.ts +1 -1
  134. package/dist/types/compute-engine/numeric-value/machine-numeric-value.d.ts +1 -1
  135. package/dist/types/compute-engine/numeric-value/types.d.ts +1 -1
  136. package/dist/types/compute-engine/numerics/bigint.d.ts +1 -1
  137. package/dist/types/compute-engine/numerics/expression.d.ts +1 -1
  138. package/dist/types/compute-engine/numerics/interval.d.ts +1 -1
  139. package/dist/types/compute-engine/numerics/monte-carlo.d.ts +1 -1
  140. package/dist/types/compute-engine/numerics/numeric-bigint.d.ts +1 -1
  141. package/dist/types/compute-engine/numerics/numeric-bignum.d.ts +1 -1
  142. package/dist/types/compute-engine/numerics/numeric-complex.d.ts +1 -1
  143. package/dist/types/compute-engine/numerics/numeric.d.ts +1 -1
  144. package/dist/types/compute-engine/numerics/primes.d.ts +1 -1
  145. package/dist/types/compute-engine/numerics/rationals.d.ts +1 -1
  146. package/dist/types/compute-engine/numerics/richardson.d.ts +1 -1
  147. package/dist/types/compute-engine/numerics/special-functions.d.ts +1 -1
  148. package/dist/types/compute-engine/numerics/statistics.d.ts +1 -1
  149. package/dist/types/compute-engine/numerics/strings.d.ts +1 -1
  150. package/dist/types/compute-engine/numerics/types.d.ts +1 -1
  151. package/dist/types/compute-engine/oeis.d.ts +1 -1
  152. package/dist/types/compute-engine/sequence.d.ts +1 -1
  153. package/dist/types/compute-engine/symbolic/antiderivative.d.ts +1 -1
  154. package/dist/types/compute-engine/symbolic/derivative.d.ts +1 -1
  155. package/dist/types/compute-engine/symbolic/distribute.d.ts +1 -1
  156. package/dist/types/compute-engine/symbolic/fu-cost.d.ts +1 -1
  157. package/dist/types/compute-engine/symbolic/fu-transforms.d.ts +1 -1
  158. package/dist/types/compute-engine/symbolic/fu.d.ts +1 -1
  159. package/dist/types/compute-engine/symbolic/simplify-abs.d.ts +1 -1
  160. package/dist/types/compute-engine/symbolic/simplify-divide.d.ts +1 -1
  161. package/dist/types/compute-engine/symbolic/simplify-hyperbolic.d.ts +1 -1
  162. package/dist/types/compute-engine/symbolic/simplify-infinity.d.ts +1 -1
  163. package/dist/types/compute-engine/symbolic/simplify-log.d.ts +1 -1
  164. package/dist/types/compute-engine/symbolic/simplify-power.d.ts +1 -1
  165. package/dist/types/compute-engine/symbolic/simplify-product.d.ts +1 -1
  166. package/dist/types/compute-engine/symbolic/simplify-rules.d.ts +1 -1
  167. package/dist/types/compute-engine/symbolic/simplify-sum.d.ts +1 -1
  168. package/dist/types/compute-engine/symbolic/simplify-trig.d.ts +1 -1
  169. package/dist/types/compute-engine/tensor/tensor-fields.d.ts +1 -1
  170. package/dist/types/compute-engine/tensor/tensors.d.ts +1 -1
  171. package/dist/types/compute-engine/types.d.ts +1 -1
  172. package/dist/types/compute-engine.d.ts +1 -1
  173. package/dist/types/math-json/symbols.d.ts +1 -1
  174. package/dist/types/math-json/types.d.ts +1 -1
  175. package/dist/types/math-json/utils.d.ts +1 -1
  176. package/dist/types/math-json.d.ts +2 -2
  177. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- /** Compute Engine 0.35.0 */
1
+ /** Compute Engine 0.35.1 */
2
2
  var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -20105,6 +20105,14 @@ var init_base_compiler = __esm({
20105
20105
  return `return ${_BaseCompiler.compile(args[0], target)}`;
20106
20106
  if (h === "If") {
20107
20107
  if (args.length !== 3) throw new Error("If: wrong number of arguments");
20108
+ const fn2 = target.functions?.(h);
20109
+ if (fn2) {
20110
+ if (typeof fn2 === "function") {
20111
+ return fn2(args, (expr) => _BaseCompiler.compile(expr, target), target);
20112
+ }
20113
+ if (args === null) return `${fn2}()`;
20114
+ return `${fn2}(${args.map((x) => _BaseCompiler.compile(x, target)).join(", ")})`;
20115
+ }
20108
20116
  return `((${_BaseCompiler.compile(args[0], target)}) ? (${_BaseCompiler.compile(
20109
20117
  args[1],
20110
20118
  target
@@ -52265,49 +52273,64 @@ function intPow2(base, n) {
52265
52273
  return { lo: Math.pow(base.lo, n), hi: Math.pow(base.hi, n) };
52266
52274
  }
52267
52275
  function pow3(base, exp3) {
52276
+ const unwrapped = unwrapOrPropagate(base);
52277
+ if (!Array.isArray(unwrapped)) return unwrapped;
52278
+ const [baseVal] = unwrapped;
52268
52279
  if (Number.isInteger(exp3)) {
52269
52280
  if (exp3 >= 0) {
52270
- return ok(intPow2(base, exp3));
52281
+ return ok(intPow2(baseVal, exp3));
52271
52282
  } else {
52272
- if (containsZero(base)) {
52283
+ if (containsZero(baseVal)) {
52273
52284
  return { kind: "singular" };
52274
52285
  }
52275
- const denom = intPow2(base, -exp3);
52286
+ const denom = intPow2(baseVal, -exp3);
52276
52287
  return ok({ lo: 1 / denom.hi, hi: 1 / denom.lo });
52277
52288
  }
52278
52289
  } else {
52279
- if (isNegative(base)) {
52290
+ if (isNegative(baseVal)) {
52280
52291
  return { kind: "empty" };
52281
52292
  }
52282
- if (base.lo < 0) {
52283
- const value = exp3 > 0 ? { lo: 0, hi: Math.pow(base.hi, exp3) } : { lo: Math.pow(base.hi, exp3), hi: Infinity };
52293
+ if (baseVal.lo < 0) {
52294
+ const value = exp3 > 0 ? { lo: 0, hi: Math.pow(baseVal.hi, exp3) } : { lo: Math.pow(baseVal.hi, exp3), hi: Infinity };
52284
52295
  return { kind: "partial", value, domainClipped: "lo" };
52285
52296
  }
52286
52297
  if (exp3 > 0) {
52287
- return ok({ lo: Math.pow(base.lo, exp3), hi: Math.pow(base.hi, exp3) });
52298
+ return ok({
52299
+ lo: Math.pow(baseVal.lo, exp3),
52300
+ hi: Math.pow(baseVal.hi, exp3)
52301
+ });
52288
52302
  } else {
52289
- if (base.lo === 0) {
52303
+ if (baseVal.lo === 0) {
52290
52304
  return {
52291
52305
  kind: "partial",
52292
- value: { lo: Math.pow(base.hi, exp3), hi: Infinity },
52306
+ value: { lo: Math.pow(baseVal.hi, exp3), hi: Infinity },
52293
52307
  domainClipped: "hi"
52294
52308
  };
52295
52309
  }
52296
- return ok({ lo: Math.pow(base.hi, exp3), hi: Math.pow(base.lo, exp3) });
52310
+ return ok({
52311
+ lo: Math.pow(baseVal.hi, exp3),
52312
+ hi: Math.pow(baseVal.lo, exp3)
52313
+ });
52297
52314
  }
52298
52315
  }
52299
52316
  }
52300
52317
  function powInterval(base, exp3) {
52301
- if (base.hi <= 0) {
52318
+ const unwrapped = unwrapOrPropagate(base, exp3);
52319
+ if (!Array.isArray(unwrapped)) return unwrapped;
52320
+ const [baseVal, expVal] = unwrapped;
52321
+ if (baseVal.hi <= 0) {
52302
52322
  return { kind: "empty" };
52303
52323
  }
52304
- if (base.lo <= 0) {
52305
- const posBase = { lo: Math.max(base.lo, Number.EPSILON), hi: base.hi };
52324
+ if (baseVal.lo <= 0) {
52325
+ const posBase = {
52326
+ lo: Math.max(baseVal.lo, Number.EPSILON),
52327
+ hi: baseVal.hi
52328
+ };
52306
52329
  const corners2 = [
52307
- Math.pow(posBase.lo, exp3.lo),
52308
- Math.pow(posBase.lo, exp3.hi),
52309
- Math.pow(posBase.hi, exp3.lo),
52310
- Math.pow(posBase.hi, exp3.hi)
52330
+ Math.pow(posBase.lo, expVal.lo),
52331
+ Math.pow(posBase.lo, expVal.hi),
52332
+ Math.pow(posBase.hi, expVal.lo),
52333
+ Math.pow(posBase.hi, expVal.hi)
52311
52334
  ];
52312
52335
  return {
52313
52336
  kind: "partial",
@@ -52316,10 +52339,10 @@ function powInterval(base, exp3) {
52316
52339
  };
52317
52340
  }
52318
52341
  const corners = [
52319
- Math.pow(base.lo, exp3.lo),
52320
- Math.pow(base.lo, exp3.hi),
52321
- Math.pow(base.hi, exp3.lo),
52322
- Math.pow(base.hi, exp3.hi)
52342
+ Math.pow(baseVal.lo, expVal.lo),
52343
+ Math.pow(baseVal.lo, expVal.hi),
52344
+ Math.pow(baseVal.hi, expVal.lo),
52345
+ Math.pow(baseVal.hi, expVal.hi)
52323
52346
  ];
52324
52347
  return ok({ lo: Math.min(...corners), hi: Math.max(...corners) });
52325
52348
  }
@@ -52330,79 +52353,115 @@ function exp2(x) {
52330
52353
  return ok({ lo: Math.exp(xVal.lo), hi: Math.exp(xVal.hi) });
52331
52354
  }
52332
52355
  function ln2(x) {
52333
- if (x.hi <= 0) {
52356
+ const unwrapped = unwrapOrPropagate(x);
52357
+ if (!Array.isArray(unwrapped)) return unwrapped;
52358
+ const [xVal] = unwrapped;
52359
+ if (xVal.hi <= 0) {
52334
52360
  return { kind: "empty" };
52335
52361
  }
52336
- if (x.lo > 0) {
52337
- return ok({ lo: Math.log(x.lo), hi: Math.log(x.hi) });
52362
+ if (xVal.lo > 0) {
52363
+ return ok({ lo: Math.log(xVal.lo), hi: Math.log(xVal.hi) });
52338
52364
  }
52339
52365
  return {
52340
52366
  kind: "partial",
52341
- value: { lo: -Infinity, hi: Math.log(x.hi) },
52367
+ value: { lo: -Infinity, hi: Math.log(xVal.hi) },
52342
52368
  domainClipped: "lo"
52343
52369
  };
52344
52370
  }
52345
52371
  function log102(x) {
52346
- if (x.hi <= 0) {
52372
+ const unwrapped = unwrapOrPropagate(x);
52373
+ if (!Array.isArray(unwrapped)) return unwrapped;
52374
+ const [xVal] = unwrapped;
52375
+ if (xVal.hi <= 0) {
52347
52376
  return { kind: "empty" };
52348
52377
  }
52349
- if (x.lo > 0) {
52350
- return ok({ lo: Math.log10(x.lo), hi: Math.log10(x.hi) });
52378
+ if (xVal.lo > 0) {
52379
+ return ok({ lo: Math.log10(xVal.lo), hi: Math.log10(xVal.hi) });
52351
52380
  }
52352
52381
  return {
52353
52382
  kind: "partial",
52354
- value: { lo: -Infinity, hi: Math.log10(x.hi) },
52383
+ value: { lo: -Infinity, hi: Math.log10(xVal.hi) },
52355
52384
  domainClipped: "lo"
52356
52385
  };
52357
52386
  }
52358
52387
  function log22(x) {
52359
- if (x.hi <= 0) {
52388
+ const unwrapped = unwrapOrPropagate(x);
52389
+ if (!Array.isArray(unwrapped)) return unwrapped;
52390
+ const [xVal] = unwrapped;
52391
+ if (xVal.hi <= 0) {
52360
52392
  return { kind: "empty" };
52361
52393
  }
52362
- if (x.lo > 0) {
52363
- return ok({ lo: Math.log2(x.lo), hi: Math.log2(x.hi) });
52394
+ if (xVal.lo > 0) {
52395
+ return ok({ lo: Math.log2(xVal.lo), hi: Math.log2(xVal.hi) });
52364
52396
  }
52365
52397
  return {
52366
52398
  kind: "partial",
52367
- value: { lo: -Infinity, hi: Math.log2(x.hi) },
52399
+ value: { lo: -Infinity, hi: Math.log2(xVal.hi) },
52368
52400
  domainClipped: "lo"
52369
52401
  };
52370
52402
  }
52371
52403
  function abs2(x) {
52372
- if (x.lo >= 0) {
52373
- return ok(x);
52404
+ const unwrapped = unwrapOrPropagate(x);
52405
+ if (!Array.isArray(unwrapped)) return unwrapped;
52406
+ const [xVal] = unwrapped;
52407
+ if (xVal.lo >= 0) {
52408
+ return ok(xVal);
52374
52409
  }
52375
- if (x.hi <= 0) {
52376
- return ok({ lo: -x.hi, hi: -x.lo });
52410
+ if (xVal.hi <= 0) {
52411
+ return ok({ lo: -xVal.hi, hi: -xVal.lo });
52377
52412
  }
52378
- return ok({ lo: 0, hi: Math.max(-x.lo, x.hi) });
52413
+ return ok({ lo: 0, hi: Math.max(-xVal.lo, xVal.hi) });
52379
52414
  }
52380
52415
  function floor2(x) {
52381
- return ok({ lo: Math.floor(x.lo), hi: Math.floor(x.hi) });
52416
+ const unwrapped = unwrapOrPropagate(x);
52417
+ if (!Array.isArray(unwrapped)) return unwrapped;
52418
+ const [xVal] = unwrapped;
52419
+ return ok({ lo: Math.floor(xVal.lo), hi: Math.floor(xVal.hi) });
52382
52420
  }
52383
52421
  function ceil2(x) {
52384
- return ok({ lo: Math.ceil(x.lo), hi: Math.ceil(x.hi) });
52422
+ const unwrapped = unwrapOrPropagate(x);
52423
+ if (!Array.isArray(unwrapped)) return unwrapped;
52424
+ const [xVal] = unwrapped;
52425
+ return ok({ lo: Math.ceil(xVal.lo), hi: Math.ceil(xVal.hi) });
52385
52426
  }
52386
52427
  function round2(x) {
52387
- return ok({ lo: Math.round(x.lo), hi: Math.round(x.hi) });
52428
+ const unwrapped = unwrapOrPropagate(x);
52429
+ if (!Array.isArray(unwrapped)) return unwrapped;
52430
+ const [xVal] = unwrapped;
52431
+ return ok({ lo: Math.round(xVal.lo), hi: Math.round(xVal.hi) });
52388
52432
  }
52389
52433
  function min2(a, b) {
52390
- return ok({ lo: Math.min(a.lo, b.lo), hi: Math.min(a.hi, b.hi) });
52434
+ const unwrapped = unwrapOrPropagate(a, b);
52435
+ if (!Array.isArray(unwrapped)) return unwrapped;
52436
+ const [aVal, bVal] = unwrapped;
52437
+ return ok({
52438
+ lo: Math.min(aVal.lo, bVal.lo),
52439
+ hi: Math.min(aVal.hi, bVal.hi)
52440
+ });
52391
52441
  }
52392
52442
  function max2(a, b) {
52393
- return ok({ lo: Math.max(a.lo, b.lo), hi: Math.max(a.hi, b.hi) });
52443
+ const unwrapped = unwrapOrPropagate(a, b);
52444
+ if (!Array.isArray(unwrapped)) return unwrapped;
52445
+ const [aVal, bVal] = unwrapped;
52446
+ return ok({
52447
+ lo: Math.max(aVal.lo, bVal.lo),
52448
+ hi: Math.max(aVal.hi, bVal.hi)
52449
+ });
52394
52450
  }
52395
52451
  function mod2(a, b) {
52396
- if (containsZero(b)) {
52452
+ const unwrapped = unwrapOrPropagate(a, b);
52453
+ if (!Array.isArray(unwrapped)) return unwrapped;
52454
+ const [aVal, bVal] = unwrapped;
52455
+ if (containsZero(bVal)) {
52397
52456
  return { kind: "singular" };
52398
52457
  }
52399
- const bAbs = Math.max(Math.abs(b.lo), Math.abs(b.hi));
52400
- const aWidth = a.hi - a.lo;
52458
+ const bAbs = Math.max(Math.abs(bVal.lo), Math.abs(bVal.hi));
52459
+ const aWidth = aVal.hi - aVal.lo;
52401
52460
  if (aWidth >= bAbs) {
52402
52461
  return ok({ lo: 0, hi: bAbs });
52403
52462
  }
52404
- const modLo = (a.lo % bAbs + bAbs) % bAbs;
52405
- const modHi = (a.hi % bAbs + bAbs) % bAbs;
52463
+ const modLo = (aVal.lo % bAbs + bAbs) % bAbs;
52464
+ const modHi = (aVal.hi % bAbs + bAbs) % bAbs;
52406
52465
  if (modLo <= modHi) {
52407
52466
  return ok({ lo: modLo, hi: modHi });
52408
52467
  } else {
@@ -52410,11 +52469,14 @@ function mod2(a, b) {
52410
52469
  }
52411
52470
  }
52412
52471
  function sign2(x) {
52413
- if (x.lo > 0) return ok({ lo: 1, hi: 1 });
52414
- if (x.hi < 0) return ok({ lo: -1, hi: -1 });
52415
- if (x.lo === 0 && x.hi === 0) return ok({ lo: 0, hi: 0 });
52416
- if (x.lo < 0 && x.hi > 0) return ok({ lo: -1, hi: 1 });
52417
- if (x.lo === 0) return ok({ lo: 0, hi: 1 });
52472
+ const unwrapped = unwrapOrPropagate(x);
52473
+ if (!Array.isArray(unwrapped)) return unwrapped;
52474
+ const [xVal] = unwrapped;
52475
+ if (xVal.lo > 0) return ok({ lo: 1, hi: 1 });
52476
+ if (xVal.hi < 0) return ok({ lo: -1, hi: -1 });
52477
+ if (xVal.lo === 0 && xVal.hi === 0) return ok({ lo: 0, hi: 0 });
52478
+ if (xVal.lo < 0 && xVal.hi > 0) return ok({ lo: -1, hi: 1 });
52479
+ if (xVal.lo === 0) return ok({ lo: 0, hi: 1 });
52418
52480
  return ok({ lo: -1, hi: 0 });
52419
52481
  }
52420
52482
 
@@ -52424,231 +52486,298 @@ var PI2 = Math.PI;
52424
52486
  var HALF_PI = Math.PI / 2;
52425
52487
  var THREE_HALF_PI = 3 * Math.PI / 2;
52426
52488
  function sin2(x) {
52427
- if (x.hi - x.lo >= TWO_PI) {
52489
+ const unwrapped = unwrapOrPropagate(x);
52490
+ if (!Array.isArray(unwrapped)) return unwrapped;
52491
+ const [xVal] = unwrapped;
52492
+ if (xVal.hi - xVal.lo >= TWO_PI) {
52428
52493
  return ok({ lo: -1, hi: 1 });
52429
52494
  }
52430
- const sinLo = Math.sin(x.lo);
52431
- const sinHi = Math.sin(x.hi);
52495
+ const sinLo = Math.sin(xVal.lo);
52496
+ const sinHi = Math.sin(xVal.hi);
52432
52497
  let lo = Math.min(sinLo, sinHi);
52433
52498
  let hi = Math.max(sinLo, sinHi);
52434
- if (containsExtremum(x, HALF_PI, TWO_PI)) {
52499
+ if (containsExtremum(xVal, HALF_PI, TWO_PI)) {
52435
52500
  hi = 1;
52436
52501
  }
52437
- if (containsExtremum(x, THREE_HALF_PI, TWO_PI)) {
52502
+ if (containsExtremum(xVal, THREE_HALF_PI, TWO_PI)) {
52438
52503
  lo = -1;
52439
52504
  }
52440
52505
  return ok({ lo, hi });
52441
52506
  }
52442
52507
  function cos2(x) {
52443
- if (x.hi - x.lo >= TWO_PI) {
52508
+ const unwrapped = unwrapOrPropagate(x);
52509
+ if (!Array.isArray(unwrapped)) return unwrapped;
52510
+ const [xVal] = unwrapped;
52511
+ if (xVal.hi - xVal.lo >= TWO_PI) {
52444
52512
  return ok({ lo: -1, hi: 1 });
52445
52513
  }
52446
- const cosLo = Math.cos(x.lo);
52447
- const cosHi = Math.cos(x.hi);
52514
+ const cosLo = Math.cos(xVal.lo);
52515
+ const cosHi = Math.cos(xVal.hi);
52448
52516
  let lo = Math.min(cosLo, cosHi);
52449
52517
  let hi = Math.max(cosLo, cosHi);
52450
- if (containsExtremum(x, 0, TWO_PI)) {
52518
+ if (containsExtremum(xVal, 0, TWO_PI)) {
52451
52519
  hi = 1;
52452
52520
  }
52453
- if (containsExtremum(x, PI2, TWO_PI)) {
52521
+ if (containsExtremum(xVal, PI2, TWO_PI)) {
52454
52522
  lo = -1;
52455
52523
  }
52456
52524
  return ok({ lo, hi });
52457
52525
  }
52458
52526
  function tan2(x) {
52459
- if (x.hi - x.lo >= PI2) {
52527
+ const unwrapped = unwrapOrPropagate(x);
52528
+ if (!Array.isArray(unwrapped)) return unwrapped;
52529
+ const [xVal] = unwrapped;
52530
+ if (xVal.hi - xVal.lo >= PI2) {
52460
52531
  return { kind: "singular" };
52461
52532
  }
52462
- if (containsExtremum(x, HALF_PI, PI2)) {
52463
- const n = Math.ceil((x.lo - HALF_PI) / PI2);
52533
+ if (containsExtremum(xVal, HALF_PI, PI2)) {
52534
+ const n = Math.ceil((xVal.lo - HALF_PI) / PI2);
52464
52535
  const poleAt = HALF_PI + n * PI2;
52465
52536
  return { kind: "singular", at: poleAt };
52466
52537
  }
52467
- const tanLo = Math.tan(x.lo);
52468
- const tanHi = Math.tan(x.hi);
52538
+ const tanLo = Math.tan(xVal.lo);
52539
+ const tanHi = Math.tan(xVal.hi);
52469
52540
  if (tanLo > 1e10 && tanHi < -1e10 || tanLo < -1e10 && tanHi > 1e10) {
52470
52541
  return { kind: "singular" };
52471
52542
  }
52472
52543
  return ok({ lo: tanLo, hi: tanHi });
52473
52544
  }
52474
52545
  function cot(x) {
52475
- if (x.hi - x.lo >= PI2) {
52546
+ const unwrapped = unwrapOrPropagate(x);
52547
+ if (!Array.isArray(unwrapped)) return unwrapped;
52548
+ const [xVal] = unwrapped;
52549
+ if (xVal.hi - xVal.lo >= PI2) {
52476
52550
  return { kind: "singular" };
52477
52551
  }
52478
- if (containsExtremum(x, 0, PI2)) {
52479
- const n = Math.ceil(x.lo / PI2);
52552
+ if (containsExtremum(xVal, 0, PI2)) {
52553
+ const n = Math.ceil(xVal.lo / PI2);
52480
52554
  const poleAt = n * PI2;
52481
52555
  return { kind: "singular", at: poleAt };
52482
52556
  }
52483
- const cotLo = 1 / Math.tan(x.lo);
52484
- const cotHi = 1 / Math.tan(x.hi);
52557
+ const cotLo = 1 / Math.tan(xVal.lo);
52558
+ const cotHi = 1 / Math.tan(xVal.hi);
52485
52559
  return ok({ lo: Math.min(cotLo, cotHi), hi: Math.max(cotLo, cotHi) });
52486
52560
  }
52487
52561
  function sec(x) {
52488
- if (x.hi - x.lo >= PI2) {
52562
+ const unwrapped = unwrapOrPropagate(x);
52563
+ if (!Array.isArray(unwrapped)) return unwrapped;
52564
+ const [xVal] = unwrapped;
52565
+ if (xVal.hi - xVal.lo >= PI2) {
52489
52566
  return { kind: "singular" };
52490
52567
  }
52491
- if (containsExtremum(x, HALF_PI, PI2)) {
52492
- const n = Math.ceil((x.lo - HALF_PI) / PI2);
52568
+ if (containsExtremum(xVal, HALF_PI, PI2)) {
52569
+ const n = Math.ceil((xVal.lo - HALF_PI) / PI2);
52493
52570
  const poleAt = HALF_PI + n * PI2;
52494
52571
  return { kind: "singular", at: poleAt };
52495
52572
  }
52496
- const secLo = 1 / Math.cos(x.lo);
52497
- const secHi = 1 / Math.cos(x.hi);
52573
+ const secLo = 1 / Math.cos(xVal.lo);
52574
+ const secHi = 1 / Math.cos(xVal.hi);
52498
52575
  let lo = Math.min(secLo, secHi);
52499
52576
  let hi = Math.max(secLo, secHi);
52500
- if (containsExtremum(x, 0, TWO_PI)) {
52577
+ if (containsExtremum(xVal, 0, TWO_PI)) {
52501
52578
  lo = Math.min(lo, 1);
52502
52579
  hi = Math.max(hi, 1);
52503
52580
  }
52504
- if (containsExtremum(x, PI2, TWO_PI)) {
52581
+ if (containsExtremum(xVal, PI2, TWO_PI)) {
52505
52582
  lo = Math.min(lo, -1);
52506
52583
  hi = Math.max(hi, -1);
52507
52584
  }
52508
52585
  return ok({ lo, hi });
52509
52586
  }
52510
52587
  function csc(x) {
52511
- if (x.hi - x.lo >= PI2) {
52588
+ const unwrapped = unwrapOrPropagate(x);
52589
+ if (!Array.isArray(unwrapped)) return unwrapped;
52590
+ const [xVal] = unwrapped;
52591
+ if (xVal.hi - xVal.lo >= PI2) {
52512
52592
  return { kind: "singular" };
52513
52593
  }
52514
- if (containsExtremum(x, 0, PI2)) {
52515
- const n = Math.ceil(x.lo / PI2);
52594
+ if (containsExtremum(xVal, 0, PI2)) {
52595
+ const n = Math.ceil(xVal.lo / PI2);
52516
52596
  const poleAt = n * PI2;
52517
52597
  return { kind: "singular", at: poleAt };
52518
52598
  }
52519
- const cscLo = 1 / Math.sin(x.lo);
52520
- const cscHi = 1 / Math.sin(x.hi);
52599
+ const cscLo = 1 / Math.sin(xVal.lo);
52600
+ const cscHi = 1 / Math.sin(xVal.hi);
52521
52601
  let lo = Math.min(cscLo, cscHi);
52522
52602
  let hi = Math.max(cscLo, cscHi);
52523
- if (containsExtremum(x, HALF_PI, TWO_PI)) {
52603
+ if (containsExtremum(xVal, HALF_PI, TWO_PI)) {
52524
52604
  lo = Math.min(lo, 1);
52525
52605
  hi = Math.max(hi, 1);
52526
52606
  }
52527
- if (containsExtremum(x, THREE_HALF_PI, TWO_PI)) {
52607
+ if (containsExtremum(xVal, THREE_HALF_PI, TWO_PI)) {
52528
52608
  lo = Math.min(lo, -1);
52529
52609
  hi = Math.max(hi, -1);
52530
52610
  }
52531
52611
  return ok({ lo, hi });
52532
52612
  }
52533
52613
  function asin2(x) {
52534
- if (x.lo > 1 || x.hi < -1) {
52614
+ const unwrapped = unwrapOrPropagate(x);
52615
+ if (!Array.isArray(unwrapped)) return unwrapped;
52616
+ const [xVal] = unwrapped;
52617
+ if (xVal.lo > 1 || xVal.hi < -1) {
52535
52618
  return { kind: "empty" };
52536
52619
  }
52537
- if (x.lo < -1 || x.hi > 1) {
52538
- const clippedLo = Math.max(x.lo, -1);
52539
- const clippedHi = Math.min(x.hi, 1);
52620
+ if (xVal.lo < -1 || xVal.hi > 1) {
52621
+ const clippedLo = Math.max(xVal.lo, -1);
52622
+ const clippedHi = Math.min(xVal.hi, 1);
52540
52623
  return {
52541
52624
  kind: "partial",
52542
52625
  value: { lo: Math.asin(clippedLo), hi: Math.asin(clippedHi) },
52543
- domainClipped: x.lo < -1 && x.hi > 1 ? "both" : x.lo < -1 ? "lo" : "hi"
52626
+ domainClipped: xVal.lo < -1 && xVal.hi > 1 ? "both" : xVal.lo < -1 ? "lo" : "hi"
52544
52627
  };
52545
52628
  }
52546
- return ok({ lo: Math.asin(x.lo), hi: Math.asin(x.hi) });
52629
+ return ok({ lo: Math.asin(xVal.lo), hi: Math.asin(xVal.hi) });
52547
52630
  }
52548
52631
  function acos2(x) {
52549
- if (x.lo > 1 || x.hi < -1) {
52632
+ const unwrapped = unwrapOrPropagate(x);
52633
+ if (!Array.isArray(unwrapped)) return unwrapped;
52634
+ const [xVal] = unwrapped;
52635
+ if (xVal.lo > 1 || xVal.hi < -1) {
52550
52636
  return { kind: "empty" };
52551
52637
  }
52552
- if (x.lo < -1 || x.hi > 1) {
52553
- const clippedLo = Math.max(x.lo, -1);
52554
- const clippedHi = Math.min(x.hi, 1);
52638
+ if (xVal.lo < -1 || xVal.hi > 1) {
52639
+ const clippedLo = Math.max(xVal.lo, -1);
52640
+ const clippedHi = Math.min(xVal.hi, 1);
52555
52641
  return {
52556
52642
  kind: "partial",
52557
52643
  value: { lo: Math.acos(clippedHi), hi: Math.acos(clippedLo) },
52558
- domainClipped: x.lo < -1 && x.hi > 1 ? "both" : x.lo < -1 ? "lo" : "hi"
52644
+ domainClipped: xVal.lo < -1 && xVal.hi > 1 ? "both" : xVal.lo < -1 ? "lo" : "hi"
52559
52645
  };
52560
52646
  }
52561
- return ok({ lo: Math.acos(x.hi), hi: Math.acos(x.lo) });
52647
+ return ok({ lo: Math.acos(xVal.hi), hi: Math.acos(xVal.lo) });
52562
52648
  }
52563
52649
  function atan3(x) {
52564
- return ok({ lo: Math.atan(x.lo), hi: Math.atan(x.hi) });
52650
+ const unwrapped = unwrapOrPropagate(x);
52651
+ if (!Array.isArray(unwrapped)) return unwrapped;
52652
+ const [xVal] = unwrapped;
52653
+ return ok({ lo: Math.atan(xVal.lo), hi: Math.atan(xVal.hi) });
52565
52654
  }
52566
52655
  function atan22(y, x) {
52567
- if (y.lo === y.hi && x.lo === x.hi) {
52568
- const result = Math.atan2(y.lo, x.lo);
52656
+ const unwrapped = unwrapOrPropagate(y, x);
52657
+ if (!Array.isArray(unwrapped)) return unwrapped;
52658
+ const [yVal, xVal] = unwrapped;
52659
+ if (yVal.lo === yVal.hi && xVal.lo === xVal.hi) {
52660
+ const result = Math.atan2(yVal.lo, xVal.lo);
52569
52661
  return ok({ lo: result, hi: result });
52570
52662
  }
52571
52663
  const angles = [];
52572
- angles.push(Math.atan2(y.lo, x.lo));
52573
- angles.push(Math.atan2(y.lo, x.hi));
52574
- angles.push(Math.atan2(y.hi, x.lo));
52575
- angles.push(Math.atan2(y.hi, x.hi));
52576
- if (x.lo < 0 && y.lo < 0 && y.hi > 0) {
52664
+ angles.push(Math.atan2(yVal.lo, xVal.lo));
52665
+ angles.push(Math.atan2(yVal.lo, xVal.hi));
52666
+ angles.push(Math.atan2(yVal.hi, xVal.lo));
52667
+ angles.push(Math.atan2(yVal.hi, xVal.hi));
52668
+ if (xVal.lo < 0 && yVal.lo < 0 && yVal.hi > 0) {
52577
52669
  return ok({ lo: -PI2, hi: PI2 });
52578
52670
  }
52579
52671
  return ok({ lo: Math.min(...angles), hi: Math.max(...angles) });
52580
52672
  }
52581
52673
  function sinh3(x) {
52582
- return ok({ lo: Math.sinh(x.lo), hi: Math.sinh(x.hi) });
52674
+ const unwrapped = unwrapOrPropagate(x);
52675
+ if (!Array.isArray(unwrapped)) return unwrapped;
52676
+ const [xVal] = unwrapped;
52677
+ return ok({ lo: Math.sinh(xVal.lo), hi: Math.sinh(xVal.hi) });
52583
52678
  }
52584
52679
  function cosh3(x) {
52585
- if (x.lo >= 0) {
52586
- return ok({ lo: Math.cosh(x.lo), hi: Math.cosh(x.hi) });
52587
- } else if (x.hi <= 0) {
52588
- return ok({ lo: Math.cosh(x.hi), hi: Math.cosh(x.lo) });
52680
+ const unwrapped = unwrapOrPropagate(x);
52681
+ if (!Array.isArray(unwrapped)) return unwrapped;
52682
+ const [xVal] = unwrapped;
52683
+ if (xVal.lo >= 0) {
52684
+ return ok({ lo: Math.cosh(xVal.lo), hi: Math.cosh(xVal.hi) });
52685
+ } else if (xVal.hi <= 0) {
52686
+ return ok({ lo: Math.cosh(xVal.hi), hi: Math.cosh(xVal.lo) });
52589
52687
  } else {
52590
- return ok({ lo: 1, hi: Math.max(Math.cosh(x.lo), Math.cosh(x.hi)) });
52688
+ return ok({
52689
+ lo: 1,
52690
+ hi: Math.max(Math.cosh(xVal.lo), Math.cosh(xVal.hi))
52691
+ });
52591
52692
  }
52592
52693
  }
52593
52694
  function tanh2(x) {
52594
- return ok({ lo: Math.tanh(x.lo), hi: Math.tanh(x.hi) });
52695
+ const unwrapped = unwrapOrPropagate(x);
52696
+ if (!Array.isArray(unwrapped)) return unwrapped;
52697
+ const [xVal] = unwrapped;
52698
+ return ok({ lo: Math.tanh(xVal.lo), hi: Math.tanh(xVal.hi) });
52595
52699
  }
52596
52700
  function asinh2(x) {
52597
- return ok({ lo: Math.asinh(x.lo), hi: Math.asinh(x.hi) });
52701
+ const unwrapped = unwrapOrPropagate(x);
52702
+ if (!Array.isArray(unwrapped)) return unwrapped;
52703
+ const [xVal] = unwrapped;
52704
+ return ok({ lo: Math.asinh(xVal.lo), hi: Math.asinh(xVal.hi) });
52598
52705
  }
52599
52706
  function acosh2(x) {
52600
- if (x.hi < 1) {
52707
+ const unwrapped = unwrapOrPropagate(x);
52708
+ if (!Array.isArray(unwrapped)) return unwrapped;
52709
+ const [xVal] = unwrapped;
52710
+ if (xVal.hi < 1) {
52601
52711
  return { kind: "empty" };
52602
52712
  }
52603
- if (x.lo < 1) {
52713
+ if (xVal.lo < 1) {
52604
52714
  return {
52605
52715
  kind: "partial",
52606
- value: { lo: 0, hi: Math.acosh(x.hi) },
52716
+ value: { lo: 0, hi: Math.acosh(xVal.hi) },
52607
52717
  domainClipped: "lo"
52608
52718
  };
52609
52719
  }
52610
- return ok({ lo: Math.acosh(x.lo), hi: Math.acosh(x.hi) });
52720
+ return ok({ lo: Math.acosh(xVal.lo), hi: Math.acosh(xVal.hi) });
52611
52721
  }
52612
52722
  function atanh2(x) {
52613
- if (x.lo >= 1 || x.hi <= -1) {
52723
+ const unwrapped = unwrapOrPropagate(x);
52724
+ if (!Array.isArray(unwrapped)) return unwrapped;
52725
+ const [xVal] = unwrapped;
52726
+ if (xVal.lo >= 1 || xVal.hi <= -1) {
52614
52727
  return { kind: "empty" };
52615
52728
  }
52616
- if (x.lo <= -1 || x.hi >= 1) {
52617
- const clippedLo = Math.max(x.lo, -1 + Number.EPSILON);
52618
- const clippedHi = Math.min(x.hi, 1 - Number.EPSILON);
52729
+ if (xVal.lo <= -1 || xVal.hi >= 1) {
52730
+ const clippedLo = Math.max(xVal.lo, -1 + Number.EPSILON);
52731
+ const clippedHi = Math.min(xVal.hi, 1 - Number.EPSILON);
52619
52732
  return {
52620
52733
  kind: "partial",
52621
52734
  value: { lo: Math.atanh(clippedLo), hi: Math.atanh(clippedHi) },
52622
- domainClipped: x.lo <= -1 && x.hi >= 1 ? "both" : x.lo <= -1 ? "lo" : "hi"
52735
+ domainClipped: xVal.lo <= -1 && xVal.hi >= 1 ? "both" : xVal.lo <= -1 ? "lo" : "hi"
52623
52736
  };
52624
52737
  }
52625
- return ok({ lo: Math.atanh(x.lo), hi: Math.atanh(x.hi) });
52738
+ return ok({ lo: Math.atanh(xVal.lo), hi: Math.atanh(xVal.hi) });
52626
52739
  }
52627
52740
 
52628
52741
  // src/compute-engine/interval/comparison.ts
52629
52742
  function less(a, b) {
52630
- if (a.hi < b.lo) return "true";
52631
- if (a.lo >= b.hi) return "false";
52743
+ const unwrapped = unwrapOrPropagate(a, b);
52744
+ if (!Array.isArray(unwrapped)) return "maybe";
52745
+ const [aVal, bVal] = unwrapped;
52746
+ if (aVal.hi < bVal.lo) return "true";
52747
+ if (aVal.lo >= bVal.hi) return "false";
52632
52748
  return "maybe";
52633
52749
  }
52634
52750
  function lessEqual(a, b) {
52635
- if (a.hi <= b.lo) return "true";
52636
- if (a.lo > b.hi) return "false";
52751
+ const unwrapped = unwrapOrPropagate(a, b);
52752
+ if (!Array.isArray(unwrapped)) return "maybe";
52753
+ const [aVal, bVal] = unwrapped;
52754
+ if (aVal.hi <= bVal.lo) return "true";
52755
+ if (aVal.lo > bVal.hi) return "false";
52637
52756
  return "maybe";
52638
52757
  }
52639
52758
  function greater(a, b) {
52640
- if (a.lo > b.hi) return "true";
52641
- if (a.hi <= b.lo) return "false";
52759
+ const unwrapped = unwrapOrPropagate(a, b);
52760
+ if (!Array.isArray(unwrapped)) return "maybe";
52761
+ const [aVal, bVal] = unwrapped;
52762
+ if (aVal.lo > bVal.hi) return "true";
52763
+ if (aVal.hi <= bVal.lo) return "false";
52642
52764
  return "maybe";
52643
52765
  }
52644
52766
  function greaterEqual(a, b) {
52645
- if (a.lo >= b.hi) return "true";
52646
- if (a.hi < b.lo) return "false";
52767
+ const unwrapped = unwrapOrPropagate(a, b);
52768
+ if (!Array.isArray(unwrapped)) return "maybe";
52769
+ const [aVal, bVal] = unwrapped;
52770
+ if (aVal.lo >= bVal.hi) return "true";
52771
+ if (aVal.hi < bVal.lo) return "false";
52647
52772
  return "maybe";
52648
52773
  }
52649
52774
  function equal(a, b) {
52650
- if (a.lo === a.hi && b.lo === b.hi && a.lo === b.lo) return "true";
52651
- if (a.hi < b.lo || b.hi < a.lo) return "false";
52775
+ const unwrapped = unwrapOrPropagate(a, b);
52776
+ if (!Array.isArray(unwrapped)) return "maybe";
52777
+ const [aVal, bVal] = unwrapped;
52778
+ if (aVal.lo === aVal.hi && bVal.lo === bVal.hi && aVal.lo === bVal.lo)
52779
+ return "true";
52780
+ if (aVal.hi < bVal.lo || bVal.hi < aVal.lo) return "false";
52652
52781
  return "maybe";
52653
52782
  }
52654
52783
  function notEqual(a, b) {
@@ -52672,22 +52801,45 @@ function not(a) {
52672
52801
  if (a === "false") return "true";
52673
52802
  return "maybe";
52674
52803
  }
52675
- function piecewise(x, condition, trueBranch, falseBranch) {
52676
- const cond = condition(x);
52804
+ function piecewise(xOrCond, conditionOrTrue, trueOrFalse, falseBranch) {
52805
+ if (xOrCond === "true" || xOrCond === "false" || xOrCond === "maybe") {
52806
+ const cond2 = xOrCond;
52807
+ const trueBranch2 = conditionOrTrue;
52808
+ const falseBranchFn2 = trueOrFalse;
52809
+ switch (cond2) {
52810
+ case "true":
52811
+ return trueBranch2();
52812
+ case "false":
52813
+ return falseBranchFn2();
52814
+ case "maybe":
52815
+ return unionResults(trueBranch2(), falseBranchFn2());
52816
+ }
52817
+ }
52818
+ const x = xOrCond;
52819
+ const condition = conditionOrTrue;
52820
+ const trueBranch = trueOrFalse;
52821
+ const falseBranchFn = falseBranch;
52822
+ const unwrapped = unwrapOrPropagate(x);
52823
+ if (!Array.isArray(unwrapped)) return unwrapped;
52824
+ const [xVal] = unwrapped;
52825
+ const cond = condition(xVal);
52677
52826
  switch (cond) {
52678
52827
  case "true":
52679
- return trueBranch(x);
52828
+ return trueBranch(xVal);
52680
52829
  case "false":
52681
- return falseBranch(x);
52830
+ return falseBranchFn(xVal);
52682
52831
  case "maybe":
52683
- const t = trueBranch(x);
52684
- const f = falseBranch(x);
52832
+ const t = trueBranch(xVal);
52833
+ const f = falseBranchFn(xVal);
52685
52834
  return unionResults(t, f);
52686
52835
  }
52687
52836
  }
52688
52837
  function clamp2(x, lo, hi) {
52689
- const resultLo = Math.max(x.lo, lo.lo);
52690
- const resultHi = Math.min(x.hi, hi.hi);
52838
+ const unwrapped = unwrapOrPropagate(x, lo, hi);
52839
+ if (!Array.isArray(unwrapped)) return unwrapped;
52840
+ const [xVal, loVal, hiVal] = unwrapped;
52841
+ const resultLo = Math.max(xVal.lo, loVal.lo);
52842
+ const resultHi = Math.min(xVal.hi, hiVal.hi);
52691
52843
  if (resultLo > resultHi) {
52692
52844
  return { kind: "empty" };
52693
52845
  }
@@ -52915,11 +53067,20 @@ var INTERVAL_JAVASCRIPT_FUNCTIONS = {
52915
53067
  if (args.length !== 3) throw new Error("If: wrong number of arguments");
52916
53068
  return `_IA.piecewise(
52917
53069
  ${compile(args[0])},
52918
- (_x) => ${compile(args[0])},
52919
- (_x) => ${compile(args[1])},
52920
- (_x) => ${compile(args[2])}
53070
+ () => ${compile(args[1])},
53071
+ () => ${compile(args[2])}
52921
53072
  )`;
52922
- }
53073
+ },
53074
+ // Comparisons
53075
+ Equal: (args, compile) => `_IA.equal(${compile(args[0])}, ${compile(args[1])})`,
53076
+ NotEqual: (args, compile) => `_IA.notEqual(${compile(args[0])}, ${compile(args[1])})`,
53077
+ LessEqual: (args, compile) => `_IA.lessEqual(${compile(args[0])}, ${compile(args[1])})`,
53078
+ GreaterEqual: (args, compile) => `_IA.greaterEqual(${compile(args[0])}, ${compile(args[1])})`,
53079
+ Less: (args, compile) => `_IA.less(${compile(args[0])}, ${compile(args[1])})`,
53080
+ Greater: (args, compile) => `_IA.greater(${compile(args[0])}, ${compile(args[1])})`,
53081
+ And: (args, compile) => `_IA.and(${compile(args[0])}, ${compile(args[1])})`,
53082
+ Or: (args, compile) => `_IA.or(${compile(args[0])}, ${compile(args[1])})`,
53083
+ Not: (args, compile) => `_IA.not(${compile(args[0])})`
52923
53084
  };
52924
53085
  var ComputeEngineIntervalFunction = class extends Function {
52925
53086
  IA = IntervalArithmetic;
@@ -53097,6 +53258,10 @@ IntervalResult ia_partial(vec2 v, float clip) {
53097
53258
  return IntervalResult(v, clip);
53098
53259
  }
53099
53260
 
53261
+ bool ia_is_error(float status) {
53262
+ return status == IA_EMPTY || status == IA_ENTIRE || status == IA_SINGULAR;
53263
+ }
53264
+
53100
53265
  // Addition
53101
53266
  IntervalResult ia_add(vec2 a, vec2 b) {
53102
53267
  return ia_ok(vec2(a.x + b.x - IA_EPS, a.y + b.y + IA_EPS));
@@ -53412,6 +53577,198 @@ IntervalResult ia_cosh(vec2 x) {
53412
53577
  IntervalResult ia_tanh(vec2 x) {
53413
53578
  return ia_ok(vec2(tanh(x.x) - IA_EPS, tanh(x.y) + IA_EPS));
53414
53579
  }
53580
+
53581
+ // IntervalResult overloads for propagation
53582
+ IntervalResult ia_add(IntervalResult a, IntervalResult b) {
53583
+ if (ia_is_error(a.status)) return a;
53584
+ if (ia_is_error(b.status)) return b;
53585
+ return ia_add(a.value, b.value);
53586
+ }
53587
+
53588
+ IntervalResult ia_add(IntervalResult a, vec2 b) {
53589
+ if (ia_is_error(a.status)) return a;
53590
+ return ia_add(a.value, b);
53591
+ }
53592
+
53593
+ IntervalResult ia_add(vec2 a, IntervalResult b) {
53594
+ if (ia_is_error(b.status)) return b;
53595
+ return ia_add(a, b.value);
53596
+ }
53597
+
53598
+ IntervalResult ia_sub(IntervalResult a, IntervalResult b) {
53599
+ if (ia_is_error(a.status)) return a;
53600
+ if (ia_is_error(b.status)) return b;
53601
+ return ia_sub(a.value, b.value);
53602
+ }
53603
+
53604
+ IntervalResult ia_sub(IntervalResult a, vec2 b) {
53605
+ if (ia_is_error(a.status)) return a;
53606
+ return ia_sub(a.value, b);
53607
+ }
53608
+
53609
+ IntervalResult ia_sub(vec2 a, IntervalResult b) {
53610
+ if (ia_is_error(b.status)) return b;
53611
+ return ia_sub(a, b.value);
53612
+ }
53613
+
53614
+ IntervalResult ia_mul(IntervalResult a, IntervalResult b) {
53615
+ if (ia_is_error(a.status)) return a;
53616
+ if (ia_is_error(b.status)) return b;
53617
+ return ia_mul(a.value, b.value);
53618
+ }
53619
+
53620
+ IntervalResult ia_mul(IntervalResult a, vec2 b) {
53621
+ if (ia_is_error(a.status)) return a;
53622
+ return ia_mul(a.value, b);
53623
+ }
53624
+
53625
+ IntervalResult ia_mul(vec2 a, IntervalResult b) {
53626
+ if (ia_is_error(b.status)) return b;
53627
+ return ia_mul(a, b.value);
53628
+ }
53629
+
53630
+ IntervalResult ia_div(IntervalResult a, IntervalResult b) {
53631
+ if (ia_is_error(a.status)) return a;
53632
+ if (ia_is_error(b.status)) return b;
53633
+ return ia_div(a.value, b.value);
53634
+ }
53635
+
53636
+ IntervalResult ia_div(IntervalResult a, vec2 b) {
53637
+ if (ia_is_error(a.status)) return a;
53638
+ return ia_div(a.value, b);
53639
+ }
53640
+
53641
+ IntervalResult ia_div(vec2 a, IntervalResult b) {
53642
+ if (ia_is_error(b.status)) return b;
53643
+ return ia_div(a, b.value);
53644
+ }
53645
+
53646
+ IntervalResult ia_negate(IntervalResult x) {
53647
+ if (ia_is_error(x.status)) return x;
53648
+ return ia_negate(x.value);
53649
+ }
53650
+
53651
+ IntervalResult ia_sqrt(IntervalResult x) {
53652
+ if (ia_is_error(x.status)) return x;
53653
+ return ia_sqrt(x.value);
53654
+ }
53655
+
53656
+ IntervalResult ia_square(IntervalResult x) {
53657
+ if (ia_is_error(x.status)) return x;
53658
+ return ia_square(x.value);
53659
+ }
53660
+
53661
+ IntervalResult ia_exp(IntervalResult x) {
53662
+ if (ia_is_error(x.status)) return x;
53663
+ return ia_exp(x.value);
53664
+ }
53665
+
53666
+ IntervalResult ia_ln(IntervalResult x) {
53667
+ if (ia_is_error(x.status)) return x;
53668
+ return ia_ln(x.value);
53669
+ }
53670
+
53671
+ IntervalResult ia_abs(IntervalResult x) {
53672
+ if (ia_is_error(x.status)) return x;
53673
+ return ia_abs(x.value);
53674
+ }
53675
+
53676
+ IntervalResult ia_sign(IntervalResult x) {
53677
+ if (ia_is_error(x.status)) return x;
53678
+ return ia_sign(x.value);
53679
+ }
53680
+
53681
+ IntervalResult ia_floor(IntervalResult x) {
53682
+ if (ia_is_error(x.status)) return x;
53683
+ return ia_floor(x.value);
53684
+ }
53685
+
53686
+ IntervalResult ia_ceil(IntervalResult x) {
53687
+ if (ia_is_error(x.status)) return x;
53688
+ return ia_ceil(x.value);
53689
+ }
53690
+
53691
+ IntervalResult ia_min(IntervalResult a, IntervalResult b) {
53692
+ if (ia_is_error(a.status)) return a;
53693
+ if (ia_is_error(b.status)) return b;
53694
+ return ia_min(a.value, b.value);
53695
+ }
53696
+
53697
+ IntervalResult ia_min(IntervalResult a, vec2 b) {
53698
+ if (ia_is_error(a.status)) return a;
53699
+ return ia_min(a.value, b);
53700
+ }
53701
+
53702
+ IntervalResult ia_min(vec2 a, IntervalResult b) {
53703
+ if (ia_is_error(b.status)) return b;
53704
+ return ia_min(a, b.value);
53705
+ }
53706
+
53707
+ IntervalResult ia_max(IntervalResult a, IntervalResult b) {
53708
+ if (ia_is_error(a.status)) return a;
53709
+ if (ia_is_error(b.status)) return b;
53710
+ return ia_max(a.value, b.value);
53711
+ }
53712
+
53713
+ IntervalResult ia_max(IntervalResult a, vec2 b) {
53714
+ if (ia_is_error(a.status)) return a;
53715
+ return ia_max(a.value, b);
53716
+ }
53717
+
53718
+ IntervalResult ia_max(vec2 a, IntervalResult b) {
53719
+ if (ia_is_error(b.status)) return b;
53720
+ return ia_max(a, b.value);
53721
+ }
53722
+
53723
+ IntervalResult ia_pow(IntervalResult base, float exp) {
53724
+ if (ia_is_error(base.status)) return base;
53725
+ return ia_pow(base.value, exp);
53726
+ }
53727
+
53728
+ IntervalResult ia_sin(IntervalResult x) {
53729
+ if (ia_is_error(x.status)) return x;
53730
+ return ia_sin(x.value);
53731
+ }
53732
+
53733
+ IntervalResult ia_cos(IntervalResult x) {
53734
+ if (ia_is_error(x.status)) return x;
53735
+ return ia_cos(x.value);
53736
+ }
53737
+
53738
+ IntervalResult ia_tan(IntervalResult x) {
53739
+ if (ia_is_error(x.status)) return x;
53740
+ return ia_tan(x.value);
53741
+ }
53742
+
53743
+ IntervalResult ia_asin(IntervalResult x) {
53744
+ if (ia_is_error(x.status)) return x;
53745
+ return ia_asin(x.value);
53746
+ }
53747
+
53748
+ IntervalResult ia_acos(IntervalResult x) {
53749
+ if (ia_is_error(x.status)) return x;
53750
+ return ia_acos(x.value);
53751
+ }
53752
+
53753
+ IntervalResult ia_atan(IntervalResult x) {
53754
+ if (ia_is_error(x.status)) return x;
53755
+ return ia_atan(x.value);
53756
+ }
53757
+
53758
+ IntervalResult ia_sinh(IntervalResult x) {
53759
+ if (ia_is_error(x.status)) return x;
53760
+ return ia_sinh(x.value);
53761
+ }
53762
+
53763
+ IntervalResult ia_cosh(IntervalResult x) {
53764
+ if (ia_is_error(x.status)) return x;
53765
+ return ia_cosh(x.value);
53766
+ }
53767
+
53768
+ IntervalResult ia_tanh(IntervalResult x) {
53769
+ if (ia_is_error(x.status)) return x;
53770
+ return ia_tanh(x.value);
53771
+ }
53415
53772
  `;
53416
53773
  var INTERVAL_GLSL_OPERATORS = {
53417
53774
  Add: ["ia_add", 20],
@@ -55408,10 +55765,10 @@ function defToString(name, def, v) {
55408
55765
  // src/compute-engine.ts
55409
55766
  init_types6();
55410
55767
  init_base_compiler();
55411
- var version = "0.35.0";
55768
+ var version = "0.35.1";
55412
55769
  globalThis[Symbol.for("io.cortexjs.compute-engine")] = {
55413
55770
  ComputeEngine: ComputeEngine.prototype.constructor,
55414
- version: "0.35.0"
55771
+ version: "0.35.1"
55415
55772
  };
55416
55773
  export {
55417
55774
  BaseCompiler,