@cortex-js/compute-engine 0.55.5 → 0.55.6

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 (258) hide show
  1. package/dist/compile.esm.js +138 -633
  2. package/dist/compile.min.esm.js +71 -493
  3. package/dist/compile.min.umd.cjs +71 -493
  4. package/dist/compile.umd.cjs +138 -633
  5. package/dist/compute-engine.esm.js +227 -651
  6. package/dist/compute-engine.min.esm.js +68 -489
  7. package/dist/compute-engine.min.umd.cjs +68 -489
  8. package/dist/compute-engine.umd.cjs +227 -651
  9. package/dist/core.esm.js +226 -650
  10. package/dist/core.min.esm.js +66 -487
  11. package/dist/core.min.umd.cjs +67 -488
  12. package/dist/core.umd.cjs +226 -650
  13. package/dist/interval.esm.js +136 -60
  14. package/dist/interval.min.esm.js +7 -7
  15. package/dist/interval.min.umd.cjs +7 -7
  16. package/dist/interval.umd.cjs +136 -60
  17. package/dist/latex-syntax.esm.js +219 -74
  18. package/dist/latex-syntax.min.esm.js +7 -6
  19. package/dist/latex-syntax.min.umd.cjs +7 -6
  20. package/dist/latex-syntax.umd.cjs +219 -74
  21. package/dist/math-json.esm.js +2 -2
  22. package/dist/math-json.min.esm.js +2 -2
  23. package/dist/math-json.min.umd.cjs +2 -2
  24. package/dist/math-json.umd.cjs +2 -2
  25. package/dist/numerics.esm.js +2 -2
  26. package/dist/numerics.min.esm.js +2 -2
  27. package/dist/numerics.min.umd.cjs +2 -2
  28. package/dist/numerics.umd.cjs +2 -2
  29. package/dist/types/big-decimal/big-decimal.d.ts +1 -1
  30. package/dist/types/big-decimal/index.d.ts +1 -1
  31. package/dist/types/big-decimal/transcendentals.d.ts +1 -1
  32. package/dist/types/big-decimal/utils.d.ts +1 -1
  33. package/dist/types/common/ansi-codes.d.ts +1 -1
  34. package/dist/types/common/configuration-change.d.ts +1 -1
  35. package/dist/types/common/fuzzy-string-match.d.ts +1 -1
  36. package/dist/types/common/grapheme-splitter.d.ts +1 -1
  37. package/dist/types/common/interruptible.d.ts +1 -1
  38. package/dist/types/common/one-of.d.ts +1 -1
  39. package/dist/types/common/signals.d.ts +1 -1
  40. package/dist/types/common/type/ast-nodes.d.ts +1 -1
  41. package/dist/types/common/type/boxed-type.d.ts +1 -1
  42. package/dist/types/common/type/lexer.d.ts +1 -1
  43. package/dist/types/common/type/parse.d.ts +1 -1
  44. package/dist/types/common/type/parser.d.ts +1 -1
  45. package/dist/types/common/type/primitive.d.ts +1 -1
  46. package/dist/types/common/type/reduce.d.ts +1 -1
  47. package/dist/types/common/type/serialize.d.ts +1 -1
  48. package/dist/types/common/type/subtype.d.ts +1 -1
  49. package/dist/types/common/type/type-builder.d.ts +1 -1
  50. package/dist/types/common/type/types.d.ts +1 -1
  51. package/dist/types/common/type/utils.d.ts +1 -1
  52. package/dist/types/common/utils.d.ts +1 -1
  53. package/dist/types/compile.d.ts +1 -1
  54. package/dist/types/compute-engine/assume.d.ts +1 -1
  55. package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +1 -1
  56. package/dist/types/compute-engine/boxed-expression/apply.d.ts +1 -1
  57. package/dist/types/compute-engine/boxed-expression/arithmetic-add.d.ts +1 -1
  58. package/dist/types/compute-engine/boxed-expression/arithmetic-mul-div.d.ts +1 -1
  59. package/dist/types/compute-engine/boxed-expression/arithmetic-power.d.ts +1 -1
  60. package/dist/types/compute-engine/boxed-expression/ascii-math.d.ts +1 -1
  61. package/dist/types/compute-engine/boxed-expression/box.d.ts +1 -1
  62. package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +1 -1
  63. package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +1 -1
  64. package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +1 -1
  65. package/dist/types/compute-engine/boxed-expression/boxed-operator-definition.d.ts +1 -1
  66. package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +1 -1
  67. package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +1 -1
  68. package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +1 -1
  69. package/dist/types/compute-engine/boxed-expression/boxed-tensor.d.ts +1 -1
  70. package/dist/types/compute-engine/boxed-expression/boxed-value-definition.d.ts +1 -1
  71. package/dist/types/compute-engine/boxed-expression/cache.d.ts +1 -1
  72. package/dist/types/compute-engine/boxed-expression/canonical-utils.d.ts +1 -1
  73. package/dist/types/compute-engine/boxed-expression/canonical.d.ts +1 -1
  74. package/dist/types/compute-engine/boxed-expression/compare.d.ts +1 -1
  75. package/dist/types/compute-engine/boxed-expression/constants.d.ts +1 -1
  76. package/dist/types/compute-engine/boxed-expression/expand.d.ts +1 -1
  77. package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +1 -1
  78. package/dist/types/compute-engine/boxed-expression/factor.d.ts +1 -1
  79. package/dist/types/compute-engine/boxed-expression/flatten.d.ts +1 -1
  80. package/dist/types/compute-engine/boxed-expression/hold.d.ts +1 -1
  81. package/dist/types/compute-engine/boxed-expression/inequality-bounds.d.ts +1 -1
  82. package/dist/types/compute-engine/boxed-expression/init-lazy-refs.d.ts +1 -1
  83. package/dist/types/compute-engine/boxed-expression/invisible-operator.d.ts +1 -1
  84. package/dist/types/compute-engine/boxed-expression/match.d.ts +1 -1
  85. package/dist/types/compute-engine/boxed-expression/negate.d.ts +1 -1
  86. package/dist/types/compute-engine/boxed-expression/numerics.d.ts +1 -1
  87. package/dist/types/compute-engine/boxed-expression/order.d.ts +1 -1
  88. package/dist/types/compute-engine/boxed-expression/pattern-utils.d.ts +1 -1
  89. package/dist/types/compute-engine/boxed-expression/polynomial-degree.d.ts +1 -1
  90. package/dist/types/compute-engine/boxed-expression/polynomials.d.ts +1 -1
  91. package/dist/types/compute-engine/boxed-expression/predicates.d.ts +1 -1
  92. package/dist/types/compute-engine/boxed-expression/rules.d.ts +1 -1
  93. package/dist/types/compute-engine/boxed-expression/serialize.d.ts +1 -1
  94. package/dist/types/compute-engine/boxed-expression/sgn.d.ts +1 -1
  95. package/dist/types/compute-engine/boxed-expression/simplify.d.ts +1 -1
  96. package/dist/types/compute-engine/boxed-expression/solve-linear-system.d.ts +1 -1
  97. package/dist/types/compute-engine/boxed-expression/solve.d.ts +1 -1
  98. package/dist/types/compute-engine/boxed-expression/stochastic-equal.d.ts +1 -1
  99. package/dist/types/compute-engine/boxed-expression/trigonometry.d.ts +1 -1
  100. package/dist/types/compute-engine/boxed-expression/type-guards.d.ts +1 -1
  101. package/dist/types/compute-engine/boxed-expression/utils.d.ts +1 -1
  102. package/dist/types/compute-engine/boxed-expression/validate.d.ts +1 -1
  103. package/dist/types/compute-engine/collection-utils.d.ts +1 -1
  104. package/dist/types/compute-engine/compilation/base-compiler.d.ts +1 -1
  105. package/dist/types/compute-engine/compilation/compile-expression.d.ts +2 -3
  106. package/dist/types/compute-engine/compilation/constant-folding.d.ts +1 -1
  107. package/dist/types/compute-engine/compilation/glsl-target.d.ts +1 -1
  108. package/dist/types/compute-engine/compilation/gpu-target.d.ts +1 -54
  109. package/dist/types/compute-engine/compilation/interval-javascript-target.d.ts +1 -1
  110. package/dist/types/compute-engine/compilation/javascript-target.d.ts +1 -1
  111. package/dist/types/compute-engine/compilation/python-target.d.ts +1 -1
  112. package/dist/types/compute-engine/compilation/types.d.ts +1 -67
  113. package/dist/types/compute-engine/compilation/wgsl-target.d.ts +1 -1
  114. package/dist/types/compute-engine/cost-function.d.ts +1 -1
  115. package/dist/types/compute-engine/engine-assumptions.d.ts +1 -1
  116. package/dist/types/compute-engine/engine-cache.d.ts +1 -1
  117. package/dist/types/compute-engine/engine-common-symbols.d.ts +1 -1
  118. package/dist/types/compute-engine/engine-compilation-targets.d.ts +1 -1
  119. package/dist/types/compute-engine/engine-configuration-lifecycle.d.ts +1 -1
  120. package/dist/types/compute-engine/engine-declarations.d.ts +1 -1
  121. package/dist/types/compute-engine/engine-expression-entrypoints.d.ts +1 -1
  122. package/dist/types/compute-engine/engine-extension-contracts.d.ts +1 -1
  123. package/dist/types/compute-engine/engine-library-bootstrap.d.ts +1 -1
  124. package/dist/types/compute-engine/engine-numeric-configuration.d.ts +1 -1
  125. package/dist/types/compute-engine/engine-runtime-state.d.ts +1 -1
  126. package/dist/types/compute-engine/engine-scope.d.ts +1 -1
  127. package/dist/types/compute-engine/engine-sequences.d.ts +1 -1
  128. package/dist/types/compute-engine/engine-simplification-rules.d.ts +1 -1
  129. package/dist/types/compute-engine/engine-startup-coordinator.d.ts +1 -1
  130. package/dist/types/compute-engine/engine-type-resolver.d.ts +1 -1
  131. package/dist/types/compute-engine/engine-validation-entrypoints.d.ts +1 -1
  132. package/dist/types/compute-engine/free-functions.d.ts +1 -1
  133. package/dist/types/compute-engine/function-utils.d.ts +1 -1
  134. package/dist/types/compute-engine/global-types.d.ts +1 -1
  135. package/dist/types/compute-engine/index.d.ts +2 -2
  136. package/dist/types/compute-engine/interval/arithmetic.d.ts +1 -1
  137. package/dist/types/compute-engine/interval/comparison.d.ts +1 -1
  138. package/dist/types/compute-engine/interval/elementary.d.ts +1 -1
  139. package/dist/types/compute-engine/interval/index.d.ts +1 -1
  140. package/dist/types/compute-engine/interval/trigonometric.d.ts +1 -1
  141. package/dist/types/compute-engine/interval/types.d.ts +1 -1
  142. package/dist/types/compute-engine/interval/util.d.ts +1 -1
  143. package/dist/types/compute-engine/latex-syntax/dictionary/default-dictionary.d.ts +1 -1
  144. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-algebra.d.ts +1 -1
  145. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-arithmetic.d.ts +1 -1
  146. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-calculus.d.ts +1 -1
  147. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-complex.d.ts +1 -1
  148. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-core.d.ts +1 -1
  149. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-linear-algebra.d.ts +1 -1
  150. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-logic.d.ts +1 -1
  151. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-other.d.ts +1 -1
  152. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-relational-operators.d.ts +1 -1
  153. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-sets.d.ts +1 -1
  154. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-statistics.d.ts +1 -1
  155. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-symbols.d.ts +1 -1
  156. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-trigonometry.d.ts +1 -1
  157. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-units.d.ts +1 -1
  158. package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +1 -1
  159. package/dist/types/compute-engine/latex-syntax/dictionary/indexed-types.d.ts +1 -1
  160. package/dist/types/compute-engine/latex-syntax/latex-syntax.d.ts +1 -1
  161. package/dist/types/compute-engine/latex-syntax/parse-number.d.ts +1 -1
  162. package/dist/types/compute-engine/latex-syntax/parse-symbol.d.ts +1 -1
  163. package/dist/types/compute-engine/latex-syntax/parse.d.ts +1 -1
  164. package/dist/types/compute-engine/latex-syntax/serialize-dms.d.ts +1 -1
  165. package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +1 -1
  166. package/dist/types/compute-engine/latex-syntax/serializer-style.d.ts +1 -1
  167. package/dist/types/compute-engine/latex-syntax/serializer.d.ts +4 -2
  168. package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +1 -1
  169. package/dist/types/compute-engine/latex-syntax/types.d.ts +1 -1
  170. package/dist/types/compute-engine/latex-syntax/utils.d.ts +1 -1
  171. package/dist/types/compute-engine/library/arithmetic.d.ts +1 -1
  172. package/dist/types/compute-engine/library/calculus.d.ts +1 -1
  173. package/dist/types/compute-engine/library/collections.d.ts +1 -1
  174. package/dist/types/compute-engine/library/colors.d.ts +1 -1
  175. package/dist/types/compute-engine/library/combinatorics.d.ts +1 -1
  176. package/dist/types/compute-engine/library/complex.d.ts +1 -1
  177. package/dist/types/compute-engine/library/control-structures.d.ts +1 -1
  178. package/dist/types/compute-engine/library/core.d.ts +1 -1
  179. package/dist/types/compute-engine/library/fractals.d.ts +1 -1
  180. package/dist/types/compute-engine/library/library.d.ts +1 -1
  181. package/dist/types/compute-engine/library/linear-algebra.d.ts +1 -1
  182. package/dist/types/compute-engine/library/logic-analysis.d.ts +1 -1
  183. package/dist/types/compute-engine/library/logic.d.ts +1 -1
  184. package/dist/types/compute-engine/library/number-theory.d.ts +1 -1
  185. package/dist/types/compute-engine/library/polynomials.d.ts +1 -1
  186. package/dist/types/compute-engine/library/quantity-arithmetic.d.ts +1 -1
  187. package/dist/types/compute-engine/library/random-expression.d.ts +1 -1
  188. package/dist/types/compute-engine/library/relational-operator.d.ts +1 -1
  189. package/dist/types/compute-engine/library/sets.d.ts +1 -1
  190. package/dist/types/compute-engine/library/statistics.d.ts +1 -1
  191. package/dist/types/compute-engine/library/trigonometry.d.ts +1 -1
  192. package/dist/types/compute-engine/library/type-handlers.d.ts +1 -1
  193. package/dist/types/compute-engine/library/unit-data.d.ts +1 -1
  194. package/dist/types/compute-engine/library/units.d.ts +1 -1
  195. package/dist/types/compute-engine/library/utils.d.ts +1 -1
  196. package/dist/types/compute-engine/numeric-value/big-numeric-value.d.ts +1 -1
  197. package/dist/types/compute-engine/numeric-value/exact-numeric-value.d.ts +1 -1
  198. package/dist/types/compute-engine/numeric-value/machine-numeric-value.d.ts +1 -1
  199. package/dist/types/compute-engine/numeric-value/types.d.ts +1 -1
  200. package/dist/types/compute-engine/numerics/bigint.d.ts +1 -1
  201. package/dist/types/compute-engine/numerics/expression.d.ts +1 -1
  202. package/dist/types/compute-engine/numerics/interval.d.ts +1 -1
  203. package/dist/types/compute-engine/numerics/linear-algebra.d.ts +1 -1
  204. package/dist/types/compute-engine/numerics/monte-carlo.d.ts +1 -1
  205. package/dist/types/compute-engine/numerics/numeric-bigint.d.ts +1 -1
  206. package/dist/types/compute-engine/numerics/numeric-bignum.d.ts +1 -1
  207. package/dist/types/compute-engine/numerics/numeric-complex.d.ts +1 -1
  208. package/dist/types/compute-engine/numerics/numeric.d.ts +1 -1
  209. package/dist/types/compute-engine/numerics/primes.d.ts +1 -1
  210. package/dist/types/compute-engine/numerics/rationals.d.ts +1 -1
  211. package/dist/types/compute-engine/numerics/richardson.d.ts +1 -1
  212. package/dist/types/compute-engine/numerics/special-functions.d.ts +1 -1
  213. package/dist/types/compute-engine/numerics/statistics.d.ts +1 -1
  214. package/dist/types/compute-engine/numerics/strings.d.ts +1 -1
  215. package/dist/types/compute-engine/numerics/types.d.ts +1 -1
  216. package/dist/types/compute-engine/numerics/unit-data.d.ts +1 -1
  217. package/dist/types/compute-engine/oeis.d.ts +1 -1
  218. package/dist/types/compute-engine/sequence.d.ts +1 -1
  219. package/dist/types/compute-engine/symbolic/antiderivative.d.ts +1 -1
  220. package/dist/types/compute-engine/symbolic/derivative.d.ts +1 -1
  221. package/dist/types/compute-engine/symbolic/distribute.d.ts +1 -1
  222. package/dist/types/compute-engine/symbolic/fu-cost.d.ts +1 -1
  223. package/dist/types/compute-engine/symbolic/fu-transforms.d.ts +1 -1
  224. package/dist/types/compute-engine/symbolic/fu.d.ts +1 -1
  225. package/dist/types/compute-engine/symbolic/logic-utils.d.ts +1 -1
  226. package/dist/types/compute-engine/symbolic/simplify-abs.d.ts +1 -1
  227. package/dist/types/compute-engine/symbolic/simplify-divide.d.ts +1 -1
  228. package/dist/types/compute-engine/symbolic/simplify-factorial.d.ts +1 -1
  229. package/dist/types/compute-engine/symbolic/simplify-hyperbolic.d.ts +1 -1
  230. package/dist/types/compute-engine/symbolic/simplify-infinity.d.ts +1 -1
  231. package/dist/types/compute-engine/symbolic/simplify-log.d.ts +1 -1
  232. package/dist/types/compute-engine/symbolic/simplify-logic.d.ts +1 -1
  233. package/dist/types/compute-engine/symbolic/simplify-power.d.ts +1 -1
  234. package/dist/types/compute-engine/symbolic/simplify-product.d.ts +1 -1
  235. package/dist/types/compute-engine/symbolic/simplify-rules.d.ts +1 -1
  236. package/dist/types/compute-engine/symbolic/simplify-sum.d.ts +1 -1
  237. package/dist/types/compute-engine/symbolic/simplify-trig.d.ts +1 -1
  238. package/dist/types/compute-engine/tensor/tensor-fields.d.ts +1 -1
  239. package/dist/types/compute-engine/tensor/tensors.d.ts +1 -1
  240. package/dist/types/compute-engine/types-definitions.d.ts +1 -1
  241. package/dist/types/compute-engine/types-engine.d.ts +1 -1
  242. package/dist/types/compute-engine/types-evaluation.d.ts +1 -1
  243. package/dist/types/compute-engine/types-expression.d.ts +1 -1
  244. package/dist/types/compute-engine/types-kernel-evaluation.d.ts +1 -1
  245. package/dist/types/compute-engine/types-kernel-serialization.d.ts +1 -1
  246. package/dist/types/compute-engine/types-serialization.d.ts +1 -1
  247. package/dist/types/compute-engine/types.d.ts +1 -1
  248. package/dist/types/compute-engine.d.ts +2 -2
  249. package/dist/types/core.d.ts +1 -1
  250. package/dist/types/interval.d.ts +1 -1
  251. package/dist/types/latex-syntax.d.ts +2 -2
  252. package/dist/types/math-json/symbols.d.ts +1 -1
  253. package/dist/types/math-json/types.d.ts +1 -1
  254. package/dist/types/math-json/utils.d.ts +1 -1
  255. package/dist/types/math-json.d.ts +2 -2
  256. package/dist/types/numerics.d.ts +1 -1
  257. package/package.json +1 -1
  258. package/dist/types/compute-engine/compilation/fractal-orbit.d.ts +0 -19
