@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
  (function(global,factory){typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'],factory):(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ComputeEngine = {}));})(this, (function (exports) { 'use strict';
3
3
  "use strict";
4
4
  var ComputeEngine = (() => {
@@ -7499,10 +7499,18 @@ var ComputeEngine = (() => {
7499
7499
  }
7500
7500
  function canonicalFunctionLiteralArguments(ce, ops) {
7501
7501
  if (ops.length === 0) return void 0;
7502
- const block = ops[0].operator === "Block" ? ops[0].canonical : ce.function("Block", [ops[0]]);
7503
7502
  const params = ops.slice(1).map(
7504
7503
  (x) => isSymbol2(x) ? x : ce.error("expected-a-symbol", x.toString())
7505
7504
  );
7505
+ ce._pushShadowedParameters(
7506
+ params.filter((p) => isSymbol2(p)).map((p) => p.symbol)
7507
+ );
7508
+ let block;
7509
+ try {
7510
+ block = ops[0].operator === "Block" ? ops[0].canonical : ce.function("Block", [ops[0]]);
7511
+ } finally {
7512
+ ce._popShadowedParameters();
7513
+ }
7506
7514
  console.assert(block.isScoped);
7507
7515
  for (const param of params) {
7508
7516
  if (isSymbol2(param) && !block.localScope.bindings.has(param.symbol)) {
@@ -66991,6 +66999,13 @@ Error in definition of "${name}"`,
66991
66999
 
66992
67000
  // src/compute-engine/compilation/base-compiler.ts
66993
67001
  var BaseCompiler = class _BaseCompiler {
67002
+ /**
67003
+ * Precedence used when compiling a folded symbol value. Higher than any
67004
+ * target's infix operator precedence, so a compound value parenthesizes
67005
+ * itself when spliced into a surrounding expression. See
67006
+ * `tryFoldKnownSymbol`.
67007
+ */
67008
+ static FOLD_OPERAND_PREC = 1e3;
66994
67009
  /**
66995
67010
  * Compile an expression to target language source code
66996
67011
  */
@@ -67007,7 +67022,9 @@ Error in definition of "${name}"`,
67007
67022
  if (op !== void 0) {
67008
67023
  return `(a,b) => a ${op[0]} b`;
67009
67024
  }
67010
- return target.var?.(s) ?? s;
67025
+ const resolved = target.var?.(s);
67026
+ if (resolved !== void 0) return resolved;
67027
+ return _BaseCompiler.tryFoldKnownSymbol(expr2.engine, s, target) ?? s;
67011
67028
  }
67012
67029
  if (isNumber(expr2)) {
67013
67030
  if (expr2.im !== 0) {
@@ -67333,10 +67350,10 @@ Error in definition of "${name}"`,
67333
67350
  )
67334
67351
  );
67335
67352
  const needsWrap2 = target.number(0) !== "0";
67336
- const bodyTarget2 = needsWrap2 ? {
67353
+ const bodyTarget2 = {
67337
67354
  ...target,
67338
- var: (id) => loopVarSet.has(id) ? target.number(0).replace("0", id) : target.var(id)
67339
- } : target;
67355
+ var: (id) => loopVarSet.has(id) ? needsWrap2 ? target.number(0).replace("0", id) : id : target.var(id)
67356
+ };
67340
67357
  const bodyCode = _BaseCompiler.compile(body, bodyTarget2);
67341
67358
  let inner = `result.push(${bodyCode});`;
67342
67359
  for (let i = narrowedElements.length - 1; i >= 0; i--) {
@@ -67634,6 +67651,167 @@ Error in definition of "${name}"`,
67634
67651
  if (isNumber(expr2)) return expr2.im === 0 && expr2.re >= 0;
67635
67652
  return expr2.isNonNegative === true;
67636
67653
  }
67654
+ /**
67655
+ * If `id` names a symbol that is *known* to the engine — it has an assigned
67656
+ * value (`ce.assign("a", 1.5)`) or is a declared constant — return the
67657
+ * compiled target code for that value, i.e. **fold** the value into the
67658
+ * generated code the way `evaluate()` does. Returns `undefined` for a
67659
+ * genuinely free symbol (no value), so the caller falls back to its
67660
+ * free-symbol plumbing (a `vars` mapping, a `_.id` argument lookup, or a
67661
+ * declarable identifier).
67662
+ *
67663
+ * This keeps the compiled output consistent with `expr.unknowns` and
67664
+ * `evaluate()`: a symbol they treat as known (folded / dropped) is also
67665
+ * folded by `compile()`, instead of being emitted as a bare, dangling
67666
+ * reference (an undeclared GLSL identifier, or a bare JS global that throws
67667
+ * `ReferenceError` at run time).
67668
+ *
67669
+ * Callers MUST resolve any `vars` mapping for `id` **before** calling this,
67670
+ * so an explicitly `vars`-mapped symbol is never folded — the GPU/JS live
67671
+ * path relies on a mapped symbol staying a per-frame uniform / argument.
67672
+ *
67673
+ * `target` is the in-flight target: nested symbols inside the value resolve
67674
+ * through the same `vars`/constant/fold rules as the top-level expression.
67675
+ *
67676
+ * The value is compiled at a high precedence so a compound (operator) value
67677
+ * self-parenthesizes: folding `b = c + 1` into `b * x` must yield
67678
+ * `(c + 1) * x`, not `c + 1 * x`, and must stay safe when a handler splices
67679
+ * the folded string into its own expression (e.g. `Power`'s `(code * code)`).
67680
+ * An atomic value (number, symbol, function call) ignores the precedence, so
67681
+ * no redundant parentheses are added in the common assigned-number case.
67682
+ */
67683
+ static tryFoldKnownSymbol(engine, id, target) {
67684
+ const value = engine._getSymbolValue(id);
67685
+ if (value === void 0) return void 0;
67686
+ return _BaseCompiler.compile(value, target, _BaseCompiler.FOLD_OPERAND_PREC);
67687
+ }
67688
+ /**
67689
+ * Operator heads the compiler lowers directly in `compileExpr`, independent
67690
+ * of any target operator/function mapping (control-flow, binding, and
67691
+ * indexing-set forms). `analyzeReferences` never reports these as
67692
+ * "unsupported".
67693
+ */
67694
+ static STRUCTURAL_HEADS = /* @__PURE__ */ new Set([
67695
+ "Sequence",
67696
+ "Sum",
67697
+ "Product",
67698
+ "Function",
67699
+ "Declare",
67700
+ "Assign",
67701
+ "Return",
67702
+ "Break",
67703
+ "Continue",
67704
+ "Loop",
67705
+ "If",
67706
+ "Which",
67707
+ "When",
67708
+ "Block",
67709
+ // Indexing-set wrappers consumed by Sum/Product/Loop — never compiled
67710
+ // standalone.
67711
+ "Limits",
67712
+ "Element"
67713
+ ]);
67714
+ /**
67715
+ * Analyze — without compiling, and never throwing — which external references
67716
+ * the generated code for `expr` would have on `target`:
67717
+ *
67718
+ * - `freeSymbols`: identifiers the caller must supply at run time. These are
67719
+ * the free symbols *as codegen sees them*: symbols with no value in the
67720
+ * engine, after descending into the values of folded (assigned / constant)
67721
+ * symbols — so `a = b + 1` surfaces `b`, which `expr.unknowns` misses — and
67722
+ * after excluding bound variables (lambda parameters, indices of
67723
+ * `Sum`/`Product`/`Integrate`/`Loop`, `Block` locals). A `vars`-mapped
67724
+ * symbol is always included: the mapping makes it an external input even
67725
+ * when it also has an assigned value.
67726
+ *
67727
+ * - `unsupported`: operator heads with no operator/function mapping in the
67728
+ * target and not one of the structural forms above.
67729
+ *
67730
+ * Lets a caller validate that a compiled result is self-contained
67731
+ * (`freeSymbols` covered by its inputs, `unsupported` empty) declaratively,
67732
+ * instead of executing or GPU-compiling the code to discover a dangling
67733
+ * reference or an unlowerable operator.
67734
+ */
67735
+ static analyzeReferences(expr2, target, varsKeys) {
67736
+ const engine = expr2.engine;
67737
+ const free = /* @__PURE__ */ new Set();
67738
+ const unsupported = /* @__PURE__ */ new Set();
67739
+ const foldedSeen = /* @__PURE__ */ new Set();
67740
+ const union2 = (a, more) => {
67741
+ const s = new Set(a);
67742
+ for (const m of more) s.add(m);
67743
+ return s;
67744
+ };
67745
+ const visit = (e, bound) => {
67746
+ if (isSymbol2(e)) {
67747
+ const s = e.symbol;
67748
+ if (bound.has(s)) return;
67749
+ if (target.operators?.(s) !== void 0) return;
67750
+ if (varsKeys?.has(s)) {
67751
+ free.add(s);
67752
+ return;
67753
+ }
67754
+ const value = engine._getSymbolValue(s);
67755
+ if (value !== void 0) {
67756
+ if (!foldedSeen.has(s)) {
67757
+ foldedSeen.add(s);
67758
+ visit(value, bound);
67759
+ }
67760
+ return;
67761
+ }
67762
+ free.add(s);
67763
+ return;
67764
+ }
67765
+ if (!isFunction2(e)) return;
67766
+ const h = e.operator;
67767
+ const ops = e.ops;
67768
+ if (h !== "Error" && !_BaseCompiler.STRUCTURAL_HEADS.has(h) && target.functions?.(h) === void 0 && target.operators?.(h) === void 0)
67769
+ unsupported.add(h);
67770
+ if (h === "Function") {
67771
+ const params = ops.slice(1).filter((p) => isSymbol2(p)).map((p) => p.symbol);
67772
+ visit(ops[0], params.length ? union2(bound, params) : bound);
67773
+ return;
67774
+ }
67775
+ if (h === "Sum" || h === "Product" || h === "Integrate" || h === "Loop") {
67776
+ const indices = [];
67777
+ const limitExprs = [];
67778
+ for (const clause of ops.slice(1)) {
67779
+ if (isFunction2(clause)) {
67780
+ if (isSymbol2(clause.ops[0])) indices.push(clause.ops[0].symbol);
67781
+ for (const sub2 of clause.ops.slice(1)) limitExprs.push(sub2);
67782
+ } else {
67783
+ limitExprs.push(clause);
67784
+ }
67785
+ }
67786
+ visit(ops[0], indices.length ? union2(bound, indices) : bound);
67787
+ for (const le of limitExprs) visit(le, bound);
67788
+ return;
67789
+ }
67790
+ if (h === "Block") {
67791
+ const locals = [];
67792
+ for (const stmt of ops)
67793
+ if (isFunction2(stmt, "Declare") && isSymbol2(stmt.ops[0]))
67794
+ locals.push(stmt.ops[0].symbol);
67795
+ const inner = locals.length ? union2(bound, locals) : bound;
67796
+ for (const op of ops) visit(op, inner);
67797
+ return;
67798
+ }
67799
+ for (const op of ops) visit(op, bound);
67800
+ };
67801
+ visit(expr2, /* @__PURE__ */ new Set());
67802
+ return { freeSymbols: [...free], unsupported: [...unsupported] };
67803
+ }
67804
+ /**
67805
+ * Attach `freeSymbols` / `unsupported` (from `analyzeReferences`) to a
67806
+ * compilation result, returning the same object. Used by the built-in
67807
+ * targets to make every result carry its declarative reference analysis.
67808
+ */
67809
+ static withReferences(result, expr2, target, varsKeys) {
67810
+ return Object.assign(
67811
+ result,
67812
+ _BaseCompiler.analyzeReferences(expr2, target, varsKeys)
67813
+ );
67814
+ }
67637
67815
  /**
67638
67816
  * Generate a temporary variable name
67639
67817
  */
@@ -67863,11 +68041,16 @@ Error in definition of "${name}"`,
67863
68041
  try {
67864
68042
  if (options?.target) {
67865
68043
  const code = BaseCompiler.compile(expr2, options.target);
67866
- return {
67867
- target: options.target.language ?? "custom",
67868
- success: true,
67869
- code
67870
- };
68044
+ return BaseCompiler.withReferences(
68045
+ {
68046
+ target: options.target.language ?? "custom",
68047
+ success: true,
68048
+ code
68049
+ },
68050
+ expr2,
68051
+ options.target,
68052
+ options.vars ? new Set(Object.keys(options.vars)) : void 0
68053
+ );
67871
68054
  }
67872
68055
  const targetName = options?.to ?? "javascript";
67873
68056
  const languageTarget = expr2.engine.getCompilationTarget(targetName);
@@ -67886,11 +68069,26 @@ Error in definition of "${name}"`,
67886
68069
  });
67887
68070
  } catch (e) {
67888
68071
  if (options?.fallback ?? true) {
68072
+ const error = e.message;
67889
68073
  console.warn(
67890
- `Compilation fallback for "${expr2.operator}" (target: ${options?.to ?? "javascript"}): ${e.message}`
68074
+ `Compilation fallback for "${expr2.operator}" (target: ${options?.to ?? "javascript"}): ${error}`
67891
68075
  );
67892
68076
  const ce = expr2.engine;
67893
68077
  const target = options?.to ?? "javascript";
68078
+ let refs = {
68079
+ freeSymbols: [],
68080
+ unsupported: []
68081
+ };
68082
+ try {
68083
+ const compileTarget = options?.target ?? expr2.engine.getCompilationTarget(target)?.createTarget();
68084
+ if (compileTarget)
68085
+ refs = BaseCompiler.analyzeReferences(
68086
+ expr2,
68087
+ compileTarget,
68088
+ options?.vars ? new Set(Object.keys(options.vars)) : void 0
68089
+ );
68090
+ } catch {
68091
+ }
67894
68092
  if (isFunction2(expr2, "Function")) {
67895
68093
  const lambdaRun = ((...args) => ce.function("Apply", [expr2, ...args.map((a) => ce.expr(a))]).evaluate().re);
67896
68094
  return {
@@ -67898,7 +68096,9 @@ Error in definition of "${name}"`,
67898
68096
  success: false,
67899
68097
  code: "",
67900
68098
  calling: "lambda",
67901
- run: lambdaRun
68099
+ run: lambdaRun,
68100
+ error,
68101
+ ...refs
67902
68102
  };
67903
68103
  }
67904
68104
  const fallbackRun = ((vars) => {
@@ -67917,7 +68117,9 @@ Error in definition of "${name}"`,
67917
68117
  success: false,
67918
68118
  code: "",
67919
68119
  calling: "expression",
67920
- run: fallbackRun
68120
+ run: fallbackRun,
68121
+ error,
68122
+ ...refs
67921
68123
  };
67922
68124
  }
67923
68125
  throw e;
@@ -73443,6 +73645,10 @@ Error in definition of "${name}"`,
73443
73645
 
73444
73646
  // src/compute-engine/compilation/constant-folding.ts
73445
73647
  function formatFloat(n) {
73648
+ if (!Number.isFinite(n))
73649
+ throw new Error(
73650
+ `Cannot compile the non-finite value \`${n}\` to a GPU shader: GLSL/WGSL have no infinity or NaN literals.`
73651
+ );
73446
73652
  const str = n.toString();
73447
73653
  if (!str.includes(".") && !str.includes("e") && !str.includes("E")) {
73448
73654
  return `${str}.0`;
@@ -74038,6 +74244,7 @@ Error in definition of "${name}"`,
74038
74244
  Erf: "_SYS.erf",
74039
74245
  Erfc: "_SYS.erfc",
74040
74246
  ErfInv: "_SYS.erfInv",
74247
+ Erfi: "_SYS.erfi",
74041
74248
  // Special functions
74042
74249
  Beta: "_SYS.beta",
74043
74250
  Digamma: "_SYS.digamma",
@@ -74053,6 +74260,30 @@ Error in definition of "${name}"`,
74053
74260
  // Airy functions
74054
74261
  AiryAi: "_SYS.airyAi",
74055
74262
  AiryBi: "_SYS.airyBi",
74263
+ // Exponential / trigonometric / logarithmic integrals. These are the closed
74264
+ // forms the antiderivative engine emits (e.g. ∫sin x/x dx = SinIntegral(x)),
74265
+ // so an "evaluate then compile" pipeline must be able to lower them.
74266
+ SinIntegral: "_SYS.sinIntegral",
74267
+ CosIntegral: "_SYS.cosIntegral",
74268
+ ExpIntegralEi: "_SYS.expIntegralEi",
74269
+ LogIntegral: "_SYS.logIntegral",
74270
+ // Arithmetic-geometric mean and elliptic integrals (parameter convention
74271
+ // m = k², as in the library). `AGM`, `EllipticE`, and `EllipticPi` are
74272
+ // arity-overloaded — the handlers mirror the library's evaluate dispatch.
74273
+ AGM: (args, compile3) => args.length === 1 ? `_SYS.agm(1, ${compile3(args[0])})` : `_SYS.agm(${compile3(args[0])}, ${compile3(args[1])})`,
74274
+ EllipticK: "_SYS.ellipticK",
74275
+ EllipticE: (args, compile3) => args.length === 2 ? `_SYS.ellipticEIncomplete(${compile3(args[0])}, ${compile3(args[1])})` : `_SYS.ellipticE(${compile3(args[0])})`,
74276
+ EllipticF: (args, compile3) => `_SYS.ellipticF(${compile3(args[0])}, ${compile3(args[1])})`,
74277
+ EllipticPi: (args, compile3) => args.length === 3 ? `_SYS.ellipticPiIncomplete(${compile3(args[0])}, ${compile3(
74278
+ args[1]
74279
+ )}, ${compile3(args[2])})` : `_SYS.ellipticPiComplete(${compile3(args[0])}, ${compile3(args[1])})`,
74280
+ // Hypergeometric functions.
74281
+ Hypergeometric2F1: (args, compile3) => `_SYS.hypergeometric2F1(${compile3(args[0])}, ${compile3(args[1])}, ${compile3(
74282
+ args[2]
74283
+ )}, ${compile3(args[3])})`,
74284
+ Hypergeometric1F1: (args, compile3) => `_SYS.hypergeometric1F1(${compile3(args[0])}, ${compile3(args[1])}, ${compile3(
74285
+ args[2]
74286
+ )})`,
74056
74287
  // Combinatorics
74057
74288
  Mandelbrot: ([c, maxIter], compile3) => {
74058
74289
  if (c === null || maxIter === null)
@@ -74065,6 +74296,8 @@ Error in definition of "${name}"`,
74065
74296
  return `_SYS.julia(${compile3(z)}, ${compile3(c)}, ${compile3(maxIter)})`;
74066
74297
  },
74067
74298
  Binomial: (args, compile3) => `_SYS.binomial(${compile3(args[0])}, ${compile3(args[1])})`,
74299
+ // Choose(n, k) is the binomial coefficient — same runtime helper.
74300
+ Choose: (args, compile3) => `_SYS.binomial(${compile3(args[0])}, ${compile3(args[1])})`,
74068
74301
  Fibonacci: "_SYS.fibonacci",
74069
74302
  // Complex-specific functions
74070
74303
  Real: (args, compile3) => {
@@ -74570,6 +74803,20 @@ Error in definition of "${name}"`,
74570
74803
  sinc,
74571
74804
  fresnelS,
74572
74805
  fresnelC,
74806
+ sinIntegral,
74807
+ cosIntegral,
74808
+ expIntegralEi,
74809
+ logIntegral,
74810
+ erfi,
74811
+ agm,
74812
+ ellipticK,
74813
+ ellipticE,
74814
+ ellipticEIncomplete,
74815
+ ellipticF,
74816
+ ellipticPiComplete,
74817
+ ellipticPiIncomplete,
74818
+ hypergeometric2F1,
74819
+ hypergeometric1F1,
74573
74820
  mandelbrot: (c, maxIter) => {
74574
74821
  let zx = 0, zy = 0;
74575
74822
  const cx = typeof c === "number" ? c : c.re;
@@ -74756,7 +75003,7 @@ Error in definition of "${name}"`,
74756
75003
  functions: (id) => namedFunctions?.[id] ? namedFunctions[id] : JAVASCRIPT_FUNCTIONS[id],
74757
75004
  var: (id) => {
74758
75005
  if (vars && id in vars) return JSON.stringify(vars[id]);
74759
- const result = {
75006
+ const result2 = {
74760
75007
  Pi: "Math.PI",
74761
75008
  ExponentialE: "Math.E",
74762
75009
  NaN: "Number.NaN",
@@ -74767,13 +75014,20 @@ Error in definition of "${name}"`,
74767
75014
  CatalanConstant: "0.91596559417721901",
74768
75015
  EulerGamma: "0.57721566490153286"
74769
75016
  }[id];
74770
- if (result !== void 0) return result;
75017
+ if (result2 !== void 0) return result2;
74771
75018
  if (unknowns.includes(id)) return `_.${id}`;
74772
- return void 0;
75019
+ if (expr2.engine._getSymbolValue(id) !== void 0) return void 0;
75020
+ return `_.${id}`;
74773
75021
  },
74774
75022
  preamble: (preamble ?? "") + preambleImports
74775
75023
  });
74776
- return compileToTarget(expr2, target, realOnly);
75024
+ const result = compileToTarget(expr2, target, realOnly);
75025
+ return BaseCompiler.withReferences(
75026
+ result,
75027
+ expr2,
75028
+ target,
75029
+ vars ? new Set(Object.keys(vars)) : void 0
75030
+ );
74777
75031
  }
74778
75032
  };
74779
75033
  function wrapRealOnly(result) {
@@ -77344,6 +77598,10 @@ fn _gpu_apca(lch_bg: vec3f, lch_fg: vec3f) -> f32 {
77344
77598
  EulerGamma: "0.57721566490"
77345
77599
  };
77346
77600
  function formatGPUNumber(n) {
77601
+ if (!Number.isFinite(n))
77602
+ throw new Error(
77603
+ `Cannot compile the non-finite value \`${n}\` to a GPU shader: GLSL/WGSL have no infinity or NaN literals.`
77604
+ );
77347
77605
  const str = n.toString();
77348
77606
  if (!str.includes(".") && !str.includes("e") && !str.includes("E")) {
77349
77607
  return `${str}.0`;
@@ -77371,7 +77629,7 @@ fn _gpu_apca(lch_bg: vec3f, lch_fg: vec3f) -> f32 {
77371
77629
  var: (id) => {
77372
77630
  if (id === "ImaginaryUnit") return `${v2}(0.0, 1.0)`;
77373
77631
  if (id in constants) return constants[id];
77374
- return id;
77632
+ return void 0;
77375
77633
  },
77376
77634
  string: (str) => JSON.stringify(str),
77377
77635
  number: formatGPUNumber,
@@ -77410,7 +77668,7 @@ fn _gpu_apca(lch_bg: vec3f, lch_fg: vec3f) -> f32 {
77410
77668
  if (vars && id in vars) return vars[id];
77411
77669
  if (id === "ImaginaryUnit") return `${v2}(0.0, 1.0)`;
77412
77670
  if (id in constants) return constants[id];
77413
- return id;
77671
+ return void 0;
77414
77672
  }
77415
77673
  });
77416
77674
  const code = BaseCompiler.compile(expr2, target);
@@ -77450,7 +77708,12 @@ fn _gpu_apca(lch_bg: vec3f, lch_fg: vec3f) -> f32 {
77450
77708
  preamble += this.languageId === "wgsl" ? GPU_COLOR_PREAMBLE_WGSL : GPU_COLOR_PREAMBLE_GLSL;
77451
77709
  }
77452
77710
  if (preamble) result.preamble = preamble;
77453
- return result;
77711
+ return BaseCompiler.withReferences(
77712
+ result,
77713
+ expr2,
77714
+ target,
77715
+ vars ? new Set(Object.keys(vars)) : void 0
77716
+ );
77454
77717
  }
77455
77718
  compileToSource(expr2, _options = {}) {
77456
77719
  const target = this.createTarget();
@@ -77483,6 +77746,8 @@ fn _gpu_apca(lch_bg: vec3f, lch_fg: vec3f) -> f32 {
77483
77746
  Tuple: compileGLSLList
77484
77747
  };
77485
77748
  var GLSLTarget = class extends GPUShaderTarget {
77749
+ // Annotated `string` (not the literal `'glsl'`) so subclasses such as
77750
+ // `IntervalGLSLTarget` can override it while reusing the GLSL shader assembly.
77486
77751
  languageId = "glsl";
77487
77752
  getLanguageSpecificFunctions() {
77488
77753
  return GLSL_FUNCTIONS;
@@ -79444,11 +79709,18 @@ ${workgroupAttr}fn main(${paramStr})${returnStr} {
79444
79709
  };
79445
79710
  if (id in constants) return constants[id];
79446
79711
  if (unknowns.includes(id)) return `_.${id}`;
79447
- return void 0;
79712
+ if (expr2.engine._getSymbolValue(id) !== void 0) return void 0;
79713
+ return `_.${id}`;
79448
79714
  },
79449
79715
  preamble: (preamble ?? "") + preambleImports
79450
79716
  });
79451
- return compileToIntervalTarget(expr2, target);
79717
+ const result = compileToIntervalTarget(expr2, target);
79718
+ return BaseCompiler.withReferences(
79719
+ result,
79720
+ expr2,
79721
+ target,
79722
+ vars ? new Set(Object.keys(vars)) : void 0
79723
+ );
79452
79724
  }
79453
79725
  };
79454
79726
  function compileToIntervalTarget(expr2, target) {
@@ -79472,6 +79744,532 @@ ${workgroupAttr}fn main(${paramStr})${returnStr} {
79472
79744
  };
79473
79745
  }
79474
79746
 
79747
+ // src/compute-engine/compilation/interval-glsl-target.ts
79748
+ var IV_INF = "1e18";
79749
+ var INTERVAL_GLSL_PREAMBLE = `
79750
+ const float IV_INF = ${IV_INF};
79751
+ const vec2 IV_ENTIRE = vec2(-IV_INF, IV_INF);
79752
+ const vec2 IV_EMPTY = vec2(IV_INF, -IV_INF);
79753
+
79754
+ bool _iv_is_empty(vec2 a) { return a.x > a.y; }
79755
+
79756
+ // Clamp bounds to the finite sentinel range. Preserves IV_EMPTY (its components
79757
+ // already sit at the sentinels) and folds any overflowed intermediate back to
79758
+ // the sentinel (min(inf, IV_INF) = IV_INF), so a real \`inf\` never escapes an op.
79759
+ vec2 _iv_clamp(vec2 a) { return clamp(a, -IV_INF, IV_INF); }
79760
+
79761
+ // Exact empty propagation: force empty if any operand is empty.
79762
+ vec2 _iv_guard1(vec2 r, vec2 a) { return _iv_is_empty(a) ? IV_EMPTY : r; }
79763
+ vec2 _iv_guard2(vec2 r, vec2 a, vec2 b) {
79764
+ return (_iv_is_empty(a) || _iv_is_empty(b)) ? IV_EMPTY : r;
79765
+ }
79766
+
79767
+ vec2 _iv_negate(vec2 a) { return _iv_guard1(_iv_clamp(vec2(-a.y, -a.x)), a); }
79768
+
79769
+ vec2 _iv_add(vec2 a, vec2 b) {
79770
+ return _iv_guard2(_iv_clamp(vec2(a.x + b.x, a.y + b.y)), a, b);
79771
+ }
79772
+
79773
+ vec2 _iv_sub(vec2 a, vec2 b) {
79774
+ return _iv_guard2(_iv_clamp(vec2(a.x - b.y, a.y - b.x)), a, b);
79775
+ }
79776
+
79777
+ vec2 _iv_mul(vec2 a, vec2 b) {
79778
+ float p1 = a.x * b.x, p2 = a.x * b.y, p3 = a.y * b.x, p4 = a.y * b.y;
79779
+ vec2 r = vec2(min(min(p1, p2), min(p3, p4)), max(max(p1, p2), max(p3, p4)));
79780
+ return _iv_guard2(_iv_clamp(r), a, b);
79781
+ }
79782
+
79783
+ vec2 _iv_div(vec2 a, vec2 b) {
79784
+ // Denominator spanning 0 \u2192 entire (wide, never narrow): the CPU pass turns
79785
+ // the pole into a proper asymptote break.
79786
+ bool spansZero = (b.x <= 0.0 && b.y >= 0.0);
79787
+ float q1 = a.x / b.x, q2 = a.x / b.y, q3 = a.y / b.x, q4 = a.y / b.y;
79788
+ vec2 r = vec2(min(min(q1, q2), min(q3, q4)), max(max(q1, q2), max(q3, q4)));
79789
+ r = spansZero ? IV_ENTIRE : r;
79790
+ return _iv_guard2(_iv_clamp(r), a, b);
79791
+ }
79792
+
79793
+ vec2 _iv_square(vec2 a) {
79794
+ float lo2 = a.x * a.x, hi2 = a.y * a.y;
79795
+ // Straddles 0 \u21D2 min is 0; otherwise the smaller endpoint\xB2 is the min.
79796
+ float lo = (a.x <= 0.0 && a.y >= 0.0) ? 0.0 : min(lo2, hi2);
79797
+ return _iv_guard1(_iv_clamp(vec2(lo, max(lo2, hi2))), a);
79798
+ }
79799
+
79800
+ // Scalar integer power that is correct for negative bases (GLSL \`pow\` requires
79801
+ // a non-negative base): keep the sign for odd exponents, drop it for even.
79802
+ float _iv_powi_scalar(float x, float n) {
79803
+ float a = pow(abs(x), n);
79804
+ return (mod(n, 2.0) == 1.0 && x < 0.0) ? -a : a;
79805
+ }
79806
+
79807
+ vec2 _iv_powi(vec2 a, float n) {
79808
+ float pl = _iv_powi_scalar(a.x, n);
79809
+ float ph = _iv_powi_scalar(a.y, n);
79810
+ bool even = (mod(n, 2.0) == 0.0);
79811
+ bool straddle = (a.x <= 0.0 && a.y >= 0.0);
79812
+ float lo = even ? (straddle ? 0.0 : min(pl, ph)) : pl;
79813
+ float hi = even ? max(pl, ph) : ph;
79814
+ return _iv_guard1(_iv_clamp(vec2(lo, hi)), a);
79815
+ }
79816
+
79817
+ // \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
79818
+
79819
+ vec2 _iv_abs(vec2 a) {
79820
+ float al = abs(a.x), ah = abs(a.y);
79821
+ bool straddle = (a.x <= 0.0 && a.y >= 0.0);
79822
+ return _iv_guard1(_iv_clamp(vec2(straddle ? 0.0 : min(al, ah), max(al, ah))), a);
79823
+ }
79824
+
79825
+ // Domain x \u2265 0: fully-negative box \u2192 empty; a box straddling 0 clamps lo to 0.
79826
+ vec2 _iv_sqrt(vec2 a) {
79827
+ vec2 r = vec2(sqrt(max(a.x, 0.0)), sqrt(max(a.y, 0.0)));
79828
+ r = (a.y < 0.0) ? IV_EMPTY : r;
79829
+ return _iv_guard1(_iv_clamp(r), a);
79830
+ }
79831
+
79832
+ vec2 _iv_exp(vec2 a) {
79833
+ return _iv_guard1(_iv_clamp(vec2(exp(a.x), exp(a.y))), a);
79834
+ }
79835
+
79836
+ // Domain x > 0: fully-\u22640 box \u2192 empty; straddling box \u2192 lo clamped to \u2212IV_INF
79837
+ // (ln \u2192 \u2212\u221E as x \u2192 0\u207A, never a real \u2212inf).
79838
+ vec2 _iv_ln(vec2 a) {
79839
+ vec2 r = vec2(a.x > 0.0 ? log(a.x) : -IV_INF, log(a.y));
79840
+ r = (a.y <= 0.0) ? IV_EMPTY : r;
79841
+ return _iv_guard1(_iv_clamp(r), a);
79842
+ }
79843
+
79844
+ const float _IV_INV_LN10 = 0.43429448190325176;
79845
+ const float _IV_INV_LN2 = 1.4426950408889634;
79846
+
79847
+ vec2 _iv_log10(vec2 a) {
79848
+ vec2 r = vec2(a.x > 0.0 ? log(a.x) * _IV_INV_LN10 : -IV_INF, log(a.y) * _IV_INV_LN10);
79849
+ r = (a.y <= 0.0) ? IV_EMPTY : r;
79850
+ return _iv_guard1(_iv_clamp(r), a);
79851
+ }
79852
+
79853
+ vec2 _iv_log2(vec2 a) {
79854
+ vec2 r = vec2(a.x > 0.0 ? log(a.x) * _IV_INV_LN2 : -IV_INF, log(a.y) * _IV_INV_LN2);
79855
+ r = (a.y <= 0.0) ? IV_EMPTY : r;
79856
+ return _iv_guard1(_iv_clamp(r), a);
79857
+ }
79858
+
79859
+ // Non-integer power. Real only for base \u2265 0: fully-negative box \u2192 empty; a box
79860
+ // straddling 0 clamps the base low end to 0. \`p\` is a compile-time constant, so
79861
+ // the \`p >= 0\` test is a constant branch.
79862
+ vec2 _iv_powf(vec2 a, float p) {
79863
+ float lob = max(a.x, 0.0);
79864
+ float e0 = pow(lob, p), e1 = pow(a.y, p);
79865
+ vec2 r = (p >= 0.0) ? vec2(e0, e1) : vec2(e1, e0);
79866
+ r = (a.y < 0.0) ? IV_EMPTY : r;
79867
+ return _iv_guard1(_iv_clamp(r), a);
79868
+ }
79869
+
79870
+ // \u2500\u2500 Phase 3: trigonometric & inverse-trigonometric functions \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
79871
+ // Mirrors interval-js (interval/trigonometric.ts): exact endpoints with
79872
+ // extremum snapping (no outward epsilon). Per the Option-A contract, a tan pole
79873
+ // yields \`entire\` (interval-js returns \`singular\`; entire \u2287 singular and the
79874
+ // CPU classifies the asymptote).
79875
+
79876
+ const float _IV_PI = 3.141592653589793;
79877
+ const float _IV_TWO_PI = 6.283185307179586;
79878
+ const float _IV_HALF_PI = 1.5707963267948966;
79879
+ const float _IV_THREE_HALF_PI = 4.71238898038469;
79880
+
79881
+ // True if [a] contains an extremum of the family { ext + n\xB7period }.
79882
+ bool _iv_has_ext(vec2 a, float ext, float period) {
79883
+ float n = ceil((a.x - ext) / period);
79884
+ float cand = ext + n * period;
79885
+ return cand >= a.x - 1e-15 && cand <= a.y + 1e-15;
79886
+ }
79887
+
79888
+ vec2 _iv_sin(vec2 a) {
79889
+ vec2 r;
79890
+ if (a.y - a.x >= _IV_TWO_PI) r = vec2(-1.0, 1.0);
79891
+ else {
79892
+ float sl = sin(a.x), sh = sin(a.y);
79893
+ float lo = min(sl, sh), hi = max(sl, sh);
79894
+ if (_iv_has_ext(a, _IV_HALF_PI, _IV_TWO_PI)) hi = 1.0;
79895
+ if (_iv_has_ext(a, _IV_THREE_HALF_PI, _IV_TWO_PI)) lo = -1.0;
79896
+ r = vec2(lo, hi);
79897
+ }
79898
+ return _iv_guard1(_iv_clamp(r), a);
79899
+ }
79900
+
79901
+ vec2 _iv_cos(vec2 a) {
79902
+ vec2 r;
79903
+ if (a.y - a.x >= _IV_TWO_PI) r = vec2(-1.0, 1.0);
79904
+ else {
79905
+ float cl = cos(a.x), ch = cos(a.y);
79906
+ float lo = min(cl, ch), hi = max(cl, ch);
79907
+ if (_iv_has_ext(a, 0.0, _IV_TWO_PI)) hi = 1.0;
79908
+ if (_iv_has_ext(a, _IV_PI, _IV_TWO_PI)) lo = -1.0;
79909
+ r = vec2(lo, hi);
79910
+ }
79911
+ return _iv_guard1(_iv_clamp(r), a);
79912
+ }
79913
+
79914
+ vec2 _iv_tan(vec2 a) {
79915
+ // A pole in the interval \u2192 entire (cannot exclude).
79916
+ bool pole =
79917
+ (a.y - a.x >= _IV_PI) || _iv_has_ext(a, _IV_HALF_PI, _IV_PI);
79918
+ float tl = tan(a.x), th = tan(a.y);
79919
+ // Floating-point branch-cross sanity (large opposite-sign endpoints).
79920
+ bool crossed = (tl > 1e10 && th < -1e10) || (tl < -1e10 && th > 1e10);
79921
+ vec2 r = (pole || crossed) ? IV_ENTIRE : vec2(tl, th);
79922
+ return _iv_guard1(_iv_clamp(r), a);
79923
+ }
79924
+
79925
+ // asin: domain [\u22121, 1]. Fully outside \u2192 empty; straddling clamps to the valid
79926
+ // sub-range. Monotonic increasing.
79927
+ vec2 _iv_asin(vec2 a) {
79928
+ vec2 r = vec2(asin(max(a.x, -1.0)), asin(min(a.y, 1.0)));
79929
+ r = (a.x > 1.0 || a.y < -1.0) ? IV_EMPTY : r;
79930
+ return _iv_guard1(_iv_clamp(r), a);
79931
+ }
79932
+
79933
+ // acos: domain [\u22121, 1], monotonic decreasing (bounds swap).
79934
+ vec2 _iv_acos(vec2 a) {
79935
+ vec2 r = vec2(acos(min(a.y, 1.0)), acos(max(a.x, -1.0)));
79936
+ r = (a.x > 1.0 || a.y < -1.0) ? IV_EMPTY : r;
79937
+ return _iv_guard1(_iv_clamp(r), a);
79938
+ }
79939
+
79940
+ vec2 _iv_atan(vec2 a) {
79941
+ return _iv_guard1(_iv_clamp(vec2(atan(a.x), atan(a.y))), a);
79942
+ }
79943
+
79944
+ // \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
79945
+ // Bounded jump-discontinuity functions return the TIGHT value-range enclosure
79946
+ // (sound, and excludable when the range misses 0) rather than \`entire\` \u2014 only
79947
+ // genuine poles are entire. Per the Option-A division of labor, the CPU still
79948
+ // classifies the discontinuity on the (kept) live cells; the GPU only needs a
79949
+ // sound bound for the exclusion test. These functions are monotone, so the
79950
+ // enclosure is just [f(lo), f(hi)] unless noted.
79951
+
79952
+ vec2 _iv_floor(vec2 a) { return _iv_guard1(_iv_clamp(vec2(floor(a.x), floor(a.y))), a); }
79953
+ vec2 _iv_ceil(vec2 a) { return _iv_guard1(_iv_clamp(vec2(ceil(a.x), ceil(a.y))), a); }
79954
+ vec2 _iv_round(vec2 a) { return _iv_guard1(_iv_clamp(vec2(floor(a.x + 0.5), floor(a.y + 0.5))), a); }
79955
+ vec2 _iv_trunc(vec2 a) { return _iv_guard1(_iv_clamp(vec2(trunc(a.x), trunc(a.y))), a); }
79956
+ vec2 _iv_sign(vec2 a) { return _iv_guard1(vec2(sign(a.x), sign(a.y)), a); }
79957
+
79958
+ vec2 _iv_heaviside(vec2 a) {
79959
+ float hl = a.x < 0.0 ? 0.0 : (a.x > 0.0 ? 1.0 : 0.5);
79960
+ float hh = a.y < 0.0 ? 0.0 : (a.y > 0.0 ? 1.0 : 0.5);
79961
+ return _iv_guard1(vec2(hl, hh), a);
79962
+ }
79963
+
79964
+ // fract(x) = x \u2212 floor(x): continuous within an integer cell, sawtooth across
79965
+ // one (\u2192 full [0, 1] range).
79966
+ vec2 _iv_fract(vec2 a) {
79967
+ float fl = floor(a.x);
79968
+ vec2 r = (fl == floor(a.y)) ? vec2(a.x - fl, a.y - fl) : vec2(0.0, 1.0);
79969
+ return _iv_guard1(_iv_clamp(r), a);
79970
+ }
79971
+
79972
+ vec2 _iv_min(vec2 a, vec2 b) {
79973
+ return _iv_guard2(_iv_clamp(vec2(min(a.x, b.x), min(a.y, b.y))), a, b);
79974
+ }
79975
+ vec2 _iv_max(vec2 a, vec2 b) {
79976
+ return _iv_guard2(_iv_clamp(vec2(max(a.x, b.x), max(a.y, b.y))), a, b);
79977
+ }
79978
+
79979
+ // mod(x, y) = x \u2212 y\xB7floor(x/y). A modulus straddling 0 is a pole \u2192 entire. For
79980
+ // a constant (point) modulus the fast path is exact; otherwise compose (the
79981
+ // tight floor keeps it sound).
79982
+ vec2 _iv_mod(vec2 a, vec2 b) {
79983
+ if (b.x <= 0.0 && b.y >= 0.0) return _iv_guard2(IV_ENTIRE, a, b);
79984
+ if (b.x == b.y) {
79985
+ float p = abs(b.x);
79986
+ float flo = floor(a.x / p);
79987
+ vec2 r = (flo == floor(a.y / p)) ? vec2(a.x - p * flo, a.y - p * flo)
79988
+ : vec2(0.0, p);
79989
+ return _iv_guard2(_iv_clamp(r), a, b);
79990
+ }
79991
+ return _iv_sub(a, _iv_mul(b, _iv_floor(_iv_div(a, b))));
79992
+ }
79993
+ `;
79994
+ var INTERVAL_GLSL_FUNCTIONS = {
79995
+ Add: (args, compile3) => {
79996
+ if (args.length === 0) return "vec2(0.0, 0.0)";
79997
+ let r = compile3(args[0]);
79998
+ for (let i = 1; i < args.length; i++)
79999
+ r = `_iv_add(${r}, ${compile3(args[i])})`;
80000
+ return r;
80001
+ },
80002
+ Subtract: ([a, b], compile3) => {
80003
+ if (a === null || b === null) throw new Error("Subtract: missing argument");
80004
+ return `_iv_sub(${compile3(a)}, ${compile3(b)})`;
80005
+ },
80006
+ Multiply: (args, compile3) => {
80007
+ if (args.length === 0) return "vec2(1.0, 1.0)";
80008
+ let r = compile3(args[0]);
80009
+ for (let i = 1; i < args.length; i++)
80010
+ r = `_iv_mul(${r}, ${compile3(args[i])})`;
80011
+ return r;
80012
+ },
80013
+ Divide: ([a, b], compile3) => {
80014
+ if (a === null || b === null) throw new Error("Divide: missing argument");
80015
+ return `_iv_div(${compile3(a)}, ${compile3(b)})`;
80016
+ },
80017
+ Negate: ([a], compile3) => {
80018
+ if (a === null) throw new Error("Negate: no argument");
80019
+ return `_iv_negate(${compile3(a)})`;
80020
+ },
80021
+ Square: ([a], compile3) => {
80022
+ if (a === null) throw new Error("Square: no argument");
80023
+ return `_iv_square(${compile3(a)})`;
80024
+ },
80025
+ Sqrt: ([a], compile3) => {
80026
+ if (a === null) throw new Error("Sqrt: no argument");
80027
+ return `_iv_sqrt(${compile3(a)})`;
80028
+ },
80029
+ Abs: ([a], compile3) => {
80030
+ if (a === null) throw new Error("Abs: no argument");
80031
+ return `_iv_abs(${compile3(a)})`;
80032
+ },
80033
+ Exp: ([a], compile3) => {
80034
+ if (a === null) throw new Error("Exp: no argument");
80035
+ return `_iv_exp(${compile3(a)})`;
80036
+ },
80037
+ Ln: ([a], compile3) => {
80038
+ if (a === null) throw new Error("Ln: no argument");
80039
+ return `_iv_ln(${compile3(a)})`;
80040
+ },
80041
+ Log: (args, compile3) => {
80042
+ if (args.length === 1) return `_iv_log10(${compile3(args[0])})`;
80043
+ return `_iv_div(_iv_ln(${compile3(args[0])}), _iv_ln(${compile3(args[1])}))`;
80044
+ },
80045
+ Lb: ([a], compile3) => {
80046
+ if (a === null) throw new Error("Lb: no argument");
80047
+ return `_iv_log2(${compile3(a)})`;
80048
+ },
80049
+ Sin: ([a], compile3) => {
80050
+ if (a === null) throw new Error("Sin: no argument");
80051
+ return `_iv_sin(${compile3(a)})`;
80052
+ },
80053
+ Cos: ([a], compile3) => {
80054
+ if (a === null) throw new Error("Cos: no argument");
80055
+ return `_iv_cos(${compile3(a)})`;
80056
+ },
80057
+ Tan: ([a], compile3) => {
80058
+ if (a === null) throw new Error("Tan: no argument");
80059
+ return `_iv_tan(${compile3(a)})`;
80060
+ },
80061
+ Arcsin: ([a], compile3) => {
80062
+ if (a === null) throw new Error("Arcsin: no argument");
80063
+ return `_iv_asin(${compile3(a)})`;
80064
+ },
80065
+ Arccos: ([a], compile3) => {
80066
+ if (a === null) throw new Error("Arccos: no argument");
80067
+ return `_iv_acos(${compile3(a)})`;
80068
+ },
80069
+ Arctan: ([a], compile3) => {
80070
+ if (a === null) throw new Error("Arctan: no argument");
80071
+ return `_iv_atan(${compile3(a)})`;
80072
+ },
80073
+ Floor: ([a], compile3) => {
80074
+ if (a === null) throw new Error("Floor: no argument");
80075
+ return `_iv_floor(${compile3(a)})`;
80076
+ },
80077
+ Ceil: ([a], compile3) => {
80078
+ if (a === null) throw new Error("Ceil: no argument");
80079
+ return `_iv_ceil(${compile3(a)})`;
80080
+ },
80081
+ Round: ([a], compile3) => {
80082
+ if (a === null) throw new Error("Round: no argument");
80083
+ return `_iv_round(${compile3(a)})`;
80084
+ },
80085
+ Truncate: ([a], compile3) => {
80086
+ if (a === null) throw new Error("Truncate: no argument");
80087
+ return `_iv_trunc(${compile3(a)})`;
80088
+ },
80089
+ Fract: ([a], compile3) => {
80090
+ if (a === null) throw new Error("Fract: no argument");
80091
+ return `_iv_fract(${compile3(a)})`;
80092
+ },
80093
+ Sign: ([a], compile3) => {
80094
+ if (a === null) throw new Error("Sign: no argument");
80095
+ return `_iv_sign(${compile3(a)})`;
80096
+ },
80097
+ Heaviside: ([a], compile3) => {
80098
+ if (a === null) throw new Error("Heaviside: no argument");
80099
+ return `_iv_heaviside(${compile3(a)})`;
80100
+ },
80101
+ Mod: ([a, b], compile3) => {
80102
+ if (a === null || b === null) throw new Error("Mod: missing argument");
80103
+ return `_iv_mod(${compile3(a)}, ${compile3(b)})`;
80104
+ },
80105
+ Min: (args, compile3) => {
80106
+ if (args.length === 0) throw new Error("Min: no argument");
80107
+ let r = compile3(args[0]);
80108
+ for (let i = 1; i < args.length; i++)
80109
+ r = `_iv_min(${r}, ${compile3(args[i])})`;
80110
+ return r;
80111
+ },
80112
+ Max: (args, compile3) => {
80113
+ if (args.length === 0) throw new Error("Max: no argument");
80114
+ let r = compile3(args[0]);
80115
+ for (let i = 1; i < args.length; i++)
80116
+ r = `_iv_max(${r}, ${compile3(args[i])})`;
80117
+ return r;
80118
+ },
80119
+ Power: ([base, exp3], compile3) => {
80120
+ if (base === null || exp3 === null)
80121
+ throw new Error("Power: missing argument");
80122
+ if (isSymbol2(base, "ExponentialE")) return `_iv_exp(${compile3(exp3)})`;
80123
+ if (isNumber(exp3) && exp3.im === 0) {
80124
+ const v = exp3.re;
80125
+ if (v === 0.5) return `_iv_sqrt(${compile3(base)})`;
80126
+ if (v === 2) return `_iv_square(${compile3(base)})`;
80127
+ if (Number.isInteger(v) && v >= 0)
80128
+ return `_iv_powi(${compile3(base)}, ${formatGPUNumber(v)})`;
80129
+ if (!Number.isInteger(v) && v > 0)
80130
+ return `_iv_powf(${compile3(base)}, ${formatGPUNumber(v)})`;
80131
+ throw new Error(
80132
+ `interval-glsl: Power with exponent \`${exp3.toString()}\` is not yet supported`
80133
+ );
80134
+ }
80135
+ throw new Error(
80136
+ "interval-glsl: Power with a variable exponent is not yet supported"
80137
+ );
80138
+ }
80139
+ };
80140
+ var INTERVAL_GLSL_CONSTANTS = {
80141
+ Pi: "vec2(3.14159265359, 3.14159265359)",
80142
+ ExponentialE: "vec2(2.71828182846, 2.71828182846)",
80143
+ GoldenRatio: "vec2(1.61803398875, 1.61803398875)",
80144
+ CatalanConstant: "vec2(0.91596559417, 0.91596559417)",
80145
+ EulerGamma: "vec2(0.57721566490, 0.57721566490)"
80146
+ };
80147
+ var IntervalGLSLTarget = class extends GLSLTarget {
80148
+ languageId = "interval-glsl";
80149
+ getOperators() {
80150
+ return {};
80151
+ }
80152
+ getFunctions() {
80153
+ return INTERVAL_GLSL_FUNCTIONS;
80154
+ }
80155
+ getConstants() {
80156
+ return INTERVAL_GLSL_CONSTANTS;
80157
+ }
80158
+ createTarget(options = {}) {
80159
+ return super.createTarget({
80160
+ operators: () => void 0,
80161
+ functions: (id) => INTERVAL_GLSL_FUNCTIONS[id],
80162
+ number: (n) => `vec2(${formatGPUNumber(n)}, ${formatGPUNumber(n)})`,
80163
+ complex: () => {
80164
+ throw new Error("interval-glsl: complex values are not supported");
80165
+ },
80166
+ var: (id) => INTERVAL_GLSL_CONSTANTS[id],
80167
+ ...options
80168
+ });
80169
+ }
80170
+ compile(expr2, options = {}) {
80171
+ const { vars } = options;
80172
+ const target = this.createTarget({
80173
+ var: (id) => {
80174
+ if (vars && id in vars) return vars[id];
80175
+ if (id in INTERVAL_GLSL_CONSTANTS) return INTERVAL_GLSL_CONSTANTS[id];
80176
+ return void 0;
80177
+ }
80178
+ });
80179
+ const code = BaseCompiler.compile(expr2, target);
80180
+ const result = {
80181
+ target: "interval-glsl",
80182
+ success: true,
80183
+ code
80184
+ };
80185
+ if (code.includes("_iv_")) result.preamble = INTERVAL_GLSL_PREAMBLE;
80186
+ return BaseCompiler.withReferences(
80187
+ result,
80188
+ expr2,
80189
+ target,
80190
+ vars ? new Set(Object.keys(vars)) : void 0
80191
+ );
80192
+ }
80193
+ /**
80194
+ * Emit a complete, self-contained GLSL fragment shader implementing the
80195
+ * **interval exclusion oracle** for the implicit curve `f = 0` (Phase 4).
80196
+ *
80197
+ * The shader is structured so the core contract — the interval evaluator —
80198
+ * is cleanly separable from the render harness:
80199
+ *
80200
+ * - `vec2 _implicit(<vec2 per free variable>)` evaluates the interval of `f`
80201
+ * over a cell box (this is the part that matters; it is identical to
80202
+ * `compile(expr).code` wrapped in a function).
80203
+ * - `main()` is a **reference harness**: it derives each fragment's cell box
80204
+ * from `gl_FragCoord` and the viewport uniforms, evaluates `_implicit`, and
80205
+ * writes the exclusion result. The renderer is free to replace `main()` /
80206
+ * the uniforms with its own conventions and keep `_implicit`.
80207
+ *
80208
+ * The first free variable maps to `u_domainX`, the second to `u_domainY`
80209
+ * (≤ 2 free variables; a 2D implicit curve). The exclusion predicate is
80210
+ * `f.lo > 0 || f.hi < 0` — which also excludes the `empty` (domain-undefined)
80211
+ * interval, since its `lo` is the `+IV_INF` sentinel.
80212
+ *
80213
+ * @throws if the expression has more than two free variables, or cannot be
80214
+ * lowered (an unsupported head propagates from `BaseCompiler.compile`).
80215
+ */
80216
+ compileExclusionShader(expr2, options = {}) {
80217
+ const { version: version2 = "300 es", precision = "highp" } = options;
80218
+ const compiled = this.compile(expr2);
80219
+ const vars = compiled.freeSymbols ?? [];
80220
+ if (vars.length > 2)
80221
+ throw new Error(
80222
+ `interval-glsl exclusion shader supports at most 2 free variables (got ${vars.length}: ${vars.join(", ")})`
80223
+ );
80224
+ const params = vars.map((v) => `vec2 ${v}`).join(", ");
80225
+ const [axisX, axisY] = vars;
80226
+ const main = ["void main() {"];
80227
+ main.push(" vec2 _cell = gl_FragCoord.xy / u_resolution;");
80228
+ main.push(" vec2 _step = 1.0 / u_resolution;");
80229
+ const callArgs = [];
80230
+ if (axisX !== void 0) {
80231
+ main.push(" float _xlo = mix(u_domainX.x, u_domainX.y, _cell.x);");
80232
+ main.push(
80233
+ " float _xhi = mix(u_domainX.x, u_domainX.y, _cell.x + _step.x);"
80234
+ );
80235
+ callArgs.push("vec2(_xlo, _xhi)");
80236
+ }
80237
+ if (axisY !== void 0) {
80238
+ main.push(" float _ylo = mix(u_domainY.x, u_domainY.y, _cell.y);");
80239
+ main.push(
80240
+ " float _yhi = mix(u_domainY.x, u_domainY.y, _cell.y + _step.y);"
80241
+ );
80242
+ callArgs.push("vec2(_ylo, _yhi)");
80243
+ }
80244
+ main.push(` vec2 _f = _implicit(${callArgs.join(", ")});`);
80245
+ main.push(" bool _excluded = (_f.x > 0.0 || _f.y < 0.0);");
80246
+ main.push(
80247
+ " fragColor = _excluded ? vec4(0.0, 0.0, 0.0, 1.0) : vec4(1.0);"
80248
+ );
80249
+ main.push("}");
80250
+ return [
80251
+ `#version ${version2}`,
80252
+ `precision ${precision} float;`,
80253
+ "",
80254
+ INTERVAL_GLSL_PREAMBLE.trim(),
80255
+ "",
80256
+ "uniform vec2 u_domainX; // [min, max] for the 1st free variable",
80257
+ "uniform vec2 u_domainY; // [min, max] for the 2nd free variable",
80258
+ "uniform vec2 u_resolution; // render target size, in pixels",
80259
+ "",
80260
+ "out vec4 fragColor;",
80261
+ "",
80262
+ "// Interval evaluation of the implicit field f over a cell box.",
80263
+ `vec2 _implicit(${params}) {`,
80264
+ ` return ${compiled.code};`,
80265
+ "}",
80266
+ "",
80267
+ main.join("\n"),
80268
+ ""
80269
+ ].join("\n");
80270
+ }
80271
+ };
80272
+
79475
80273
  // src/compute-engine/engine-compilation-targets.ts
79476
80274
  var CompilationTargetRegistry = class {
79477
80275
  _targets = /* @__PURE__ */ new Map();
@@ -79494,6 +80292,7 @@ ${workgroupAttr}fn main(${paramStr})${returnStr} {
79494
80292
  this.register("glsl", new GLSLTarget());
79495
80293
  this.register("wgsl", new WGSLTarget());
79496
80294
  this.register("interval-js", new IntervalJavaScriptTarget());
80295
+ this.register("interval-glsl", new IntervalGLSLTarget());
79497
80296
  }
79498
80297
  };
79499
80298
 
@@ -79611,6 +80410,20 @@ ${workgroupAttr}fn main(${paramStr})${returnStr} {
79611
80410
  if (engine.strict && !isValidSymbol(name))
79612
80411
  return engine.error(["invalid-symbol", validateSymbol(name)], name);
79613
80412
  if (!canonical2) return new BoxedSymbol(engine, name, { metadata });
80413
+ if (engine._isShadowedParameter(name)) {
80414
+ let pdef = engine.lookupDefinition(name);
80415
+ if (!pdef || isValueDef(pdef) && pdef.value.isConstant) {
80416
+ let autoScope2 = engine.context.lexicalScope;
80417
+ while (autoScope2.noAutoDeclare && autoScope2.parent)
80418
+ autoScope2 = autoScope2.parent;
80419
+ pdef = engine._declareSymbolValue(
80420
+ name,
80421
+ { type: "unknown", inferred: true },
80422
+ autoScope2
80423
+ );
80424
+ }
80425
+ return new BoxedSymbol(engine, name, { metadata, def: pdef });
80426
+ }
79614
80427
  const result = commonSymbols[name];
79615
80428
  if (result) return result;
79616
80429
  let def = engine.lookupDefinition(name);
@@ -80362,7 +81175,17 @@ ${workgroupAttr}fn main(${paramStr})${returnStr} {
80362
81175
  */
80363
81176
  compile(expr2, options = {}) {
80364
81177
  const code = this.compileToSource(expr2, options);
80365
- return { target: "python", success: true, code };
81178
+ const result = {
81179
+ target: "python",
81180
+ success: true,
81181
+ code
81182
+ };
81183
+ return BaseCompiler.withReferences(
81184
+ result,
81185
+ expr2,
81186
+ this.createTarget(),
81187
+ options.vars ? new Set(Object.keys(options.vars)) : void 0
81188
+ );
80366
81189
  }
80367
81190
  /**
80368
81191
  * Compile an expression to Python source code
@@ -82718,6 +83541,24 @@ ${code}`;
82718
83541
  _printStack(options) {
82719
83542
  printStack(this, options);
82720
83543
  }
83544
+ /** Stack of parameter-name sets active while canonicalizing function bodies.
83545
+ * @internal */
83546
+ _shadowedParameterStack = [];
83547
+ /** @internal */
83548
+ _pushShadowedParameters(names) {
83549
+ this._shadowedParameterStack.push(new Set(names));
83550
+ }
83551
+ /** @internal */
83552
+ _popShadowedParameters() {
83553
+ this._shadowedParameterStack.pop();
83554
+ }
83555
+ /** @internal */
83556
+ _isShadowedParameter(name) {
83557
+ const stack = this._shadowedParameterStack;
83558
+ for (let i = stack.length - 1; i >= 0; i--)
83559
+ if (stack[i].has(name)) return true;
83560
+ return false;
83561
+ }
82721
83562
  /**
82722
83563
  * Use `ce.expr(name)` instead
82723
83564
  * @internal */
@@ -83137,14 +83978,14 @@ ${code}`;
83137
83978
  _setDefaultEngineFactory(() => new ComputeEngine());
83138
83979
 
83139
83980
  // src/compute-engine.ts
83140
- var version = "0.60.0";
83981
+ var version = "0.61.0";
83141
83982
  ComputeEngine._latexSyntaxFactory = () => new LatexSyntax();
83142
83983
  _setDefaultEngineFactory(
83143
83984
  () => new ComputeEngine({ latexSyntax: new LatexSyntax() })
83144
83985
  );
83145
83986
  globalThis[/* @__PURE__ */ Symbol.for("io.cortexjs.compute-engine")] = {
83146
83987
  ComputeEngine: ComputeEngine.prototype.constructor,
83147
- version: "0.60.0"
83988
+ version: "0.61.0"
83148
83989
  };
83149
83990
  return __toCommonJS(compute_engine_exports);
83150
83991
  })();