@cortex-js/compute-engine 0.60.0 → 0.61.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.
Files changed (292) hide show
  1. package/dist/compile.esm.js +1270 -25
  2. package/dist/compile.min.esm.js +324 -78
  3. package/dist/compile.min.umd.cjs +324 -78
  4. package/dist/compile.umd.cjs +1270 -25
  5. package/dist/compute-engine.esm.js +867 -26
  6. package/dist/compute-engine.min.esm.js +329 -83
  7. package/dist/compute-engine.min.umd.cjs +329 -83
  8. package/dist/compute-engine.umd.cjs +867 -26
  9. package/dist/core.esm.js +855 -24
  10. package/dist/core.min.esm.js +330 -84
  11. package/dist/core.min.umd.cjs +330 -84
  12. package/dist/core.umd.cjs +855 -24
  13. package/dist/identities.esm.js +2 -2
  14. package/dist/identities.min.esm.js +2 -2
  15. package/dist/identities.min.umd.cjs +2 -2
  16. package/dist/identities.umd.cjs +2 -2
  17. package/dist/integration-rules.esm.js +2 -2
  18. package/dist/integration-rules.min.esm.js +2 -2
  19. package/dist/integration-rules.min.umd.cjs +2 -2
  20. package/dist/integration-rules.umd.cjs +2 -2
  21. package/dist/interval.esm.js +2 -2
  22. package/dist/interval.min.esm.js +2 -2
  23. package/dist/interval.min.umd.cjs +2 -2
  24. package/dist/interval.umd.cjs +2 -2
  25. package/dist/latex-syntax.esm.js +2 -2
  26. package/dist/latex-syntax.min.esm.js +2 -2
  27. package/dist/latex-syntax.min.umd.cjs +2 -2
  28. package/dist/latex-syntax.umd.cjs +2 -2
  29. package/dist/math-json.esm.js +2 -2
  30. package/dist/math-json.min.esm.js +2 -2
  31. package/dist/math-json.min.umd.cjs +2 -2
  32. package/dist/math-json.umd.cjs +2 -2
  33. package/dist/numerics.esm.js +2 -2
  34. package/dist/numerics.min.esm.js +2 -2
  35. package/dist/numerics.min.umd.cjs +2 -2
  36. package/dist/numerics.umd.cjs +2 -2
  37. package/dist/types/big-decimal/big-decimal.d.ts +1 -1
  38. package/dist/types/big-decimal/index.d.ts +1 -1
  39. package/dist/types/big-decimal/transcendentals.d.ts +1 -1
  40. package/dist/types/big-decimal/utils.d.ts +1 -1
  41. package/dist/types/common/ansi-codes.d.ts +1 -1
  42. package/dist/types/common/configuration-change.d.ts +1 -1
  43. package/dist/types/common/fuzzy-string-match.d.ts +1 -1
  44. package/dist/types/common/grapheme-splitter.d.ts +1 -1
  45. package/dist/types/common/interruptible.d.ts +1 -1
  46. package/dist/types/common/one-of.d.ts +1 -1
  47. package/dist/types/common/signals.d.ts +1 -1
  48. package/dist/types/common/type/ast-nodes.d.ts +1 -1
  49. package/dist/types/common/type/boxed-type.d.ts +1 -1
  50. package/dist/types/common/type/lexer.d.ts +1 -1
  51. package/dist/types/common/type/parse.d.ts +1 -1
  52. package/dist/types/common/type/parser.d.ts +1 -1
  53. package/dist/types/common/type/primitive.d.ts +1 -1
  54. package/dist/types/common/type/reduce.d.ts +1 -1
  55. package/dist/types/common/type/serialize.d.ts +1 -1
  56. package/dist/types/common/type/subtype.d.ts +1 -1
  57. package/dist/types/common/type/type-builder.d.ts +1 -1
  58. package/dist/types/common/type/types.d.ts +1 -1
  59. package/dist/types/common/type/utils.d.ts +1 -1
  60. package/dist/types/common/utils.d.ts +1 -1
  61. package/dist/types/compile.d.ts +2 -1
  62. package/dist/types/compute-engine/assume.d.ts +1 -1
  63. package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +1 -1
  64. package/dist/types/compute-engine/boxed-expression/apply.d.ts +1 -1
  65. package/dist/types/compute-engine/boxed-expression/arithmetic-add.d.ts +1 -1
  66. package/dist/types/compute-engine/boxed-expression/arithmetic-mul-div.d.ts +1 -1
  67. package/dist/types/compute-engine/boxed-expression/arithmetic-power.d.ts +1 -1
  68. package/dist/types/compute-engine/boxed-expression/ascii-math.d.ts +1 -1
  69. package/dist/types/compute-engine/boxed-expression/box.d.ts +1 -1
  70. package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +1 -1
  71. package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +1 -1
  72. package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +1 -1
  73. package/dist/types/compute-engine/boxed-expression/boxed-operator-definition.d.ts +1 -1
  74. package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +1 -1
  75. package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +1 -1
  76. package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +1 -1
  77. package/dist/types/compute-engine/boxed-expression/boxed-tensor.d.ts +1 -1
  78. package/dist/types/compute-engine/boxed-expression/boxed-value-definition.d.ts +1 -1
  79. package/dist/types/compute-engine/boxed-expression/cache.d.ts +1 -1
  80. package/dist/types/compute-engine/boxed-expression/canonical-utils.d.ts +1 -1
  81. package/dist/types/compute-engine/boxed-expression/canonical.d.ts +1 -1
  82. package/dist/types/compute-engine/boxed-expression/compare.d.ts +1 -1
  83. package/dist/types/compute-engine/boxed-expression/constants.d.ts +1 -1
  84. package/dist/types/compute-engine/boxed-expression/constraint-subject.d.ts +1 -1
  85. package/dist/types/compute-engine/boxed-expression/exp-to-trig.d.ts +1 -1
  86. package/dist/types/compute-engine/boxed-expression/expand.d.ts +1 -1
  87. package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +1 -1
  88. package/dist/types/compute-engine/boxed-expression/factor.d.ts +1 -1
  89. package/dist/types/compute-engine/boxed-expression/flatten.d.ts +1 -1
  90. package/dist/types/compute-engine/boxed-expression/hold.d.ts +1 -1
  91. package/dist/types/compute-engine/boxed-expression/inequality-bounds.d.ts +1 -1
  92. package/dist/types/compute-engine/boxed-expression/init-lazy-refs.d.ts +1 -1
  93. package/dist/types/compute-engine/boxed-expression/invisible-operator.d.ts +1 -1
  94. package/dist/types/compute-engine/boxed-expression/match.d.ts +1 -1
  95. package/dist/types/compute-engine/boxed-expression/multivariate-gcd.d.ts +1 -1
  96. package/dist/types/compute-engine/boxed-expression/multivariate-poly.d.ts +1 -1
  97. package/dist/types/compute-engine/boxed-expression/negate.d.ts +1 -1
  98. package/dist/types/compute-engine/boxed-expression/numerics.d.ts +1 -1
  99. package/dist/types/compute-engine/boxed-expression/order.d.ts +1 -1
  100. package/dist/types/compute-engine/boxed-expression/pattern-utils.d.ts +1 -1
  101. package/dist/types/compute-engine/boxed-expression/polynomial-degree.d.ts +1 -1
  102. package/dist/types/compute-engine/boxed-expression/polynomials.d.ts +1 -1
  103. package/dist/types/compute-engine/boxed-expression/predicates.d.ts +1 -1
  104. package/dist/types/compute-engine/boxed-expression/rule-index.d.ts +1 -1
  105. package/dist/types/compute-engine/boxed-expression/rules.d.ts +1 -1
  106. package/dist/types/compute-engine/boxed-expression/serialize.d.ts +1 -1
  107. package/dist/types/compute-engine/boxed-expression/sgn.d.ts +1 -1
  108. package/dist/types/compute-engine/boxed-expression/simplify.d.ts +1 -1
  109. package/dist/types/compute-engine/boxed-expression/solve-linear-system.d.ts +1 -1
  110. package/dist/types/compute-engine/boxed-expression/solve.d.ts +1 -1
  111. package/dist/types/compute-engine/boxed-expression/stochastic-equal.d.ts +1 -1
  112. package/dist/types/compute-engine/boxed-expression/trigonometry.d.ts +1 -1
  113. package/dist/types/compute-engine/boxed-expression/type-guards.d.ts +1 -1
  114. package/dist/types/compute-engine/boxed-expression/utils.d.ts +1 -1
  115. package/dist/types/compute-engine/boxed-expression/validate.d.ts +1 -1
  116. package/dist/types/compute-engine/collection-utils.d.ts +1 -1
  117. package/dist/types/compute-engine/compilation/base-compiler.d.ts +79 -1
  118. package/dist/types/compute-engine/compilation/compile-expression.d.ts +1 -1
  119. package/dist/types/compute-engine/compilation/constant-folding.d.ts +1 -1
  120. package/dist/types/compute-engine/compilation/glsl-target.d.ts +2 -2
  121. package/dist/types/compute-engine/compilation/gpu-target.d.ts +7 -1
  122. package/dist/types/compute-engine/compilation/interval-glsl-target.d.ts +49 -0
  123. package/dist/types/compute-engine/compilation/interval-javascript-target.d.ts +1 -1
  124. package/dist/types/compute-engine/compilation/javascript-target.d.ts +30 -2
  125. package/dist/types/compute-engine/compilation/python-target.d.ts +1 -1
  126. package/dist/types/compute-engine/compilation/types.d.ts +54 -2
  127. package/dist/types/compute-engine/compilation/wgsl-target.d.ts +1 -1
  128. package/dist/types/compute-engine/cost-function.d.ts +1 -1
  129. package/dist/types/compute-engine/engine-assumptions.d.ts +1 -1
  130. package/dist/types/compute-engine/engine-cache.d.ts +1 -1
  131. package/dist/types/compute-engine/engine-common-symbols.d.ts +1 -1
  132. package/dist/types/compute-engine/engine-compilation-targets.d.ts +1 -1
  133. package/dist/types/compute-engine/engine-configuration-lifecycle.d.ts +1 -1
  134. package/dist/types/compute-engine/engine-declarations.d.ts +1 -1
  135. package/dist/types/compute-engine/engine-expression-entrypoints.d.ts +1 -1
  136. package/dist/types/compute-engine/engine-extension-contracts.d.ts +1 -1
  137. package/dist/types/compute-engine/engine-library-bootstrap.d.ts +1 -1
  138. package/dist/types/compute-engine/engine-numeric-configuration.d.ts +1 -1
  139. package/dist/types/compute-engine/engine-runtime-state.d.ts +1 -1
  140. package/dist/types/compute-engine/engine-scope.d.ts +1 -1
  141. package/dist/types/compute-engine/engine-sequences.d.ts +1 -1
  142. package/dist/types/compute-engine/engine-simplification-rules.d.ts +1 -1
  143. package/dist/types/compute-engine/engine-startup-coordinator.d.ts +1 -1
  144. package/dist/types/compute-engine/engine-type-resolver.d.ts +1 -1
  145. package/dist/types/compute-engine/engine-validation-entrypoints.d.ts +1 -1
  146. package/dist/types/compute-engine/free-functions.d.ts +1 -1
  147. package/dist/types/compute-engine/function-properties/index.d.ts +1 -1
  148. package/dist/types/compute-engine/function-utils.d.ts +1 -1
  149. package/dist/types/compute-engine/fungrim/loader.d.ts +1 -1
  150. package/dist/types/compute-engine/fungrim/types.d.ts +1 -1
  151. package/dist/types/compute-engine/global-types.d.ts +1 -1
  152. package/dist/types/compute-engine/index.d.ts +10 -1
  153. package/dist/types/compute-engine/interval/arithmetic.d.ts +1 -1
  154. package/dist/types/compute-engine/interval/comparison.d.ts +1 -1
  155. package/dist/types/compute-engine/interval/elementary.d.ts +1 -1
  156. package/dist/types/compute-engine/interval/index.d.ts +1 -1
  157. package/dist/types/compute-engine/interval/trigonometric.d.ts +1 -1
  158. package/dist/types/compute-engine/interval/types.d.ts +1 -1
  159. package/dist/types/compute-engine/interval/util.d.ts +1 -1
  160. package/dist/types/compute-engine/latex-syntax/dictionary/default-dictionary.d.ts +1 -1
  161. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-algebra.d.ts +1 -1
  162. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-arithmetic.d.ts +1 -1
  163. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-calculus.d.ts +1 -1
  164. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-colors.d.ts +1 -1
  165. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-complex.d.ts +1 -1
  166. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-core.d.ts +1 -1
  167. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-linear-algebra.d.ts +1 -1
  168. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-logic.d.ts +1 -1
  169. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-other.d.ts +1 -1
  170. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-relational-operators.d.ts +1 -1
  171. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-sets.d.ts +1 -1
  172. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-statistics.d.ts +1 -1
  173. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-symbols.d.ts +1 -1
  174. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-trigonometry.d.ts +1 -1
  175. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-units.d.ts +1 -1
  176. package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +1 -1
  177. package/dist/types/compute-engine/latex-syntax/dictionary/indexed-types.d.ts +1 -1
  178. package/dist/types/compute-engine/latex-syntax/latex-syntax.d.ts +1 -1
  179. package/dist/types/compute-engine/latex-syntax/parse-number.d.ts +1 -1
  180. package/dist/types/compute-engine/latex-syntax/parse-symbol.d.ts +1 -1
  181. package/dist/types/compute-engine/latex-syntax/parse.d.ts +1 -1
  182. package/dist/types/compute-engine/latex-syntax/serialize-dms.d.ts +1 -1
  183. package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +1 -1
  184. package/dist/types/compute-engine/latex-syntax/serializer-style.d.ts +1 -1
  185. package/dist/types/compute-engine/latex-syntax/serializer.d.ts +1 -1
  186. package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +1 -1
  187. package/dist/types/compute-engine/latex-syntax/types.d.ts +1 -1
  188. package/dist/types/compute-engine/latex-syntax/utils.d.ts +1 -1
  189. package/dist/types/compute-engine/library/arithmetic.d.ts +1 -1
  190. package/dist/types/compute-engine/library/calculus.d.ts +1 -1
  191. package/dist/types/compute-engine/library/collections.d.ts +1 -1
  192. package/dist/types/compute-engine/library/colors.d.ts +1 -1
  193. package/dist/types/compute-engine/library/combinatorics.d.ts +1 -1
  194. package/dist/types/compute-engine/library/complex.d.ts +1 -1
  195. package/dist/types/compute-engine/library/control-structures.d.ts +1 -1
  196. package/dist/types/compute-engine/library/core.d.ts +1 -1
  197. package/dist/types/compute-engine/library/fractals.d.ts +1 -1
  198. package/dist/types/compute-engine/library/library.d.ts +1 -1
  199. package/dist/types/compute-engine/library/linear-algebra.d.ts +1 -1
  200. package/dist/types/compute-engine/library/logic-analysis.d.ts +1 -1
  201. package/dist/types/compute-engine/library/logic.d.ts +1 -1
  202. package/dist/types/compute-engine/library/number-theory.d.ts +1 -1
  203. package/dist/types/compute-engine/library/polynomials.d.ts +1 -1
  204. package/dist/types/compute-engine/library/quantity-arithmetic.d.ts +1 -1
  205. package/dist/types/compute-engine/library/random-expression.d.ts +1 -1
  206. package/dist/types/compute-engine/library/relational-operator.d.ts +1 -1
  207. package/dist/types/compute-engine/library/sets.d.ts +1 -1
  208. package/dist/types/compute-engine/library/special-functions.d.ts +1 -1
  209. package/dist/types/compute-engine/library/statistics.d.ts +1 -1
  210. package/dist/types/compute-engine/library/trigonometry.d.ts +1 -1
  211. package/dist/types/compute-engine/library/type-handlers.d.ts +1 -1
  212. package/dist/types/compute-engine/library/unit-data.d.ts +1 -1
  213. package/dist/types/compute-engine/library/units.d.ts +1 -1
  214. package/dist/types/compute-engine/library/utils.d.ts +1 -1
  215. package/dist/types/compute-engine/numeric-value/big-numeric-value.d.ts +1 -1
  216. package/dist/types/compute-engine/numeric-value/exact-numeric-value.d.ts +1 -1
  217. package/dist/types/compute-engine/numeric-value/machine-numeric-value.d.ts +1 -1
  218. package/dist/types/compute-engine/numeric-value/types.d.ts +1 -1
  219. package/dist/types/compute-engine/numerics/bernoulli.d.ts +1 -1
  220. package/dist/types/compute-engine/numerics/bigint.d.ts +1 -1
  221. package/dist/types/compute-engine/numerics/complex-esm-augment.d.ts +1 -1
  222. package/dist/types/compute-engine/numerics/expression.d.ts +1 -1
  223. package/dist/types/compute-engine/numerics/interval.d.ts +1 -1
  224. package/dist/types/compute-engine/numerics/linear-algebra.d.ts +1 -1
  225. package/dist/types/compute-engine/numerics/monte-carlo.d.ts +1 -1
  226. package/dist/types/compute-engine/numerics/numeric-bigint.d.ts +1 -1
  227. package/dist/types/compute-engine/numerics/numeric-bignum.d.ts +1 -1
  228. package/dist/types/compute-engine/numerics/numeric-complex.d.ts +1 -1
  229. package/dist/types/compute-engine/numerics/numeric.d.ts +1 -1
  230. package/dist/types/compute-engine/numerics/oscillatory-quadrature.d.ts +1 -1
  231. package/dist/types/compute-engine/numerics/polynomial-roots.d.ts +1 -1
  232. package/dist/types/compute-engine/numerics/primes.d.ts +1 -1
  233. package/dist/types/compute-engine/numerics/random.d.ts +1 -1
  234. package/dist/types/compute-engine/numerics/rationals.d.ts +1 -1
  235. package/dist/types/compute-engine/numerics/richardson.d.ts +1 -1
  236. package/dist/types/compute-engine/numerics/special-functions.d.ts +1 -1
  237. package/dist/types/compute-engine/numerics/statistics.d.ts +1 -1
  238. package/dist/types/compute-engine/numerics/strings.d.ts +1 -1
  239. package/dist/types/compute-engine/numerics/types.d.ts +1 -1
  240. package/dist/types/compute-engine/numerics/unit-data.d.ts +1 -1
  241. package/dist/types/compute-engine/oeis.d.ts +1 -1
  242. package/dist/types/compute-engine/rubi/compile.d.ts +1 -1
  243. package/dist/types/compute-engine/rubi/driver.d.ts +1 -1
  244. package/dist/types/compute-engine/rubi/loader.d.ts +1 -1
  245. package/dist/types/compute-engine/rubi/match.d.ts +1 -1
  246. package/dist/types/compute-engine/rubi/normal-form.d.ts +1 -1
  247. package/dist/types/compute-engine/rubi/rubi-utils.d.ts +1 -1
  248. package/dist/types/compute-engine/rubi/types.d.ts +1 -1
  249. package/dist/types/compute-engine/sequence.d.ts +1 -1
  250. package/dist/types/compute-engine/symbolic/antiderivative.d.ts +1 -1
  251. package/dist/types/compute-engine/symbolic/derivative.d.ts +1 -1
  252. package/dist/types/compute-engine/symbolic/distribute.d.ts +1 -1
  253. package/dist/types/compute-engine/symbolic/fu-cost.d.ts +1 -1
  254. package/dist/types/compute-engine/symbolic/fu-transforms.d.ts +1 -1
  255. package/dist/types/compute-engine/symbolic/fu.d.ts +1 -1
  256. package/dist/types/compute-engine/symbolic/limit.d.ts +1 -1
  257. package/dist/types/compute-engine/symbolic/logic-utils.d.ts +1 -1
  258. package/dist/types/compute-engine/symbolic/residue.d.ts +1 -1
  259. package/dist/types/compute-engine/symbolic/simplify-abs.d.ts +1 -1
  260. package/dist/types/compute-engine/symbolic/simplify-divide.d.ts +1 -1
  261. package/dist/types/compute-engine/symbolic/simplify-factorial.d.ts +1 -1
  262. package/dist/types/compute-engine/symbolic/simplify-hyperbolic.d.ts +1 -1
  263. package/dist/types/compute-engine/symbolic/simplify-infinity.d.ts +1 -1
  264. package/dist/types/compute-engine/symbolic/simplify-log.d.ts +1 -1
  265. package/dist/types/compute-engine/symbolic/simplify-logic.d.ts +1 -1
  266. package/dist/types/compute-engine/symbolic/simplify-power.d.ts +1 -1
  267. package/dist/types/compute-engine/symbolic/simplify-product.d.ts +1 -1
  268. package/dist/types/compute-engine/symbolic/simplify-rules.d.ts +1 -1
  269. package/dist/types/compute-engine/symbolic/simplify-sum.d.ts +1 -1
  270. package/dist/types/compute-engine/symbolic/simplify-trig.d.ts +1 -1
  271. package/dist/types/compute-engine/tensor/tensor-fields.d.ts +1 -1
  272. package/dist/types/compute-engine/tensor/tensors.d.ts +1 -1
  273. package/dist/types/compute-engine/types-definitions.d.ts +1 -1
  274. package/dist/types/compute-engine/types-engine.d.ts +11 -1
  275. package/dist/types/compute-engine/types-evaluation.d.ts +1 -1
  276. package/dist/types/compute-engine/types-expression.d.ts +1 -1
  277. package/dist/types/compute-engine/types-kernel-evaluation.d.ts +1 -1
  278. package/dist/types/compute-engine/types-kernel-serialization.d.ts +1 -1
  279. package/dist/types/compute-engine/types-serialization.d.ts +1 -1
  280. package/dist/types/compute-engine/types.d.ts +1 -1
  281. package/dist/types/compute-engine.d.ts +1 -1
  282. package/dist/types/core.d.ts +1 -1
  283. package/dist/types/identities.d.ts +1 -1
  284. package/dist/types/integration-rules.d.ts +1 -1
  285. package/dist/types/interval.d.ts +1 -1
  286. package/dist/types/latex-syntax.d.ts +2 -2
  287. package/dist/types/math-json/symbols.d.ts +1 -1
  288. package/dist/types/math-json/types.d.ts +1 -1
  289. package/dist/types/math-json/utils.d.ts +1 -1
  290. package/dist/types/math-json.d.ts +2 -2
  291. package/dist/types/numerics.d.ts +1 -1
  292. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- /** Compute Engine 0.60.0 */