package/dist/core.umd.cjs CHANGED
@@ -1,4 +1,4 @@
1
- /** ComputeEngineCore 0.55.5 */
1
+ /** ComputeEngineCore 0.55.6 */
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.ComputeEngineCore = {}));})(this, (function (exports) { 'use strict';
3
3
  var ComputeEngineCore = (() => {
4
4
  var __defProp = Object.defineProperty;
@@ -11084,10 +11084,6 @@ var ComputeEngineCore = (() => {
11084
11084
  // Lagrange notation
11085
11085
  {
11086
11086
  name: "Derivative",
11087
- // @todo: Leibniz notation: {% latex " \\frac{d^n}{dx^n} f(x)" %}
11088
- // @todo: Euler modified notation: This notation is used by Mathematica. The Euler notation uses `D` instead of
11089
- // `\partial`: `\partial_{x} f`, `\partial_{x,y} f`
11090
- // Newton notation (\dot{v}, \ddot{v}) is implemented below
11091
11087
  serialize: (serializer, expr2) => {
11092
11088
  const degree = machineValue(operand(expr2, 2)) ?? 1;
11093
11089
  const base = serializer.serialize(operand(expr2, 1));
@@ -12125,14 +12121,18 @@ var ComputeEngineCore = (() => {
12125
12121
  return ["Complement", lhs];
12126
12122
  }
12127
12123
  // precedence: 240,
12128
- // @todo: serialize for the multiple argument case
12129
12124
  },
12130
12125
  {
12131
12126
  name: "Complement",
12132
12127
  latexTrigger: ["^", "<{>", "\\complement", "<}>"],
12133
- kind: "postfix"
12128
+ kind: "postfix",
12134
12129
  // precedence: 240,
12135
- // @todo: serialize for the multiple argument case
12130
+ serialize: (serializer, expr2) => {
12131
+ return joinLatex([
12132
+ serializer.serialize(operand(expr2, 1)),
12133
+ "^\\complement"
12134
+ ]);
12135
+ }
12136
12136
  },
12137
12137
  {
12138
12138
  name: "Intersection",
@@ -12219,7 +12219,6 @@ var ComputeEngineCore = (() => {
12219
12219
  // commands like \rbrack a, b \rbrack which are unambiguous.
12220
12220
  {
12221
12221
  name: "Multiple",
12222
- // @todo: parse
12223
12222
  serialize: serializeSet
12224
12223
  },
12225
12224
  {
@@ -12228,14 +12227,28 @@ var ComputeEngineCore = (() => {
12228
12227
  kind: "infix",
12229
12228
  precedence: 350
12230
12229
  },
12230
+ // \mid as a separator/operator (used in set-builder notation: {x \mid x > 0})
12231
+ // Low precedence so it binds loosely — everything on each side is parsed first
12232
+ {
12233
+ name: "Divides",
12234
+ latexTrigger: ["\\mid"],
12235
+ kind: "infix",
12236
+ precedence: 160
12237
+ },
12231
12238
  {
12232
12239
  name: "Set",
12233
12240
  kind: "matchfix",
12234
12241
  openTrigger: "{",
12235
12242
  closeTrigger: "}",
12236
- // @todo: the set syntax can also include conditions...
12237
12243
  parse: (_parser, body) => {
12238
12244
  if (isEmptySequence(body)) return "EmptySet";
12245
+ const h = operator(body);
12246
+ if (h === "Divides" || h === "Colon") {
12247
+ const expr2 = operand(body, 1);
12248
+ const condition = operand(body, 2);
12249
+ if (expr2 !== null && condition !== null)
12250
+ return ["Set", expr2, ["Condition", condition]];
12251
+ }
12239
12252
  if (operator(body) == "Delimiter" && stringValue(operand(body, 2)) === ",") {
12240
12253
  body = operand(body, 1);
12241
12254
  }
@@ -12243,6 +12256,17 @@ var ComputeEngineCore = (() => {
12243
12256
  return ["Set", ...operands(body)];
12244
12257
  },
12245
12258
  serialize: (serializer, expr2) => {
12259
+ if (nops(expr2) === 2 && operator(operand(expr2, 2)) === "Condition") {
12260
+ const condition = operand(expr2, 2);
12261
+ return joinLatex([
12262
+ "\\lbrace",
12263
+ serializer.serialize(operand(expr2, 1)),
12264
+ "\\mid",
12265
+ // Serialize the inner expression of the Condition wrapper
12266
+ serializer.serialize(operand(condition, 1)),
12267
+ "\\rbrace"
12268
+ ]);
12269
+ }
12246
12270
  return joinLatex([
12247
12271
  "\\lbrace",
12248
12272
  operands(expr2).map((x) => serializer.serialize(x)).join(", "),
@@ -12409,23 +12433,6 @@ var ComputeEngineCore = (() => {
12409
12433
  if (expr2 === null) return "";
12410
12434
  const h = operator(expr2);
12411
12435
  if (!h) return "";
12412
- if (h === "Set") {
12413
- if (nops(expr2) === 0) return "\\emptyset";
12414
- if (nops(expr2) === 2 && operator(operand(expr2, 2)) === "Condition") {
12415
- return joinLatex([
12416
- "\\left\\lbrace",
12417
- serializer.serialize(operand(expr2, 1)),
12418
- "\\middle\\mid",
12419
- serializer.serialize(operand(expr2, 2)),
12420
- "\\right\\rbrace"
12421
- ]);
12422
- }
12423
- return joinLatex([
12424
- "\\left\\lbrace",
12425
- ...operands(expr2).map((x) => serializer.serialize(x) + " ,"),
12426
- "\\right\\rbrace"
12427
- ]);
12428
- }
12429
12436
  if (h === "Multiple") {
12430
12437
  }
12431
12438
  if (h === "Range") {
@@ -13573,11 +13580,13 @@ var ComputeEngineCore = (() => {
13573
13580
  if (!parser.match("_")) return null;
13574
13581
  const base = parser.parseGroup();
13575
13582
  if (operator(base) !== "To") return null;
13576
- const expr2 = parser.parseArguments("implicit");
13583
+ const expr2 = parser.parseExpression({
13584
+ minPrec: MULTIPLICATION_PRECEDENCE
13585
+ });
13577
13586
  if (!expr2) return null;
13578
13587
  return [
13579
13588
  "Limit",
13580
- ["Function", expr2[0], operand(base, 1)],
13589
+ ["Function", expr2, operand(base, 1)],
13581
13590
  operand(base, 2)
13582
13591
  ];
13583
13592
  },
@@ -15874,12 +15883,52 @@ var ComputeEngineCore = (() => {
15874
15883
  ];
15875
15884
 
15876
15885
  // src/compute-engine/latex-syntax/dictionary/definitions-other.ts
15886
+ var TEX_UNITS = [
15887
+ "pt",
15888
+ "em",
15889
+ "mu",
15890
+ "ex",
15891
+ "mm",
15892
+ "cm",
15893
+ "in",
15894
+ "bp",
15895
+ "sp",
15896
+ "dd",
15897
+ "cc",
15898
+ "pc",
15899
+ "nc",
15900
+ "nd"
15901
+ ];
15902
+ function skipTexDimension(parser) {
15903
+ parser.skipSpace();
15904
+ if (parser.peek === "-" || parser.peek === "+") parser.nextToken();
15905
+ while (/^[\d.]$/.test(parser.peek)) parser.nextToken();
15906
+ for (const unit of TEX_UNITS) {
15907
+ if (parser.matchAll([...unit])) return;
15908
+ }
15909
+ }
15877
15910
  function parseSingleArg(cmd) {
15878
15911
  return (parser) => {
15879
15912
  const arg = parser.parseGroup();
15880
15913
  return arg === null ? [cmd] : [cmd, arg];
15881
15914
  };
15882
15915
  }
15916
+ function parseMathStyleSwitch(mathStyle) {
15917
+ return (parser) => {
15918
+ const body = parser.parseExpression();
15919
+ if (body !== null && !isEmptySequence(body))
15920
+ return ["Annotated", body, { dict: { mathStyle } }];
15921
+ return "Nothing";
15922
+ };
15923
+ }
15924
+ function parseSizeSwitch(size) {
15925
+ return (parser) => {
15926
+ const body = parser.parseExpression();
15927
+ if (body !== null && !isEmptySequence(body))
15928
+ return ["Annotated", body, { dict: { size } }];
15929
+ return "Nothing";
15930
+ };
15931
+ }
15883
15932
  var DEFINITIONS_OTHERS = [
15884
15933
  {
15885
15934
  name: "Overscript",
@@ -16119,80 +16168,71 @@ var ComputeEngineCore = (() => {
16119
16168
  },
16120
16169
  {
16121
16170
  latexTrigger: ["\\displaystyle"],
16122
- parse: () => "Nothing"
16123
- // @todo: parse as ['Annotated'...]
16171
+ parse: parseMathStyleSwitch("normal")
16124
16172
  },
16125
16173
  {
16126
16174
  latexTrigger: ["\\textstyle"],
16127
- parse: () => "Nothing"
16128
- // @todo: parse as ['Annotated'...]
16175
+ parse: parseMathStyleSwitch("compact")
16129
16176
  },
16130
16177
  {
16131
16178
  latexTrigger: ["\\scriptstyle"],
16132
- parse: () => "Nothing"
16133
- // @todo: parse as ['Annotated'...]
16179
+ parse: parseMathStyleSwitch("script")
16134
16180
  },
16135
16181
  {
16136
16182
  latexTrigger: ["\\scriptscriptstyle"],
16137
- parse: () => "Nothing"
16138
- // @todo: parse as ['Annotated'...]
16183
+ parse: parseMathStyleSwitch("scriptscript")
16139
16184
  },
16140
16185
  {
16141
16186
  latexTrigger: ["\\color"],
16142
16187
  parse: (parser) => {
16143
- parser.parseGroup();
16188
+ const color = parser.parseStringGroup();
16189
+ if (color !== null) {
16190
+ const body = parser.parseExpression();
16191
+ if (body !== null && !isEmptySequence(body))
16192
+ return ["Annotated", body, { dict: { color } }];
16193
+ }
16144
16194
  return "Nothing";
16145
16195
  }
16146
16196
  },
16147
16197
  {
16148
16198
  latexTrigger: ["\\tiny"],
16149
- parse: () => "Nothing"
16150
- // @todo: parse as ['Annotated'...]
16199
+ parse: parseSizeSwitch(1)
16151
16200
  },
16152
16201
  {
16153
16202
  latexTrigger: ["\\scriptsize"],
16154
- parse: () => "Nothing"
16155
- // @todo: parse as ['Annotated'...]
16203
+ parse: parseSizeSwitch(2)
16156
16204
  },
16157
16205
  {
16158
16206
  latexTrigger: ["\\footnotesize"],
16159
- parse: () => "Nothing"
16160
- // @todo: parse as ['Annotated'...]
16207
+ parse: parseSizeSwitch(3)
16161
16208
  },
16162
16209
  {
16163
16210
  latexTrigger: ["\\small"],
16164
- parse: () => "Nothing"
16165
- // @todo: parse as ['Annotated'...]
16211
+ parse: parseSizeSwitch(4)
16166
16212
  },
16167
16213
  {
16168
16214
  latexTrigger: ["\\normalsize"],
16169
- parse: () => "Nothing"
16170
- // @todo: parse as ['Annotated'...]
16215
+ parse: parseSizeSwitch(5)
16171
16216
  },
16172
16217
  {
16173
16218
  latexTrigger: ["\\large"],
16174
- parse: () => "Nothing"
16175
- // @todo: parse as ['Annotated'...]
16219
+ parse: parseSizeSwitch(6)
16176
16220
  },
16177
16221
  {
16178
16222
  latexTrigger: ["\\Large"],
16179
- parse: () => "Nothing"
16180
- // @todo: parse as ['Annotated'...]
16223
+ parse: parseSizeSwitch(7)
16181
16224
  },
16182
16225
  {
16183
16226
  latexTrigger: ["\\LARGE"],
16184
- parse: () => "Nothing"
16185
- // @todo: parse as ['Annotated'...]
16227
+ parse: parseSizeSwitch(8)
16186
16228
  },
16187
16229
  {
16188
16230
  latexTrigger: ["\\huge"],
16189
- parse: () => "Nothing"
16190
- // @todo: parse as ['Annotated'...]
16231
+ parse: parseSizeSwitch(9)
16191
16232
  },
16192
16233
  {
16193
16234
  latexTrigger: ["\\Huge"],
16194
- parse: () => "Nothing"
16195
- // @todo: parse as ['Annotated'...]
16235
+ parse: parseSizeSwitch(10)
16196
16236
  },
16197
16237
  {
16198
16238
  name: "Annotated",
@@ -16204,6 +16244,10 @@ var ComputeEngineCore = (() => {
16204
16244
  result = joinLatex(["{\\displaystyle", result, "}"]);
16205
16245
  else if (dict.dict.mathStyle === "compact")
16206
16246
  result = joinLatex(["{\\textstyle", result, "}"]);
16247
+ else if (dict.dict.mathStyle === "script")
16248
+ result = joinLatex(["{\\scriptstyle", result, "}"]);
16249
+ else if (dict.dict.mathStyle === "scriptscript")
16250
+ result = joinLatex(["{\\scriptscriptstyle", result, "}"]);
16207
16251
  const v = dict.dict.size;
16208
16252
  if (v !== null && v >= 1 && v <= 10) {
16209
16253
  result = joinLatex([
@@ -16291,6 +16335,28 @@ var ComputeEngineCore = (() => {
16291
16335
  latexTrigger: ["\\enspace"],
16292
16336
  parse: () => ["HorizontalSpacing", 9]
16293
16337
  },
16338
+ {
16339
+ latexTrigger: ["\\hspace"],
16340
+ parse: (parser) => {
16341
+ if (parser.peek === "*") parser.nextToken();
16342
+ parser.parseStringGroup();
16343
+ return ["HorizontalSpacing", 0];
16344
+ }
16345
+ },
16346
+ {
16347
+ latexTrigger: ["\\hskip"],
16348
+ parse: (parser) => {
16349
+ skipTexDimension(parser);
16350
+ return ["HorizontalSpacing", 0];
16351
+ }
16352
+ },
16353
+ {
16354
+ latexTrigger: ["\\kern"],
16355
+ parse: (parser) => {
16356
+ skipTexDimension(parser);
16357
+ return ["HorizontalSpacing", 0];
16358
+ }
16359
+ },
16294
16360
  {
16295
16361
  latexTrigger: ["\\phantom"],
16296
16362
  parse: (parser) => {
@@ -16341,7 +16407,17 @@ var ComputeEngineCore = (() => {
16341
16407
  // `["HorizontalSpacing", expr, 'op'|'bin'|rel]` -> indicate a spacing around and expression, i.e. `\mathbin{x}`, etc...
16342
16408
  serialize: (serializer, expr2) => {
16343
16409
  if (operand(expr2, 2) !== null) {
16344
- return serializer.serialize(operand(expr2, 1));
16410
+ const cls = stringValue(operand(expr2, 2));
16411
+ const inner = serializer.serialize(operand(expr2, 1));
16412
+ if (cls === "bin") return `\\mathbin{${inner}}`;
16413
+ if (cls === "op") return `\\mathop{${inner}}`;
16414
+ if (cls === "rel") return `\\mathrel{${inner}}`;
16415
+ if (cls === "ord") return `\\mathord{${inner}}`;
16416
+ if (cls === "open") return `\\mathopen{${inner}}`;
16417
+ if (cls === "close") return `\\mathclose{${inner}}`;
16418
+ if (cls === "punct") return `\\mathpunct{${inner}}`;
16419
+ if (cls === "inner") return `\\mathinner{${inner}}`;
16420
+ return inner;
16345
16421
  }
16346
16422
  const v = machineValue(operand(expr2, 1));
16347
16423
  if (v === null) return "";
@@ -16732,25 +16808,47 @@ var ComputeEngineCore = (() => {
16732
16808
  result.arguments = entry.arguments;
16733
16809
  return result;
16734
16810
  }
16811
+ function serializeTabularBody(serializer, body) {
16812
+ if (!body) return "";
16813
+ if (operator(body) !== "List") return serializer.serialize(body);
16814
+ const rows = operands(body);
16815
+ if (rows.length === 0) return "";
16816
+ if (!rows.every((row) => operator(row) === "List"))
16817
+ return serializer.serialize(body);
16818
+ return rows.map(
16819
+ (row) => operands(row).map((cell) => serializer.serialize(cell)).join(" & ")
16820
+ ).join(" \\\\\n");
16821
+ }
16735
16822
  function makeSerializeHandler(entry, latexTrigger, idTrigger) {
16736
16823
  if (typeof entry.serialize === "function") return entry.serialize;
16737
16824
  const kind = entry["kind"] ?? "expression";
16738
16825
  if (kind === "environment") {
16739
16826
  const envName = entry["symbolTrigger"] ?? entry.name ?? "unknown";
16740
- return (serializer, expr2) => joinLatex([
16741
- `\\begin{${envName}}`,
16742
- serializer.serialize(operand(expr2, 1)),
16743
- `\\end{${envName}}`
16744
- ]);
16827
+ return (serializer, expr2) => {
16828
+ const body = operand(expr2, 1);
16829
+ return joinLatex([
16830
+ `\\begin{${envName}}`,
16831
+ serializeTabularBody(serializer, body),
16832
+ `\\end{${envName}}`
16833
+ ]);
16834
+ };
16745
16835
  }
16746
16836
  if (isMatchfixEntry(entry)) {
16747
16837
  const openDelim = typeof entry.openTrigger === "string" ? DEFAULT_DELIMITER[entry.openTrigger] : tokensToString(entry.openTrigger);
16748
16838
  const closeDelim = typeof entry.closeTrigger === "string" ? DEFAULT_DELIMITER[entry.closeTrigger] : tokensToString(entry.closeTrigger);
16749
- return (serializer, expr2) => joinLatex([
16750
- openDelim,
16751
- serializer.serialize(operand(expr2, 1)),
16752
- closeDelim
16753
- ]);
16839
+ return (serializer, expr2) => {
16840
+ const style = serializer.groupStyle(expr2, serializer.level + 1);
16841
+ const inner = serializer.serialize(operand(expr2, 1));
16842
+ if (style === "scaled")
16843
+ return joinLatex([`\\left${openDelim}`, inner, `\\right${closeDelim}`]);
16844
+ if (style === "big")
16845
+ return joinLatex([
16846
+ `\\Bigl${openDelim}`,
16847
+ inner,
16848
+ `\\Bigr${closeDelim}`
16849
+ ]);
16850
+ return joinLatex([openDelim, inner, closeDelim]);
16851
+ };
16754
16852
  }
16755
16853
  let latex = entry.serialize;
16756
16854
  if (latex === void 0 && latexTrigger) latex = tokensToString(latexTrigger);
@@ -17635,6 +17733,16 @@ var ComputeEngineCore = (() => {
17635
17733
  }
17636
17734
 
17637
17735
  // src/compute-engine/latex-syntax/parse.ts
17736
+ var _symbolToUnicode = null;
17737
+ function getSymbolToUnicode() {
17738
+ if (!_symbolToUnicode) {
17739
+ _symbolToUnicode = /* @__PURE__ */ new Map();
17740
+ for (const [, latex, codepoint] of SYMBOLS2) {
17741
+ _symbolToUnicode.set(latex, String.fromCodePoint(codepoint));
17742
+ }
17743
+ }
17744
+ return _symbolToUnicode;
17745
+ }
17638
17746
  var DELIMITER_SHORTHAND2 = {
17639
17747
  "(": ["\\lparen", "("],
17640
17748
  ")": ["\\rparen", ")"],
@@ -18082,6 +18190,35 @@ var ComputeEngineCore = (() => {
18082
18190
  this.nextToken();
18083
18191
  this.skipVisualSpace();
18084
18192
  }
18193
+ if (this.match("\\hspace")) {
18194
+ this.match("*");
18195
+ this.parseStringGroup();
18196
+ this.skipVisualSpace();
18197
+ }
18198
+ if (this.match("\\hskip") || this.match("\\kern")) {
18199
+ this.skipSpace();
18200
+ this.match("-") || this.match("+");
18201
+ while (/^[\d.]$/.test(this.peek)) this.nextToken();
18202
+ for (const unit of [
18203
+ "pt",
18204
+ "em",
18205
+ "mu",
18206
+ "ex",
18207
+ "mm",
18208
+ "cm",
18209
+ "in",
18210
+ "bp",
18211
+ "sp",
18212
+ "dd",
18213
+ "cc",
18214
+ "pc",
18215
+ "nc",
18216
+ "nd"
18217
+ ]) {
18218
+ if (this.matchAll([...unit])) break;
18219
+ }
18220
+ this.skipVisualSpace();
18221
+ }
18085
18222
  this.skipSpace();
18086
18223
  }
18087
18224
  match(token) {
@@ -18419,7 +18556,8 @@ var ComputeEngineCore = (() => {
18419
18556
  } else if (token === "<space>") {
18420
18557
  result += " ";
18421
18558
  } else if (token[0] === "\\") {
18422
- result += token;
18559
+ const unicode = getSymbolToUnicode().get(token);
18560
+ result += unicode ?? token;
18423
18561
  } else {
18424
18562
  result += token;
18425
18563
  }
@@ -19779,7 +19917,7 @@ var ComputeEngineCore = (() => {
19779
19917
  sansserif: (s) => `\\mathsf{${s}}`,
19780
19918
  monospace: (s) => `\\mathtt{${s}}`
19781
19919
  };
19782
- var Serializer4 = class {
19920
+ var Serializer5 = class {
19783
19921
  options;
19784
19922
  dictionary;
19785
19923
  level = -1;
@@ -19794,11 +19932,18 @@ var ComputeEngineCore = (() => {
19794
19932
  /**
19795
19933
  * Serialize the expression, and if the expression is an operator
19796
19934
  * of precedence less than or equal to prec, wrap it in some parens.
19797
- * @todo: don't wrap Abs, Floor, Ceil, Delimiter
19935
+ *
19936
+ * Skip wrapping for matchfix operators (Abs, Floor, Ceil, Norm, etc.)
19937
+ * and Delimiter since they already have visible delimiters.
19798
19938
  */
19799
19939
  wrap(expr2, prec) {
19800
19940
  if (expr2 === null || expr2 === void 0) return "";
19801
19941
  if (prec === void 0) {
19942
+ const name2 = operator(expr2);
19943
+ if (name2) {
19944
+ const def = this.dictionary.ids.get(name2);
19945
+ if (def?.kind === "matchfix") return this.serialize(expr2);
19946
+ }
19802
19947
  return this.wrapString(
19803
19948
  this.serialize(expr2),
19804
19949
  this.options.groupStyle(expr2, this.level + 1)
@@ -20092,7 +20237,7 @@ var ComputeEngineCore = (() => {
20092
20237
  return body;
20093
20238
  }
20094
20239
  function serializeLatex(expr2, dict, options) {
20095
- const serializer = new Serializer4(dict, options);
20240
+ const serializer = new Serializer5(dict, options);
20096
20241
  return serializer.serialize(expr2);
20097
20242
  }
20098
20243
 
@@ -42131,12 +42276,14 @@ ${e.message}
42131
42276
  canonical: canonicalBlock,
42132
42277
  evaluate: evaluateBlock
42133
42278
  },
42134
- // A condition expression tests for one or more conditions of an expression
42135
- // ['Condition', value, "positive"]
42279
+ // A condition expression tests for one or more conditions of an expression.
42280
+ // Two forms:
42281
+ // ['Condition', value, "positive"] — tests value against named condition(s)
42282
+ // ['Condition', predicate] — set-builder predicate (e.g. x > 0)
42136
42283
  Condition: {
42137
42284
  description: "Test whether a value satisfies one or more conditions.",
42138
42285
  lazy: true,
42139
- signature: "(value, symbol) -> boolean",
42286
+ signature: "(expression, symbol?) -> boolean",
42140
42287
  evaluate: ([value, conds], { engine }) => {
42141
42288
  let conditions = [];
42142
42289
  if (isSymbol2(conds)) {
@@ -54810,8 +54957,7 @@ Error in definition of "${name}"`,
54810
54957
  vars: options?.vars,
54811
54958
  imports: options?.imports,
54812
54959
  preamble: options?.preamble,
54813
- realOnly: options?.realOnly,
54814
- hints: options?.hints
54960
+ realOnly: options?.realOnly
54815
54961
  });
54816
54962
  } catch (e) {
54817
54963
  if (options?.fallback ?? true) {
@@ -61311,43 +61457,6 @@ Error in definition of "${name}"`,
61311
61457
  return b;
61312
61458
  }
61313
61459
 
61314
- // src/compute-engine/compilation/fractal-orbit.ts
61315
- function toBigDecimal(v) {
61316
- if (typeof v === "object" && "hi" in v)
61317
- return new BigDecimal(v.hi).add(new BigDecimal(v.lo));
61318
- return new BigDecimal(v);
61319
- }
61320
- function hpToNumber(v) {
61321
- if (typeof v === "number") return v;
61322
- if (typeof v === "string") return Number(v);
61323
- return v.hi + v.lo;
61324
- }
61325
- function computeReferenceOrbit(center, maxIter, precision) {
61326
- const prevPrecision = BigDecimal.precision;
61327
- BigDecimal.precision = precision;
61328
- try {
61329
- const cr = toBigDecimal(center[0]);
61330
- const ci = toBigDecimal(center[1]);
61331
- let zr = BigDecimal.ZERO;
61332
- let zi = BigDecimal.ZERO;
61333
- const ESCAPE = new BigDecimal(256);
61334
- const points = [];
61335
- for (let i = 0; i < maxIter; i++) {
61336
- points.push(zr.toNumber(), zi.toNumber());
61337
- const zr2 = zr.mul(zr).toPrecision(precision);
61338
- const zi2 = zi.mul(zi).toPrecision(precision);
61339
- const mag2 = zr2.add(zi2);
61340
- if (mag2.cmp(ESCAPE) > 0) break;
61341
- const new_zi = zr.mul(zi).toPrecision(precision).mul(2).add(ci);
61342
- zr = zr2.sub(zi2).add(cr);
61343
- zi = new_zi;
61344
- }
61345
- return new Float32Array(points);
61346
- } finally {
61347
- BigDecimal.precision = prevPrecision;
61348
- }
61349
- }
61350
-
61351
61460
  // src/compute-engine/compilation/gpu-target.ts
61352
61461
  var GPU_OPERATORS = {
61353
61462
  Add: ["+", 11],
@@ -61431,13 +61540,6 @@ Error in definition of "${name}"`,
61431
61540
  ];
61432
61541
  return lines.join("\n");
61433
61542
  }
61434
- function selectFractalStrategy(target) {
61435
- const radius = target.hints?.viewport?.radius;
61436
- if (radius === void 0) return "single";
61437
- if (radius > 1e-6) return "single";
61438
- if (radius > 1e-14) return "double";
61439
- return "perturbation";
61440
- }
61441
61543
  var GPU_FUNCTIONS = {
61442
61544
  // Variadic arithmetic (for function-call form, e.g., with vectors)
61443
61545
  Add: (args, compile3, target) => {
@@ -61933,32 +62035,12 @@ Error in definition of "${name}"`,
61933
62035
  if (c === null || maxIter === null)
61934
62036
  throw new Error("Mandelbrot: missing arguments");
61935
62037
  const iterCode = compileIntArg(maxIter, compile3, target);
61936
- const strategy = selectFractalStrategy(target);
61937
- if (strategy === "double") {
61938
- const dpCoord = target?.language === "wgsl" ? "_dp_coord(v_uv)" : "_dp_coord()";
61939
- return `_fractal_mandelbrot_dp(${dpCoord}, ${iterCode})`;
61940
- }
61941
- if (strategy === "perturbation") {
61942
- const ptDelta = target?.language === "wgsl" ? "_pt_delta(v_uv)" : "_pt_delta()";
61943
- return `_fractal_mandelbrot_pt(${ptDelta}, ${iterCode})`;
61944
- }
61945
62038
  return `_fractal_mandelbrot(${compile3(c)}, ${iterCode})`;
61946
62039
  },
61947
62040
  Julia: ([z, c, maxIter], compile3, target) => {
61948
62041
  if (z === null || c === null || maxIter === null)
61949
62042
  throw new Error("Julia: missing arguments");
61950
62043
  const iterCode = compileIntArg(maxIter, compile3, target);
61951
- const strategy = selectFractalStrategy(target);
61952
- if (strategy === "double") {
61953
- const dpCoord = target?.language === "wgsl" ? "_dp_coord(v_uv)" : "_dp_coord()";
61954
- const cCode = compile3(c);
61955
- return `_fractal_julia_dp(${dpCoord}, vec4(${cCode}, vec2(0.0)), ${iterCode})`;
61956
- }
61957
- if (strategy === "perturbation") {
61958
- const ptDelta = target?.language === "wgsl" ? "_pt_delta(v_uv)" : "_pt_delta()";
61959
- const cCode = compile3(c);
61960
- return `_fractal_julia_pt(${ptDelta}, ${cCode}, ${iterCode})`;
61961
- }
61962
62044
  return `_fractal_julia(${compile3(z)}, ${compile3(c)}, ${iterCode})`;
61963
62045
  },
61964
62046
  // Vector/Matrix operations
@@ -62555,232 +62637,6 @@ fn _gpu_besselJ(n_in: i32, x_in: f32) -> f32 {
62555
62637
  for (var k2: i32 = 2; k2 <= M; k2 += 2) { norm += 2.0 * vals[k2]; }
62556
62638
  return sgn * vals[n] / norm;
62557
62639
  }
62558
- `;
62559
- var GPU_DS_ARITHMETIC_PREAMBLE_GLSL = `
62560
- // Split a float into high and low parts for exact multiplication
62561
- vec2 ds_split(float a) {
62562
- const float SPLIT = 4097.0; // 2^12 + 1
62563
- float t = SPLIT * a;
62564
- float hi = t - (t - a);
62565
- float lo = a - hi;
62566
- return vec2(hi, lo);
62567
- }
62568
-
62569
- // Create a double-single from a single float
62570
- vec2 ds_from(float a) {
62571
- return vec2(a, 0.0);
62572
- }
62573
-
62574
- // Error-free addition (Knuth TwoSum)
62575
- vec2 ds_add(vec2 a, vec2 b) {
62576
- float s = a.x + b.x;
62577
- float v = s - a.x;
62578
- float e = (a.x - (s - v)) + (b.x - v);
62579
- float lo = (a.y + b.y) + e;
62580
- float hi = s + lo;
62581
- lo = lo - (hi - s);
62582
- return vec2(hi, lo);
62583
- }
62584
-
62585
- // Double-single subtraction
62586
- vec2 ds_sub(vec2 a, vec2 b) {
62587
- return ds_add(a, vec2(-b.x, -b.y));
62588
- }
62589
-
62590
- // Error-free multiplication (Dekker TwoProduct)
62591
- vec2 ds_mul(vec2 a, vec2 b) {
62592
- float p = a.x * b.x;
62593
- vec2 sa = ds_split(a.x);
62594
- vec2 sb = ds_split(b.x);
62595
- float err = ((sa.x * sb.x - p) + sa.x * sb.y + sa.y * sb.x) + sa.y * sb.y;
62596
- err += a.x * b.y + a.y * b.x;
62597
- float hi = p + err;
62598
- float lo = err - (hi - p);
62599
- return vec2(hi, lo);
62600
- }
62601
-
62602
- // Optimized self-multiply
62603
- vec2 ds_sqr(vec2 a) {
62604
- float p = a.x * a.x;
62605
- vec2 sa = ds_split(a.x);
62606
- float err = ((sa.x * sa.x - p) + 2.0 * sa.x * sa.y) + sa.y * sa.y;
62607
- err += 2.0 * a.x * a.y;
62608
- float hi = p + err;
62609
- float lo = err - (hi - p);
62610
- return vec2(hi, lo);
62611
- }
62612
-
62613
- // Compare magnitude: returns -1, 0, or 1
62614
- float ds_cmp(vec2 a, vec2 b) {
62615
- float d = a.x - b.x;
62616
- if (d != 0.0) return sign(d);
62617
- return sign(a.y - b.y);
62618
- }
62619
- `;
62620
- var GPU_DS_ARITHMETIC_PREAMBLE_WGSL = `
62621
- fn ds_split(a: f32) -> vec2f {
62622
- const SPLIT: f32 = 4097.0;
62623
- let t = SPLIT * a;
62624
- let hi = t - (t - a);
62625
- let lo = a - hi;
62626
- return vec2f(hi, lo);
62627
- }
62628
-
62629
- fn ds_from(a: f32) -> vec2f {
62630
- return vec2f(a, 0.0);
62631
- }
62632
-
62633
- fn ds_add(a: vec2f, b: vec2f) -> vec2f {
62634
- let s = a.x + b.x;
62635
- let v = s - a.x;
62636
- let e = (a.x - (s - v)) + (b.x - v);
62637
- let lo_t = (a.y + b.y) + e;
62638
- let hi = s + lo_t;
62639
- let lo = lo_t - (hi - s);
62640
- return vec2f(hi, lo);
62641
- }
62642
-
62643
- fn ds_sub(a: vec2f, b: vec2f) -> vec2f {
62644
- return ds_add(a, vec2f(-b.x, -b.y));
62645
- }
62646
-
62647
- fn ds_mul(a: vec2f, b: vec2f) -> vec2f {
62648
- let p = a.x * b.x;
62649
- let sa = ds_split(a.x);
62650
- let sb = ds_split(b.x);
62651
- var err = ((sa.x * sb.x - p) + sa.x * sb.y + sa.y * sb.x) + sa.y * sb.y;
62652
- err += a.x * b.y + a.y * b.x;
62653
- let hi = p + err;
62654
- let lo = err - (hi - p);
62655
- return vec2f(hi, lo);
62656
- }
62657
-
62658
- fn ds_sqr(a: vec2f) -> vec2f {
62659
- let p = a.x * a.x;
62660
- let sa = ds_split(a.x);
62661
- var err = ((sa.x * sa.x - p) + 2.0 * sa.x * sa.y) + sa.y * sa.y;
62662
- err += 2.0 * a.x * a.y;
62663
- let hi = p + err;
62664
- let lo = err - (hi - p);
62665
- return vec2f(hi, lo);
62666
- }
62667
-
62668
- fn ds_cmp(a: vec2f, b: vec2f) -> f32 {
62669
- let d = a.x - b.x;
62670
- if (d != 0.0) { return sign(d); }
62671
- return sign(a.y - b.y);
62672
- }
62673
- `;
62674
- var GPU_FRACTAL_DP_PREAMBLE_GLSL = `
62675
- uniform float _dp_cx_hi;
62676
- uniform float _dp_cx_lo;
62677
- uniform float _dp_cy_hi;
62678
- uniform float _dp_cy_lo;
62679
- uniform float _dp_w;
62680
- uniform float _dp_h;
62681
-
62682
- vec4 _dp_coord() {
62683
- // Per-pixel offset from center \u2014 small, so float-precise
62684
- float dx = (v_uv.x - 0.5) * _dp_w;
62685
- float dy = (v_uv.y - 0.5) * _dp_h;
62686
- // Combine center (hi+lo) + delta with emulated double precision
62687
- vec2 cre = ds_add(vec2(_dp_cx_hi, _dp_cx_lo), ds_from(dx));
62688
- vec2 cim = ds_add(vec2(_dp_cy_hi, _dp_cy_lo), ds_from(dy));
62689
- return vec4(cre.x, cim.x, cre.y, cim.y);
62690
- }
62691
-
62692
- float _fractal_mandelbrot_dp(vec4 c, int maxIter) {
62693
- // c = (re_hi, im_hi, re_lo, im_lo)
62694
- vec2 cr = vec2(c.x, c.z); // real part as ds
62695
- vec2 ci = vec2(c.y, c.w); // imag part as ds
62696
- vec2 zr = vec2(0.0, 0.0);
62697
- vec2 zi = vec2(0.0, 0.0);
62698
- for (int i = 0; i < maxIter; i++) {
62699
- vec2 zr2 = ds_sqr(zr);
62700
- vec2 zi2 = ds_sqr(zi);
62701
- // |z|^2 > 4.0 ?
62702
- vec2 mag2 = ds_add(zr2, zi2);
62703
- if (mag2.x > 4.0)
62704
- return clamp((float(i) - log2(log2(mag2.x)) + 4.0) / float(maxIter), 0.0, 1.0);
62705
- // z = z^2 + c
62706
- vec2 new_zi = ds_add(ds_mul(ds_add(zr, zr), zi), ci); // 2*zr*zi + ci
62707
- zr = ds_add(ds_sub(zr2, zi2), cr); // zr^2 - zi^2 + cr
62708
- zi = new_zi;
62709
- }
62710
- return 1.0;
62711
- }
62712
-
62713
- float _fractal_julia_dp(vec4 z_in, vec4 c, int maxIter) {
62714
- vec2 zr = vec2(z_in.x, z_in.z);
62715
- vec2 zi = vec2(z_in.y, z_in.w);
62716
- vec2 cr = vec2(c.x, c.z);
62717
- vec2 ci = vec2(c.y, c.w);
62718
- for (int i = 0; i < maxIter; i++) {
62719
- vec2 zr2 = ds_sqr(zr);
62720
- vec2 zi2 = ds_sqr(zi);
62721
- vec2 mag2 = ds_add(zr2, zi2);
62722
- if (mag2.x > 4.0)
62723
- return clamp((float(i) - log2(log2(mag2.x)) + 4.0) / float(maxIter), 0.0, 1.0);
62724
- vec2 new_zi = ds_add(ds_mul(ds_add(zr, zr), zi), ci);
62725
- zr = ds_add(ds_sub(zr2, zi2), cr);
62726
- zi = new_zi;
62727
- }
62728
- return 1.0;
62729
- }
62730
- `;
62731
- var GPU_FRACTAL_DP_PREAMBLE_WGSL = `
62732
- @group(0) @binding(10) var<uniform> _dp_cx_hi: f32;
62733
- @group(0) @binding(11) var<uniform> _dp_cx_lo: f32;
62734
- @group(0) @binding(12) var<uniform> _dp_cy_hi: f32;
62735
- @group(0) @binding(13) var<uniform> _dp_cy_lo: f32;
62736
- @group(0) @binding(14) var<uniform> _dp_w: f32;
62737
- @group(0) @binding(15) var<uniform> _dp_h: f32;
62738
-
62739
- fn _dp_coord(uv: vec2f) -> vec4f {
62740
- let dx = (uv.x - 0.5) * _dp_w;
62741
- let dy = (uv.y - 0.5) * _dp_h;
62742
- let cre = ds_add(vec2f(_dp_cx_hi, _dp_cx_lo), ds_from(dx));
62743
- let cim = ds_add(vec2f(_dp_cy_hi, _dp_cy_lo), ds_from(dy));
62744
- return vec4f(cre.x, cim.x, cre.y, cim.y);
62745
- }
62746
-
62747
- fn _fractal_mandelbrot_dp(c: vec4f, maxIter: i32) -> f32 {
62748
- let cr = vec2f(c.x, c.z);
62749
- let ci = vec2f(c.y, c.w);
62750
- var zr = vec2f(0.0, 0.0);
62751
- var zi = vec2f(0.0, 0.0);
62752
- for (var i: i32 = 0; i < maxIter; i++) {
62753
- let zr2 = ds_sqr(zr);
62754
- let zi2 = ds_sqr(zi);
62755
- let mag2 = ds_add(zr2, zi2);
62756
- if (mag2.x > 4.0) {
62757
- return clamp((f32(i) - log2(log2(mag2.x)) + 4.0) / f32(maxIter), 0.0, 1.0);
62758
- }
62759
- let new_zi = ds_add(ds_mul(ds_add(zr, zr), zi), ci);
62760
- zr = ds_add(ds_sub(zr2, zi2), cr);
62761
- zi = new_zi;
62762
- }
62763
- return 1.0;
62764
- }
62765
-
62766
- fn _fractal_julia_dp(z_in: vec4f, c: vec4f, maxIter: i32) -> f32 {
62767
- var zr = vec2f(z_in.x, z_in.z);
62768
- var zi = vec2f(z_in.y, z_in.w);
62769
- let cr = vec2f(c.x, c.z);
62770
- let ci = vec2f(c.y, c.w);
62771
- for (var i: i32 = 0; i < maxIter; i++) {
62772
- let zr2 = ds_sqr(zr);
62773
- let zi2 = ds_sqr(zi);
62774
- let mag2 = ds_add(zr2, zi2);
62775
- if (mag2.x > 4.0) {
62776
- return clamp((f32(i) - log2(log2(mag2.x)) + 4.0) / f32(maxIter), 0.0, 1.0);
62777
- }
62778
- let new_zi = ds_add(ds_mul(ds_add(zr, zr), zi), ci);
62779
- zr = ds_add(ds_sub(zr2, zi2), cr);
62780
- zi = new_zi;
62781
- }
62782
- return 1.0;
62783
- }
62784
62640
  `;
62785
62641
  var GPU_FRACTAL_PREAMBLE_GLSL = `
62786
62642
  float _fractal_mandelbrot(vec2 c, int maxIter) {
@@ -62824,208 +62680,6 @@ fn _fractal_julia(z_in: vec2f, c: vec2f, maxIter: i32) -> f32 {
62824
62680
  }
62825
62681
  return 1.0;
62826
62682
  }
62827
- `;
62828
- var GPU_FRACTAL_PT_PREAMBLE_GLSL = `
62829
- uniform sampler2D _refOrbit;
62830
- uniform int _refOrbitLen;
62831
- uniform int _refOrbitTexWidth;
62832
- uniform float _pt_offset_x;
62833
- uniform float _pt_offset_y;
62834
- uniform float _pt_w;
62835
- uniform float _pt_h;
62836
-
62837
- vec2 _pt_delta() {
62838
- float dx = _pt_offset_x + (v_uv.x - 0.5) * _pt_w;
62839
- float dy = _pt_offset_y + (v_uv.y - 0.5) * _pt_h;
62840
- return vec2(dx, dy);
62841
- }
62842
-
62843
- vec2 _pt_fetch_orbit(int i) {
62844
- int y = i / _refOrbitTexWidth;
62845
- int x = i - y * _refOrbitTexWidth;
62846
- return texelFetch(_refOrbit, ivec2(x, y), 0).rg;
62847
- }
62848
-
62849
- float _fractal_mandelbrot_pt(vec2 delta_c, int maxIter) {
62850
- float dr = 0.0;
62851
- float di = 0.0;
62852
- int orbitLen = min(maxIter, _refOrbitLen);
62853
- for (int i = 0; i < orbitLen; i++) {
62854
- vec2 Zn = _pt_fetch_orbit(i);
62855
- // delta_{n+1} = 2*Z_n*delta_n + delta_n^2 + delta_c
62856
- float new_dr = 2.0 * (Zn.x * dr - Zn.y * di) + dr * dr - di * di + delta_c.x;
62857
- float new_di = 2.0 * (Zn.x * di + Zn.y * dr) + 2.0 * dr * di + delta_c.y;
62858
- dr = new_dr;
62859
- di = new_di;
62860
- // Full z = Z_{n+1} + delta for escape check
62861
- vec2 Zn1 = (i + 1 < orbitLen) ? _pt_fetch_orbit(i + 1) : vec2(0.0);
62862
- float zr = Zn1.x + dr;
62863
- float zi = Zn1.y + di;
62864
- float mag2 = zr * zr + zi * zi;
62865
- if (mag2 > 4.0)
62866
- return clamp((float(i) - log2(log2(mag2)) + 4.0) / float(maxIter), 0.0, 1.0);
62867
- // Glitch detection: |delta|^2 > |Z|^2
62868
- float dmag2 = dr * dr + di * di;
62869
- float Zmag2 = Zn.x * Zn.x + Zn.y * Zn.y;
62870
- if (dmag2 > Zmag2 && Zmag2 > 0.0) {
62871
- // Rebase to absolute coordinates and continue with single-float
62872
- float abs_zr = Zn1.x + dr;
62873
- float abs_zi = Zn1.y + di;
62874
- // Reconstruct absolute c from reference + delta
62875
- // (Use ds_from for the concept, but single-float suffices for fallback)
62876
- float cx = abs_zr - dr + delta_c.x;
62877
- float cy = abs_zi - di + delta_c.y;
62878
- for (int j = i + 1; j < maxIter; j++) {
62879
- float new_zr = abs_zr * abs_zr - abs_zi * abs_zi + cx;
62880
- abs_zi = 2.0 * abs_zr * abs_zi + cy;
62881
- abs_zr = new_zr;
62882
- mag2 = abs_zr * abs_zr + abs_zi * abs_zi;
62883
- if (mag2 > 4.0)
62884
- return clamp((float(j) - log2(log2(mag2)) + 4.0) / float(maxIter), 0.0, 1.0);
62885
- }
62886
- return 1.0;
62887
- }
62888
- }
62889
- return 1.0;
62890
- }
62891
-
62892
- float _fractal_julia_pt(vec2 z_delta, vec2 delta_c, int maxIter) {
62893
- float dr = z_delta.x;
62894
- float di = z_delta.y;
62895
- int orbitLen = min(maxIter, _refOrbitLen);
62896
- for (int i = 0; i < orbitLen; i++) {
62897
- vec2 Zn = _pt_fetch_orbit(i);
62898
- float new_dr = 2.0 * (Zn.x * dr - Zn.y * di) + dr * dr - di * di + delta_c.x;
62899
- float new_di = 2.0 * (Zn.x * di + Zn.y * dr) + 2.0 * dr * di + delta_c.y;
62900
- dr = new_dr;
62901
- di = new_di;
62902
- vec2 Zn1 = (i + 1 < orbitLen) ? _pt_fetch_orbit(i + 1) : vec2(0.0);
62903
- float zr = Zn1.x + dr;
62904
- float zi = Zn1.y + di;
62905
- float mag2 = zr * zr + zi * zi;
62906
- if (mag2 > 4.0)
62907
- return clamp((float(i) - log2(log2(mag2)) + 4.0) / float(maxIter), 0.0, 1.0);
62908
- float dmag2 = dr * dr + di * di;
62909
- float Zmag2 = Zn.x * Zn.x + Zn.y * Zn.y;
62910
- if (dmag2 > Zmag2 && Zmag2 > 0.0) {
62911
- float abs_zr = Zn1.x + dr;
62912
- float abs_zi = Zn1.y + di;
62913
- float cx = delta_c.x;
62914
- float cy = delta_c.y;
62915
- for (int j = i + 1; j < maxIter; j++) {
62916
- float new_zr = abs_zr * abs_zr - abs_zi * abs_zi + cx;
62917
- abs_zi = 2.0 * abs_zr * abs_zi + cy;
62918
- abs_zr = new_zr;
62919
- mag2 = abs_zr * abs_zr + abs_zi * abs_zi;
62920
- if (mag2 > 4.0)
62921
- return clamp((float(j) - log2(log2(mag2)) + 4.0) / float(maxIter), 0.0, 1.0);
62922
- }
62923
- return 1.0;
62924
- }
62925
- }
62926
- return 1.0;
62927
- }
62928
- `;
62929
- var GPU_FRACTAL_PT_PREAMBLE_WGSL = `
62930
- @group(0) @binding(1) var _refOrbit: texture_2d<f32>;
62931
- var<uniform> _refOrbitLen: i32;
62932
- var<uniform> _refOrbitTexWidth: i32;
62933
- var<uniform> _pt_offset_x: f32;
62934
- var<uniform> _pt_offset_y: f32;
62935
- var<uniform> _pt_w: f32;
62936
- var<uniform> _pt_h: f32;
62937
-
62938
- fn _pt_delta(uv: vec2f) -> vec2f {
62939
- let dx = _pt_offset_x + (uv.x - 0.5) * _pt_w;
62940
- let dy = _pt_offset_y + (uv.y - 0.5) * _pt_h;
62941
- return vec2f(dx, dy);
62942
- }
62943
-
62944
- fn _pt_fetch_orbit(i: i32) -> vec2f {
62945
- let y = i / _refOrbitTexWidth;
62946
- let x = i - y * _refOrbitTexWidth;
62947
- return textureLoad(_refOrbit, vec2i(x, y), 0).rg;
62948
- }
62949
-
62950
- fn _fractal_mandelbrot_pt(delta_c: vec2f, maxIter: i32) -> f32 {
62951
- var dr: f32 = 0.0;
62952
- var di: f32 = 0.0;
62953
- let orbitLen = min(maxIter, _refOrbitLen);
62954
- for (var i: i32 = 0; i < orbitLen; i++) {
62955
- let Zn = _pt_fetch_orbit(i);
62956
- let new_dr = 2.0 * (Zn.x * dr - Zn.y * di) + dr * dr - di * di + delta_c.x;
62957
- let new_di = 2.0 * (Zn.x * di + Zn.y * dr) + 2.0 * dr * di + delta_c.y;
62958
- dr = new_dr;
62959
- di = new_di;
62960
- var Zn1 = vec2f(0.0);
62961
- if (i + 1 < orbitLen) { Zn1 = _pt_fetch_orbit(i + 1); }
62962
- let zr = Zn1.x + dr;
62963
- let zi = Zn1.y + di;
62964
- var mag2 = zr * zr + zi * zi;
62965
- if (mag2 > 4.0) {
62966
- return clamp((f32(i) - log2(log2(mag2)) + 4.0) / f32(maxIter), 0.0, 1.0);
62967
- }
62968
- let dmag2 = dr * dr + di * di;
62969
- let Zmag2 = Zn.x * Zn.x + Zn.y * Zn.y;
62970
- if (dmag2 > Zmag2 && Zmag2 > 0.0) {
62971
- var f_zr = Zn1.x + dr;
62972
- var f_zi = Zn1.y + di;
62973
- let cx = delta_c.x;
62974
- let cy = delta_c.y;
62975
- for (var j: i32 = i + 1; j < maxIter; j++) {
62976
- let t_zr = f_zr * f_zr - f_zi * f_zi + cx;
62977
- f_zi = 2.0 * f_zr * f_zi + cy;
62978
- f_zr = t_zr;
62979
- mag2 = f_zr * f_zr + f_zi * f_zi;
62980
- if (mag2 > 4.0) {
62981
- return clamp((f32(j) - log2(log2(mag2)) + 4.0) / f32(maxIter), 0.0, 1.0);
62982
- }
62983
- }
62984
- return 1.0;
62985
- }
62986
- }
62987
- return 1.0;
62988
- }
62989
-
62990
- fn _fractal_julia_pt(z_delta: vec2f, delta_c: vec2f, maxIter: i32) -> f32 {
62991
- var dr = z_delta.x;
62992
- var di = z_delta.y;
62993
- let orbitLen = min(maxIter, _refOrbitLen);
62994
- for (var i: i32 = 0; i < orbitLen; i++) {
62995
- let Zn = _pt_fetch_orbit(i);
62996
- let new_dr = 2.0 * (Zn.x * dr - Zn.y * di) + dr * dr - di * di + delta_c.x;
62997
- let new_di = 2.0 * (Zn.x * di + Zn.y * dr) + 2.0 * dr * di + delta_c.y;
62998
- dr = new_dr;
62999
- di = new_di;
63000
- var Zn1 = vec2f(0.0);
63001
- if (i + 1 < orbitLen) { Zn1 = _pt_fetch_orbit(i + 1); }
63002
- let zr = Zn1.x + dr;
63003
- let zi = Zn1.y + di;
63004
- var mag2 = zr * zr + zi * zi;
63005
- if (mag2 > 4.0) {
63006
- return clamp((f32(i) - log2(log2(mag2)) + 4.0) / f32(maxIter), 0.0, 1.0);
63007
- }
63008
- let dmag2 = dr * dr + di * di;
63009
- let Zmag2 = Zn.x * Zn.x + Zn.y * Zn.y;
63010
- if (dmag2 > Zmag2 && Zmag2 > 0.0) {
63011
- var f_zr = Zn1.x + dr;
63012
- var f_zi = Zn1.y + di;
63013
- let cx = delta_c.x;
63014
- let cy = delta_c.y;
63015
- for (var j: i32 = i + 1; j < maxIter; j++) {
63016
- let t_zr = f_zr * f_zr - f_zi * f_zi + cx;
63017
- f_zi = 2.0 * f_zr * f_zi + cy;
63018
- f_zr = t_zr;
63019
- mag2 = f_zr * f_zr + f_zi * f_zi;
63020
- if (mag2 > 4.0) {
63021
- return clamp((f32(j) - log2(log2(mag2)) + 4.0) / f32(maxIter), 0.0, 1.0);
63022
- }
63023
- }
63024
- return 1.0;
63025
- }
63026
- }
63027
- return 1.0;
63028
- }
63029
62683
  `;
63030
62684
  var GPU_COLOR_PREAMBLE_GLSL = `
63031
62685
  float _gpu_srgb_to_linear(float c) {
@@ -63465,7 +63119,6 @@ fn _gpu_apca(bg: vec3f, fg: vec3f) -> f32 {
63465
63119
  const constants = this.getConstants();
63466
63120
  const v2 = this.languageId === "wgsl" ? "vec2f" : "vec2";
63467
63121
  const target = this.createTarget({
63468
- hints: options.hints,
63469
63122
  functions: (id) => {
63470
63123
  if (userFunctions && id in userFunctions) {
63471
63124
  const fn = userFunctions[id];
@@ -63504,89 +63157,12 @@ fn _gpu_apca(bg: vec3f, fg: vec3f) -> f32 {
63504
63157
  if (code.includes("_gpu_besselJ"))
63505
63158
  preamble += this.languageId === "wgsl" ? GPU_BESSELJ_PREAMBLE_WGSL : GPU_BESSELJ_PREAMBLE_GLSL;
63506
63159
  if (code.includes("_fractal_")) {
63507
- if (code.includes("_fractal_mandelbrot_pt") || code.includes("_fractal_julia_pt")) {
63508
- preamble += this.languageId === "wgsl" ? GPU_DS_ARITHMETIC_PREAMBLE_WGSL : GPU_DS_ARITHMETIC_PREAMBLE_GLSL;
63509
- preamble += this.languageId === "wgsl" ? GPU_FRACTAL_PT_PREAMBLE_WGSL : GPU_FRACTAL_PT_PREAMBLE_GLSL;
63510
- } else if (code.includes("_fractal_mandelbrot_dp") || code.includes("_fractal_julia_dp")) {
63511
- preamble += this.languageId === "wgsl" ? GPU_DS_ARITHMETIC_PREAMBLE_WGSL : GPU_DS_ARITHMETIC_PREAMBLE_GLSL;
63512
- preamble += this.languageId === "wgsl" ? GPU_FRACTAL_DP_PREAMBLE_WGSL : GPU_FRACTAL_DP_PREAMBLE_GLSL;
63513
- } else {
63514
- preamble += this.languageId === "wgsl" ? GPU_FRACTAL_PREAMBLE_WGSL : GPU_FRACTAL_PREAMBLE_GLSL;
63515
- }
63160
+ preamble += this.languageId === "wgsl" ? GPU_FRACTAL_PREAMBLE_WGSL : GPU_FRACTAL_PREAMBLE_GLSL;
63516
63161
  }
63517
63162
  if (code.includes("_gpu_srgb_to") || code.includes("_gpu_oklab") || code.includes("_gpu_oklch") || code.includes("_gpu_color_mix") || code.includes("_gpu_apca")) {
63518
63163
  preamble += this.languageId === "wgsl" ? GPU_COLOR_PREAMBLE_WGSL : GPU_COLOR_PREAMBLE_GLSL;
63519
63164
  }
63520
63165
  if (preamble) result.preamble = preamble;
63521
- if (code.includes("_fractal_") && options.hints?.viewport) {
63522
- const strategy = selectFractalStrategy(target);
63523
- const radius = options.hints.viewport.radius;
63524
- switch (strategy) {
63525
- case "single":
63526
- result.staleWhen = { radiusBelow: 1e-6 };
63527
- break;
63528
- case "double":
63529
- result.staleWhen = { radiusBelow: 1e-14, radiusAbove: 1e-5 };
63530
- break;
63531
- case "perturbation":
63532
- result.staleWhen = {
63533
- radiusAbove: 1e-5,
63534
- radiusBelow: radius * 0.01,
63535
- centerDistance: radius * 2
63536
- };
63537
- break;
63538
- }
63539
- }
63540
- if ((code.includes("_fractal_mandelbrot_dp") || code.includes("_fractal_julia_dp")) && options.hints?.viewport) {
63541
- const cx = hpToNumber(options.hints.viewport.center[0]);
63542
- const cy = hpToNumber(options.hints.viewport.center[1]);
63543
- const size = options.hints.viewport.radius * 2;
63544
- const cx_hi = Math.fround(cx);
63545
- const cy_hi = Math.fround(cy);
63546
- result.uniforms = {
63547
- ...result.uniforms,
63548
- _dp_cx_hi: cx_hi,
63549
- _dp_cx_lo: cx - cx_hi,
63550
- _dp_cy_hi: cy_hi,
63551
- _dp_cy_lo: cy - cy_hi,
63552
- _dp_w: size,
63553
- _dp_h: size
63554
- };
63555
- }
63556
- if ((code.includes("_fractal_mandelbrot_pt") || code.includes("_fractal_julia_pt")) && options.hints?.viewport) {
63557
- const viewport = options.hints.viewport;
63558
- const size = viewport.radius * 2;
63559
- result.uniforms = {
63560
- ...result.uniforms,
63561
- _pt_offset_x: 0,
63562
- _pt_offset_y: 0,
63563
- _pt_w: size,
63564
- _pt_h: size
63565
- };
63566
- const digits = Math.max(50, Math.ceil(-Math.log10(viewport.radius)) + 10);
63567
- const maxIter = 1e3;
63568
- const orbit = computeReferenceOrbit(
63569
- viewport.center,
63570
- maxIter,
63571
- digits
63572
- );
63573
- const orbitLen = orbit.length / 2;
63574
- const texWidth = Math.min(orbitLen, 4096);
63575
- const texHeight = Math.ceil(orbitLen / texWidth);
63576
- result.textures = {
63577
- _refOrbit: {
63578
- data: orbit,
63579
- width: texWidth,
63580
- height: texHeight,
63581
- format: "rg32f"
63582
- }
63583
- };
63584
- result.uniforms = {
63585
- ...result.uniforms,
63586
- _refOrbitLen: orbitLen,
63587
- _refOrbitTexWidth: texWidth
63588
- };
63589
- }
63590
63166
  return result;
63591
63167
  }
63592
63168
  compileToSource(expr2, _options = {}) {
@@ -68569,7 +68145,7 @@ ${workgroupAttr}fn main(${paramStr})${returnStr} {
68569
68145
  _setDefaultEngineFactory(() => new ComputeEngine());
68570
68146
 
68571
68147
  // src/core.ts
68572
- var version = "0.55.5";
68148
+ var version = "0.55.6";
68573
68149
  return __toCommonJS(core_exports);
68574
68150
  })();
68575
68151
  /*! Bundled license information: