@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
  (function(global,factory){typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'],factory):(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ComputeEngine = {}));})(this, (function (exports) { 'use strict';
3
3
  var ComputeEngine = (() => {
4
4
  var __defProp = Object.defineProperty;
@@ -25,6 +25,7 @@ var ComputeEngine = (() => {
25
25
  ALGEBRA_DICTIONARY: () => DEFINITIONS_ALGEBRA,
26
26
  ARITHMETIC_DICTIONARY: () => DEFINITIONS_ARITHMETIC,
27
27
  BaseCompiler: () => BaseCompiler,
28
+ BigDecimal: () => BigDecimal,
28
29
  CALCULUS_DICTIONARY: () => DEFINITIONS_CALCULUS,
29
30
  COMPLEX_DICTIONARY: () => DEFINITIONS_COMPLEX,
30
31
  CORE_DICTIONARY: () => DEFINITIONS_CORE,
@@ -17227,6 +17228,10 @@ var ComputeEngine = (() => {
17227
17228
  parser.nextToken();
17228
17229
  continue;
17229
17230
  }
17231
+ if (EMOJIS.test(id + token)) {
17232
+ id += parser.nextToken();
17233
+ continue;
17234
+ }
17230
17235
  const next = parseSymbolToken(parser, { toplevel: false });
17231
17236
  if (next === null) return null;
17232
17237
  id += next;
@@ -17266,6 +17271,7 @@ var ComputeEngine = (() => {
17266
17271
  function matchPrefixedSymbol(parser) {
17267
17272
  const prefix = SYMBOL_PREFIX[parser.peek] ?? null;
17268
17273
  if (prefix === null) return null;
17274
+ const start = parser.index;
17269
17275
  parser.nextToken();
17270
17276
  if (parser.match("<{>")) {
17271
17277
  let body = "";
@@ -17286,17 +17292,48 @@ var ComputeEngine = (() => {
17286
17292
  parser.nextToken();
17287
17293
  }
17288
17294
  body += parseSymbolBody(parser);
17289
- if (body === null || !parser.match("<}>")) return null;
17295
+ if (body === null || !parser.match("<}>")) {
17296
+ parser.index = start;
17297
+ return null;
17298
+ }
17290
17299
  if (prefix === "_upright" && body.length > 1) return body;
17291
17300
  return body + prefix;
17292
17301
  }
17302
+ parser.index = start;
17293
17303
  return null;
17294
17304
  }
17295
17305
  function parseInvalidSymbol(parser) {
17296
17306
  const start = parser.index;
17297
17307
  const id = matchPrefixedSymbol(parser);
17298
- if (id === null || isValidSymbol(id)) return null;
17299
- return parser.error(["invalid-symbol", { str: validateSymbol(id) }], start);
17308
+ if (id !== null) {
17309
+ if (isValidSymbol(id)) return null;
17310
+ return parser.error(["invalid-symbol", { str: validateSymbol(id) }], start);
17311
+ }
17312
+ parser.index = start;
17313
+ const prefix = SYMBOL_PREFIX[parser.peek] ?? null;
17314
+ if (prefix === null) return null;
17315
+ parser.nextToken();
17316
+ if (!parser.match("<{>")) {
17317
+ parser.index = start;
17318
+ return null;
17319
+ }
17320
+ const bodyStart = parser.index;
17321
+ let level = 0;
17322
+ while (!parser.atEnd && !(level === 0 && parser.peek === "<}>")) {
17323
+ if (parser.peek === "<{>") level += 1;
17324
+ if (parser.peek === "<}>") level -= 1;
17325
+ parser.nextToken();
17326
+ }
17327
+ const bodyText = parser.latex(bodyStart, parser.index);
17328
+ if (isValidSymbol(bodyText)) {
17329
+ parser.index = start;
17330
+ return null;
17331
+ }
17332
+ parser.match("<}>");
17333
+ return parser.error(
17334
+ ["invalid-symbol", { str: validateSymbol(bodyText) }],
17335
+ start
17336
+ );
17300
17337
  }
17301
17338
  function parseSymbol(parser) {
17302
17339
  if (/^[a-zA-Z]$/.test(parser.peek) || /^\p{XIDS}$/u.test(parser.peek)) {
@@ -18251,18 +18288,12 @@ var ComputeEngine = (() => {
18251
18288
  this.index = start;
18252
18289
  return false;
18253
18290
  }
18254
- const matchedToken = this.nextToken();
18255
- const useLatexCommand = matchedToken.startsWith("\\");
18291
+ this.nextToken();
18256
18292
  if (hasBracedDelimiter && !this.match("<}>")) {
18257
18293
  this.index = start;
18258
18294
  return false;
18259
18295
  }
18260
- const closeTokens = DELIMITER_SHORTHAND2[close[0]] ?? [
18261
- close[0]
18262
- ];
18263
- const closeToken = closeTokens.find(
18264
- (t) => useLatexCommand ? t.startsWith("\\") : !t.startsWith("\\")
18265
- ) ?? closeTokens[0];
18296
+ const closeToken = close[0];
18266
18297
  const closeBoundary3 = closePrefix ? hasBracedDelimiter ? [closePrefix, "<{>", closeToken, "<}>"] : [closePrefix, closeToken] : [closeToken];
18267
18298
  this.addBoundary(closeBoundary3);
18268
18299
  return true;
@@ -39657,30 +39688,6 @@ ${e.message}
39657
39688
  "#ae2036",
39658
39689
  "#b40426"
39659
39690
  ];
39660
- var OCEAN_BALANCE = [
39661
- "#00441b",
39662
- "#006d5b",
39663
- "#1a8c7d",
39664
- "#2fa394",
39665
- "#4fb3a3",
39666
- "#6fc1b3",
39667
- "#8dcfc3",
39668
- "#a6dbd1",
39669
- "#bfe6de",
39670
- "#d7f0ea",
39671
- "#f7f7f7",
39672
- "#eeeeee",
39673
- "#ddd8e6",
39674
- "#c7bcda",
39675
- "#b3a0d0",
39676
- "#9f86c7",
39677
- "#8d6dbd",
39678
- "#7b56b1",
39679
- "#6a42a3",
39680
- "#5a3093",
39681
- "#4a1f82",
39682
- "#3b0f70"
39683
- ];
39684
39691
  var reversePalette = (palette) => palette.slice().reverse();
39685
39692
  var DIVERGING_PALETTES = {
39686
39693
  roma: ROMA,
@@ -39692,9 +39699,7 @@ ${e.message}
39692
39699
  rdbu: RDBU,
39693
39700
  "rdbu-reversed": reversePalette(RDBU),
39694
39701
  coolwarm: COOLWARM,
39695
- "coolwarm-reversed": reversePalette(COOLWARM),
39696
- "ocean-balance": OCEAN_BALANCE,
39697
- "ocean-balance-reversed": reversePalette(OCEAN_BALANCE)
39702
+ "coolwarm-reversed": reversePalette(COOLWARM)
39698
39703
  };
39699
39704
  var TURBO = [
39700
39705
  "#30123b",
@@ -41778,6 +41783,40 @@ ${e.message}
41778
41783
  "#eeeeee",
41779
41784
  "#ffffff"
41780
41785
  ];
41786
+ var CMOCEAN_PHASE = [
41787
+ "#a8780d",
41788
+ "#b3701b",
41789
+ "#be6828",
41790
+ "#c75f35",
41791
+ "#cf5643",
41792
+ "#d54b53",
41793
+ "#db4066",
41794
+ "#de357b",
41795
+ "#df2a93",
41796
+ "#dc25ad",
41797
+ "#d529c4",
41798
+ "#cc34d7",
41799
+ "#c041e5",
41800
+ "#b24fef",
41801
+ "#a25cf3",
41802
+ "#9168f4",
41803
+ "#7d73f0",
41804
+ "#687ce8",
41805
+ "#5285dc",
41806
+ "#3d8bcd",
41807
+ "#2c90bc",
41808
+ "#2093ac",
41809
+ "#19959c",
41810
+ "#12978c",
41811
+ "#0c987c",
41812
+ "#119a69",
41813
+ "#249a52",
41814
+ "#409839",
41815
+ "#5e9420",
41816
+ "#778d12",
41817
+ "#8b860d",
41818
+ "#9b7f0d"
41819
+ ];
41781
41820
  var reversePalette2 = (palette) => palette.slice().reverse();
41782
41821
  var SEQUENTIAL_PALETTES = {
41783
41822
  turbo: TURBO,
@@ -41801,7 +41840,9 @@ ${e.message}
41801
41840
  "rocket-reversed": reversePalette2(ROCKET),
41802
41841
  mako: MAKO,
41803
41842
  // blue to teal
41804
- "mako-reversed": reversePalette2(MAKO)
41843
+ "mako-reversed": reversePalette2(MAKO),
41844
+ "cmocean-phase": CMOCEAN_PHASE,
41845
+ "cmocean-phase-reversed": reversePalette2(CMOCEAN_PHASE)
41805
41846
  };
41806
41847
 
41807
41848
  // src/compute-engine/library/colors.ts
@@ -54798,7 +54839,8 @@ Error in definition of "${name}"`,
54798
54839
  vars: options?.vars,
54799
54840
  imports: options?.imports,
54800
54841
  preamble: options?.preamble,
54801
- realOnly: options?.realOnly
54842
+ realOnly: options?.realOnly,
54843
+ hints: options?.hints
54802
54844
  });
54803
54845
  } catch (e) {
54804
54846
  if (options?.fallback ?? true) {
@@ -61298,6 +61340,43 @@ Error in definition of "${name}"`,
61298
61340
  return b;
61299
61341
  }
61300
61342
 
61343
+ // src/compute-engine/compilation/fractal-orbit.ts
61344
+ function toBigDecimal(v) {
61345
+ if (typeof v === "object" && "hi" in v)
61346
+ return new BigDecimal(v.hi).add(new BigDecimal(v.lo));
61347
+ return new BigDecimal(v);
61348
+ }
61349
+ function hpToNumber(v) {
61350
+ if (typeof v === "number") return v;
61351
+ if (typeof v === "string") return Number(v);
61352
+ return v.hi + v.lo;
61353
+ }
61354
+ function computeReferenceOrbit(center, maxIter, precision) {
61355
+ const prevPrecision = BigDecimal.precision;
61356
+ BigDecimal.precision = precision;
61357
+ try {
61358
+ const cr = toBigDecimal(center[0]);
61359
+ const ci = toBigDecimal(center[1]);
61360
+ let zr = BigDecimal.ZERO;
61361
+ let zi = BigDecimal.ZERO;
61362
+ const ESCAPE = new BigDecimal(256);
61363
+ const points = [];
61364
+ for (let i = 0; i < maxIter; i++) {
61365
+ points.push(zr.toNumber(), zi.toNumber());
61366
+ const zr2 = zr.mul(zr).toPrecision(precision);
61367
+ const zi2 = zi.mul(zi).toPrecision(precision);
61368
+ const mag2 = zr2.add(zi2);
61369
+ if (mag2.cmp(ESCAPE) > 0) break;
61370
+ const new_zi = zr.mul(zi).toPrecision(precision).mul(2).add(ci);
61371
+ zr = zr2.sub(zi2).add(cr);
61372
+ zi = new_zi;
61373
+ }
61374
+ return new Float32Array(points);
61375
+ } finally {
61376
+ BigDecimal.precision = prevPrecision;
61377
+ }
61378
+ }
61379
+
61301
61380
  // src/compute-engine/compilation/gpu-target.ts
61302
61381
  var GPU_OPERATORS = {
61303
61382
  Add: ["+", 11],
@@ -61381,6 +61460,13 @@ Error in definition of "${name}"`,
61381
61460
  ];
61382
61461
  return lines.join("\n");
61383
61462
  }
61463
+ function selectFractalStrategy(target) {
61464
+ const radius = target.hints?.viewport?.radius;
61465
+ if (radius === void 0) return "single";
61466
+ if (radius > 1e-6) return "single";
61467
+ if (radius > 1e-14) return "double";
61468
+ return "perturbation";
61469
+ }
61384
61470
  var GPU_FUNCTIONS = {
61385
61471
  // Variadic arithmetic (for function-call form, e.g., with vectors)
61386
61472
  Add: (args, compile3, target) => {
@@ -61876,12 +61962,32 @@ Error in definition of "${name}"`,
61876
61962
  if (c === null || maxIter === null)
61877
61963
  throw new Error("Mandelbrot: missing arguments");
61878
61964
  const iterCode = compileIntArg(maxIter, compile3, target);
61965
+ const strategy = selectFractalStrategy(target);
61966
+ if (strategy === "double") {
61967
+ const dpCoord = target?.language === "wgsl" ? "_dp_coord(v_uv)" : "_dp_coord()";
61968
+ return `_fractal_mandelbrot_dp(${dpCoord}, ${iterCode})`;
61969
+ }
61970
+ if (strategy === "perturbation") {
61971
+ const ptDelta = target?.language === "wgsl" ? "_pt_delta(v_uv)" : "_pt_delta()";
61972
+ return `_fractal_mandelbrot_pt(${ptDelta}, ${iterCode})`;
61973
+ }
61879
61974
  return `_fractal_mandelbrot(${compile3(c)}, ${iterCode})`;
61880
61975
  },
61881
61976
  Julia: ([z, c, maxIter], compile3, target) => {
61882
61977
  if (z === null || c === null || maxIter === null)
61883
61978
  throw new Error("Julia: missing arguments");
61884
61979
  const iterCode = compileIntArg(maxIter, compile3, target);
61980
+ const strategy = selectFractalStrategy(target);
61981
+ if (strategy === "double") {
61982
+ const dpCoord = target?.language === "wgsl" ? "_dp_coord(v_uv)" : "_dp_coord()";
61983
+ const cCode = compile3(c);
61984
+ return `_fractal_julia_dp(${dpCoord}, vec4(${cCode}, vec2(0.0)), ${iterCode})`;
61985
+ }
61986
+ if (strategy === "perturbation") {
61987
+ const ptDelta = target?.language === "wgsl" ? "_pt_delta(v_uv)" : "_pt_delta()";
61988
+ const cCode = compile3(c);
61989
+ return `_fractal_julia_pt(${ptDelta}, ${cCode}, ${iterCode})`;
61990
+ }
61885
61991
  return `_fractal_julia(${compile3(z)}, ${compile3(c)}, ${iterCode})`;
61886
61992
  },
61887
61993
  // Vector/Matrix operations
@@ -62478,6 +62584,232 @@ fn _gpu_besselJ(n_in: i32, x_in: f32) -> f32 {
62478
62584
  for (var k2: i32 = 2; k2 <= M; k2 += 2) { norm += 2.0 * vals[k2]; }
62479
62585
  return sgn * vals[n] / norm;
62480
62586
  }
62587
+ `;
62588
+ var GPU_DS_ARITHMETIC_PREAMBLE_GLSL = `
62589
+ // Split a float into high and low parts for exact multiplication
62590
+ vec2 ds_split(float a) {
62591
+ const float SPLIT = 4097.0; // 2^12 + 1
62592
+ float t = SPLIT * a;
62593
+ float hi = t - (t - a);
62594
+ float lo = a - hi;
62595
+ return vec2(hi, lo);
62596
+ }
62597
+
62598
+ // Create a double-single from a single float
62599
+ vec2 ds_from(float a) {
62600
+ return vec2(a, 0.0);
62601
+ }
62602
+
62603
+ // Error-free addition (Knuth TwoSum)
62604
+ vec2 ds_add(vec2 a, vec2 b) {
62605
+ float s = a.x + b.x;
62606
+ float v = s - a.x;
62607
+ float e = (a.x - (s - v)) + (b.x - v);
62608
+ float lo = (a.y + b.y) + e;
62609
+ float hi = s + lo;
62610
+ lo = lo - (hi - s);
62611
+ return vec2(hi, lo);
62612
+ }
62613
+
62614
+ // Double-single subtraction
62615
+ vec2 ds_sub(vec2 a, vec2 b) {
62616
+ return ds_add(a, vec2(-b.x, -b.y));
62617
+ }
62618
+
62619
+ // Error-free multiplication (Dekker TwoProduct)
62620
+ vec2 ds_mul(vec2 a, vec2 b) {
62621
+ float p = a.x * b.x;
62622
+ vec2 sa = ds_split(a.x);
62623
+ vec2 sb = ds_split(b.x);
62624
+ float err = ((sa.x * sb.x - p) + sa.x * sb.y + sa.y * sb.x) + sa.y * sb.y;
62625
+ err += a.x * b.y + a.y * b.x;
62626
+ float hi = p + err;
62627
+ float lo = err - (hi - p);
62628
+ return vec2(hi, lo);
62629
+ }
62630
+
62631
+ // Optimized self-multiply
62632
+ vec2 ds_sqr(vec2 a) {
62633
+ float p = a.x * a.x;
62634
+ vec2 sa = ds_split(a.x);
62635
+ float err = ((sa.x * sa.x - p) + 2.0 * sa.x * sa.y) + sa.y * sa.y;
62636
+ err += 2.0 * a.x * a.y;
62637
+ float hi = p + err;
62638
+ float lo = err - (hi - p);
62639
+ return vec2(hi, lo);
62640
+ }
62641
+
62642
+ // Compare magnitude: returns -1, 0, or 1
62643
+ float ds_cmp(vec2 a, vec2 b) {
62644
+ float d = a.x - b.x;
62645
+ if (d != 0.0) return sign(d);
62646
+ return sign(a.y - b.y);
62647
+ }
62648
+ `;
62649
+ var GPU_DS_ARITHMETIC_PREAMBLE_WGSL = `
62650
+ fn ds_split(a: f32) -> vec2f {
62651
+ const SPLIT: f32 = 4097.0;
62652
+ let t = SPLIT * a;
62653
+ let hi = t - (t - a);
62654
+ let lo = a - hi;
62655
+ return vec2f(hi, lo);
62656
+ }
62657
+
62658
+ fn ds_from(a: f32) -> vec2f {
62659
+ return vec2f(a, 0.0);
62660
+ }
62661
+
62662
+ fn ds_add(a: vec2f, b: vec2f) -> vec2f {
62663
+ let s = a.x + b.x;
62664
+ let v = s - a.x;
62665
+ let e = (a.x - (s - v)) + (b.x - v);
62666
+ let lo_t = (a.y + b.y) + e;
62667
+ let hi = s + lo_t;
62668
+ let lo = lo_t - (hi - s);
62669
+ return vec2f(hi, lo);
62670
+ }
62671
+
62672
+ fn ds_sub(a: vec2f, b: vec2f) -> vec2f {
62673
+ return ds_add(a, vec2f(-b.x, -b.y));
62674
+ }
62675
+
62676
+ fn ds_mul(a: vec2f, b: vec2f) -> vec2f {
62677
+ let p = a.x * b.x;
62678
+ let sa = ds_split(a.x);
62679
+ let sb = ds_split(b.x);
62680
+ var err = ((sa.x * sb.x - p) + sa.x * sb.y + sa.y * sb.x) + sa.y * sb.y;
62681
+ err += a.x * b.y + a.y * b.x;
62682
+ let hi = p + err;
62683
+ let lo = err - (hi - p);
62684
+ return vec2f(hi, lo);
62685
+ }
62686
+
62687
+ fn ds_sqr(a: vec2f) -> vec2f {
62688
+ let p = a.x * a.x;
62689
+ let sa = ds_split(a.x);
62690
+ var err = ((sa.x * sa.x - p) + 2.0 * sa.x * sa.y) + sa.y * sa.y;
62691
+ err += 2.0 * a.x * a.y;
62692
+ let hi = p + err;
62693
+ let lo = err - (hi - p);
62694
+ return vec2f(hi, lo);
62695
+ }
62696
+
62697
+ fn ds_cmp(a: vec2f, b: vec2f) -> f32 {
62698
+ let d = a.x - b.x;
62699
+ if (d != 0.0) { return sign(d); }
62700
+ return sign(a.y - b.y);
62701
+ }
62702
+ `;
62703
+ var GPU_FRACTAL_DP_PREAMBLE_GLSL = `
62704
+ uniform float _dp_cx_hi;
62705
+ uniform float _dp_cx_lo;
62706
+ uniform float _dp_cy_hi;
62707
+ uniform float _dp_cy_lo;
62708
+ uniform float _dp_w;
62709
+ uniform float _dp_h;
62710
+
62711
+ vec4 _dp_coord() {
62712
+ // Per-pixel offset from center \u2014 small, so float-precise
62713
+ float dx = (v_uv.x - 0.5) * _dp_w;
62714
+ float dy = (v_uv.y - 0.5) * _dp_h;
62715
+ // Combine center (hi+lo) + delta with emulated double precision
62716
+ vec2 cre = ds_add(vec2(_dp_cx_hi, _dp_cx_lo), ds_from(dx));
62717
+ vec2 cim = ds_add(vec2(_dp_cy_hi, _dp_cy_lo), ds_from(dy));
62718
+ return vec4(cre.x, cim.x, cre.y, cim.y);
62719
+ }
62720
+
62721
+ float _fractal_mandelbrot_dp(vec4 c, int maxIter) {
62722
+ // c = (re_hi, im_hi, re_lo, im_lo)
62723
+ vec2 cr = vec2(c.x, c.z); // real part as ds
62724
+ vec2 ci = vec2(c.y, c.w); // imag part as ds
62725
+ vec2 zr = vec2(0.0, 0.0);
62726
+ vec2 zi = vec2(0.0, 0.0);
62727
+ for (int i = 0; i < maxIter; i++) {
62728
+ vec2 zr2 = ds_sqr(zr);
62729
+ vec2 zi2 = ds_sqr(zi);
62730
+ // |z|^2 > 4.0 ?
62731
+ vec2 mag2 = ds_add(zr2, zi2);
62732
+ if (mag2.x > 4.0)
62733
+ return clamp((float(i) - log2(log2(mag2.x)) + 4.0) / float(maxIter), 0.0, 1.0);
62734
+ // z = z^2 + c
62735
+ vec2 new_zi = ds_add(ds_mul(ds_add(zr, zr), zi), ci); // 2*zr*zi + ci
62736
+ zr = ds_add(ds_sub(zr2, zi2), cr); // zr^2 - zi^2 + cr
62737
+ zi = new_zi;
62738
+ }
62739
+ return 1.0;
62740
+ }
62741
+
62742
+ float _fractal_julia_dp(vec4 z_in, vec4 c, int maxIter) {
62743
+ vec2 zr = vec2(z_in.x, z_in.z);
62744
+ vec2 zi = vec2(z_in.y, z_in.w);
62745
+ vec2 cr = vec2(c.x, c.z);
62746
+ vec2 ci = vec2(c.y, c.w);
62747
+ for (int i = 0; i < maxIter; i++) {
62748
+ vec2 zr2 = ds_sqr(zr);
62749
+ vec2 zi2 = ds_sqr(zi);
62750
+ vec2 mag2 = ds_add(zr2, zi2);
62751
+ if (mag2.x > 4.0)
62752
+ return clamp((float(i) - log2(log2(mag2.x)) + 4.0) / float(maxIter), 0.0, 1.0);
62753
+ vec2 new_zi = ds_add(ds_mul(ds_add(zr, zr), zi), ci);
62754
+ zr = ds_add(ds_sub(zr2, zi2), cr);
62755
+ zi = new_zi;
62756
+ }
62757
+ return 1.0;
62758
+ }
62759
+ `;
62760
+ var GPU_FRACTAL_DP_PREAMBLE_WGSL = `
62761
+ @group(0) @binding(10) var<uniform> _dp_cx_hi: f32;
62762
+ @group(0) @binding(11) var<uniform> _dp_cx_lo: f32;
62763
+ @group(0) @binding(12) var<uniform> _dp_cy_hi: f32;
62764
+ @group(0) @binding(13) var<uniform> _dp_cy_lo: f32;
62765
+ @group(0) @binding(14) var<uniform> _dp_w: f32;
62766
+ @group(0) @binding(15) var<uniform> _dp_h: f32;
62767
+
62768
+ fn _dp_coord(uv: vec2f) -> vec4f {
62769
+ let dx = (uv.x - 0.5) * _dp_w;
62770
+ let dy = (uv.y - 0.5) * _dp_h;
62771
+ let cre = ds_add(vec2f(_dp_cx_hi, _dp_cx_lo), ds_from(dx));
62772
+ let cim = ds_add(vec2f(_dp_cy_hi, _dp_cy_lo), ds_from(dy));
62773
+ return vec4f(cre.x, cim.x, cre.y, cim.y);
62774
+ }
62775
+
62776
+ fn _fractal_mandelbrot_dp(c: vec4f, maxIter: i32) -> f32 {
62777
+ let cr = vec2f(c.x, c.z);
62778
+ let ci = vec2f(c.y, c.w);
62779
+ var zr = vec2f(0.0, 0.0);
62780
+ var zi = vec2f(0.0, 0.0);
62781
+ for (var i: i32 = 0; i < maxIter; i++) {
62782
+ let zr2 = ds_sqr(zr);
62783
+ let zi2 = ds_sqr(zi);
62784
+ let mag2 = ds_add(zr2, zi2);
62785
+ if (mag2.x > 4.0) {
62786
+ return clamp((f32(i) - log2(log2(mag2.x)) + 4.0) / f32(maxIter), 0.0, 1.0);
62787
+ }
62788
+ let new_zi = ds_add(ds_mul(ds_add(zr, zr), zi), ci);
62789
+ zr = ds_add(ds_sub(zr2, zi2), cr);
62790
+ zi = new_zi;
62791
+ }
62792
+ return 1.0;
62793
+ }
62794
+
62795
+ fn _fractal_julia_dp(z_in: vec4f, c: vec4f, maxIter: i32) -> f32 {
62796
+ var zr = vec2f(z_in.x, z_in.z);
62797
+ var zi = vec2f(z_in.y, z_in.w);
62798
+ let cr = vec2f(c.x, c.z);
62799
+ let ci = vec2f(c.y, c.w);
62800
+ for (var i: i32 = 0; i < maxIter; i++) {
62801
+ let zr2 = ds_sqr(zr);
62802
+ let zi2 = ds_sqr(zi);
62803
+ let mag2 = ds_add(zr2, zi2);
62804
+ if (mag2.x > 4.0) {
62805
+ return clamp((f32(i) - log2(log2(mag2.x)) + 4.0) / f32(maxIter), 0.0, 1.0);
62806
+ }
62807
+ let new_zi = ds_add(ds_mul(ds_add(zr, zr), zi), ci);
62808
+ zr = ds_add(ds_sub(zr2, zi2), cr);
62809
+ zi = new_zi;
62810
+ }
62811
+ return 1.0;
62812
+ }
62481
62813
  `;
62482
62814
  var GPU_FRACTAL_PREAMBLE_GLSL = `
62483
62815
  float _fractal_mandelbrot(vec2 c, int maxIter) {
@@ -62521,6 +62853,208 @@ fn _fractal_julia(z_in: vec2f, c: vec2f, maxIter: i32) -> f32 {
62521
62853
  }
62522
62854
  return 1.0;
62523
62855
  }
62856
+ `;
62857
+ var GPU_FRACTAL_PT_PREAMBLE_GLSL = `
62858
+ uniform sampler2D _refOrbit;
62859
+ uniform int _refOrbitLen;
62860
+ uniform int _refOrbitTexWidth;
62861
+ uniform float _pt_offset_x;
62862
+ uniform float _pt_offset_y;
62863
+ uniform float _pt_w;
62864
+ uniform float _pt_h;
62865
+
62866
+ vec2 _pt_delta() {
62867
+ float dx = _pt_offset_x + (v_uv.x - 0.5) * _pt_w;
62868
+ float dy = _pt_offset_y + (v_uv.y - 0.5) * _pt_h;
62869
+ return vec2(dx, dy);
62870
+ }
62871
+
62872
+ vec2 _pt_fetch_orbit(int i) {
62873
+ int y = i / _refOrbitTexWidth;
62874
+ int x = i - y * _refOrbitTexWidth;
62875
+ return texelFetch(_refOrbit, ivec2(x, y), 0).rg;
62876
+ }
62877
+
62878
+ float _fractal_mandelbrot_pt(vec2 delta_c, int maxIter) {
62879
+ float dr = 0.0;
62880
+ float di = 0.0;
62881
+ int orbitLen = min(maxIter, _refOrbitLen);
62882
+ for (int i = 0; i < orbitLen; i++) {
62883
+ vec2 Zn = _pt_fetch_orbit(i);
62884
+ // delta_{n+1} = 2*Z_n*delta_n + delta_n^2 + delta_c
62885
+ float new_dr = 2.0 * (Zn.x * dr - Zn.y * di) + dr * dr - di * di + delta_c.x;
62886
+ float new_di = 2.0 * (Zn.x * di + Zn.y * dr) + 2.0 * dr * di + delta_c.y;
62887
+ dr = new_dr;
62888
+ di = new_di;
62889
+ // Full z = Z_{n+1} + delta for escape check
62890
+ vec2 Zn1 = (i + 1 < orbitLen) ? _pt_fetch_orbit(i + 1) : vec2(0.0);
62891
+ float zr = Zn1.x + dr;
62892
+ float zi = Zn1.y + di;
62893
+ float mag2 = zr * zr + zi * zi;
62894
+ if (mag2 > 4.0)
62895
+ return clamp((float(i) - log2(log2(mag2)) + 4.0) / float(maxIter), 0.0, 1.0);
62896
+ // Glitch detection: |delta|^2 > |Z|^2
62897
+ float dmag2 = dr * dr + di * di;
62898
+ float Zmag2 = Zn.x * Zn.x + Zn.y * Zn.y;
62899
+ if (dmag2 > Zmag2 && Zmag2 > 0.0) {
62900
+ // Rebase to absolute coordinates and continue with single-float
62901
+ float abs_zr = Zn1.x + dr;
62902
+ float abs_zi = Zn1.y + di;
62903
+ // Reconstruct absolute c from reference + delta
62904
+ // (Use ds_from for the concept, but single-float suffices for fallback)
62905
+ float cx = abs_zr - dr + delta_c.x;
62906
+ float cy = abs_zi - di + delta_c.y;
62907
+ for (int j = i + 1; j < maxIter; j++) {
62908
+ float new_zr = abs_zr * abs_zr - abs_zi * abs_zi + cx;
62909
+ abs_zi = 2.0 * abs_zr * abs_zi + cy;
62910
+ abs_zr = new_zr;
62911
+ mag2 = abs_zr * abs_zr + abs_zi * abs_zi;
62912
+ if (mag2 > 4.0)
62913
+ return clamp((float(j) - log2(log2(mag2)) + 4.0) / float(maxIter), 0.0, 1.0);
62914
+ }
62915
+ return 1.0;
62916
+ }
62917
+ }
62918
+ return 1.0;
62919
+ }
62920
+
62921
+ float _fractal_julia_pt(vec2 z_delta, vec2 delta_c, int maxIter) {
62922
+ float dr = z_delta.x;
62923
+ float di = z_delta.y;
62924
+ int orbitLen = min(maxIter, _refOrbitLen);
62925
+ for (int i = 0; i < orbitLen; i++) {
62926
+ vec2 Zn = _pt_fetch_orbit(i);
62927
+ float new_dr = 2.0 * (Zn.x * dr - Zn.y * di) + dr * dr - di * di + delta_c.x;
62928
+ float new_di = 2.0 * (Zn.x * di + Zn.y * dr) + 2.0 * dr * di + delta_c.y;
62929
+ dr = new_dr;
62930
+ di = new_di;
62931
+ vec2 Zn1 = (i + 1 < orbitLen) ? _pt_fetch_orbit(i + 1) : vec2(0.0);
62932
+ float zr = Zn1.x + dr;
62933
+ float zi = Zn1.y + di;
62934
+ float mag2 = zr * zr + zi * zi;
62935
+ if (mag2 > 4.0)
62936
+ return clamp((float(i) - log2(log2(mag2)) + 4.0) / float(maxIter), 0.0, 1.0);
62937
+ float dmag2 = dr * dr + di * di;
62938
+ float Zmag2 = Zn.x * Zn.x + Zn.y * Zn.y;
62939
+ if (dmag2 > Zmag2 && Zmag2 > 0.0) {
62940
+ float abs_zr = Zn1.x + dr;
62941
+ float abs_zi = Zn1.y + di;
62942
+ float cx = delta_c.x;
62943
+ float cy = delta_c.y;
62944
+ for (int j = i + 1; j < maxIter; j++) {
62945
+ float new_zr = abs_zr * abs_zr - abs_zi * abs_zi + cx;
62946
+ abs_zi = 2.0 * abs_zr * abs_zi + cy;
62947
+ abs_zr = new_zr;
62948
+ mag2 = abs_zr * abs_zr + abs_zi * abs_zi;
62949
+ if (mag2 > 4.0)
62950
+ return clamp((float(j) - log2(log2(mag2)) + 4.0) / float(maxIter), 0.0, 1.0);
62951
+ }
62952
+ return 1.0;
62953
+ }
62954
+ }
62955
+ return 1.0;
62956
+ }
62957
+ `;
62958
+ var GPU_FRACTAL_PT_PREAMBLE_WGSL = `
62959
+ @group(0) @binding(1) var _refOrbit: texture_2d<f32>;
62960
+ var<uniform> _refOrbitLen: i32;
62961
+ var<uniform> _refOrbitTexWidth: i32;
62962
+ var<uniform> _pt_offset_x: f32;
62963
+ var<uniform> _pt_offset_y: f32;
62964
+ var<uniform> _pt_w: f32;
62965
+ var<uniform> _pt_h: f32;
62966
+
62967
+ fn _pt_delta(uv: vec2f) -> vec2f {
62968
+ let dx = _pt_offset_x + (uv.x - 0.5) * _pt_w;
62969
+ let dy = _pt_offset_y + (uv.y - 0.5) * _pt_h;
62970
+ return vec2f(dx, dy);
62971
+ }
62972
+
62973
+ fn _pt_fetch_orbit(i: i32) -> vec2f {
62974
+ let y = i / _refOrbitTexWidth;
62975
+ let x = i - y * _refOrbitTexWidth;
62976
+ return textureLoad(_refOrbit, vec2i(x, y), 0).rg;
62977
+ }
62978
+
62979
+ fn _fractal_mandelbrot_pt(delta_c: vec2f, maxIter: i32) -> f32 {
62980
+ var dr: f32 = 0.0;
62981
+ var di: f32 = 0.0;
62982
+ let orbitLen = min(maxIter, _refOrbitLen);
62983
+ for (var i: i32 = 0; i < orbitLen; i++) {
62984
+ let Zn = _pt_fetch_orbit(i);
62985
+ let new_dr = 2.0 * (Zn.x * dr - Zn.y * di) + dr * dr - di * di + delta_c.x;
62986
+ let new_di = 2.0 * (Zn.x * di + Zn.y * dr) + 2.0 * dr * di + delta_c.y;
62987
+ dr = new_dr;
62988
+ di = new_di;
62989
+ var Zn1 = vec2f(0.0);
62990
+ if (i + 1 < orbitLen) { Zn1 = _pt_fetch_orbit(i + 1); }
62991
+ let zr = Zn1.x + dr;
62992
+ let zi = Zn1.y + di;
62993
+ var mag2 = zr * zr + zi * zi;
62994
+ if (mag2 > 4.0) {
62995
+ return clamp((f32(i) - log2(log2(mag2)) + 4.0) / f32(maxIter), 0.0, 1.0);
62996
+ }
62997
+ let dmag2 = dr * dr + di * di;
62998
+ let Zmag2 = Zn.x * Zn.x + Zn.y * Zn.y;
62999
+ if (dmag2 > Zmag2 && Zmag2 > 0.0) {
63000
+ var f_zr = Zn1.x + dr;
63001
+ var f_zi = Zn1.y + di;
63002
+ let cx = delta_c.x;
63003
+ let cy = delta_c.y;
63004
+ for (var j: i32 = i + 1; j < maxIter; j++) {
63005
+ let t_zr = f_zr * f_zr - f_zi * f_zi + cx;
63006
+ f_zi = 2.0 * f_zr * f_zi + cy;
63007
+ f_zr = t_zr;
63008
+ mag2 = f_zr * f_zr + f_zi * f_zi;
63009
+ if (mag2 > 4.0) {
63010
+ return clamp((f32(j) - log2(log2(mag2)) + 4.0) / f32(maxIter), 0.0, 1.0);
63011
+ }
63012
+ }
63013
+ return 1.0;
63014
+ }
63015
+ }
63016
+ return 1.0;
63017
+ }
63018
+
63019
+ fn _fractal_julia_pt(z_delta: vec2f, delta_c: vec2f, maxIter: i32) -> f32 {
63020
+ var dr = z_delta.x;
63021
+ var di = z_delta.y;
63022
+ let orbitLen = min(maxIter, _refOrbitLen);
63023
+ for (var i: i32 = 0; i < orbitLen; i++) {
63024
+ let Zn = _pt_fetch_orbit(i);
63025
+ let new_dr = 2.0 * (Zn.x * dr - Zn.y * di) + dr * dr - di * di + delta_c.x;
63026
+ let new_di = 2.0 * (Zn.x * di + Zn.y * dr) + 2.0 * dr * di + delta_c.y;
63027
+ dr = new_dr;
63028
+ di = new_di;
63029
+ var Zn1 = vec2f(0.0);
63030
+ if (i + 1 < orbitLen) { Zn1 = _pt_fetch_orbit(i + 1); }
63031
+ let zr = Zn1.x + dr;
63032
+ let zi = Zn1.y + di;
63033
+ var mag2 = zr * zr + zi * zi;
63034
+ if (mag2 > 4.0) {
63035
+ return clamp((f32(i) - log2(log2(mag2)) + 4.0) / f32(maxIter), 0.0, 1.0);
63036
+ }
63037
+ let dmag2 = dr * dr + di * di;
63038
+ let Zmag2 = Zn.x * Zn.x + Zn.y * Zn.y;
63039
+ if (dmag2 > Zmag2 && Zmag2 > 0.0) {
63040
+ var f_zr = Zn1.x + dr;
63041
+ var f_zi = Zn1.y + di;
63042
+ let cx = delta_c.x;
63043
+ let cy = delta_c.y;
63044
+ for (var j: i32 = i + 1; j < maxIter; j++) {
63045
+ let t_zr = f_zr * f_zr - f_zi * f_zi + cx;
63046
+ f_zi = 2.0 * f_zr * f_zi + cy;
63047
+ f_zr = t_zr;
63048
+ mag2 = f_zr * f_zr + f_zi * f_zi;
63049
+ if (mag2 > 4.0) {
63050
+ return clamp((f32(j) - log2(log2(mag2)) + 4.0) / f32(maxIter), 0.0, 1.0);
63051
+ }
63052
+ }
63053
+ return 1.0;
63054
+ }
63055
+ }
63056
+ return 1.0;
63057
+ }
62524
63058
  `;
62525
63059
  var GPU_COLOR_PREAMBLE_GLSL = `
62526
63060
  float _gpu_srgb_to_linear(float c) {
@@ -62960,6 +63494,7 @@ fn _gpu_apca(bg: vec3f, fg: vec3f) -> f32 {
62960
63494
  const constants = this.getConstants();
62961
63495
  const v2 = this.languageId === "wgsl" ? "vec2f" : "vec2";
62962
63496
  const target = this.createTarget({
63497
+ hints: options.hints,
62963
63498
  functions: (id) => {
62964
63499
  if (userFunctions && id in userFunctions) {
62965
63500
  const fn = userFunctions[id];
@@ -62998,12 +63533,89 @@ fn _gpu_apca(bg: vec3f, fg: vec3f) -> f32 {
62998
63533
  if (code.includes("_gpu_besselJ"))
62999
63534
  preamble += this.languageId === "wgsl" ? GPU_BESSELJ_PREAMBLE_WGSL : GPU_BESSELJ_PREAMBLE_GLSL;
63000
63535
  if (code.includes("_fractal_")) {
63001
- preamble += this.languageId === "wgsl" ? GPU_FRACTAL_PREAMBLE_WGSL : GPU_FRACTAL_PREAMBLE_GLSL;
63536
+ if (code.includes("_fractal_mandelbrot_pt") || code.includes("_fractal_julia_pt")) {
63537
+ preamble += this.languageId === "wgsl" ? GPU_DS_ARITHMETIC_PREAMBLE_WGSL : GPU_DS_ARITHMETIC_PREAMBLE_GLSL;
63538
+ preamble += this.languageId === "wgsl" ? GPU_FRACTAL_PT_PREAMBLE_WGSL : GPU_FRACTAL_PT_PREAMBLE_GLSL;
63539
+ } else if (code.includes("_fractal_mandelbrot_dp") || code.includes("_fractal_julia_dp")) {
63540
+ preamble += this.languageId === "wgsl" ? GPU_DS_ARITHMETIC_PREAMBLE_WGSL : GPU_DS_ARITHMETIC_PREAMBLE_GLSL;
63541
+ preamble += this.languageId === "wgsl" ? GPU_FRACTAL_DP_PREAMBLE_WGSL : GPU_FRACTAL_DP_PREAMBLE_GLSL;
63542
+ } else {
63543
+ preamble += this.languageId === "wgsl" ? GPU_FRACTAL_PREAMBLE_WGSL : GPU_FRACTAL_PREAMBLE_GLSL;
63544
+ }
63002
63545
  }
63003
63546
  if (code.includes("_gpu_srgb_to") || code.includes("_gpu_oklab") || code.includes("_gpu_oklch") || code.includes("_gpu_color_mix") || code.includes("_gpu_apca")) {
63004
63547
  preamble += this.languageId === "wgsl" ? GPU_COLOR_PREAMBLE_WGSL : GPU_COLOR_PREAMBLE_GLSL;
63005
63548
  }
63006
63549
  if (preamble) result.preamble = preamble;
63550
+ if (code.includes("_fractal_") && options.hints?.viewport) {
63551
+ const strategy = selectFractalStrategy(target);
63552
+ const radius = options.hints.viewport.radius;
63553
+ switch (strategy) {
63554
+ case "single":
63555
+ result.staleWhen = { radiusBelow: 1e-6 };
63556
+ break;
63557
+ case "double":
63558
+ result.staleWhen = { radiusBelow: 1e-14, radiusAbove: 1e-5 };
63559
+ break;
63560
+ case "perturbation":
63561
+ result.staleWhen = {
63562
+ radiusAbove: 1e-5,
63563
+ radiusBelow: radius * 0.01,
63564
+ centerDistance: radius * 2
63565
+ };
63566
+ break;
63567
+ }
63568
+ }
63569
+ if ((code.includes("_fractal_mandelbrot_dp") || code.includes("_fractal_julia_dp")) && options.hints?.viewport) {
63570
+ const cx = hpToNumber(options.hints.viewport.center[0]);
63571
+ const cy = hpToNumber(options.hints.viewport.center[1]);
63572
+ const size = options.hints.viewport.radius * 2;
63573
+ const cx_hi = Math.fround(cx);
63574
+ const cy_hi = Math.fround(cy);
63575
+ result.uniforms = {
63576
+ ...result.uniforms,
63577
+ _dp_cx_hi: cx_hi,
63578
+ _dp_cx_lo: cx - cx_hi,
63579
+ _dp_cy_hi: cy_hi,
63580
+ _dp_cy_lo: cy - cy_hi,
63581
+ _dp_w: size,
63582
+ _dp_h: size
63583
+ };
63584
+ }
63585
+ if ((code.includes("_fractal_mandelbrot_pt") || code.includes("_fractal_julia_pt")) && options.hints?.viewport) {
63586
+ const viewport = options.hints.viewport;
63587
+ const size = viewport.radius * 2;
63588
+ result.uniforms = {
63589
+ ...result.uniforms,
63590
+ _pt_offset_x: 0,
63591
+ _pt_offset_y: 0,
63592
+ _pt_w: size,
63593
+ _pt_h: size
63594
+ };
63595
+ const digits = Math.max(50, Math.ceil(-Math.log10(viewport.radius)) + 10);
63596
+ const maxIter = 1e3;
63597
+ const orbit = computeReferenceOrbit(
63598
+ viewport.center,
63599
+ maxIter,
63600
+ digits
63601
+ );
63602
+ const orbitLen = orbit.length / 2;
63603
+ const texWidth = Math.min(orbitLen, 4096);
63604
+ const texHeight = Math.ceil(orbitLen / texWidth);
63605
+ result.textures = {
63606
+ _refOrbit: {
63607
+ data: orbit,
63608
+ width: texWidth,
63609
+ height: texHeight,
63610
+ format: "rg32f"
63611
+ }
63612
+ };
63613
+ result.uniforms = {
63614
+ ...result.uniforms,
63615
+ _refOrbitLen: orbitLen,
63616
+ _refOrbitTexWidth: texWidth
63617
+ };
63618
+ }
63007
63619
  return result;
63008
63620
  }
63009
63621
  compileToSource(expr2, _options = {}) {
@@ -68408,14 +69020,14 @@ ${code}`;
68408
69020
  _setDefaultEngineFactory(() => new ComputeEngine());
68409
69021
 
68410
69022
  // src/compute-engine.ts
68411
- var version = "0.55.3";
69023
+ var version = "0.55.5";
68412
69024
  ComputeEngine._latexSyntaxFactory = () => new LatexSyntax();
68413
69025
  _setDefaultEngineFactory(
68414
69026
  () => new ComputeEngine({ latexSyntax: new LatexSyntax() })
68415
69027
  );
68416
69028
  globalThis[/* @__PURE__ */ Symbol.for("io.cortexjs.compute-engine")] = {
68417
69029
  ComputeEngine: ComputeEngine.prototype.constructor,
68418
- version: "0.55.3"
69030
+ version: "0.55.5"
68419
69031
  };
68420
69032
  return __toCommonJS(compute_engine_exports);
68421
69033
  })();