1
+ /** Compute Engine 0.61.0 */
2
2
 
3
3
  // node_modules/complex-esm/dist/src/complex.js
4
4
  var cosh = Math.cosh || function(x) {
@@ -7421,10 +7421,18 @@ function canonicalFunctionLiteral(expr2) {
7421
7421
  }
7422
7422
  function canonicalFunctionLiteralArguments(ce, ops) {
7423
7423
  if (ops.length === 0) return void 0;
7424
- const block = ops[0].operator === "Block" ? ops[0].canonical : ce.function("Block", [ops[0]]);
7425
7424
  const params = ops.slice(1).map(
7426
7425
  (x) => isSymbol2(x) ? x : ce.error("expected-a-symbol", x.toString())
7427
7426
  );
7427
+ ce._pushShadowedParameters(
7428
+ params.filter((p) => isSymbol2(p)).map((p) => p.symbol)
7429
+ );
7430
+ let block;
7431
+ try {
7432
+ block = ops[0].operator === "Block" ? ops[0].canonical : ce.function("Block", [ops[0]]);
7433
+ } finally {
7434
+ ce._popShadowedParameters();
7435
+ }
7428
7436
  console.assert(block.isScoped);
7429
7437
  for (const param of params) {
7430
7438
  if (isSymbol2(param) && !block.localScope.bindings.has(param.symbol)) {
@@ -66913,6 +66921,13 @@ function serializeJson(ce, expr2, options) {
66913
66921
 
66914
66922
  // src/compute-engine/compilation/base-compiler.ts
66915
66923
  var BaseCompiler = class _BaseCompiler {
66924
+ /**
66925
+ * Precedence used when compiling a folded symbol value. Higher than any
66926
+ * target's infix operator precedence, so a compound value parenthesizes
66927
+ * itself when spliced into a surrounding expression. See
66928
+ * `tryFoldKnownSymbol`.
66929
+ */
66930
+ static FOLD_OPERAND_PREC = 1e3;
66916
66931
  /**
66917
66932
  * Compile an expression to target language source code
66918
66933
  */
@@ -66929,7 +66944,9 @@ var BaseCompiler = class _BaseCompiler {
66929
66944
  if (op !== void 0) {
66930
66945
  return `(a,b) => a ${op[0]} b`;
66931
66946
  }
66932
- return target.var?.(s) ?? s;
66947
+ const resolved = target.var?.(s);
66948
+ if (resolved !== void 0) return resolved;
66949
+ return _BaseCompiler.tryFoldKnownSymbol(expr2.engine, s, target) ?? s;
66933
66950
  }
66934
66951
  if (isNumber(expr2)) {
66935
66952
  if (expr2.im !== 0) {
@@ -67255,10 +67272,10 @@ var BaseCompiler = class _BaseCompiler {
67255
67272
  )
67256
67273
  );
67257
67274
  const needsWrap2 = target.number(0) !== "0";
67258
- const bodyTarget2 = needsWrap2 ? {
67275
+ const bodyTarget2 = {
67259
67276
  ...target,
67260
- var: (id) => loopVarSet.has(id) ? target.number(0).replace("0", id) : target.var(id)
67261
- } : target;
67277
+ var: (id) => loopVarSet.has(id) ? needsWrap2 ? target.number(0).replace("0", id) : id : target.var(id)
67278
+ };
67262
67279
  const bodyCode = _BaseCompiler.compile(body, bodyTarget2);
67263
67280
  let inner = `result.push(${bodyCode});`;
67264
67281
  for (let i = narrowedElements.length - 1; i >= 0; i--) {
@@ -67556,6 +67573,167 @@ var BaseCompiler = class _BaseCompiler {
67556
67573
  if (isNumber(expr2)) return expr2.im === 0 && expr2.re >= 0;
67557
67574
  return expr2.isNonNegative === true;
67558
67575
  }
67576
+ /**
67577
+ * If `id` names a symbol that is *known* to the engine — it has an assigned
67578
+ * value (`ce.assign("a", 1.5)`) or is a declared constant — return the
67579
+ * compiled target code for that value, i.e. **fold** the value into the
67580
+ * generated code the way `evaluate()` does. Returns `undefined` for a
67581
+ * genuinely free symbol (no value), so the caller falls back to its
67582
+ * free-symbol plumbing (a `vars` mapping, a `_.id` argument lookup, or a
67583
+ * declarable identifier).
67584
+ *
67585
+ * This keeps the compiled output consistent with `expr.unknowns` and
67586
+ * `evaluate()`: a symbol they treat as known (folded / dropped) is also
67587
+ * folded by `compile()`, instead of being emitted as a bare, dangling
67588
+ * reference (an undeclared GLSL identifier, or a bare JS global that throws
67589
+ * `ReferenceError` at run time).
67590
+ *
67591
+ * Callers MUST resolve any `vars` mapping for `id` **before** calling this,
67592
+ * so an explicitly `vars`-mapped symbol is never folded — the GPU/JS live
67593
+ * path relies on a mapped symbol staying a per-frame uniform / argument.
67594
+ *
67595
+ * `target` is the in-flight target: nested symbols inside the value resolve
67596
+ * through the same `vars`/constant/fold rules as the top-level expression.
67597
+ *
67598
+ * The value is compiled at a high precedence so a compound (operator) value
67599
+ * self-parenthesizes: folding `b = c + 1` into `b * x` must yield
67600
+ * `(c + 1) * x`, not `c + 1 * x`, and must stay safe when a handler splices
67601
+ * the folded string into its own expression (e.g. `Power`'s `(code * code)`).
67602
+ * An atomic value (number, symbol, function call) ignores the precedence, so
67603
+ * no redundant parentheses are added in the common assigned-number case.
67604
+ */
67605
+ static tryFoldKnownSymbol(engine, id, target) {
67606
+ const value = engine._getSymbolValue(id);
67607
+ if (value === void 0) return void 0;
67608
+ return _BaseCompiler.compile(value, target, _BaseCompiler.FOLD_OPERAND_PREC);
67609
+ }
67610
+ /**
67611
+ * Operator heads the compiler lowers directly in `compileExpr`, independent
67612
+ * of any target operator/function mapping (control-flow, binding, and
67613
+ * indexing-set forms). `analyzeReferences` never reports these as
67614
+ * "unsupported".
67615
+ */
67616
+ static STRUCTURAL_HEADS = /* @__PURE__ */ new Set([
67617
+ "Sequence",
67618
+ "Sum",
67619
+ "Product",
67620
+ "Function",
67621
+ "Declare",
67622
+ "Assign",
67623
+ "Return",
67624
+ "Break",
67625
+ "Continue",
67626
+ "Loop",
67627
+ "If",
67628
+ "Which",
67629
+ "When",
67630
+ "Block",
67631
+ // Indexing-set wrappers consumed by Sum/Product/Loop — never compiled
67632
+ // standalone.
67633
+ "Limits",
67634
+ "Element"
67635
+ ]);
67636
+ /**
67637
+ * Analyze — without compiling, and never throwing — which external references
67638
+ * the generated code for `expr` would have on `target`:
67639
+ *
67640
+ * - `freeSymbols`: identifiers the caller must supply at run time. These are
67641
+ * the free symbols *as codegen sees them*: symbols with no value in the
67642
+ * engine, after descending into the values of folded (assigned / constant)
67643
+ * symbols — so `a = b + 1` surfaces `b`, which `expr.unknowns` misses — and
67644
+ * after excluding bound variables (lambda parameters, indices of
67645
+ * `Sum`/`Product`/`Integrate`/`Loop`, `Block` locals). A `vars`-mapped
67646
+ * symbol is always included: the mapping makes it an external input even
67647
+ * when it also has an assigned value.
67648
+ *
67649
+ * - `unsupported`: operator heads with no operator/function mapping in the
67650
+ * target and not one of the structural forms above.
67651
+ *
67652
+ * Lets a caller validate that a compiled result is self-contained
67653
+ * (`freeSymbols` covered by its inputs, `unsupported` empty) declaratively,
67654
+ * instead of executing or GPU-compiling the code to discover a dangling
67655
+ * reference or an unlowerable operator.
67656
+ */
67657
+ static analyzeReferences(expr2, target, varsKeys) {
67658
+ const engine = expr2.engine;
67659
+ const free = /* @__PURE__ */ new Set();
67660
+ const unsupported = /* @__PURE__ */ new Set();
67661
+ const foldedSeen = /* @__PURE__ */ new Set();
67662
+ const union2 = (a, more) => {
67663
+ const s = new Set(a);
67664
+ for (const m of more) s.add(m);
67665
+ return s;
67666
+ };
67667
+ const visit = (e, bound) => {
67668
+ if (isSymbol2(e)) {
67669
+ const s = e.symbol;
67670
+ if (bound.has(s)) return;
67671
+ if (target.operators?.(s) !== void 0) return;
67672
+ if (varsKeys?.has(s)) {
67673
+ free.add(s);
67674
+ return;
67675
+ }
67676
+ const value = engine._getSymbolValue(s);
67677
+ if (value !== void 0) {
67678
+ if (!foldedSeen.has(s)) {
67679
+ foldedSeen.add(s);
67680
+ visit(value, bound);
67681
+ }
67682
+ return;
67683
+ }
67684
+ free.add(s);
67685
+ return;
67686
+ }
67687
+ if (!isFunction2(e)) return;
67688
+ const h = e.operator;
67689
+ const ops = e.ops;
67690
+ if (h !== "Error" && !_BaseCompiler.STRUCTURAL_HEADS.has(h) && target.functions?.(h) === void 0 && target.operators?.(h) === void 0)
67691
+ unsupported.add(h);
67692
+ if (h === "Function") {
67693
+ const params = ops.slice(1).filter((p) => isSymbol2(p)).map((p) => p.symbol);
67694
+ visit(ops[0], params.length ? union2(bound, params) : bound);
67695
+ return;
67696
+ }
67697
+ if (h === "Sum" || h === "Product" || h === "Integrate" || h === "Loop") {
67698
+ const indices = [];
67699
+ const limitExprs = [];
67700
+ for (const clause of ops.slice(1)) {
67701
+ if (isFunction2(clause)) {
67702
+ if (isSymbol2(clause.ops[0])) indices.push(clause.ops[0].symbol);
67703
+ for (const sub2 of clause.ops.slice(1)) limitExprs.push(sub2);
67704
+ } else {
67705
+ limitExprs.push(clause);
67706
+ }
67707
+ }
67708
+ visit(ops[0], indices.length ? union2(bound, indices) : bound);
67709
+ for (const le of limitExprs) visit(le, bound);
67710
+ return;
67711
+ }
67712
+ if (h === "Block") {
67713
+ const locals = [];
67714
+ for (const stmt of ops)
67715
+ if (isFunction2(stmt, "Declare") && isSymbol2(stmt.ops[0]))
67716
+ locals.push(stmt.ops[0].symbol);
67717
+ const inner = locals.length ? union2(bound, locals) : bound;
67718
+ for (const op of ops) visit(op, inner);
67719
+ return;
67720
+ }
67721
+ for (const op of ops) visit(op, bound);
67722
+ };
67723
+ visit(expr2, /* @__PURE__ */ new Set());
67724
+ return { freeSymbols: [...free], unsupported: [...unsupported] };
67725
+ }
67726
+ /**
67727
+ * Attach `freeSymbols` / `unsupported` (from `analyzeReferences`) to a
67728
+ * compilation result, returning the same object. Used by the built-in
67729
+ * targets to make every result carry its declarative reference analysis.
67730
+ */
67731
+ static withReferences(result, expr2, target, varsKeys) {
67732
+ return Object.assign(
67733
+ result,
67734
+ _BaseCompiler.analyzeReferences(expr2, target, varsKeys)
67735
+ );
67736
+ }
67559
67737
  /**
67560
67738
  * Generate a temporary variable name
67561
67739
  */
@@ -67785,11 +67963,16 @@ function compile(expr2, options) {
67785
67963
  try {
67786
67964
  if (options?.target) {
67787
67965
  const code = BaseCompiler.compile(expr2, options.target);
67788
- return {
67789
- target: options.target.language ?? "custom",
67790
- success: true,
67791
- code
67792
- };
67966
+ return BaseCompiler.withReferences(
67967
+ {
67968
+ target: options.target.language ?? "custom",
67969
+ success: true,
67970
+ code
67971
+ },
67972
+ expr2,
67973
+ options.target,
67974
+ options.vars ? new Set(Object.keys(options.vars)) : void 0
67975
+ );
67793
67976
  }
67794
67977
  const targetName = options?.to ?? "javascript";
67795
67978
  const languageTarget = expr2.engine.getCompilationTarget(targetName);
@@ -67808,11 +67991,26 @@ function compile(expr2, options) {
67808
67991
  });
67809
67992
  } catch (e) {
67810
67993
  if (options?.fallback ?? true) {
67994
+ const error = e.message;
67811
67995
  console.warn(
67812
- `Compilation fallback for "${expr2.operator}" (target: ${options?.to ?? "javascript"}): ${e.message}`
67996
+ `Compilation fallback for "${expr2.operator}" (target: ${options?.to ?? "javascript"}): ${error}`
67813
67997
  );
67814
67998
  const ce = expr2.engine;
67815
67999
  const target = options?.to ?? "javascript";
68000
+ let refs = {
68001
+ freeSymbols: [],
68002
+ unsupported: []
68003
+ };
68004
+ try {
68005
+ const compileTarget = options?.target ?? expr2.engine.getCompilationTarget(target)?.createTarget();
68006
+ if (compileTarget)
68007
+ refs = BaseCompiler.analyzeReferences(
68008
+ expr2,
68009
+ compileTarget,
68010
+ options?.vars ? new Set(Object.keys(options.vars)) : void 0
68011
+ );
68012
+ } catch {
68013
+ }
67816
68014
  if (isFunction2(expr2, "Function")) {
67817
68015
  const lambdaRun = ((...args) => ce.function("Apply", [expr2, ...args.map((a) => ce.expr(a))]).evaluate().re);
67818
68016
  return {
@@ -67820,7 +68018,9 @@ function compile(expr2, options) {
67820
68018
  success: false,
67821
68019
  code: "",
67822
68020
  calling: "lambda",
67823
- run: lambdaRun
68021
+ run: lambdaRun,
68022
+ error,
68023
+ ...refs
67824
68024
  };
67825
68025
  }
67826
68026
  const fallbackRun = ((vars) => {
@@ -67839,7 +68039,9 @@ function compile(expr2, options) {
67839
68039
  success: false,
67840
68040
  code: "",
67841
68041
  calling: "expression",
67842
- run: fallbackRun
68042
+ run: fallbackRun,
68043
+ error,
68044
+ ...refs
67843
68045
  };
67844
68046
  }
67845
68047
  throw e;
@@ -73365,6 +73567,10 @@ function resetCommonSymbols(commonSymbols) {
73365
73567
 
73366
73568
  // src/compute-engine/compilation/constant-folding.ts
73367
73569
  function formatFloat(n) {
73570
+ if (!Number.isFinite(n))
73571
+ throw new Error(
73572
+ `Cannot compile the non-finite value \`${n}\` to a GPU shader: GLSL/WGSL have no infinity or NaN literals.`
73573
+ );
73368
73574
  const str = n.toString();
73369
73575
  if (!str.includes(".") && !str.includes("e") && !str.includes("E")) {
73370
73576
  return `${str}.0`;
@@ -73960,6 +74166,7 @@ var JAVASCRIPT_FUNCTIONS = {
73960
74166
  Erf: "_SYS.erf",
73961
74167
  Erfc: "_SYS.erfc",
73962
74168
  ErfInv: "_SYS.erfInv",
74169
+ Erfi: "_SYS.erfi",
73963
74170
  // Special functions
73964
74171
  Beta: "_SYS.beta",
73965
74172
  Digamma: "_SYS.digamma",
@@ -73975,6 +74182,30 @@ var JAVASCRIPT_FUNCTIONS = {
73975
74182
  // Airy functions
73976
74183
  AiryAi: "_SYS.airyAi",
73977
74184
  AiryBi: "_SYS.airyBi",
74185
+ // Exponential / trigonometric / logarithmic integrals. These are the closed
74186
+ // forms the antiderivative engine emits (e.g. ∫sin x/x dx = SinIntegral(x)),
74187
+ // so an "evaluate then compile" pipeline must be able to lower them.
74188
+ SinIntegral: "_SYS.sinIntegral",
74189
+ CosIntegral: "_SYS.cosIntegral",
74190
+ ExpIntegralEi: "_SYS.expIntegralEi",
74191
+ LogIntegral: "_SYS.logIntegral",
74192
+ // Arithmetic-geometric mean and elliptic integrals (parameter convention
74193
+ // m = k², as in the library). `AGM`, `EllipticE`, and `EllipticPi` are
74194
+ // arity-overloaded — the handlers mirror the library's evaluate dispatch.
74195
+ AGM: (args, compile3) => args.length === 1 ? `_SYS.agm(1, ${compile3(args[0])})` : `_SYS.agm(${compile3(args[0])}, ${compile3(args[1])})`,
74196
+ EllipticK: "_SYS.ellipticK",
74197
+ EllipticE: (args, compile3) => args.length === 2 ? `_SYS.ellipticEIncomplete(${compile3(args[0])}, ${compile3(args[1])})` : `_SYS.ellipticE(${compile3(args[0])})`,
74198
+ EllipticF: (args, compile3) => `_SYS.ellipticF(${compile3(args[0])}, ${compile3(args[1])})`,
74199
+ EllipticPi: (args, compile3) => args.length === 3 ? `_SYS.ellipticPiIncomplete(${compile3(args[0])}, ${compile3(
74200
+ args[1]
74201
+ )}, ${compile3(args[2])})` : `_SYS.ellipticPiComplete(${compile3(args[0])}, ${compile3(args[1])})`,
74202
+ // Hypergeometric functions.
74203
+ Hypergeometric2F1: (args, compile3) => `_SYS.hypergeometric2F1(${compile3(args[0])}, ${compile3(args[1])}, ${compile3(
74204
+ args[2]
74205
+ )}, ${compile3(args[3])})`,
74206
+ Hypergeometric1F1: (args, compile3) => `_SYS.hypergeometric1F1(${compile3(args[0])}, ${compile3(args[1])}, ${compile3(
74207
+ args[2]
74208
+ )})`,
73978
74209
  // Combinatorics
73979
74210
  Mandelbrot: ([c, maxIter], compile3) => {
73980
74211
  if (c === null || maxIter === null)
@@ -73987,6 +74218,8 @@ var JAVASCRIPT_FUNCTIONS = {
73987
74218
  return `_SYS.julia(${compile3(z)}, ${compile3(c)}, ${compile3(maxIter)})`;
73988
74219
  },
73989
74220
  Binomial: (args, compile3) => `_SYS.binomial(${compile3(args[0])}, ${compile3(args[1])})`,
74221
+ // Choose(n, k) is the binomial coefficient — same runtime helper.
74222
+ Choose: (args, compile3) => `_SYS.binomial(${compile3(args[0])}, ${compile3(args[1])})`,
73990
74223
  Fibonacci: "_SYS.fibonacci",
73991
74224
  // Complex-specific functions
73992
74225
  Real: (args, compile3) => {
@@ -74492,6 +74725,20 @@ var SYS_HELPERS = {
74492
74725
  sinc,
74493
74726
  fresnelS,
74494
74727
  fresnelC,
74728
+ sinIntegral,
74729
+ cosIntegral,
74730
+ expIntegralEi,
74731
+ logIntegral,
74732
+ erfi,
74733
+ agm,
74734
+ ellipticK,
74735
+ ellipticE,
74736
+ ellipticEIncomplete,
74737
+ ellipticF,
74738
+ ellipticPiComplete,
74739
+ ellipticPiIncomplete,
74740
+ hypergeometric2F1,
74741
+ hypergeometric1F1,
74495
74742
  mandelbrot: (c, maxIter) => {
74496
74743
  let zx = 0, zy = 0;
74497
74744
  const cx = typeof c === "number" ? c : c.re;
@@ -74678,7 +74925,7 @@ var JavaScriptTarget = class {
74678
74925
  functions: (id) => namedFunctions?.[id] ? namedFunctions[id] : JAVASCRIPT_FUNCTIONS[id],
74679
74926
  var: (id) => {
74680
74927
  if (vars && id in vars) return JSON.stringify(vars[id]);
74681
- const result = {
74928
+ const result2 = {
74682
74929
  Pi: "Math.PI",
74683
74930
  ExponentialE: "Math.E",
74684
74931
  NaN: "Number.NaN",
@@ -74689,13 +74936,20 @@ var JavaScriptTarget = class {
74689
74936
  CatalanConstant: "0.91596559417721901",
74690
74937
  EulerGamma: "0.57721566490153286"
74691
74938
  }[id];
74692
- if (result !== void 0) return result;
74939
+ if (result2 !== void 0) return result2;
74693
74940
  if (unknowns.includes(id)) return `_.${id}`;
74694
- return void 0;
74941
+ if (expr2.engine._getSymbolValue(id) !== void 0) return void 0;
74942
+ return `_.${id}`;
74695
74943
  },
74696
74944
  preamble: (preamble ?? "") + preambleImports
74697
74945
  });
74698
- return compileToTarget(expr2, target, realOnly);
74946
+ const result = compileToTarget(expr2, target, realOnly);
74947
+ return BaseCompiler.withReferences(
74948
+ result,
74949
+ expr2,
74950
+ target,
74951
+ vars ? new Set(Object.keys(vars)) : void 0
74952
+ );
74699
74953
  }
74700
74954
  };
74701
74955
  function wrapRealOnly(result) {
@@ -77266,6 +77520,10 @@ var GPU_CONSTANTS = {
77266
77520
  EulerGamma: "0.57721566490"
77267
77521
  };
77268
77522
  function formatGPUNumber(n) {
77523
+ if (!Number.isFinite(n))
77524
+ throw new Error(
77525
+ `Cannot compile the non-finite value \`${n}\` to a GPU shader: GLSL/WGSL have no infinity or NaN literals.`
77526
+ );
77269
77527
  const str = n.toString();
77270
77528
  if (!str.includes(".") && !str.includes("e") && !str.includes("E")) {
77271
77529
  return `${str}.0`;
@@ -77293,7 +77551,7 @@ var GPUShaderTarget = class {
77293
77551
  var: (id) => {
77294
77552
  if (id === "ImaginaryUnit") return `${v2}(0.0, 1.0)`;
77295
77553
  if (id in constants) return constants[id];
77296
- return id;
77554
+ return void 0;
77297
77555
  },
77298
77556
  string: (str) => JSON.stringify(str),
77299
77557
  number: formatGPUNumber,
@@ -77332,7 +77590,7 @@ var GPUShaderTarget = class {
77332
77590
  if (vars && id in vars) return vars[id];
77333
77591
  if (id === "ImaginaryUnit") return `${v2}(0.0, 1.0)`;
77334
77592
  if (id in constants) return constants[id];
77335
- return id;
77593
+ return void 0;
77336
77594
  }
77337
77595
  });
77338
77596
  const code = BaseCompiler.compile(expr2, target);
@@ -77372,7 +77630,12 @@ var GPUShaderTarget = class {
77372
77630
  preamble += this.languageId === "wgsl" ? GPU_COLOR_PREAMBLE_WGSL : GPU_COLOR_PREAMBLE_GLSL;
77373
77631
  }
77374
77632
  if (preamble) result.preamble = preamble;
77375
- return result;
77633
+ return BaseCompiler.withReferences(
77634
+ result,
77635
+ expr2,
77636
+ target,
77637
+ vars ? new Set(Object.keys(vars)) : void 0
77638
+ );
77376
77639
  }
77377
77640
  compileToSource(expr2, _options = {}) {
77378
77641
  const target = this.createTarget();
@@ -77405,6 +77668,8 @@ var GLSL_FUNCTIONS = {
77405
77668
  Tuple: compileGLSLList
77406
77669
  };
77407
77670
  var GLSLTarget = class extends GPUShaderTarget {
77671
+ // Annotated `string` (not the literal `'glsl'`) so subclasses such as
77672
+ // `IntervalGLSLTarget` can override it while reusing the GLSL shader assembly.
77408
77673
  languageId = "glsl";
77409
77674
  getLanguageSpecificFunctions() {
77410
77675
  return GLSL_FUNCTIONS;
@@ -79366,11 +79631,18 @@ var IntervalJavaScriptTarget = class {
79366
79631
  };
79367
79632
  if (id in constants) return constants[id];
79368
79633
  if (unknowns.includes(id)) return `_.${id}`;
79369
- return void 0;
79634
+ if (expr2.engine._getSymbolValue(id) !== void 0) return void 0;
79635
+ return `_.${id}`;
79370
79636
  },
79371
79637
  preamble: (preamble ?? "") + preambleImports
79372
79638
  });
79373
- return compileToIntervalTarget(expr2, target);
79639
+ const result = compileToIntervalTarget(expr2, target);
79640
+ return BaseCompiler.withReferences(
79641
+ result,
79642
+ expr2,
79643
+ target,
79644
+ vars ? new Set(Object.keys(vars)) : void 0
79645
+ );
79374
79646
  }
79375
79647
  };
79376
79648
  function compileToIntervalTarget(expr2, target) {
@@ -79394,6 +79666,532 @@ function compileToIntervalTarget(expr2, target) {
79394
79666
  };
79395
79667
  }
79396
79668
 
79669
+ // src/compute-engine/compilation/interval-glsl-target.ts
79670
+ var IV_INF = "1e18";
79671
+ var INTERVAL_GLSL_PREAMBLE = `
79672
+ const float IV_INF = ${IV_INF};
79673
+ const vec2 IV_ENTIRE = vec2(-IV_INF, IV_INF);
79674
+ const vec2 IV_EMPTY = vec2(IV_INF, -IV_INF);
79675
+
79676
+ bool _iv_is_empty(vec2 a) { return a.x > a.y; }
79677
+
79678
+ // Clamp bounds to the finite sentinel range. Preserves IV_EMPTY (its components
79679
+ // already sit at the sentinels) and folds any overflowed intermediate back to
79680
+ // the sentinel (min(inf, IV_INF) = IV_INF), so a real \`inf\` never escapes an op.
79681
+ vec2 _iv_clamp(vec2 a) { return clamp(a, -IV_INF, IV_INF); }
79682
+
79683
+ // Exact empty propagation: force empty if any operand is empty.
79684
+ vec2 _iv_guard1(vec2 r, vec2 a) { return _iv_is_empty(a) ? IV_EMPTY : r; }
79685
+ vec2 _iv_guard2(vec2 r, vec2 a, vec2 b) {
79686
+ return (_iv_is_empty(a) || _iv_is_empty(b)) ? IV_EMPTY : r;
79687
+ }
79688
+
79689
+ vec2 _iv_negate(vec2 a) { return _iv_guard1(_iv_clamp(vec2(-a.y, -a.x)), a); }
79690
+
79691
+ vec2 _iv_add(vec2 a, vec2 b) {
79692
+ return _iv_guard2(_iv_clamp(vec2(a.x + b.x, a.y + b.y)), a, b);
79693
+ }
79694
+
79695
+ vec2 _iv_sub(vec2 a, vec2 b) {
79696
+ return _iv_guard2(_iv_clamp(vec2(a.x - b.y, a.y - b.x)), a, b);
79697
+ }
79698
+
79699
+ vec2 _iv_mul(vec2 a, vec2 b) {
79700
+ float p1 = a.x * b.x, p2 = a.x * b.y, p3 = a.y * b.x, p4 = a.y * b.y;
79701
+ vec2 r = vec2(min(min(p1, p2), min(p3, p4)), max(max(p1, p2), max(p3, p4)));
79702
+ return _iv_guard2(_iv_clamp(r), a, b);
79703
+ }
79704
+
79705
+ vec2 _iv_div(vec2 a, vec2 b) {
79706
+ // Denominator spanning 0 \u2192 entire (wide, never narrow): the CPU pass turns
79707
+ // the pole into a proper asymptote break.
79708
+ bool spansZero = (b.x <= 0.0 && b.y >= 0.0);
79709
+ float q1 = a.x / b.x, q2 = a.x / b.y, q3 = a.y / b.x, q4 = a.y / b.y;
79710
+ vec2 r = vec2(min(min(q1, q2), min(q3, q4)), max(max(q1, q2), max(q3, q4)));
79711
+ r = spansZero ? IV_ENTIRE : r;
79712
+ return _iv_guard2(_iv_clamp(r), a, b);
79713
+ }
79714
+
79715
+ vec2 _iv_square(vec2 a) {
79716
+ float lo2 = a.x * a.x, hi2 = a.y * a.y;
79717
+ // Straddles 0 \u21D2 min is 0; otherwise the smaller endpoint\xB2 is the min.
79718
+ float lo = (a.x <= 0.0 && a.y >= 0.0) ? 0.0 : min(lo2, hi2);
79719
+ return _iv_guard1(_iv_clamp(vec2(lo, max(lo2, hi2))), a);
79720
+ }
79721
+
79722
+ // Scalar integer power that is correct for negative bases (GLSL \`pow\` requires
79723
+ // a non-negative base): keep the sign for odd exponents, drop it for even.
79724
+ float _iv_powi_scalar(float x, float n) {
79725
+ float a = pow(abs(x), n);
79726
+ return (mod(n, 2.0) == 1.0 && x < 0.0) ? -a : a;
79727
+ }
79728
+
79729
+ vec2 _iv_powi(vec2 a, float n) {
79730
+ float pl = _iv_powi_scalar(a.x, n);
79731
+ float ph = _iv_powi_scalar(a.y, n);
79732
+ bool even = (mod(n, 2.0) == 0.0);
79733
+ bool straddle = (a.x <= 0.0 && a.y >= 0.0);
79734
+ float lo = even ? (straddle ? 0.0 : min(pl, ph)) : pl;
79735
+ float hi = even ? max(pl, ph) : ph;
79736
+ return _iv_guard1(_iv_clamp(vec2(lo, hi)), a);
79737
+ }
79738
+
79739
+ // \u2500\u2500 Phase 2: elementary functions \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
79740
+
79741
+ vec2 _iv_abs(vec2 a) {
79742
+ float al = abs(a.x), ah = abs(a.y);
79743
+ bool straddle = (a.x <= 0.0 && a.y >= 0.0);
79744
+ return _iv_guard1(_iv_clamp(vec2(straddle ? 0.0 : min(al, ah), max(al, ah))), a);
79745
+ }
79746
+
79747
+ // Domain x \u2265 0: fully-negative box \u2192 empty; a box straddling 0 clamps lo to 0.
79748
+ vec2 _iv_sqrt(vec2 a) {
79749
+ vec2 r = vec2(sqrt(max(a.x, 0.0)), sqrt(max(a.y, 0.0)));
79750
+ r = (a.y < 0.0) ? IV_EMPTY : r;
79751
+ return _iv_guard1(_iv_clamp(r), a);
79752
+ }
79753
+
79754
+ vec2 _iv_exp(vec2 a) {
79755
+ return _iv_guard1(_iv_clamp(vec2(exp(a.x), exp(a.y))), a);
79756
+ }
79757
+
79758
+ // Domain x > 0: fully-\u22640 box \u2192 empty; straddling box \u2192 lo clamped to \u2212IV_INF
79759
+ // (ln \u2192 \u2212\u221E as x \u2192 0\u207A, never a real \u2212inf).
79760
+ vec2 _iv_ln(vec2 a) {
79761
+ vec2 r = vec2(a.x > 0.0 ? log(a.x) : -IV_INF, log(a.y));
79762
+ r = (a.y <= 0.0) ? IV_EMPTY : r;
79763
+ return _iv_guard1(_iv_clamp(r), a);
79764
+ }
79765
+
79766
+ const float _IV_INV_LN10 = 0.43429448190325176;
79767
+ const float _IV_INV_LN2 = 1.4426950408889634;
79768
+
79769
+ vec2 _iv_log10(vec2 a) {
79770
+ vec2 r = vec2(a.x > 0.0 ? log(a.x) * _IV_INV_LN10 : -IV_INF, log(a.y) * _IV_INV_LN10);
79771
+ r = (a.y <= 0.0) ? IV_EMPTY : r;
79772
+ return _iv_guard1(_iv_clamp(r), a);
79773
+ }
79774
+
79775
+ vec2 _iv_log2(vec2 a) {
79776
+ vec2 r = vec2(a.x > 0.0 ? log(a.x) * _IV_INV_LN2 : -IV_INF, log(a.y) * _IV_INV_LN2);
79777
+ r = (a.y <= 0.0) ? IV_EMPTY : r;
79778
+ return _iv_guard1(_iv_clamp(r), a);
79779
+ }
79780
+
79781
+ // Non-integer power. Real only for base \u2265 0: fully-negative box \u2192 empty; a box
79782
+ // straddling 0 clamps the base low end to 0. \`p\` is a compile-time constant, so
79783
+ // the \`p >= 0\` test is a constant branch.
79784
+ vec2 _iv_powf(vec2 a, float p) {
79785
+ float lob = max(a.x, 0.0);
79786
+ float e0 = pow(lob, p), e1 = pow(a.y, p);
79787
+ vec2 r = (p >= 0.0) ? vec2(e0, e1) : vec2(e1, e0);
79788
+ r = (a.y < 0.0) ? IV_EMPTY : r;
79789
+ return _iv_guard1(_iv_clamp(r), a);
79790
+ }
79791
+
79792
+ // \u2500\u2500 Phase 3: trigonometric & inverse-trigonometric functions \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
79793
+ // Mirrors interval-js (interval/trigonometric.ts): exact endpoints with
79794
+ // extremum snapping (no outward epsilon). Per the Option-A contract, a tan pole
79795
+ // yields \`entire\` (interval-js returns \`singular\`; entire \u2287 singular and the
79796
+ // CPU classifies the asymptote).
79797
+
79798
+ const float _IV_PI = 3.141592653589793;
79799
+ const float _IV_TWO_PI = 6.283185307179586;
79800
+ const float _IV_HALF_PI = 1.5707963267948966;
79801
+ const float _IV_THREE_HALF_PI = 4.71238898038469;
79802
+
79803
+ // True if [a] contains an extremum of the family { ext + n\xB7period }.
79804
+ bool _iv_has_ext(vec2 a, float ext, float period) {
79805
+ float n = ceil((a.x - ext) / period);
79806
+ float cand = ext + n * period;
79807
+ return cand >= a.x - 1e-15 && cand <= a.y + 1e-15;
79808
+ }
79809
+
79810
+ vec2 _iv_sin(vec2 a) {
79811
+ vec2 r;
79812
+ if (a.y - a.x >= _IV_TWO_PI) r = vec2(-1.0, 1.0);
79813
+ else {
79814
+ float sl = sin(a.x), sh = sin(a.y);
79815
+ float lo = min(sl, sh), hi = max(sl, sh);
79816
+ if (_iv_has_ext(a, _IV_HALF_PI, _IV_TWO_PI)) hi = 1.0;
79817
+ if (_iv_has_ext(a, _IV_THREE_HALF_PI, _IV_TWO_PI)) lo = -1.0;
79818
+ r = vec2(lo, hi);
79819
+ }
79820
+ return _iv_guard1(_iv_clamp(r), a);
79821
+ }
79822
+
79823
+ vec2 _iv_cos(vec2 a) {
79824
+ vec2 r;
79825
+ if (a.y - a.x >= _IV_TWO_PI) r = vec2(-1.0, 1.0);
79826
+ else {
79827
+ float cl = cos(a.x), ch = cos(a.y);
79828
+ float lo = min(cl, ch), hi = max(cl, ch);
79829
+ if (_iv_has_ext(a, 0.0, _IV_TWO_PI)) hi = 1.0;
79830
+ if (_iv_has_ext(a, _IV_PI, _IV_TWO_PI)) lo = -1.0;
79831
+ r = vec2(lo, hi);
79832
+ }
79833
+ return _iv_guard1(_iv_clamp(r), a);
79834
+ }
79835
+
79836
+ vec2 _iv_tan(vec2 a) {
79837
+ // A pole in the interval \u2192 entire (cannot exclude).
79838
+ bool pole =
79839
+ (a.y - a.x >= _IV_PI) || _iv_has_ext(a, _IV_HALF_PI, _IV_PI);
79840
+ float tl = tan(a.x), th = tan(a.y);
79841
+ // Floating-point branch-cross sanity (large opposite-sign endpoints).
79842
+ bool crossed = (tl > 1e10 && th < -1e10) || (tl < -1e10 && th > 1e10);
79843
+ vec2 r = (pole || crossed) ? IV_ENTIRE : vec2(tl, th);
79844
+ return _iv_guard1(_iv_clamp(r), a);
79845
+ }
79846
+
79847
+ // asin: domain [\u22121, 1]. Fully outside \u2192 empty; straddling clamps to the valid
79848
+ // sub-range. Monotonic increasing.
79849
+ vec2 _iv_asin(vec2 a) {
79850
+ vec2 r = vec2(asin(max(a.x, -1.0)), asin(min(a.y, 1.0)));
79851
+ r = (a.x > 1.0 || a.y < -1.0) ? IV_EMPTY : r;
79852
+ return _iv_guard1(_iv_clamp(r), a);
79853
+ }
79854
+
79855
+ // acos: domain [\u22121, 1], monotonic decreasing (bounds swap).
79856
+ vec2 _iv_acos(vec2 a) {
79857
+ vec2 r = vec2(acos(min(a.y, 1.0)), acos(max(a.x, -1.0)));
79858
+ r = (a.x > 1.0 || a.y < -1.0) ? IV_EMPTY : r;
79859
+ return _iv_guard1(_iv_clamp(r), a);
79860
+ }
79861
+
79862
+ vec2 _iv_atan(vec2 a) {
79863
+ return _iv_guard1(_iv_clamp(vec2(atan(a.x), atan(a.y))), a);
79864
+ }
79865
+
79866
+ // \u2500\u2500 Discontinuous / step functions \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
79867
+ // Bounded jump-discontinuity functions return the TIGHT value-range enclosure
79868
+ // (sound, and excludable when the range misses 0) rather than \`entire\` \u2014 only
79869
+ // genuine poles are entire. Per the Option-A division of labor, the CPU still
79870
+ // classifies the discontinuity on the (kept) live cells; the GPU only needs a
79871
+ // sound bound for the exclusion test. These functions are monotone, so the
79872
+ // enclosure is just [f(lo), f(hi)] unless noted.
79873
+
79874
+ vec2 _iv_floor(vec2 a) { return _iv_guard1(_iv_clamp(vec2(floor(a.x), floor(a.y))), a); }
79875
+ vec2 _iv_ceil(vec2 a) { return _iv_guard1(_iv_clamp(vec2(ceil(a.x), ceil(a.y))), a); }
79876
+ vec2 _iv_round(vec2 a) { return _iv_guard1(_iv_clamp(vec2(floor(a.x + 0.5), floor(a.y + 0.5))), a); }
79877
+ vec2 _iv_trunc(vec2 a) { return _iv_guard1(_iv_clamp(vec2(trunc(a.x), trunc(a.y))), a); }
79878
+ vec2 _iv_sign(vec2 a) { return _iv_guard1(vec2(sign(a.x), sign(a.y)), a); }
79879
+
79880
+ vec2 _iv_heaviside(vec2 a) {
79881
+ float hl = a.x < 0.0 ? 0.0 : (a.x > 0.0 ? 1.0 : 0.5);
79882
+ float hh = a.y < 0.0 ? 0.0 : (a.y > 0.0 ? 1.0 : 0.5);
79883
+ return _iv_guard1(vec2(hl, hh), a);
79884
+ }
79885
+
79886
+ // fract(x) = x \u2212 floor(x): continuous within an integer cell, sawtooth across
79887
+ // one (\u2192 full [0, 1] range).
79888
+ vec2 _iv_fract(vec2 a) {
79889
+ float fl = floor(a.x);
79890
+ vec2 r = (fl == floor(a.y)) ? vec2(a.x - fl, a.y - fl) : vec2(0.0, 1.0);
79891
+ return _iv_guard1(_iv_clamp(r), a);
79892
+ }
79893
+
79894
+ vec2 _iv_min(vec2 a, vec2 b) {
79895
+ return _iv_guard2(_iv_clamp(vec2(min(a.x, b.x), min(a.y, b.y))), a, b);
79896
+ }
79897
+ vec2 _iv_max(vec2 a, vec2 b) {
79898
+ return _iv_guard2(_iv_clamp(vec2(max(a.x, b.x), max(a.y, b.y))), a, b);
79899
+ }
79900
+
79901
+ // mod(x, y) = x \u2212 y\xB7floor(x/y). A modulus straddling 0 is a pole \u2192 entire. For
79902
+ // a constant (point) modulus the fast path is exact; otherwise compose (the
79903
+ // tight floor keeps it sound).
79904
+ vec2 _iv_mod(vec2 a, vec2 b) {
79905
+ if (b.x <= 0.0 && b.y >= 0.0) return _iv_guard2(IV_ENTIRE, a, b);
79906
+ if (b.x == b.y) {
79907
+ float p = abs(b.x);
79908
+ float flo = floor(a.x / p);
79909
+ vec2 r = (flo == floor(a.y / p)) ? vec2(a.x - p * flo, a.y - p * flo)
79910
+ : vec2(0.0, p);
79911
+ return _iv_guard2(_iv_clamp(r), a, b);
79912
+ }
79913
+ return _iv_sub(a, _iv_mul(b, _iv_floor(_iv_div(a, b))));
79914
+ }
79915
+ `;
79916
+ var INTERVAL_GLSL_FUNCTIONS = {
79917
+ Add: (args, compile3) => {
79918
+ if (args.length === 0) return "vec2(0.0, 0.0)";
79919
+ let r = compile3(args[0]);
79920
+ for (let i = 1; i < args.length; i++)
79921
+ r = `_iv_add(${r}, ${compile3(args[i])})`;
79922
+ return r;
79923
+ },
79924
+ Subtract: ([a, b], compile3) => {
79925
+ if (a === null || b === null) throw new Error("Subtract: missing argument");
79926
+ return `_iv_sub(${compile3(a)}, ${compile3(b)})`;
79927
+ },
79928
+ Multiply: (args, compile3) => {
79929
+ if (args.length === 0) return "vec2(1.0, 1.0)";
79930
+ let r = compile3(args[0]);
79931
+ for (let i = 1; i < args.length; i++)
79932
+ r = `_iv_mul(${r}, ${compile3(args[i])})`;
79933
+ return r;
79934
+ },
79935
+ Divide: ([a, b], compile3) => {
79936
+ if (a === null || b === null) throw new Error("Divide: missing argument");
79937
+ return `_iv_div(${compile3(a)}, ${compile3(b)})`;
79938
+ },
79939
+ Negate: ([a], compile3) => {
79940
+ if (a === null) throw new Error("Negate: no argument");
79941
+ return `_iv_negate(${compile3(a)})`;
79942
+ },
79943
+ Square: ([a], compile3) => {
79944
+ if (a === null) throw new Error("Square: no argument");
79945
+ return `_iv_square(${compile3(a)})`;
79946
+ },
79947
+ Sqrt: ([a], compile3) => {
79948
+ if (a === null) throw new Error("Sqrt: no argument");
79949
+ return `_iv_sqrt(${compile3(a)})`;
79950
+ },
79951
+ Abs: ([a], compile3) => {
79952
+ if (a === null) throw new Error("Abs: no argument");
79953
+ return `_iv_abs(${compile3(a)})`;
79954
+ },
79955
+ Exp: ([a], compile3) => {
79956
+ if (a === null) throw new Error("Exp: no argument");
79957
+ return `_iv_exp(${compile3(a)})`;
79958
+ },
79959
+ Ln: ([a], compile3) => {
79960
+ if (a === null) throw new Error("Ln: no argument");
79961
+ return `_iv_ln(${compile3(a)})`;
79962
+ },
79963
+ Log: (args, compile3) => {
79964
+ if (args.length === 1) return `_iv_log10(${compile3(args[0])})`;
79965
+ return `_iv_div(_iv_ln(${compile3(args[0])}), _iv_ln(${compile3(args[1])}))`;
79966
+ },
79967
+ Lb: ([a], compile3) => {
79968
+ if (a === null) throw new Error("Lb: no argument");
79969
+ return `_iv_log2(${compile3(a)})`;
79970
+ },
79971
+ Sin: ([a], compile3) => {
79972
+ if (a === null) throw new Error("Sin: no argument");
79973
+ return `_iv_sin(${compile3(a)})`;
79974
+ },
79975
+ Cos: ([a], compile3) => {
79976
+ if (a === null) throw new Error("Cos: no argument");
79977
+ return `_iv_cos(${compile3(a)})`;
79978
+ },
79979
+ Tan: ([a], compile3) => {
79980
+ if (a === null) throw new Error("Tan: no argument");
79981
+ return `_iv_tan(${compile3(a)})`;
79982
+ },
79983
+ Arcsin: ([a], compile3) => {
79984
+ if (a === null) throw new Error("Arcsin: no argument");
79985
+ return `_iv_asin(${compile3(a)})`;
79986
+ },
79987
+ Arccos: ([a], compile3) => {
79988
+ if (a === null) throw new Error("Arccos: no argument");
79989
+ return `_iv_acos(${compile3(a)})`;
79990
+ },
79991
+ Arctan: ([a], compile3) => {
79992
+ if (a === null) throw new Error("Arctan: no argument");
79993
+ return `_iv_atan(${compile3(a)})`;
79994
+ },
79995
+ Floor: ([a], compile3) => {
79996
+ if (a === null) throw new Error("Floor: no argument");
79997
+ return `_iv_floor(${compile3(a)})`;
79998
+ },
79999
+ Ceil: ([a], compile3) => {
80000
+ if (a === null) throw new Error("Ceil: no argument");
80001
+ return `_iv_ceil(${compile3(a)})`;
80002
+ },
80003
+ Round: ([a], compile3) => {
80004
+ if (a === null) throw new Error("Round: no argument");
80005
+ return `_iv_round(${compile3(a)})`;
80006
+ },
80007
+ Truncate: ([a], compile3) => {
80008
+ if (a === null) throw new Error("Truncate: no argument");
80009
+ return `_iv_trunc(${compile3(a)})`;
80010
+ },
80011
+ Fract: ([a], compile3) => {
80012
+ if (a === null) throw new Error("Fract: no argument");
80013
+ return `_iv_fract(${compile3(a)})`;
80014
+ },
80015
+ Sign: ([a], compile3) => {
80016
+ if (a === null) throw new Error("Sign: no argument");
80017
+ return `_iv_sign(${compile3(a)})`;
80018
+ },
80019
+ Heaviside: ([a], compile3) => {
80020
+ if (a === null) throw new Error("Heaviside: no argument");
80021
+ return `_iv_heaviside(${compile3(a)})`;
80022
+ },
80023
+ Mod: ([a, b], compile3) => {
80024
+ if (a === null || b === null) throw new Error("Mod: missing argument");
80025
+ return `_iv_mod(${compile3(a)}, ${compile3(b)})`;
80026
+ },
80027
+ Min: (args, compile3) => {
80028
+ if (args.length === 0) throw new Error("Min: no argument");
80029
+ let r = compile3(args[0]);
80030
+ for (let i = 1; i < args.length; i++)
80031
+ r = `_iv_min(${r}, ${compile3(args[i])})`;
80032
+ return r;
80033
+ },
80034
+ Max: (args, compile3) => {
80035
+ if (args.length === 0) throw new Error("Max: no argument");
80036
+ let r = compile3(args[0]);
80037
+ for (let i = 1; i < args.length; i++)
80038
+ r = `_iv_max(${r}, ${compile3(args[i])})`;
80039
+ return r;
80040
+ },
80041
+ Power: ([base, exp3], compile3) => {
80042
+ if (base === null || exp3 === null)
80043
+ throw new Error("Power: missing argument");
80044
+ if (isSymbol2(base, "ExponentialE")) return `_iv_exp(${compile3(exp3)})`;
80045
+ if (isNumber(exp3) && exp3.im === 0) {
80046
+ const v = exp3.re;
80047
+ if (v === 0.5) return `_iv_sqrt(${compile3(base)})`;
80048
+ if (v === 2) return `_iv_square(${compile3(base)})`;
80049
+ if (Number.isInteger(v) && v >= 0)
80050
+ return `_iv_powi(${compile3(base)}, ${formatGPUNumber(v)})`;
80051
+ if (!Number.isInteger(v) && v > 0)
80052
+ return `_iv_powf(${compile3(base)}, ${formatGPUNumber(v)})`;
80053
+ throw new Error(
80054
+ `interval-glsl: Power with exponent \`${exp3.toString()}\` is not yet supported`
80055
+ );
80056
+ }
80057
+ throw new Error(
80058
+ "interval-glsl: Power with a variable exponent is not yet supported"
80059
+ );
80060
+ }
80061
+ };
80062
+ var INTERVAL_GLSL_CONSTANTS = {
80063
+ Pi: "vec2(3.14159265359, 3.14159265359)",
80064
+ ExponentialE: "vec2(2.71828182846, 2.71828182846)",
80065
+ GoldenRatio: "vec2(1.61803398875, 1.61803398875)",
80066
+ CatalanConstant: "vec2(0.91596559417, 0.91596559417)",
80067
+ EulerGamma: "vec2(0.57721566490, 0.57721566490)"
80068
+ };
80069
+ var IntervalGLSLTarget = class extends GLSLTarget {
80070
+ languageId = "interval-glsl";
80071
+ getOperators() {
80072
+ return {};
80073
+ }
80074
+ getFunctions() {
80075
+ return INTERVAL_GLSL_FUNCTIONS;
80076
+ }
80077
+ getConstants() {
80078
+ return INTERVAL_GLSL_CONSTANTS;
80079
+ }
80080
+ createTarget(options = {}) {
80081
+ return super.createTarget({
80082
+ operators: () => void 0,
80083
+ functions: (id) => INTERVAL_GLSL_FUNCTIONS[id],
80084
+ number: (n) => `vec2(${formatGPUNumber(n)}, ${formatGPUNumber(n)})`,
80085
+ complex: () => {
80086
+ throw new Error("interval-glsl: complex values are not supported");
80087
+ },
80088
+ var: (id) => INTERVAL_GLSL_CONSTANTS[id],
80089
+ ...options
80090
+ });
80091
+ }
80092
+ compile(expr2, options = {}) {
80093
+ const { vars } = options;
80094
+ const target = this.createTarget({
80095
+ var: (id) => {
80096
+ if (vars && id in vars) return vars[id];
80097
+ if (id in INTERVAL_GLSL_CONSTANTS) return INTERVAL_GLSL_CONSTANTS[id];
80098
+ return void 0;
80099
+ }
80100
+ });
80101
+ const code = BaseCompiler.compile(expr2, target);
80102
+ const result = {
80103
+ target: "interval-glsl",
80104
+ success: true,
80105
+ code
80106
+ };
80107
+ if (code.includes("_iv_")) result.preamble = INTERVAL_GLSL_PREAMBLE;
80108
+ return BaseCompiler.withReferences(
80109
+ result,
80110
+ expr2,
80111
+ target,
80112
+ vars ? new Set(Object.keys(vars)) : void 0
80113
+ );
80114
+ }
80115
+ /**
80116
+ * Emit a complete, self-contained GLSL fragment shader implementing the
80117
+ * **interval exclusion oracle** for the implicit curve `f = 0` (Phase 4).
80118
+ *
80119
+ * The shader is structured so the core contract — the interval evaluator —
80120
+ * is cleanly separable from the render harness:
80121
+ *
80122
+ * - `vec2 _implicit(<vec2 per free variable>)` evaluates the interval of `f`
80123
+ * over a cell box (this is the part that matters; it is identical to
80124
+ * `compile(expr).code` wrapped in a function).
80125
+ * - `main()` is a **reference harness**: it derives each fragment's cell box
80126
+ * from `gl_FragCoord` and the viewport uniforms, evaluates `_implicit`, and
80127
+ * writes the exclusion result. The renderer is free to replace `main()` /
80128
+ * the uniforms with its own conventions and keep `_implicit`.
80129
+ *
80130
+ * The first free variable maps to `u_domainX`, the second to `u_domainY`
80131
+ * (≤ 2 free variables; a 2D implicit curve). The exclusion predicate is
80132
+ * `f.lo > 0 || f.hi < 0` — which also excludes the `empty` (domain-undefined)
80133
+ * interval, since its `lo` is the `+IV_INF` sentinel.
80134
+ *
80135
+ * @throws if the expression has more than two free variables, or cannot be
80136
+ * lowered (an unsupported head propagates from `BaseCompiler.compile`).
80137
+ */
80138
+ compileExclusionShader(expr2, options = {}) {
80139
+ const { version: version2 = "300 es", precision = "highp" } = options;
80140
+ const compiled = this.compile(expr2);
80141
+ const vars = compiled.freeSymbols ?? [];
80142
+ if (vars.length > 2)
80143
+ throw new Error(
80144
+ `interval-glsl exclusion shader supports at most 2 free variables (got ${vars.length}: ${vars.join(", ")})`
80145
+ );
80146
+ const params = vars.map((v) => `vec2 ${v}`).join(", ");
80147
+ const [axisX, axisY] = vars;
80148
+ const main = ["void main() {"];
80149
+ main.push(" vec2 _cell = gl_FragCoord.xy / u_resolution;");
80150
+ main.push(" vec2 _step = 1.0 / u_resolution;");
80151
+ const callArgs = [];
80152
+ if (axisX !== void 0) {
80153
+ main.push(" float _xlo = mix(u_domainX.x, u_domainX.y, _cell.x);");
80154
+ main.push(
80155
+ " float _xhi = mix(u_domainX.x, u_domainX.y, _cell.x + _step.x);"
80156
+ );
80157
+ callArgs.push("vec2(_xlo, _xhi)");
80158
+ }
80159
+ if (axisY !== void 0) {
80160
+ main.push(" float _ylo = mix(u_domainY.x, u_domainY.y, _cell.y);");
80161
+ main.push(
80162
+ " float _yhi = mix(u_domainY.x, u_domainY.y, _cell.y + _step.y);"
80163
+ );
80164
+ callArgs.push("vec2(_ylo, _yhi)");
80165
+ }
80166
+ main.push(` vec2 _f = _implicit(${callArgs.join(", ")});`);
80167
+ main.push(" bool _excluded = (_f.x > 0.0 || _f.y < 0.0);");
80168
+ main.push(
80169
+ " fragColor = _excluded ? vec4(0.0, 0.0, 0.0, 1.0) : vec4(1.0);"
80170
+ );
80171
+ main.push("}");
80172
+ return [
80173
+ `#version ${version2}`,
80174
+ `precision ${precision} float;`,
80175
+ "",
80176
+ INTERVAL_GLSL_PREAMBLE.trim(),
80177
+ "",
80178
+ "uniform vec2 u_domainX; // [min, max] for the 1st free variable",
80179
+ "uniform vec2 u_domainY; // [min, max] for the 2nd free variable",
80180
+ "uniform vec2 u_resolution; // render target size, in pixels",
80181
+ "",
80182
+ "out vec4 fragColor;",
80183
+ "",
80184
+ "// Interval evaluation of the implicit field f over a cell box.",
80185
+ `vec2 _implicit(${params}) {`,
80186
+ ` return ${compiled.code};`,
80187
+ "}",
80188
+ "",
80189
+ main.join("\n"),
80190
+ ""
80191
+ ].join("\n");
80192
+ }
80193
+ };
80194
+
79397
80195
  // src/compute-engine/engine-compilation-targets.ts
79398
80196
  var CompilationTargetRegistry = class {
79399
80197
  _targets = /* @__PURE__ */ new Map();
@@ -79416,6 +80214,7 @@ var CompilationTargetRegistry = class {
79416
80214
  this.register("glsl", new GLSLTarget());
79417
80215
  this.register("wgsl", new WGSLTarget());
79418
80216
  this.register("interval-js", new IntervalJavaScriptTarget());
80217
+ this.register("interval-glsl", new IntervalGLSLTarget());
79419
80218
  }
79420
80219
  };
79421
80220
 
@@ -79533,6 +80332,20 @@ function createSymbolExpression(engine, commonSymbols, symbolName2, options) {
79533
80332
  if (engine.strict && !isValidSymbol(name))
79534
80333
  return engine.error(["invalid-symbol", validateSymbol(name)], name);
79535
80334
  if (!canonical2) return new BoxedSymbol(engine, name, { metadata });
80335
+ if (engine._isShadowedParameter(name)) {
80336
+ let pdef = engine.lookupDefinition(name);
80337
+ if (!pdef || isValueDef(pdef) && pdef.value.isConstant) {
80338
+ let autoScope2 = engine.context.lexicalScope;
80339
+ while (autoScope2.noAutoDeclare && autoScope2.parent)
80340
+ autoScope2 = autoScope2.parent;
80341
+ pdef = engine._declareSymbolValue(
80342
+ name,
80343
+ { type: "unknown", inferred: true },
80344
+ autoScope2
80345
+ );
80346
+ }
80347
+ return new BoxedSymbol(engine, name, { metadata, def: pdef });
80348
+ }
79536
80349
  const result = commonSymbols[name];
79537
80350
  if (result) return result;
79538
80351
  let def = engine.lookupDefinition(name);
@@ -80284,7 +81097,17 @@ var PythonTarget = class {
80284
81097
  */
80285
81098
  compile(expr2, options = {}) {
80286
81099
  const code = this.compileToSource(expr2, options);
80287
- return { target: "python", success: true, code };
81100
+ const result = {
81101
+ target: "python",
81102
+ success: true,
81103
+ code
81104
+ };
81105
+ return BaseCompiler.withReferences(
81106
+ result,
81107
+ expr2,
81108
+ this.createTarget(),
81109
+ options.vars ? new Set(Object.keys(options.vars)) : void 0
81110
+ );
80288
81111
  }
80289
81112
  /**
80290
81113
  * Compile an expression to Python source code
@@ -82640,6 +83463,24 @@ var ComputeEngine = class _ComputeEngine {
82640
83463
  _printStack(options) {
82641
83464
  printStack(this, options);
82642
83465
  }
83466
+ /** Stack of parameter-name sets active while canonicalizing function bodies.
83467
+ * @internal */
83468
+ _shadowedParameterStack = [];
83469
+ /** @internal */
83470
+ _pushShadowedParameters(names) {
83471
+ this._shadowedParameterStack.push(new Set(names));
83472
+ }
83473
+ /** @internal */
83474
+ _popShadowedParameters() {
83475
+ this._shadowedParameterStack.pop();
83476
+ }
83477
+ /** @internal */
83478
+ _isShadowedParameter(name) {
83479
+ const stack = this._shadowedParameterStack;
83480
+ for (let i = stack.length - 1; i >= 0; i--)
83481
+ if (stack[i].has(name)) return true;
83482
+ return false;
83483
+ }
82643
83484
  /**
82644
83485
  * Use `ce.expr(name)` instead
82645
83486
  * @internal */
@@ -83059,14 +83900,14 @@ var ComputeEngine = class _ComputeEngine {
83059
83900
  _setDefaultEngineFactory(() => new ComputeEngine());
83060
83901
 
83061
83902
  // src/compute-engine.ts
83062
- var version = "0.60.0";
83903
+ var version = "0.61.0";
83063
83904
  ComputeEngine._latexSyntaxFactory = () => new LatexSyntax();
83064
83905
  _setDefaultEngineFactory(
83065
83906
  () => new ComputeEngine({ latexSyntax: new LatexSyntax() })
83066
83907
  );
83067
83908
  globalThis[/* @__PURE__ */ Symbol.for("io.cortexjs.compute-engine")] = {
83068
83909
  ComputeEngine: ComputeEngine.prototype.constructor,
83069
- version: "0.60.0"
83910
+ version: "0.61.0"
83070
83911
  };
83071
83912
  export {
83072
83913
  DEFINITIONS_ALGEBRA as ALGEBRA_DICTIONARY,