@cortex-js/compute-engine 0.55.3 → 0.55.5

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 +613 -32
  2. package/dist/compile.min.esm.js +492 -70
  3. package/dist/compile.min.umd.cjs +492 -70
  4. package/dist/compile.umd.cjs +613 -32
  5. package/dist/compute-engine.esm.js +656 -44
  6. package/dist/compute-engine.min.esm.js +485 -63
  7. package/dist/compute-engine.min.umd.cjs +484 -62
  8. package/dist/compute-engine.umd.cjs +656 -44
  9. package/dist/core.esm.js +654 -43
  10. package/dist/core.min.esm.js +483 -61
  11. package/dist/core.min.umd.cjs +483 -61
  12. package/dist/core.umd.cjs +654 -43
  13. package/dist/interval.esm.js +2 -2
  14. package/dist/interval.min.esm.js +2 -2
  15. package/dist/interval.min.umd.cjs +2 -2
  16. package/dist/interval.umd.cjs +2 -2
  17. package/dist/latex-syntax.esm.js +43 -13
  18. package/dist/latex-syntax.min.esm.js +5 -5
  19. package/dist/latex-syntax.min.umd.cjs +5 -5
  20. package/dist/latex-syntax.umd.cjs +43 -13
  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 +3 -2
  106. package/dist/types/compute-engine/compilation/constant-folding.d.ts +1 -1
  107. package/dist/types/compute-engine/compilation/fractal-orbit.d.ts +19 -0
  108. package/dist/types/compute-engine/compilation/glsl-target.d.ts +1 -1
  109. package/dist/types/compute-engine/compilation/gpu-target.d.ts +54 -1
  110. package/dist/types/compute-engine/compilation/interval-javascript-target.d.ts +1 -1
  111. package/dist/types/compute-engine/compilation/javascript-target.d.ts +1 -1
  112. package/dist/types/compute-engine/compilation/python-target.d.ts +1 -1
  113. package/dist/types/compute-engine/compilation/types.d.ts +67 -1
  114. package/dist/types/compute-engine/compilation/wgsl-target.d.ts +1 -1
  115. package/dist/types/compute-engine/cost-function.d.ts +1 -1
  116. package/dist/types/compute-engine/engine-assumptions.d.ts +1 -1
  117. package/dist/types/compute-engine/engine-cache.d.ts +1 -1
  118. package/dist/types/compute-engine/engine-common-symbols.d.ts +1 -1
  119. package/dist/types/compute-engine/engine-compilation-targets.d.ts +1 -1
  120. package/dist/types/compute-engine/engine-configuration-lifecycle.d.ts +1 -1
  121. package/dist/types/compute-engine/engine-declarations.d.ts +1 -1
  122. package/dist/types/compute-engine/engine-expression-entrypoints.d.ts +1 -1
  123. package/dist/types/compute-engine/engine-extension-contracts.d.ts +1 -1
  124. package/dist/types/compute-engine/engine-library-bootstrap.d.ts +1 -1
  125. package/dist/types/compute-engine/engine-numeric-configuration.d.ts +1 -1
  126. package/dist/types/compute-engine/engine-runtime-state.d.ts +1 -1
  127. package/dist/types/compute-engine/engine-scope.d.ts +1 -1
  128. package/dist/types/compute-engine/engine-sequences.d.ts +1 -1
  129. package/dist/types/compute-engine/engine-simplification-rules.d.ts +1 -1
  130. package/dist/types/compute-engine/engine-startup-coordinator.d.ts +1 -1
  131. package/dist/types/compute-engine/engine-type-resolver.d.ts +1 -1
  132. package/dist/types/compute-engine/engine-validation-entrypoints.d.ts +1 -1
  133. package/dist/types/compute-engine/free-functions.d.ts +1 -1
  134. package/dist/types/compute-engine/function-utils.d.ts +1 -1
  135. package/dist/types/compute-engine/global-types.d.ts +1 -1
  136. package/dist/types/compute-engine/index.d.ts +3 -2
  137. package/dist/types/compute-engine/interval/arithmetic.d.ts +1 -1
  138. package/dist/types/compute-engine/interval/comparison.d.ts +1 -1
  139. package/dist/types/compute-engine/interval/elementary.d.ts +1 -1
  140. package/dist/types/compute-engine/interval/index.d.ts +1 -1
  141. package/dist/types/compute-engine/interval/trigonometric.d.ts +1 -1
  142. package/dist/types/compute-engine/interval/types.d.ts +1 -1
  143. package/dist/types/compute-engine/interval/util.d.ts +1 -1
  144. package/dist/types/compute-engine/latex-syntax/dictionary/default-dictionary.d.ts +1 -1
  145. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-algebra.d.ts +1 -1
  146. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-arithmetic.d.ts +1 -1
  147. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-calculus.d.ts +1 -1
  148. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-complex.d.ts +1 -1
  149. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-core.d.ts +1 -1
  150. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-linear-algebra.d.ts +1 -1
  151. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-logic.d.ts +1 -1
  152. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-other.d.ts +1 -1
  153. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-relational-operators.d.ts +1 -1
  154. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-sets.d.ts +1 -1
  155. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-statistics.d.ts +1 -1
  156. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-symbols.d.ts +1 -1
  157. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-trigonometry.d.ts +1 -1
  158. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-units.d.ts +1 -1
  159. package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +1 -1
  160. package/dist/types/compute-engine/latex-syntax/dictionary/indexed-types.d.ts +1 -1
  161. package/dist/types/compute-engine/latex-syntax/latex-syntax.d.ts +1 -1
  162. package/dist/types/compute-engine/latex-syntax/parse-number.d.ts +1 -1
  163. package/dist/types/compute-engine/latex-syntax/parse-symbol.d.ts +1 -1
  164. package/dist/types/compute-engine/latex-syntax/parse.d.ts +1 -1
  165. package/dist/types/compute-engine/latex-syntax/serialize-dms.d.ts +1 -1
  166. package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +1 -1
  167. package/dist/types/compute-engine/latex-syntax/serializer-style.d.ts +1 -1
  168. package/dist/types/compute-engine/latex-syntax/serializer.d.ts +1 -1
  169. package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +1 -1
  170. package/dist/types/compute-engine/latex-syntax/types.d.ts +1 -1
  171. package/dist/types/compute-engine/latex-syntax/utils.d.ts +1 -1
  172. package/dist/types/compute-engine/library/arithmetic.d.ts +1 -1
  173. package/dist/types/compute-engine/library/calculus.d.ts +1 -1
  174. package/dist/types/compute-engine/library/collections.d.ts +1 -1
  175. package/dist/types/compute-engine/library/colors.d.ts +1 -1
  176. package/dist/types/compute-engine/library/combinatorics.d.ts +1 -1
  177. package/dist/types/compute-engine/library/complex.d.ts +1 -1
  178. package/dist/types/compute-engine/library/control-structures.d.ts +1 -1
  179. package/dist/types/compute-engine/library/core.d.ts +1 -1
  180. package/dist/types/compute-engine/library/fractals.d.ts +1 -1
  181. package/dist/types/compute-engine/library/library.d.ts +1 -1
  182. package/dist/types/compute-engine/library/linear-algebra.d.ts +1 -1
  183. package/dist/types/compute-engine/library/logic-analysis.d.ts +1 -1
  184. package/dist/types/compute-engine/library/logic.d.ts +1 -1
  185. package/dist/types/compute-engine/library/number-theory.d.ts +1 -1
  186. package/dist/types/compute-engine/library/polynomials.d.ts +1 -1
  187. package/dist/types/compute-engine/library/quantity-arithmetic.d.ts +1 -1
  188. package/dist/types/compute-engine/library/random-expression.d.ts +1 -1
  189. package/dist/types/compute-engine/library/relational-operator.d.ts +1 -1
  190. package/dist/types/compute-engine/library/sets.d.ts +1 -1
  191. package/dist/types/compute-engine/library/statistics.d.ts +1 -1
  192. package/dist/types/compute-engine/library/trigonometry.d.ts +1 -1
  193. package/dist/types/compute-engine/library/type-handlers.d.ts +1 -1
  194. package/dist/types/compute-engine/library/unit-data.d.ts +1 -1
  195. package/dist/types/compute-engine/library/units.d.ts +1 -1
  196. package/dist/types/compute-engine/library/utils.d.ts +1 -1
  197. package/dist/types/compute-engine/numeric-value/big-numeric-value.d.ts +1 -1
  198. package/dist/types/compute-engine/numeric-value/exact-numeric-value.d.ts +1 -1
  199. package/dist/types/compute-engine/numeric-value/machine-numeric-value.d.ts +1 -1
  200. package/dist/types/compute-engine/numeric-value/types.d.ts +1 -1
  201. package/dist/types/compute-engine/numerics/bigint.d.ts +1 -1
  202. package/dist/types/compute-engine/numerics/expression.d.ts +1 -1
  203. package/dist/types/compute-engine/numerics/interval.d.ts +1 -1
  204. package/dist/types/compute-engine/numerics/linear-algebra.d.ts +1 -1
  205. package/dist/types/compute-engine/numerics/monte-carlo.d.ts +1 -1
  206. package/dist/types/compute-engine/numerics/numeric-bigint.d.ts +1 -1
  207. package/dist/types/compute-engine/numerics/numeric-bignum.d.ts +1 -1
  208. package/dist/types/compute-engine/numerics/numeric-complex.d.ts +1 -1
  209. package/dist/types/compute-engine/numerics/numeric.d.ts +1 -1
  210. package/dist/types/compute-engine/numerics/primes.d.ts +1 -1
  211. package/dist/types/compute-engine/numerics/rationals.d.ts +1 -1
  212. package/dist/types/compute-engine/numerics/richardson.d.ts +1 -1
  213. package/dist/types/compute-engine/numerics/special-functions.d.ts +1 -1
  214. package/dist/types/compute-engine/numerics/statistics.d.ts +1 -1
  215. package/dist/types/compute-engine/numerics/strings.d.ts +1 -1
  216. package/dist/types/compute-engine/numerics/types.d.ts +1 -1
  217. package/dist/types/compute-engine/numerics/unit-data.d.ts +1 -1
  218. package/dist/types/compute-engine/oeis.d.ts +1 -1
  219. package/dist/types/compute-engine/sequence.d.ts +1 -1
  220. package/dist/types/compute-engine/symbolic/antiderivative.d.ts +1 -1
  221. package/dist/types/compute-engine/symbolic/derivative.d.ts +1 -1
  222. package/dist/types/compute-engine/symbolic/distribute.d.ts +1 -1
  223. package/dist/types/compute-engine/symbolic/fu-cost.d.ts +1 -1
  224. package/dist/types/compute-engine/symbolic/fu-transforms.d.ts +1 -1
  225. package/dist/types/compute-engine/symbolic/fu.d.ts +1 -1
  226. package/dist/types/compute-engine/symbolic/logic-utils.d.ts +1 -1
  227. package/dist/types/compute-engine/symbolic/simplify-abs.d.ts +1 -1
  228. package/dist/types/compute-engine/symbolic/simplify-divide.d.ts +1 -1
  229. package/dist/types/compute-engine/symbolic/simplify-factorial.d.ts +1 -1
  230. package/dist/types/compute-engine/symbolic/simplify-hyperbolic.d.ts +1 -1
  231. package/dist/types/compute-engine/symbolic/simplify-infinity.d.ts +1 -1
  232. package/dist/types/compute-engine/symbolic/simplify-log.d.ts +1 -1
  233. package/dist/types/compute-engine/symbolic/simplify-logic.d.ts +1 -1
  234. package/dist/types/compute-engine/symbolic/simplify-power.d.ts +1 -1
  235. package/dist/types/compute-engine/symbolic/simplify-product.d.ts +1 -1
  236. package/dist/types/compute-engine/symbolic/simplify-rules.d.ts +1 -1
  237. package/dist/types/compute-engine/symbolic/simplify-sum.d.ts +1 -1
  238. package/dist/types/compute-engine/symbolic/simplify-trig.d.ts +1 -1
  239. package/dist/types/compute-engine/tensor/tensor-fields.d.ts +1 -1
  240. package/dist/types/compute-engine/tensor/tensors.d.ts +1 -1
  241. package/dist/types/compute-engine/types-definitions.d.ts +1 -1
  242. package/dist/types/compute-engine/types-engine.d.ts +1 -1
  243. package/dist/types/compute-engine/types-evaluation.d.ts +1 -1
  244. package/dist/types/compute-engine/types-expression.d.ts +1 -1
  245. package/dist/types/compute-engine/types-kernel-evaluation.d.ts +1 -1
  246. package/dist/types/compute-engine/types-kernel-serialization.d.ts +1 -1
  247. package/dist/types/compute-engine/types-serialization.d.ts +1 -1
  248. package/dist/types/compute-engine/types.d.ts +1 -1
  249. package/dist/types/compute-engine.d.ts +3 -2
  250. package/dist/types/core.d.ts +1 -1
  251. package/dist/types/interval.d.ts +1 -1
  252. package/dist/types/latex-syntax.d.ts +2 -2
  253. package/dist/types/math-json/symbols.d.ts +1 -1
  254. package/dist/types/math-json/types.d.ts +1 -1
  255. package/dist/types/math-json/utils.d.ts +1 -1
  256. package/dist/types/math-json.d.ts +2 -2
  257. package/dist/types/numerics.d.ts +1 -1
  258. package/package.json +3 -3
@@ -1,4 +1,4 @@
1
- /** Compute Engine 0.55.3 */
1
+ /** Compute Engine 0.55.5 */
2
2
 
3
3
  // src/compute-engine/numerics/richardson.ts
4
4
  function extrapolate(f, x0, options = {}) {
@@ -15066,7 +15066,8 @@ function compile(expr, options) {
15066
15066
  vars: options?.vars,
15067
15067
  imports: options?.imports,
15068
15068
  preamble: options?.preamble,
15069
- realOnly: options?.realOnly
15069
+ realOnly: options?.realOnly,
15070
+ hints: options?.hints
15070
15071
  });
15071
15072
  } catch (e) {
15072
15073
  if (options?.fallback ?? true) {
@@ -16472,30 +16473,6 @@ var COOLWARM = [
16472
16473
  "#ae2036",
16473
16474
  "#b40426"
16474
16475
  ];
16475
- var OCEAN_BALANCE = [
16476
- "#00441b",
16477
- "#006d5b",
16478
- "#1a8c7d",
16479
- "#2fa394",
16480
- "#4fb3a3",
16481
- "#6fc1b3",
16482
- "#8dcfc3",
16483
- "#a6dbd1",
16484
- "#bfe6de",
16485
- "#d7f0ea",
16486
- "#f7f7f7",
16487
- "#eeeeee",
16488
- "#ddd8e6",
16489
- "#c7bcda",
16490
- "#b3a0d0",
16491
- "#9f86c7",
16492
- "#8d6dbd",
16493
- "#7b56b1",
16494
- "#6a42a3",
16495
- "#5a3093",
16496
- "#4a1f82",
16497
- "#3b0f70"
16498
- ];
16499
16476
  var reversePalette = (palette) => palette.slice().reverse();
16500
16477
  var DIVERGING_PALETTES = {
16501
16478
  roma: ROMA,
@@ -16507,9 +16484,7 @@ var DIVERGING_PALETTES = {
16507
16484
  rdbu: RDBU,
16508
16485
  "rdbu-reversed": reversePalette(RDBU),
16509
16486
  coolwarm: COOLWARM,
16510
- "coolwarm-reversed": reversePalette(COOLWARM),
16511
- "ocean-balance": OCEAN_BALANCE,
16512
- "ocean-balance-reversed": reversePalette(OCEAN_BALANCE)
16487
+ "coolwarm-reversed": reversePalette(COOLWARM)
16513
16488
  };
16514
16489
  var TURBO = [
16515
16490
  "#30123b",
@@ -18593,6 +18568,40 @@ var GREY = [
18593
18568
  "#eeeeee",
18594
18569
  "#ffffff"
18595
18570
  ];
18571
+ var CMOCEAN_PHASE = [
18572
+ "#a8780d",
18573
+ "#b3701b",
18574
+ "#be6828",
18575
+ "#c75f35",
18576
+ "#cf5643",
18577
+ "#d54b53",
18578
+ "#db4066",
18579
+ "#de357b",
18580
+ "#df2a93",
18581
+ "#dc25ad",
18582
+ "#d529c4",
18583
+ "#cc34d7",
18584
+ "#c041e5",
18585
+ "#b24fef",
18586
+ "#a25cf3",
18587
+ "#9168f4",
18588
+ "#7d73f0",
18589
+ "#687ce8",
18590
+ "#5285dc",
18591
+ "#3d8bcd",
18592
+ "#2c90bc",
18593
+ "#2093ac",
18594
+ "#19959c",
18595
+ "#12978c",
18596
+ "#0c987c",
18597
+ "#119a69",
18598
+ "#249a52",
18599
+ "#409839",
18600
+ "#5e9420",
18601
+ "#778d12",
18602
+ "#8b860d",
18603
+ "#9b7f0d"
18604
+ ];
18596
18605
  var reversePalette2 = (palette) => palette.slice().reverse();
18597
18606
  var SEQUENTIAL_PALETTES = {
18598
18607
  turbo: TURBO,
@@ -18616,7 +18625,9 @@ var SEQUENTIAL_PALETTES = {
18616
18625
  "rocket-reversed": reversePalette2(ROCKET),
18617
18626
  mako: MAKO,
18618
18627
  // blue to teal
18619
- "mako-reversed": reversePalette2(MAKO)
18628
+ "mako-reversed": reversePalette2(MAKO),
18629
+ "cmocean-phase": CMOCEAN_PHASE,
18630
+ "cmocean-phase-reversed": reversePalette2(CMOCEAN_PHASE)
18620
18631
  };
18621
18632
 
18622
18633
  // src/compute-engine/numerics/special-functions.ts
@@ -20738,6 +20749,43 @@ function fibonacci(n) {
20738
20749
  return b;
20739
20750
  }
20740
20751
 
20752
+ // src/compute-engine/compilation/fractal-orbit.ts
20753
+ function toBigDecimal(v) {
20754
+ if (typeof v === "object" && "hi" in v)
20755
+ return new BigDecimal(v.hi).add(new BigDecimal(v.lo));
20756
+ return new BigDecimal(v);
20757
+ }
20758
+ function hpToNumber(v) {
20759
+ if (typeof v === "number") return v;
20760
+ if (typeof v === "string") return Number(v);
20761
+ return v.hi + v.lo;
20762
+ }
20763
+ function computeReferenceOrbit(center, maxIter, precision) {
20764
+ const prevPrecision = BigDecimal.precision;
20765
+ BigDecimal.precision = precision;
20766
+ try {
20767
+ const cr = toBigDecimal(center[0]);
20768
+ const ci = toBigDecimal(center[1]);
20769
+ let zr = BigDecimal.ZERO;
20770
+ let zi = BigDecimal.ZERO;
20771
+ const ESCAPE = new BigDecimal(256);
20772
+ const points = [];
20773
+ for (let i = 0; i < maxIter; i++) {
20774
+ points.push(zr.toNumber(), zi.toNumber());
20775
+ const zr2 = zr.mul(zr).toPrecision(precision);
20776
+ const zi2 = zi.mul(zi).toPrecision(precision);
20777
+ const mag2 = zr2.add(zi2);
20778
+ if (mag2.cmp(ESCAPE) > 0) break;
20779
+ const new_zi = zr.mul(zi).toPrecision(precision).mul(2).add(ci);
20780
+ zr = zr2.sub(zi2).add(cr);
20781
+ zi = new_zi;
20782
+ }
20783
+ return new Float32Array(points);
20784
+ } finally {
20785
+ BigDecimal.precision = prevPrecision;
20786
+ }
20787
+ }
20788
+
20741
20789
  // src/compute-engine/compilation/gpu-target.ts
20742
20790
  var GPU_OPERATORS = {
20743
20791
  Add: ["+", 11],
@@ -20821,6 +20869,13 @@ function compileGPUSumProduct(kind, args, _compile, target) {
20821
20869
  ];
20822
20870
  return lines.join("\n");
20823
20871
  }
20872
+ function selectFractalStrategy(target) {
20873
+ const radius = target.hints?.viewport?.radius;
20874
+ if (radius === void 0) return "single";
20875
+ if (radius > 1e-6) return "single";
20876
+ if (radius > 1e-14) return "double";
20877
+ return "perturbation";
20878
+ }
20824
20879
  var GPU_FUNCTIONS = {
20825
20880
  // Variadic arithmetic (for function-call form, e.g., with vectors)
20826
20881
  Add: (args, compile2, target) => {
@@ -21316,12 +21371,32 @@ var GPU_FUNCTIONS = {
21316
21371
  if (c === null || maxIter === null)
21317
21372
  throw new Error("Mandelbrot: missing arguments");
21318
21373
  const iterCode = compileIntArg(maxIter, compile2, target);
21374
+ const strategy = selectFractalStrategy(target);
21375
+ if (strategy === "double") {
21376
+ const dpCoord = target?.language === "wgsl" ? "_dp_coord(v_uv)" : "_dp_coord()";
21377
+ return `_fractal_mandelbrot_dp(${dpCoord}, ${iterCode})`;
21378
+ }
21379
+ if (strategy === "perturbation") {
21380
+ const ptDelta = target?.language === "wgsl" ? "_pt_delta(v_uv)" : "_pt_delta()";
21381
+ return `_fractal_mandelbrot_pt(${ptDelta}, ${iterCode})`;
21382
+ }
21319
21383
  return `_fractal_mandelbrot(${compile2(c)}, ${iterCode})`;
21320
21384
  },
21321
21385
  Julia: ([z, c, maxIter], compile2, target) => {
21322
21386
  if (z === null || c === null || maxIter === null)
21323
21387
  throw new Error("Julia: missing arguments");
21324
21388
  const iterCode = compileIntArg(maxIter, compile2, target);
21389
+ const strategy = selectFractalStrategy(target);
21390
+ if (strategy === "double") {
21391
+ const dpCoord = target?.language === "wgsl" ? "_dp_coord(v_uv)" : "_dp_coord()";
21392
+ const cCode = compile2(c);
21393
+ return `_fractal_julia_dp(${dpCoord}, vec4(${cCode}, vec2(0.0)), ${iterCode})`;
21394
+ }
21395
+ if (strategy === "perturbation") {
21396
+ const ptDelta = target?.language === "wgsl" ? "_pt_delta(v_uv)" : "_pt_delta()";
21397
+ const cCode = compile2(c);
21398
+ return `_fractal_julia_pt(${ptDelta}, ${cCode}, ${iterCode})`;
21399
+ }
21325
21400
  return `_fractal_julia(${compile2(z)}, ${compile2(c)}, ${iterCode})`;
21326
21401
  },
21327
21402
  // Vector/Matrix operations
@@ -21919,6 +21994,232 @@ fn _gpu_besselJ(n_in: i32, x_in: f32) -> f32 {
21919
21994
  return sgn * vals[n] / norm;
21920
21995
  }
21921
21996
  `;
21997
+ var GPU_DS_ARITHMETIC_PREAMBLE_GLSL = `
21998
+ // Split a float into high and low parts for exact multiplication
21999
+ vec2 ds_split(float a) {
22000
+ const float SPLIT = 4097.0; // 2^12 + 1
22001
+ float t = SPLIT * a;
22002
+ float hi = t - (t - a);
22003
+ float lo = a - hi;
22004
+ return vec2(hi, lo);
22005
+ }
22006
+
22007
+ // Create a double-single from a single float
22008
+ vec2 ds_from(float a) {
22009
+ return vec2(a, 0.0);
22010
+ }
22011
+
22012
+ // Error-free addition (Knuth TwoSum)
22013
+ vec2 ds_add(vec2 a, vec2 b) {
22014
+ float s = a.x + b.x;
22015
+ float v = s - a.x;
22016
+ float e = (a.x - (s - v)) + (b.x - v);
22017
+ float lo = (a.y + b.y) + e;
22018
+ float hi = s + lo;
22019
+ lo = lo - (hi - s);
22020
+ return vec2(hi, lo);
22021
+ }
22022
+
22023
+ // Double-single subtraction
22024
+ vec2 ds_sub(vec2 a, vec2 b) {
22025
+ return ds_add(a, vec2(-b.x, -b.y));
22026
+ }
22027
+
22028
+ // Error-free multiplication (Dekker TwoProduct)
22029
+ vec2 ds_mul(vec2 a, vec2 b) {
22030
+ float p = a.x * b.x;
22031
+ vec2 sa = ds_split(a.x);
22032
+ vec2 sb = ds_split(b.x);
22033
+ float err = ((sa.x * sb.x - p) + sa.x * sb.y + sa.y * sb.x) + sa.y * sb.y;
22034
+ err += a.x * b.y + a.y * b.x;
22035
+ float hi = p + err;
22036
+ float lo = err - (hi - p);
22037
+ return vec2(hi, lo);
22038
+ }
22039
+
22040
+ // Optimized self-multiply
22041
+ vec2 ds_sqr(vec2 a) {
22042
+ float p = a.x * a.x;
22043
+ vec2 sa = ds_split(a.x);
22044
+ float err = ((sa.x * sa.x - p) + 2.0 * sa.x * sa.y) + sa.y * sa.y;
22045
+ err += 2.0 * a.x * a.y;
22046
+ float hi = p + err;
22047
+ float lo = err - (hi - p);
22048
+ return vec2(hi, lo);
22049
+ }
22050
+
22051
+ // Compare magnitude: returns -1, 0, or 1
22052
+ float ds_cmp(vec2 a, vec2 b) {
22053
+ float d = a.x - b.x;
22054
+ if (d != 0.0) return sign(d);
22055
+ return sign(a.y - b.y);
22056
+ }
22057
+ `;
22058
+ var GPU_DS_ARITHMETIC_PREAMBLE_WGSL = `
22059
+ fn ds_split(a: f32) -> vec2f {
22060
+ const SPLIT: f32 = 4097.0;
22061
+ let t = SPLIT * a;
22062
+ let hi = t - (t - a);
22063
+ let lo = a - hi;
22064
+ return vec2f(hi, lo);
22065
+ }
22066
+
22067
+ fn ds_from(a: f32) -> vec2f {
22068
+ return vec2f(a, 0.0);
22069
+ }
22070
+
22071
+ fn ds_add(a: vec2f, b: vec2f) -> vec2f {
22072
+ let s = a.x + b.x;
22073
+ let v = s - a.x;
22074
+ let e = (a.x - (s - v)) + (b.x - v);
22075
+ let lo_t = (a.y + b.y) + e;
22076
+ let hi = s + lo_t;
22077
+ let lo = lo_t - (hi - s);
22078
+ return vec2f(hi, lo);
22079
+ }
22080
+
22081
+ fn ds_sub(a: vec2f, b: vec2f) -> vec2f {
22082
+ return ds_add(a, vec2f(-b.x, -b.y));
22083
+ }
22084
+
22085
+ fn ds_mul(a: vec2f, b: vec2f) -> vec2f {
22086
+ let p = a.x * b.x;
22087
+ let sa = ds_split(a.x);
22088
+ let sb = ds_split(b.x);
22089
+ var err = ((sa.x * sb.x - p) + sa.x * sb.y + sa.y * sb.x) + sa.y * sb.y;
22090
+ err += a.x * b.y + a.y * b.x;
22091
+ let hi = p + err;
22092
+ let lo = err - (hi - p);
22093
+ return vec2f(hi, lo);
22094
+ }
22095
+
22096
+ fn ds_sqr(a: vec2f) -> vec2f {
22097
+ let p = a.x * a.x;
22098
+ let sa = ds_split(a.x);
22099
+ var err = ((sa.x * sa.x - p) + 2.0 * sa.x * sa.y) + sa.y * sa.y;
22100
+ err += 2.0 * a.x * a.y;
22101
+ let hi = p + err;
22102
+ let lo = err - (hi - p);
22103
+ return vec2f(hi, lo);
22104
+ }
22105
+
22106
+ fn ds_cmp(a: vec2f, b: vec2f) -> f32 {
22107
+ let d = a.x - b.x;
22108
+ if (d != 0.0) { return sign(d); }
22109
+ return sign(a.y - b.y);
22110
+ }
22111
+ `;
22112
+ var GPU_FRACTAL_DP_PREAMBLE_GLSL = `
22113
+ uniform float _dp_cx_hi;
22114
+ uniform float _dp_cx_lo;
22115
+ uniform float _dp_cy_hi;
22116
+ uniform float _dp_cy_lo;
22117
+ uniform float _dp_w;
22118
+ uniform float _dp_h;
22119
+
22120
+ vec4 _dp_coord() {
22121
+ // Per-pixel offset from center \u2014 small, so float-precise
22122
+ float dx = (v_uv.x - 0.5) * _dp_w;
22123
+ float dy = (v_uv.y - 0.5) * _dp_h;
22124
+ // Combine center (hi+lo) + delta with emulated double precision
22125
+ vec2 cre = ds_add(vec2(_dp_cx_hi, _dp_cx_lo), ds_from(dx));
22126
+ vec2 cim = ds_add(vec2(_dp_cy_hi, _dp_cy_lo), ds_from(dy));
22127
+ return vec4(cre.x, cim.x, cre.y, cim.y);
22128
+ }
22129
+
22130
+ float _fractal_mandelbrot_dp(vec4 c, int maxIter) {
22131
+ // c = (re_hi, im_hi, re_lo, im_lo)
22132
+ vec2 cr = vec2(c.x, c.z); // real part as ds
22133
+ vec2 ci = vec2(c.y, c.w); // imag part as ds
22134
+ vec2 zr = vec2(0.0, 0.0);
22135
+ vec2 zi = vec2(0.0, 0.0);
22136
+ for (int i = 0; i < maxIter; i++) {
22137
+ vec2 zr2 = ds_sqr(zr);
22138
+ vec2 zi2 = ds_sqr(zi);
22139
+ // |z|^2 > 4.0 ?
22140
+ vec2 mag2 = ds_add(zr2, zi2);
22141
+ if (mag2.x > 4.0)
22142
+ return clamp((float(i) - log2(log2(mag2.x)) + 4.0) / float(maxIter), 0.0, 1.0);
22143
+ // z = z^2 + c
22144
+ vec2 new_zi = ds_add(ds_mul(ds_add(zr, zr), zi), ci); // 2*zr*zi + ci
22145
+ zr = ds_add(ds_sub(zr2, zi2), cr); // zr^2 - zi^2 + cr
22146
+ zi = new_zi;
22147
+ }
22148
+ return 1.0;
22149
+ }
22150
+
22151
+ float _fractal_julia_dp(vec4 z_in, vec4 c, int maxIter) {
22152
+ vec2 zr = vec2(z_in.x, z_in.z);
22153
+ vec2 zi = vec2(z_in.y, z_in.w);
22154
+ vec2 cr = vec2(c.x, c.z);
22155
+ vec2 ci = vec2(c.y, c.w);
22156
+ for (int i = 0; i < maxIter; i++) {
22157
+ vec2 zr2 = ds_sqr(zr);
22158
+ vec2 zi2 = ds_sqr(zi);
22159
+ vec2 mag2 = ds_add(zr2, zi2);
22160
+ if (mag2.x > 4.0)
22161
+ return clamp((float(i) - log2(log2(mag2.x)) + 4.0) / float(maxIter), 0.0, 1.0);
22162
+ vec2 new_zi = ds_add(ds_mul(ds_add(zr, zr), zi), ci);
22163
+ zr = ds_add(ds_sub(zr2, zi2), cr);
22164
+ zi = new_zi;
22165
+ }
22166
+ return 1.0;
22167
+ }
22168
+ `;
22169
+ var GPU_FRACTAL_DP_PREAMBLE_WGSL = `
22170
+ @group(0) @binding(10) var<uniform> _dp_cx_hi: f32;
22171
+ @group(0) @binding(11) var<uniform> _dp_cx_lo: f32;
22172
+ @group(0) @binding(12) var<uniform> _dp_cy_hi: f32;
22173
+ @group(0) @binding(13) var<uniform> _dp_cy_lo: f32;
22174
+ @group(0) @binding(14) var<uniform> _dp_w: f32;
22175
+ @group(0) @binding(15) var<uniform> _dp_h: f32;
22176
+
22177
+ fn _dp_coord(uv: vec2f) -> vec4f {
22178
+ let dx = (uv.x - 0.5) * _dp_w;
22179
+ let dy = (uv.y - 0.5) * _dp_h;
22180
+ let cre = ds_add(vec2f(_dp_cx_hi, _dp_cx_lo), ds_from(dx));
22181
+ let cim = ds_add(vec2f(_dp_cy_hi, _dp_cy_lo), ds_from(dy));
22182
+ return vec4f(cre.x, cim.x, cre.y, cim.y);
22183
+ }
22184
+
22185
+ fn _fractal_mandelbrot_dp(c: vec4f, maxIter: i32) -> f32 {
22186
+ let cr = vec2f(c.x, c.z);
22187
+ let ci = vec2f(c.y, c.w);
22188
+ var zr = vec2f(0.0, 0.0);
22189
+ var zi = vec2f(0.0, 0.0);
22190
+ for (var i: i32 = 0; i < maxIter; i++) {
22191
+ let zr2 = ds_sqr(zr);
22192
+ let zi2 = ds_sqr(zi);
22193
+ let mag2 = ds_add(zr2, zi2);
22194
+ if (mag2.x > 4.0) {
22195
+ return clamp((f32(i) - log2(log2(mag2.x)) + 4.0) / f32(maxIter), 0.0, 1.0);
22196
+ }
22197
+ let new_zi = ds_add(ds_mul(ds_add(zr, zr), zi), ci);
22198
+ zr = ds_add(ds_sub(zr2, zi2), cr);
22199
+ zi = new_zi;
22200
+ }
22201
+ return 1.0;
22202
+ }
22203
+
22204
+ fn _fractal_julia_dp(z_in: vec4f, c: vec4f, maxIter: i32) -> f32 {
22205
+ var zr = vec2f(z_in.x, z_in.z);
22206
+ var zi = vec2f(z_in.y, z_in.w);
22207
+ let cr = vec2f(c.x, c.z);
22208
+ let ci = vec2f(c.y, c.w);
22209
+ for (var i: i32 = 0; i < maxIter; i++) {
22210
+ let zr2 = ds_sqr(zr);
22211
+ let zi2 = ds_sqr(zi);
22212
+ let mag2 = ds_add(zr2, zi2);
22213
+ if (mag2.x > 4.0) {
22214
+ return clamp((f32(i) - log2(log2(mag2.x)) + 4.0) / f32(maxIter), 0.0, 1.0);
22215
+ }
22216
+ let new_zi = ds_add(ds_mul(ds_add(zr, zr), zi), ci);
22217
+ zr = ds_add(ds_sub(zr2, zi2), cr);
22218
+ zi = new_zi;
22219
+ }
22220
+ return 1.0;
22221
+ }
22222
+ `;
21922
22223
  var GPU_FRACTAL_PREAMBLE_GLSL = `
21923
22224
  float _fractal_mandelbrot(vec2 c, int maxIter) {
21924
22225
  vec2 z = vec2(0.0, 0.0);
@@ -21962,6 +22263,208 @@ fn _fractal_julia(z_in: vec2f, c: vec2f, maxIter: i32) -> f32 {
21962
22263
  return 1.0;
21963
22264
  }
21964
22265
  `;
22266
+ var GPU_FRACTAL_PT_PREAMBLE_GLSL = `
22267
+ uniform sampler2D _refOrbit;
22268
+ uniform int _refOrbitLen;
22269
+ uniform int _refOrbitTexWidth;
22270
+ uniform float _pt_offset_x;
22271
+ uniform float _pt_offset_y;
22272
+ uniform float _pt_w;
22273
+ uniform float _pt_h;
22274
+
22275
+ vec2 _pt_delta() {
22276
+ float dx = _pt_offset_x + (v_uv.x - 0.5) * _pt_w;
22277
+ float dy = _pt_offset_y + (v_uv.y - 0.5) * _pt_h;
22278
+ return vec2(dx, dy);
22279
+ }
22280
+
22281
+ vec2 _pt_fetch_orbit(int i) {
22282
+ int y = i / _refOrbitTexWidth;
22283
+ int x = i - y * _refOrbitTexWidth;
22284
+ return texelFetch(_refOrbit, ivec2(x, y), 0).rg;
22285
+ }
22286
+
22287
+ float _fractal_mandelbrot_pt(vec2 delta_c, int maxIter) {
22288
+ float dr = 0.0;
22289
+ float di = 0.0;
22290
+ int orbitLen = min(maxIter, _refOrbitLen);
22291
+ for (int i = 0; i < orbitLen; i++) {
22292
+ vec2 Zn = _pt_fetch_orbit(i);
22293
+ // delta_{n+1} = 2*Z_n*delta_n + delta_n^2 + delta_c
22294
+ float new_dr = 2.0 * (Zn.x * dr - Zn.y * di) + dr * dr - di * di + delta_c.x;
22295
+ float new_di = 2.0 * (Zn.x * di + Zn.y * dr) + 2.0 * dr * di + delta_c.y;
22296
+ dr = new_dr;
22297
+ di = new_di;
22298
+ // Full z = Z_{n+1} + delta for escape check
22299
+ vec2 Zn1 = (i + 1 < orbitLen) ? _pt_fetch_orbit(i + 1) : vec2(0.0);
22300
+ float zr = Zn1.x + dr;
22301
+ float zi = Zn1.y + di;
22302
+ float mag2 = zr * zr + zi * zi;
22303
+ if (mag2 > 4.0)
22304
+ return clamp((float(i) - log2(log2(mag2)) + 4.0) / float(maxIter), 0.0, 1.0);
22305
+ // Glitch detection: |delta|^2 > |Z|^2
22306
+ float dmag2 = dr * dr + di * di;
22307
+ float Zmag2 = Zn.x * Zn.x + Zn.y * Zn.y;
22308
+ if (dmag2 > Zmag2 && Zmag2 > 0.0) {
22309
+ // Rebase to absolute coordinates and continue with single-float
22310
+ float abs_zr = Zn1.x + dr;
22311
+ float abs_zi = Zn1.y + di;
22312
+ // Reconstruct absolute c from reference + delta
22313
+ // (Use ds_from for the concept, but single-float suffices for fallback)
22314
+ float cx = abs_zr - dr + delta_c.x;
22315
+ float cy = abs_zi - di + delta_c.y;
22316
+ for (int j = i + 1; j < maxIter; j++) {
22317
+ float new_zr = abs_zr * abs_zr - abs_zi * abs_zi + cx;
22318
+ abs_zi = 2.0 * abs_zr * abs_zi + cy;
22319
+ abs_zr = new_zr;
22320
+ mag2 = abs_zr * abs_zr + abs_zi * abs_zi;
22321
+ if (mag2 > 4.0)
22322
+ return clamp((float(j) - log2(log2(mag2)) + 4.0) / float(maxIter), 0.0, 1.0);
22323
+ }
22324
+ return 1.0;
22325
+ }
22326
+ }
22327
+ return 1.0;
22328
+ }
22329
+
22330
+ float _fractal_julia_pt(vec2 z_delta, vec2 delta_c, int maxIter) {
22331
+ float dr = z_delta.x;
22332
+ float di = z_delta.y;
22333
+ int orbitLen = min(maxIter, _refOrbitLen);
22334
+ for (int i = 0; i < orbitLen; i++) {
22335
+ vec2 Zn = _pt_fetch_orbit(i);
22336
+ float new_dr = 2.0 * (Zn.x * dr - Zn.y * di) + dr * dr - di * di + delta_c.x;
22337
+ float new_di = 2.0 * (Zn.x * di + Zn.y * dr) + 2.0 * dr * di + delta_c.y;
22338
+ dr = new_dr;
22339
+ di = new_di;
22340
+ vec2 Zn1 = (i + 1 < orbitLen) ? _pt_fetch_orbit(i + 1) : vec2(0.0);
22341
+ float zr = Zn1.x + dr;
22342
+ float zi = Zn1.y + di;
22343
+ float mag2 = zr * zr + zi * zi;
22344
+ if (mag2 > 4.0)
22345
+ return clamp((float(i) - log2(log2(mag2)) + 4.0) / float(maxIter), 0.0, 1.0);
22346
+ float dmag2 = dr * dr + di * di;
22347
+ float Zmag2 = Zn.x * Zn.x + Zn.y * Zn.y;
22348
+ if (dmag2 > Zmag2 && Zmag2 > 0.0) {
22349
+ float abs_zr = Zn1.x + dr;
22350
+ float abs_zi = Zn1.y + di;
22351
+ float cx = delta_c.x;
22352
+ float cy = delta_c.y;
22353
+ for (int j = i + 1; j < maxIter; j++) {
22354
+ float new_zr = abs_zr * abs_zr - abs_zi * abs_zi + cx;
22355
+ abs_zi = 2.0 * abs_zr * abs_zi + cy;
22356
+ abs_zr = new_zr;
22357
+ mag2 = abs_zr * abs_zr + abs_zi * abs_zi;
22358
+ if (mag2 > 4.0)
22359
+ return clamp((float(j) - log2(log2(mag2)) + 4.0) / float(maxIter), 0.0, 1.0);
22360
+ }
22361
+ return 1.0;
22362
+ }
22363
+ }
22364
+ return 1.0;
22365
+ }
22366
+ `;
22367
+ var GPU_FRACTAL_PT_PREAMBLE_WGSL = `
22368
+ @group(0) @binding(1) var _refOrbit: texture_2d<f32>;
22369
+ var<uniform> _refOrbitLen: i32;
22370
+ var<uniform> _refOrbitTexWidth: i32;
22371
+ var<uniform> _pt_offset_x: f32;
22372
+ var<uniform> _pt_offset_y: f32;
22373
+ var<uniform> _pt_w: f32;
22374
+ var<uniform> _pt_h: f32;
22375
+
22376
+ fn _pt_delta(uv: vec2f) -> vec2f {
22377
+ let dx = _pt_offset_x + (uv.x - 0.5) * _pt_w;
22378
+ let dy = _pt_offset_y + (uv.y - 0.5) * _pt_h;
22379
+ return vec2f(dx, dy);
22380
+ }
22381
+
22382
+ fn _pt_fetch_orbit(i: i32) -> vec2f {
22383
+ let y = i / _refOrbitTexWidth;
22384
+ let x = i - y * _refOrbitTexWidth;
22385
+ return textureLoad(_refOrbit, vec2i(x, y), 0).rg;
22386
+ }
22387
+
22388
+ fn _fractal_mandelbrot_pt(delta_c: vec2f, maxIter: i32) -> f32 {
22389
+ var dr: f32 = 0.0;
22390
+ var di: f32 = 0.0;
22391
+ let orbitLen = min(maxIter, _refOrbitLen);
22392
+ for (var i: i32 = 0; i < orbitLen; i++) {
22393
+ let Zn = _pt_fetch_orbit(i);
22394
+ let new_dr = 2.0 * (Zn.x * dr - Zn.y * di) + dr * dr - di * di + delta_c.x;
22395
+ let new_di = 2.0 * (Zn.x * di + Zn.y * dr) + 2.0 * dr * di + delta_c.y;
22396
+ dr = new_dr;
22397
+ di = new_di;
22398
+ var Zn1 = vec2f(0.0);
22399
+ if (i + 1 < orbitLen) { Zn1 = _pt_fetch_orbit(i + 1); }
22400
+ let zr = Zn1.x + dr;
22401
+ let zi = Zn1.y + di;
22402
+ var mag2 = zr * zr + zi * zi;
22403
+ if (mag2 > 4.0) {
22404
+ return clamp((f32(i) - log2(log2(mag2)) + 4.0) / f32(maxIter), 0.0, 1.0);
22405
+ }
22406
+ let dmag2 = dr * dr + di * di;
22407
+ let Zmag2 = Zn.x * Zn.x + Zn.y * Zn.y;
22408
+ if (dmag2 > Zmag2 && Zmag2 > 0.0) {
22409
+ var f_zr = Zn1.x + dr;
22410
+ var f_zi = Zn1.y + di;
22411
+ let cx = delta_c.x;
22412
+ let cy = delta_c.y;
22413
+ for (var j: i32 = i + 1; j < maxIter; j++) {
22414
+ let t_zr = f_zr * f_zr - f_zi * f_zi + cx;
22415
+ f_zi = 2.0 * f_zr * f_zi + cy;
22416
+ f_zr = t_zr;
22417
+ mag2 = f_zr * f_zr + f_zi * f_zi;
22418
+ if (mag2 > 4.0) {
22419
+ return clamp((f32(j) - log2(log2(mag2)) + 4.0) / f32(maxIter), 0.0, 1.0);
22420
+ }
22421
+ }
22422
+ return 1.0;
22423
+ }
22424
+ }
22425
+ return 1.0;
22426
+ }
22427
+
22428
+ fn _fractal_julia_pt(z_delta: vec2f, delta_c: vec2f, maxIter: i32) -> f32 {
22429
+ var dr = z_delta.x;
22430
+ var di = z_delta.y;
22431
+ let orbitLen = min(maxIter, _refOrbitLen);
22432
+ for (var i: i32 = 0; i < orbitLen; i++) {
22433
+ let Zn = _pt_fetch_orbit(i);
22434
+ let new_dr = 2.0 * (Zn.x * dr - Zn.y * di) + dr * dr - di * di + delta_c.x;
22435
+ let new_di = 2.0 * (Zn.x * di + Zn.y * dr) + 2.0 * dr * di + delta_c.y;
22436
+ dr = new_dr;
22437
+ di = new_di;
22438
+ var Zn1 = vec2f(0.0);
22439
+ if (i + 1 < orbitLen) { Zn1 = _pt_fetch_orbit(i + 1); }
22440
+ let zr = Zn1.x + dr;
22441
+ let zi = Zn1.y + di;
22442
+ var mag2 = zr * zr + zi * zi;
22443
+ if (mag2 > 4.0) {
22444
+ return clamp((f32(i) - log2(log2(mag2)) + 4.0) / f32(maxIter), 0.0, 1.0);
22445
+ }
22446
+ let dmag2 = dr * dr + di * di;
22447
+ let Zmag2 = Zn.x * Zn.x + Zn.y * Zn.y;
22448
+ if (dmag2 > Zmag2 && Zmag2 > 0.0) {
22449
+ var f_zr = Zn1.x + dr;
22450
+ var f_zi = Zn1.y + di;
22451
+ let cx = delta_c.x;
22452
+ let cy = delta_c.y;
22453
+ for (var j: i32 = i + 1; j < maxIter; j++) {
22454
+ let t_zr = f_zr * f_zr - f_zi * f_zi + cx;
22455
+ f_zi = 2.0 * f_zr * f_zi + cy;
22456
+ f_zr = t_zr;
22457
+ mag2 = f_zr * f_zr + f_zi * f_zi;
22458
+ if (mag2 > 4.0) {
22459
+ return clamp((f32(j) - log2(log2(mag2)) + 4.0) / f32(maxIter), 0.0, 1.0);
22460
+ }
22461
+ }
22462
+ return 1.0;
22463
+ }
22464
+ }
22465
+ return 1.0;
22466
+ }
22467
+ `;
21965
22468
  var GPU_COLOR_PREAMBLE_GLSL = `
21966
22469
  float _gpu_srgb_to_linear(float c) {
21967
22470
  if (c <= 0.04045) return c / 12.92;
@@ -22400,6 +22903,7 @@ var GPUShaderTarget = class {
22400
22903
  const constants = this.getConstants();
22401
22904
  const v2 = this.languageId === "wgsl" ? "vec2f" : "vec2";
22402
22905
  const target = this.createTarget({
22906
+ hints: options.hints,
22403
22907
  functions: (id) => {
22404
22908
  if (userFunctions && id in userFunctions) {
22405
22909
  const fn = userFunctions[id];
@@ -22438,12 +22942,89 @@ var GPUShaderTarget = class {
22438
22942
  if (code.includes("_gpu_besselJ"))
22439
22943
  preamble += this.languageId === "wgsl" ? GPU_BESSELJ_PREAMBLE_WGSL : GPU_BESSELJ_PREAMBLE_GLSL;
22440
22944
  if (code.includes("_fractal_")) {
22441
- preamble += this.languageId === "wgsl" ? GPU_FRACTAL_PREAMBLE_WGSL : GPU_FRACTAL_PREAMBLE_GLSL;
22945
+ if (code.includes("_fractal_mandelbrot_pt") || code.includes("_fractal_julia_pt")) {
22946
+ preamble += this.languageId === "wgsl" ? GPU_DS_ARITHMETIC_PREAMBLE_WGSL : GPU_DS_ARITHMETIC_PREAMBLE_GLSL;
22947
+ preamble += this.languageId === "wgsl" ? GPU_FRACTAL_PT_PREAMBLE_WGSL : GPU_FRACTAL_PT_PREAMBLE_GLSL;
22948
+ } else if (code.includes("_fractal_mandelbrot_dp") || code.includes("_fractal_julia_dp")) {
22949
+ preamble += this.languageId === "wgsl" ? GPU_DS_ARITHMETIC_PREAMBLE_WGSL : GPU_DS_ARITHMETIC_PREAMBLE_GLSL;
22950
+ preamble += this.languageId === "wgsl" ? GPU_FRACTAL_DP_PREAMBLE_WGSL : GPU_FRACTAL_DP_PREAMBLE_GLSL;
22951
+ } else {
22952
+ preamble += this.languageId === "wgsl" ? GPU_FRACTAL_PREAMBLE_WGSL : GPU_FRACTAL_PREAMBLE_GLSL;
22953
+ }
22442
22954
  }
22443
22955
  if (code.includes("_gpu_srgb_to") || code.includes("_gpu_oklab") || code.includes("_gpu_oklch") || code.includes("_gpu_color_mix") || code.includes("_gpu_apca")) {
22444
22956
  preamble += this.languageId === "wgsl" ? GPU_COLOR_PREAMBLE_WGSL : GPU_COLOR_PREAMBLE_GLSL;
22445
22957
  }
22446
22958
  if (preamble) result.preamble = preamble;
22959
+ if (code.includes("_fractal_") && options.hints?.viewport) {
22960
+ const strategy = selectFractalStrategy(target);
22961
+ const radius = options.hints.viewport.radius;
22962
+ switch (strategy) {
22963
+ case "single":
22964
+ result.staleWhen = { radiusBelow: 1e-6 };
22965
+ break;
22966
+ case "double":
22967
+ result.staleWhen = { radiusBelow: 1e-14, radiusAbove: 1e-5 };
22968
+ break;
22969
+ case "perturbation":
22970
+ result.staleWhen = {
22971
+ radiusAbove: 1e-5,
22972
+ radiusBelow: radius * 0.01,
22973
+ centerDistance: radius * 2
22974
+ };
22975
+ break;
22976
+ }
22977
+ }
22978
+ if ((code.includes("_fractal_mandelbrot_dp") || code.includes("_fractal_julia_dp")) && options.hints?.viewport) {
22979
+ const cx = hpToNumber(options.hints.viewport.center[0]);
22980
+ const cy = hpToNumber(options.hints.viewport.center[1]);
22981
+ const size = options.hints.viewport.radius * 2;
22982
+ const cx_hi = Math.fround(cx);
22983
+ const cy_hi = Math.fround(cy);
22984
+ result.uniforms = {
22985
+ ...result.uniforms,
22986
+ _dp_cx_hi: cx_hi,
22987
+ _dp_cx_lo: cx - cx_hi,
22988
+ _dp_cy_hi: cy_hi,
22989
+ _dp_cy_lo: cy - cy_hi,
22990
+ _dp_w: size,
22991
+ _dp_h: size
22992
+ };
22993
+ }
22994
+ if ((code.includes("_fractal_mandelbrot_pt") || code.includes("_fractal_julia_pt")) && options.hints?.viewport) {
22995
+ const viewport = options.hints.viewport;
22996
+ const size = viewport.radius * 2;
22997
+ result.uniforms = {
22998
+ ...result.uniforms,
22999
+ _pt_offset_x: 0,
23000
+ _pt_offset_y: 0,
23001
+ _pt_w: size,
23002
+ _pt_h: size
23003
+ };
23004
+ const digits = Math.max(50, Math.ceil(-Math.log10(viewport.radius)) + 10);
23005
+ const maxIter = 1e3;
23006
+ const orbit = computeReferenceOrbit(
23007
+ viewport.center,
23008
+ maxIter,
23009
+ digits
23010
+ );
23011
+ const orbitLen = orbit.length / 2;
23012
+ const texWidth = Math.min(orbitLen, 4096);
23013
+ const texHeight = Math.ceil(orbitLen / texWidth);
23014
+ result.textures = {
23015
+ _refOrbit: {
23016
+ data: orbit,
23017
+ width: texWidth,
23018
+ height: texHeight,
23019
+ format: "rg32f"
23020
+ }
23021
+ };
23022
+ result.uniforms = {
23023
+ ...result.uniforms,
23024
+ _refOrbitLen: orbitLen,
23025
+ _refOrbitTexWidth: texWidth
23026
+ };
23027
+ }
22447
23028
  return result;
22448
23029
  }
22449
23030
  compileToSource(expr, _options = {}) {
@@ -24778,7 +25359,7 @@ function compileToIntervalTarget(expr, target) {
24778
25359
  }
24779
25360
 
24780
25361
  // src/compile.ts
24781
- var version = "0.55.3";
25362
+ var version = "0.55.5";
24782
25363
  export {
24783
25364
  BaseCompiler,
24784
25365
  GLSLTarget,