@cortex-js/compute-engine 0.55.4 → 0.55.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (258) hide show
  1. package/dist/compile.esm.js +137 -545
  2. package/dist/compile.min.esm.js +60 -430
  3. package/dist/compile.min.umd.cjs +66 -436
  4. package/dist/compile.umd.cjs +137 -545
  5. package/dist/compute-engine.esm.js +227 -563
  6. package/dist/compute-engine.min.esm.js +68 -437
  7. package/dist/compute-engine.min.umd.cjs +68 -437
  8. package/dist/compute-engine.umd.cjs +227 -563
  9. package/dist/core.esm.js +225 -562
  10. package/dist/core.min.esm.js +67 -436
  11. package/dist/core.min.umd.cjs +67 -436
  12. package/dist/core.umd.cjs +225 -562
  13. package/dist/interval.esm.js +136 -60
  14. package/dist/interval.min.esm.js +7 -7
  15. package/dist/interval.min.umd.cjs +7 -7
  16. package/dist/interval.umd.cjs +136 -60
  17. package/dist/latex-syntax.esm.js +219 -74
  18. package/dist/latex-syntax.min.esm.js +7 -6
  19. package/dist/latex-syntax.min.umd.cjs +7 -6
  20. package/dist/latex-syntax.umd.cjs +219 -74
  21. package/dist/math-json.esm.js +2 -2
  22. package/dist/math-json.min.esm.js +2 -2
  23. package/dist/math-json.min.umd.cjs +2 -2
  24. package/dist/math-json.umd.cjs +2 -2
  25. package/dist/numerics.esm.js +2 -2
  26. package/dist/numerics.min.esm.js +2 -2
  27. package/dist/numerics.min.umd.cjs +2 -2
  28. package/dist/numerics.umd.cjs +2 -2
  29. package/dist/types/big-decimal/big-decimal.d.ts +1 -1
  30. package/dist/types/big-decimal/index.d.ts +1 -1
  31. package/dist/types/big-decimal/transcendentals.d.ts +1 -1
  32. package/dist/types/big-decimal/utils.d.ts +1 -1
  33. package/dist/types/common/ansi-codes.d.ts +1 -1
  34. package/dist/types/common/configuration-change.d.ts +1 -1
  35. package/dist/types/common/fuzzy-string-match.d.ts +1 -1
  36. package/dist/types/common/grapheme-splitter.d.ts +1 -1
  37. package/dist/types/common/interruptible.d.ts +1 -1
  38. package/dist/types/common/one-of.d.ts +1 -1
  39. package/dist/types/common/signals.d.ts +1 -1
  40. package/dist/types/common/type/ast-nodes.d.ts +1 -1
  41. package/dist/types/common/type/boxed-type.d.ts +1 -1
  42. package/dist/types/common/type/lexer.d.ts +1 -1
  43. package/dist/types/common/type/parse.d.ts +1 -1
  44. package/dist/types/common/type/parser.d.ts +1 -1
  45. package/dist/types/common/type/primitive.d.ts +1 -1
  46. package/dist/types/common/type/reduce.d.ts +1 -1
  47. package/dist/types/common/type/serialize.d.ts +1 -1
  48. package/dist/types/common/type/subtype.d.ts +1 -1
  49. package/dist/types/common/type/type-builder.d.ts +1 -1
  50. package/dist/types/common/type/types.d.ts +1 -1
  51. package/dist/types/common/type/utils.d.ts +1 -1
  52. package/dist/types/common/utils.d.ts +1 -1
  53. package/dist/types/compile.d.ts +1 -1
  54. package/dist/types/compute-engine/assume.d.ts +1 -1
  55. package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +1 -1
  56. package/dist/types/compute-engine/boxed-expression/apply.d.ts +1 -1
  57. package/dist/types/compute-engine/boxed-expression/arithmetic-add.d.ts +1 -1
  58. package/dist/types/compute-engine/boxed-expression/arithmetic-mul-div.d.ts +1 -1
  59. package/dist/types/compute-engine/boxed-expression/arithmetic-power.d.ts +1 -1
  60. package/dist/types/compute-engine/boxed-expression/ascii-math.d.ts +1 -1
  61. package/dist/types/compute-engine/boxed-expression/box.d.ts +1 -1
  62. package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +1 -1
  63. package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +1 -1
  64. package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +1 -1
  65. package/dist/types/compute-engine/boxed-expression/boxed-operator-definition.d.ts +1 -1
  66. package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +1 -1
  67. package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +1 -1
  68. package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +1 -1
  69. package/dist/types/compute-engine/boxed-expression/boxed-tensor.d.ts +1 -1
  70. package/dist/types/compute-engine/boxed-expression/boxed-value-definition.d.ts +1 -1
  71. package/dist/types/compute-engine/boxed-expression/cache.d.ts +1 -1
  72. package/dist/types/compute-engine/boxed-expression/canonical-utils.d.ts +1 -1
  73. package/dist/types/compute-engine/boxed-expression/canonical.d.ts +1 -1
  74. package/dist/types/compute-engine/boxed-expression/compare.d.ts +1 -1
  75. package/dist/types/compute-engine/boxed-expression/constants.d.ts +1 -1
  76. package/dist/types/compute-engine/boxed-expression/expand.d.ts +1 -1
  77. package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +1 -1
  78. package/dist/types/compute-engine/boxed-expression/factor.d.ts +1 -1
  79. package/dist/types/compute-engine/boxed-expression/flatten.d.ts +1 -1
  80. package/dist/types/compute-engine/boxed-expression/hold.d.ts +1 -1
  81. package/dist/types/compute-engine/boxed-expression/inequality-bounds.d.ts +1 -1
  82. package/dist/types/compute-engine/boxed-expression/init-lazy-refs.d.ts +1 -1
  83. package/dist/types/compute-engine/boxed-expression/invisible-operator.d.ts +1 -1
  84. package/dist/types/compute-engine/boxed-expression/match.d.ts +1 -1
  85. package/dist/types/compute-engine/boxed-expression/negate.d.ts +1 -1
  86. package/dist/types/compute-engine/boxed-expression/numerics.d.ts +1 -1
  87. package/dist/types/compute-engine/boxed-expression/order.d.ts +1 -1
  88. package/dist/types/compute-engine/boxed-expression/pattern-utils.d.ts +1 -1
  89. package/dist/types/compute-engine/boxed-expression/polynomial-degree.d.ts +1 -1
  90. package/dist/types/compute-engine/boxed-expression/polynomials.d.ts +1 -1
  91. package/dist/types/compute-engine/boxed-expression/predicates.d.ts +1 -1
  92. package/dist/types/compute-engine/boxed-expression/rules.d.ts +1 -1
  93. package/dist/types/compute-engine/boxed-expression/serialize.d.ts +1 -1
  94. package/dist/types/compute-engine/boxed-expression/sgn.d.ts +1 -1
  95. package/dist/types/compute-engine/boxed-expression/simplify.d.ts +1 -1
  96. package/dist/types/compute-engine/boxed-expression/solve-linear-system.d.ts +1 -1
  97. package/dist/types/compute-engine/boxed-expression/solve.d.ts +1 -1
  98. package/dist/types/compute-engine/boxed-expression/stochastic-equal.d.ts +1 -1
  99. package/dist/types/compute-engine/boxed-expression/trigonometry.d.ts +1 -1
  100. package/dist/types/compute-engine/boxed-expression/type-guards.d.ts +1 -1
  101. package/dist/types/compute-engine/boxed-expression/utils.d.ts +1 -1
  102. package/dist/types/compute-engine/boxed-expression/validate.d.ts +1 -1
  103. package/dist/types/compute-engine/collection-utils.d.ts +1 -1
  104. package/dist/types/compute-engine/compilation/base-compiler.d.ts +1 -1
  105. package/dist/types/compute-engine/compilation/compile-expression.d.ts +1 -1
  106. package/dist/types/compute-engine/compilation/constant-folding.d.ts +1 -1
  107. package/dist/types/compute-engine/compilation/glsl-target.d.ts +1 -1
  108. package/dist/types/compute-engine/compilation/gpu-target.d.ts +1 -47
  109. package/dist/types/compute-engine/compilation/interval-javascript-target.d.ts +1 -1
  110. package/dist/types/compute-engine/compilation/javascript-target.d.ts +1 -1
  111. package/dist/types/compute-engine/compilation/python-target.d.ts +1 -1
  112. package/dist/types/compute-engine/compilation/types.d.ts +1 -48
  113. package/dist/types/compute-engine/compilation/wgsl-target.d.ts +1 -1
  114. package/dist/types/compute-engine/cost-function.d.ts +1 -1
  115. package/dist/types/compute-engine/engine-assumptions.d.ts +1 -1
  116. package/dist/types/compute-engine/engine-cache.d.ts +1 -1
  117. package/dist/types/compute-engine/engine-common-symbols.d.ts +1 -1
  118. package/dist/types/compute-engine/engine-compilation-targets.d.ts +1 -1
  119. package/dist/types/compute-engine/engine-configuration-lifecycle.d.ts +1 -1
  120. package/dist/types/compute-engine/engine-declarations.d.ts +1 -1
  121. package/dist/types/compute-engine/engine-expression-entrypoints.d.ts +1 -1
  122. package/dist/types/compute-engine/engine-extension-contracts.d.ts +1 -1
  123. package/dist/types/compute-engine/engine-library-bootstrap.d.ts +1 -1
  124. package/dist/types/compute-engine/engine-numeric-configuration.d.ts +1 -1
  125. package/dist/types/compute-engine/engine-runtime-state.d.ts +1 -1
  126. package/dist/types/compute-engine/engine-scope.d.ts +1 -1
  127. package/dist/types/compute-engine/engine-sequences.d.ts +1 -1
  128. package/dist/types/compute-engine/engine-simplification-rules.d.ts +1 -1
  129. package/dist/types/compute-engine/engine-startup-coordinator.d.ts +1 -1
  130. package/dist/types/compute-engine/engine-type-resolver.d.ts +1 -1
  131. package/dist/types/compute-engine/engine-validation-entrypoints.d.ts +1 -1
  132. package/dist/types/compute-engine/free-functions.d.ts +1 -1
  133. package/dist/types/compute-engine/function-utils.d.ts +1 -1
  134. package/dist/types/compute-engine/global-types.d.ts +1 -1
  135. package/dist/types/compute-engine/index.d.ts +2 -1
  136. package/dist/types/compute-engine/interval/arithmetic.d.ts +1 -1
  137. package/dist/types/compute-engine/interval/comparison.d.ts +1 -1
  138. package/dist/types/compute-engine/interval/elementary.d.ts +1 -1
  139. package/dist/types/compute-engine/interval/index.d.ts +1 -1
  140. package/dist/types/compute-engine/interval/trigonometric.d.ts +1 -1
  141. package/dist/types/compute-engine/interval/types.d.ts +1 -1
  142. package/dist/types/compute-engine/interval/util.d.ts +1 -1
  143. package/dist/types/compute-engine/latex-syntax/dictionary/default-dictionary.d.ts +1 -1
  144. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-algebra.d.ts +1 -1
  145. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-arithmetic.d.ts +1 -1
  146. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-calculus.d.ts +1 -1
  147. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-complex.d.ts +1 -1
  148. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-core.d.ts +1 -1
  149. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-linear-algebra.d.ts +1 -1
  150. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-logic.d.ts +1 -1
  151. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-other.d.ts +1 -1
  152. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-relational-operators.d.ts +1 -1
  153. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-sets.d.ts +1 -1
  154. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-statistics.d.ts +1 -1
  155. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-symbols.d.ts +1 -1
  156. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-trigonometry.d.ts +1 -1
  157. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-units.d.ts +1 -1
  158. package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +1 -1
  159. package/dist/types/compute-engine/latex-syntax/dictionary/indexed-types.d.ts +1 -1
  160. package/dist/types/compute-engine/latex-syntax/latex-syntax.d.ts +1 -1
  161. package/dist/types/compute-engine/latex-syntax/parse-number.d.ts +1 -1
  162. package/dist/types/compute-engine/latex-syntax/parse-symbol.d.ts +1 -1
  163. package/dist/types/compute-engine/latex-syntax/parse.d.ts +1 -1
  164. package/dist/types/compute-engine/latex-syntax/serialize-dms.d.ts +1 -1
  165. package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +1 -1
  166. package/dist/types/compute-engine/latex-syntax/serializer-style.d.ts +1 -1
  167. package/dist/types/compute-engine/latex-syntax/serializer.d.ts +4 -2
  168. package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +1 -1
  169. package/dist/types/compute-engine/latex-syntax/types.d.ts +1 -1
  170. package/dist/types/compute-engine/latex-syntax/utils.d.ts +1 -1
  171. package/dist/types/compute-engine/library/arithmetic.d.ts +1 -1
  172. package/dist/types/compute-engine/library/calculus.d.ts +1 -1
  173. package/dist/types/compute-engine/library/collections.d.ts +1 -1
  174. package/dist/types/compute-engine/library/colors.d.ts +1 -1
  175. package/dist/types/compute-engine/library/combinatorics.d.ts +1 -1
  176. package/dist/types/compute-engine/library/complex.d.ts +1 -1
  177. package/dist/types/compute-engine/library/control-structures.d.ts +1 -1
  178. package/dist/types/compute-engine/library/core.d.ts +1 -1
  179. package/dist/types/compute-engine/library/fractals.d.ts +1 -1
  180. package/dist/types/compute-engine/library/library.d.ts +1 -1
  181. package/dist/types/compute-engine/library/linear-algebra.d.ts +1 -1
  182. package/dist/types/compute-engine/library/logic-analysis.d.ts +1 -1
  183. package/dist/types/compute-engine/library/logic.d.ts +1 -1
  184. package/dist/types/compute-engine/library/number-theory.d.ts +1 -1
  185. package/dist/types/compute-engine/library/polynomials.d.ts +1 -1
  186. package/dist/types/compute-engine/library/quantity-arithmetic.d.ts +1 -1
  187. package/dist/types/compute-engine/library/random-expression.d.ts +1 -1
  188. package/dist/types/compute-engine/library/relational-operator.d.ts +1 -1
  189. package/dist/types/compute-engine/library/sets.d.ts +1 -1
  190. package/dist/types/compute-engine/library/statistics.d.ts +1 -1
  191. package/dist/types/compute-engine/library/trigonometry.d.ts +1 -1
  192. package/dist/types/compute-engine/library/type-handlers.d.ts +1 -1
  193. package/dist/types/compute-engine/library/unit-data.d.ts +1 -1
  194. package/dist/types/compute-engine/library/units.d.ts +1 -1
  195. package/dist/types/compute-engine/library/utils.d.ts +1 -1
  196. package/dist/types/compute-engine/numeric-value/big-numeric-value.d.ts +1 -1
  197. package/dist/types/compute-engine/numeric-value/exact-numeric-value.d.ts +1 -1
  198. package/dist/types/compute-engine/numeric-value/machine-numeric-value.d.ts +1 -1
  199. package/dist/types/compute-engine/numeric-value/types.d.ts +1 -1
  200. package/dist/types/compute-engine/numerics/bigint.d.ts +1 -1
  201. package/dist/types/compute-engine/numerics/expression.d.ts +1 -1
  202. package/dist/types/compute-engine/numerics/interval.d.ts +1 -1
  203. package/dist/types/compute-engine/numerics/linear-algebra.d.ts +1 -1
  204. package/dist/types/compute-engine/numerics/monte-carlo.d.ts +1 -1
  205. package/dist/types/compute-engine/numerics/numeric-bigint.d.ts +1 -1
  206. package/dist/types/compute-engine/numerics/numeric-bignum.d.ts +1 -1
  207. package/dist/types/compute-engine/numerics/numeric-complex.d.ts +1 -1
  208. package/dist/types/compute-engine/numerics/numeric.d.ts +1 -1
  209. package/dist/types/compute-engine/numerics/primes.d.ts +1 -1
  210. package/dist/types/compute-engine/numerics/rationals.d.ts +1 -1
  211. package/dist/types/compute-engine/numerics/richardson.d.ts +1 -1
  212. package/dist/types/compute-engine/numerics/special-functions.d.ts +1 -1
  213. package/dist/types/compute-engine/numerics/statistics.d.ts +1 -1
  214. package/dist/types/compute-engine/numerics/strings.d.ts +1 -1
  215. package/dist/types/compute-engine/numerics/types.d.ts +1 -1
  216. package/dist/types/compute-engine/numerics/unit-data.d.ts +1 -1
  217. package/dist/types/compute-engine/oeis.d.ts +1 -1
  218. package/dist/types/compute-engine/sequence.d.ts +1 -1
  219. package/dist/types/compute-engine/symbolic/antiderivative.d.ts +1 -1
  220. package/dist/types/compute-engine/symbolic/derivative.d.ts +1 -1
  221. package/dist/types/compute-engine/symbolic/distribute.d.ts +1 -1
  222. package/dist/types/compute-engine/symbolic/fu-cost.d.ts +1 -1
  223. package/dist/types/compute-engine/symbolic/fu-transforms.d.ts +1 -1
  224. package/dist/types/compute-engine/symbolic/fu.d.ts +1 -1
  225. package/dist/types/compute-engine/symbolic/logic-utils.d.ts +1 -1
  226. package/dist/types/compute-engine/symbolic/simplify-abs.d.ts +1 -1
  227. package/dist/types/compute-engine/symbolic/simplify-divide.d.ts +1 -1
  228. package/dist/types/compute-engine/symbolic/simplify-factorial.d.ts +1 -1
  229. package/dist/types/compute-engine/symbolic/simplify-hyperbolic.d.ts +1 -1
  230. package/dist/types/compute-engine/symbolic/simplify-infinity.d.ts +1 -1
  231. package/dist/types/compute-engine/symbolic/simplify-log.d.ts +1 -1
  232. package/dist/types/compute-engine/symbolic/simplify-logic.d.ts +1 -1
  233. package/dist/types/compute-engine/symbolic/simplify-power.d.ts +1 -1
  234. package/dist/types/compute-engine/symbolic/simplify-product.d.ts +1 -1
  235. package/dist/types/compute-engine/symbolic/simplify-rules.d.ts +1 -1
  236. package/dist/types/compute-engine/symbolic/simplify-sum.d.ts +1 -1
  237. package/dist/types/compute-engine/symbolic/simplify-trig.d.ts +1 -1
  238. package/dist/types/compute-engine/tensor/tensor-fields.d.ts +1 -1
  239. package/dist/types/compute-engine/tensor/tensors.d.ts +1 -1
  240. package/dist/types/compute-engine/types-definitions.d.ts +1 -1
  241. package/dist/types/compute-engine/types-engine.d.ts +1 -1
  242. package/dist/types/compute-engine/types-evaluation.d.ts +1 -1
  243. package/dist/types/compute-engine/types-expression.d.ts +1 -1
  244. package/dist/types/compute-engine/types-kernel-evaluation.d.ts +1 -1
  245. package/dist/types/compute-engine/types-kernel-serialization.d.ts +1 -1
  246. package/dist/types/compute-engine/types-serialization.d.ts +1 -1
  247. package/dist/types/compute-engine/types.d.ts +1 -1
  248. package/dist/types/compute-engine.d.ts +2 -1
  249. package/dist/types/core.d.ts +1 -1
  250. package/dist/types/interval.d.ts +1 -1
  251. package/dist/types/latex-syntax.d.ts +2 -2
  252. package/dist/types/math-json/symbols.d.ts +1 -1
  253. package/dist/types/math-json/types.d.ts +1 -1
  254. package/dist/types/math-json/utils.d.ts +1 -1
  255. package/dist/types/math-json.d.ts +2 -2
  256. package/dist/types/numerics.d.ts +1 -1
  257. package/package.json +1 -1
  258. package/dist/types/compute-engine/compilation/fractal-orbit.d.ts +0 -13
@@ -1,4 +1,4 @@
1
- /** Compute Engine 0.55.4 */
1
+ /** Compute Engine 0.55.6 */
2
2
 
3
3
  // src/math-json/utils.ts
4
4
  var MISSING = ["Error", "'missing'"];
@@ -4743,10 +4743,6 @@ var DEFINITIONS_CORE = [
4743
4743
  // Lagrange notation
4744
4744
  {
4745
4745
  name: "Derivative",
4746
- // @todo: Leibniz notation: {% latex " \\frac{d^n}{dx^n} f(x)" %}
4747
- // @todo: Euler modified notation: This notation is used by Mathematica. The Euler notation uses `D` instead of
4748
- // `\partial`: `\partial_{x} f`, `\partial_{x,y} f`
4749
- // Newton notation (\dot{v}, \ddot{v}) is implemented below
4750
4746
  serialize: (serializer, expr) => {
4751
4747
  const degree = machineValue(operand(expr, 2)) ?? 1;
4752
4748
  const base = serializer.serialize(operand(expr, 1));
@@ -5784,14 +5780,18 @@ var DEFINITIONS_SETS = [
5784
5780
  return ["Complement", lhs];
5785
5781
  }
5786
5782
  // precedence: 240,
5787
- // @todo: serialize for the multiple argument case
5788
5783
  },
5789
5784
  {
5790
5785
  name: "Complement",
5791
5786
  latexTrigger: ["^", "<{>", "\\complement", "<}>"],
5792
- kind: "postfix"
5787
+ kind: "postfix",
5793
5788
  // precedence: 240,
5794
- // @todo: serialize for the multiple argument case
5789
+ serialize: (serializer, expr) => {
5790
+ return joinLatex([
5791
+ serializer.serialize(operand(expr, 1)),
5792
+ "^\\complement"
5793
+ ]);
5794
+ }
5795
5795
  },
5796
5796
  {
5797
5797
  name: "Intersection",
@@ -5878,7 +5878,6 @@ var DEFINITIONS_SETS = [
5878
5878
  // commands like \rbrack a, b \rbrack which are unambiguous.
5879
5879
  {
5880
5880
  name: "Multiple",
5881
- // @todo: parse
5882
5881
  serialize: serializeSet
5883
5882
  },
5884
5883
  {
@@ -5887,14 +5886,28 @@ var DEFINITIONS_SETS = [
5887
5886
  kind: "infix",
5888
5887
  precedence: 350
5889
5888
  },
5889
+ // \mid as a separator/operator (used in set-builder notation: {x \mid x > 0})
5890
+ // Low precedence so it binds loosely — everything on each side is parsed first
5891
+ {
5892
+ name: "Divides",
5893
+ latexTrigger: ["\\mid"],
5894
+ kind: "infix",
5895
+ precedence: 160
5896
+ },
5890
5897
  {
5891
5898
  name: "Set",
5892
5899
  kind: "matchfix",
5893
5900
  openTrigger: "{",
5894
5901
  closeTrigger: "}",
5895
- // @todo: the set syntax can also include conditions...
5896
5902
  parse: (_parser, body) => {
5897
5903
  if (isEmptySequence(body)) return "EmptySet";
5904
+ const h = operator(body);
5905
+ if (h === "Divides" || h === "Colon") {
5906
+ const expr = operand(body, 1);
5907
+ const condition = operand(body, 2);
5908
+ if (expr !== null && condition !== null)
5909
+ return ["Set", expr, ["Condition", condition]];
5910
+ }
5898
5911
  if (operator(body) == "Delimiter" && stringValue(operand(body, 2)) === ",") {
5899
5912
  body = operand(body, 1);
5900
5913
  }
@@ -5902,6 +5915,17 @@ var DEFINITIONS_SETS = [
5902
5915
  return ["Set", ...operands(body)];
5903
5916
  },
5904
5917
  serialize: (serializer, expr) => {
5918
+ if (nops(expr) === 2 && operator(operand(expr, 2)) === "Condition") {
5919
+ const condition = operand(expr, 2);
5920
+ return joinLatex([
5921
+ "\\lbrace",
5922
+ serializer.serialize(operand(expr, 1)),
5923
+ "\\mid",
5924
+ // Serialize the inner expression of the Condition wrapper
5925
+ serializer.serialize(operand(condition, 1)),
5926
+ "\\rbrace"
5927
+ ]);
5928
+ }
5905
5929
  return joinLatex([
5906
5930
  "\\lbrace",
5907
5931
  operands(expr).map((x) => serializer.serialize(x)).join(", "),
@@ -6068,23 +6092,6 @@ function serializeSet(serializer, expr) {
6068
6092
  if (expr === null) return "";
6069
6093
  const h = operator(expr);
6070
6094
  if (!h) return "";
6071
- if (h === "Set") {
6072
- if (nops(expr) === 0) return "\\emptyset";
6073
- if (nops(expr) === 2 && operator(operand(expr, 2)) === "Condition") {
6074
- return joinLatex([
6075
- "\\left\\lbrace",
6076
- serializer.serialize(operand(expr, 1)),
6077
- "\\middle\\mid",
6078
- serializer.serialize(operand(expr, 2)),
6079
- "\\right\\rbrace"
6080
- ]);
6081
- }
6082
- return joinLatex([
6083
- "\\left\\lbrace",
6084
- ...operands(expr).map((x) => serializer.serialize(x) + " ,"),
6085
- "\\right\\rbrace"
6086
- ]);
6087
- }
6088
6095
  if (h === "Multiple") {
6089
6096
  }
6090
6097
  if (h === "Range") {
@@ -7232,11 +7239,13 @@ var DEFINITIONS_ARITHMETIC = [
7232
7239
  if (!parser.match("_")) return null;
7233
7240
  const base = parser.parseGroup();
7234
7241
  if (operator(base) !== "To") return null;
7235
- const expr = parser.parseArguments("implicit");
7242
+ const expr = parser.parseExpression({
7243
+ minPrec: MULTIPLICATION_PRECEDENCE
7244
+ });
7236
7245
  if (!expr) return null;
7237
7246
  return [
7238
7247
  "Limit",
7239
- ["Function", expr[0], operand(base, 1)],
7248
+ ["Function", expr, operand(base, 1)],
7240
7249
  operand(base, 2)
7241
7250
  ];
7242
7251
  },
@@ -9440,12 +9449,52 @@ var DEFINITIONS_UNITS = [
9440
9449
  ];
9441
9450
 
9442
9451
  // src/compute-engine/latex-syntax/dictionary/definitions-other.ts
9452
+ var TEX_UNITS = [
9453
+ "pt",
9454
+ "em",
9455
+ "mu",
9456
+ "ex",
9457
+ "mm",
9458
+ "cm",
9459
+ "in",
9460
+ "bp",
9461
+ "sp",
9462
+ "dd",
9463
+ "cc",
9464
+ "pc",
9465
+ "nc",
9466
+ "nd"
9467
+ ];
9468
+ function skipTexDimension(parser) {
9469
+ parser.skipSpace();
9470
+ if (parser.peek === "-" || parser.peek === "+") parser.nextToken();
9471
+ while (/^[\d.]$/.test(parser.peek)) parser.nextToken();
9472
+ for (const unit of TEX_UNITS) {
9473
+ if (parser.matchAll([...unit])) return;
9474
+ }
9475
+ }
9443
9476
  function parseSingleArg(cmd) {
9444
9477
  return (parser) => {
9445
9478
  const arg = parser.parseGroup();
9446
9479
  return arg === null ? [cmd] : [cmd, arg];
9447
9480
  };
9448
9481
  }
9482
+ function parseMathStyleSwitch(mathStyle) {
9483
+ return (parser) => {
9484
+ const body = parser.parseExpression();
9485
+ if (body !== null && !isEmptySequence(body))
9486
+ return ["Annotated", body, { dict: { mathStyle } }];
9487
+ return "Nothing";
9488
+ };
9489
+ }
9490
+ function parseSizeSwitch(size) {
9491
+ return (parser) => {
9492
+ const body = parser.parseExpression();
9493
+ if (body !== null && !isEmptySequence(body))
9494
+ return ["Annotated", body, { dict: { size } }];
9495
+ return "Nothing";
9496
+ };
9497
+ }
9449
9498
  var DEFINITIONS_OTHERS = [
9450
9499
  {
9451
9500
  name: "Overscript",
@@ -9685,80 +9734,71 @@ var DEFINITIONS_OTHERS = [
9685
9734
  },
9686
9735
  {
9687
9736
  latexTrigger: ["\\displaystyle"],
9688
- parse: () => "Nothing"
9689
- // @todo: parse as ['Annotated'...]
9737
+ parse: parseMathStyleSwitch("normal")
9690
9738
  },
9691
9739
  {
9692
9740
  latexTrigger: ["\\textstyle"],
9693
- parse: () => "Nothing"
9694
- // @todo: parse as ['Annotated'...]
9741
+ parse: parseMathStyleSwitch("compact")
9695
9742
  },
9696
9743
  {
9697
9744
  latexTrigger: ["\\scriptstyle"],
9698
- parse: () => "Nothing"
9699
- // @todo: parse as ['Annotated'...]
9745
+ parse: parseMathStyleSwitch("script")
9700
9746
  },
9701
9747
  {
9702
9748
  latexTrigger: ["\\scriptscriptstyle"],
9703
- parse: () => "Nothing"
9704
- // @todo: parse as ['Annotated'...]
9749
+ parse: parseMathStyleSwitch("scriptscript")
9705
9750
  },
9706
9751
  {
9707
9752
  latexTrigger: ["\\color"],
9708
9753
  parse: (parser) => {
9709
- parser.parseGroup();
9754
+ const color = parser.parseStringGroup();
9755
+ if (color !== null) {
9756
+ const body = parser.parseExpression();
9757
+ if (body !== null && !isEmptySequence(body))
9758
+ return ["Annotated", body, { dict: { color } }];
9759
+ }
9710
9760
  return "Nothing";
9711
9761
  }
9712
9762
  },
9713
9763
  {
9714
9764
  latexTrigger: ["\\tiny"],
9715
- parse: () => "Nothing"
9716
- // @todo: parse as ['Annotated'...]
9765
+ parse: parseSizeSwitch(1)
9717
9766
  },
9718
9767
  {
9719
9768
  latexTrigger: ["\\scriptsize"],
9720
- parse: () => "Nothing"
9721
- // @todo: parse as ['Annotated'...]
9769
+ parse: parseSizeSwitch(2)
9722
9770
  },
9723
9771
  {
9724
9772
  latexTrigger: ["\\footnotesize"],
9725
- parse: () => "Nothing"
9726
- // @todo: parse as ['Annotated'...]
9773
+ parse: parseSizeSwitch(3)
9727
9774
  },
9728
9775
  {
9729
9776
  latexTrigger: ["\\small"],
9730
- parse: () => "Nothing"
9731
- // @todo: parse as ['Annotated'...]
9777
+ parse: parseSizeSwitch(4)
9732
9778
  },
9733
9779
  {
9734
9780
  latexTrigger: ["\\normalsize"],
9735
- parse: () => "Nothing"
9736
- // @todo: parse as ['Annotated'...]
9781
+ parse: parseSizeSwitch(5)
9737
9782
  },
9738
9783
  {
9739
9784
  latexTrigger: ["\\large"],
9740
- parse: () => "Nothing"
9741
- // @todo: parse as ['Annotated'...]
9785
+ parse: parseSizeSwitch(6)
9742
9786
  },
9743
9787
  {
9744
9788
  latexTrigger: ["\\Large"],
9745
- parse: () => "Nothing"
9746
- // @todo: parse as ['Annotated'...]
9789
+ parse: parseSizeSwitch(7)
9747
9790
  },
9748
9791
  {
9749
9792
  latexTrigger: ["\\LARGE"],
9750
- parse: () => "Nothing"
9751
- // @todo: parse as ['Annotated'...]
9793
+ parse: parseSizeSwitch(8)
9752
9794
  },
9753
9795
  {
9754
9796
  latexTrigger: ["\\huge"],
9755
- parse: () => "Nothing"
9756
- // @todo: parse as ['Annotated'...]
9797
+ parse: parseSizeSwitch(9)
9757
9798
  },
9758
9799
  {
9759
9800
  latexTrigger: ["\\Huge"],
9760
- parse: () => "Nothing"
9761
- // @todo: parse as ['Annotated'...]
9801
+ parse: parseSizeSwitch(10)
9762
9802
  },
9763
9803
  {
9764
9804
  name: "Annotated",
@@ -9770,6 +9810,10 @@ var DEFINITIONS_OTHERS = [
9770
9810
  result = joinLatex(["{\\displaystyle", result, "}"]);
9771
9811
  else if (dict.dict.mathStyle === "compact")
9772
9812
  result = joinLatex(["{\\textstyle", result, "}"]);
9813
+ else if (dict.dict.mathStyle === "script")
9814
+ result = joinLatex(["{\\scriptstyle", result, "}"]);
9815
+ else if (dict.dict.mathStyle === "scriptscript")
9816
+ result = joinLatex(["{\\scriptscriptstyle", result, "}"]);
9773
9817
  const v = dict.dict.size;
9774
9818
  if (v !== null && v >= 1 && v <= 10) {
9775
9819
  result = joinLatex([
@@ -9857,6 +9901,28 @@ var DEFINITIONS_OTHERS = [
9857
9901
  latexTrigger: ["\\enspace"],
9858
9902
  parse: () => ["HorizontalSpacing", 9]
9859
9903
  },
9904
+ {
9905
+ latexTrigger: ["\\hspace"],
9906
+ parse: (parser) => {
9907
+ if (parser.peek === "*") parser.nextToken();
9908
+ parser.parseStringGroup();
9909
+ return ["HorizontalSpacing", 0];
9910
+ }
9911
+ },
9912
+ {
9913
+ latexTrigger: ["\\hskip"],
9914
+ parse: (parser) => {
9915
+ skipTexDimension(parser);
9916
+ return ["HorizontalSpacing", 0];
9917
+ }
9918
+ },
9919
+ {
9920
+ latexTrigger: ["\\kern"],
9921
+ parse: (parser) => {
9922
+ skipTexDimension(parser);
9923
+ return ["HorizontalSpacing", 0];
9924
+ }
9925
+ },
9860
9926
  {
9861
9927
  latexTrigger: ["\\phantom"],
9862
9928
  parse: (parser) => {
@@ -9907,7 +9973,17 @@ var DEFINITIONS_OTHERS = [
9907
9973
  // `["HorizontalSpacing", expr, 'op'|'bin'|rel]` -> indicate a spacing around and expression, i.e. `\mathbin{x}`, etc...
9908
9974
  serialize: (serializer, expr) => {
9909
9975
  if (operand(expr, 2) !== null) {
9910
- return serializer.serialize(operand(expr, 1));
9976
+ const cls = stringValue(operand(expr, 2));
9977
+ const inner = serializer.serialize(operand(expr, 1));
9978
+ if (cls === "bin") return `\\mathbin{${inner}}`;
9979
+ if (cls === "op") return `\\mathop{${inner}}`;
9980
+ if (cls === "rel") return `\\mathrel{${inner}}`;
9981
+ if (cls === "ord") return `\\mathord{${inner}}`;
9982
+ if (cls === "open") return `\\mathopen{${inner}}`;
9983
+ if (cls === "close") return `\\mathclose{${inner}}`;
9984
+ if (cls === "punct") return `\\mathpunct{${inner}}`;
9985
+ if (cls === "inner") return `\\mathinner{${inner}}`;
9986
+ return inner;
9911
9987
  }
9912
9988
  const v = machineValue(operand(expr, 1));
9913
9989
  if (v === null) return "";
@@ -10298,25 +10374,47 @@ function makeIndexedEntry(entry, onError) {
10298
10374
  result.arguments = entry.arguments;
10299
10375
  return result;
10300
10376
  }
10377
+ function serializeTabularBody(serializer, body) {
10378
+ if (!body) return "";
10379
+ if (operator(body) !== "List") return serializer.serialize(body);
10380
+ const rows = operands(body);
10381
+ if (rows.length === 0) return "";
10382
+ if (!rows.every((row) => operator(row) === "List"))
10383
+ return serializer.serialize(body);
10384
+ return rows.map(
10385
+ (row) => operands(row).map((cell) => serializer.serialize(cell)).join(" & ")
10386
+ ).join(" \\\\\n");
10387
+ }
10301
10388
  function makeSerializeHandler(entry, latexTrigger, idTrigger) {
10302
10389
  if (typeof entry.serialize === "function") return entry.serialize;
10303
10390
  const kind = entry["kind"] ?? "expression";
10304
10391
  if (kind === "environment") {
10305
10392
  const envName = entry["symbolTrigger"] ?? entry.name ?? "unknown";
10306
- return (serializer, expr) => joinLatex([
10307
- `\\begin{${envName}}`,
10308
- serializer.serialize(operand(expr, 1)),
10309
- `\\end{${envName}}`
10310
- ]);
10393
+ return (serializer, expr) => {
10394
+ const body = operand(expr, 1);
10395
+ return joinLatex([
10396
+ `\\begin{${envName}}`,
10397
+ serializeTabularBody(serializer, body),
10398
+ `\\end{${envName}}`
10399
+ ]);
10400
+ };
10311
10401
  }
10312
10402
  if (isMatchfixEntry(entry)) {
10313
10403
  const openDelim = typeof entry.openTrigger === "string" ? DEFAULT_DELIMITER[entry.openTrigger] : tokensToString(entry.openTrigger);
10314
10404
  const closeDelim = typeof entry.closeTrigger === "string" ? DEFAULT_DELIMITER[entry.closeTrigger] : tokensToString(entry.closeTrigger);
10315
- return (serializer, expr) => joinLatex([
10316
- openDelim,
10317
- serializer.serialize(operand(expr, 1)),
10318
- closeDelim
10319
- ]);
10405
+ return (serializer, expr) => {
10406
+ const style = serializer.groupStyle(expr, serializer.level + 1);
10407
+ const inner = serializer.serialize(operand(expr, 1));
10408
+ if (style === "scaled")
10409
+ return joinLatex([`\\left${openDelim}`, inner, `\\right${closeDelim}`]);
10410
+ if (style === "big")
10411
+ return joinLatex([
10412
+ `\\Bigl${openDelim}`,
10413
+ inner,
10414
+ `\\Bigr${closeDelim}`
10415
+ ]);
10416
+ return joinLatex([openDelim, inner, closeDelim]);
10417
+ };
10320
10418
  }
10321
10419
  let latex = entry.serialize;
10322
10420
  if (latex === void 0 && latexTrigger) latex = tokensToString(latexTrigger);
@@ -12579,6 +12677,16 @@ function parseNumber(parser, fmt) {
12579
12677
  }
12580
12678
 
12581
12679
  // src/compute-engine/latex-syntax/parse.ts
12680
+ var _symbolToUnicode = null;
12681
+ function getSymbolToUnicode() {
12682
+ if (!_symbolToUnicode) {
12683
+ _symbolToUnicode = /* @__PURE__ */ new Map();
12684
+ for (const [, latex, codepoint] of SYMBOLS) {
12685
+ _symbolToUnicode.set(latex, String.fromCodePoint(codepoint));
12686
+ }
12687
+ }
12688
+ return _symbolToUnicode;
12689
+ }
12582
12690
  var DELIMITER_SHORTHAND2 = {
12583
12691
  "(": ["\\lparen", "("],
12584
12692
  ")": ["\\rparen", ")"],
@@ -13026,6 +13134,35 @@ var _Parser = class __Parser {
13026
13134
  this.nextToken();
13027
13135
  this.skipVisualSpace();
13028
13136
  }
13137
+ if (this.match("\\hspace")) {
13138
+ this.match("*");
13139
+ this.parseStringGroup();
13140
+ this.skipVisualSpace();
13141
+ }
13142
+ if (this.match("\\hskip") || this.match("\\kern")) {
13143
+ this.skipSpace();
13144
+ this.match("-") || this.match("+");
13145
+ while (/^[\d.]$/.test(this.peek)) this.nextToken();
13146
+ for (const unit of [
13147
+ "pt",
13148
+ "em",
13149
+ "mu",
13150
+ "ex",
13151
+ "mm",
13152
+ "cm",
13153
+ "in",
13154
+ "bp",
13155
+ "sp",
13156
+ "dd",
13157
+ "cc",
13158
+ "pc",
13159
+ "nc",
13160
+ "nd"
13161
+ ]) {
13162
+ if (this.matchAll([...unit])) break;
13163
+ }
13164
+ this.skipVisualSpace();
13165
+ }
13029
13166
  this.skipSpace();
13030
13167
  }
13031
13168
  match(token) {
@@ -13363,7 +13500,8 @@ var _Parser = class __Parser {
13363
13500
  } else if (token === "<space>") {
13364
13501
  result += " ";
13365
13502
  } else if (token[0] === "\\") {
13366
- result += token;
13503
+ const unicode = getSymbolToUnicode().get(token);
13504
+ result += unicode ?? token;
13367
13505
  } else {
13368
13506
  result += token;
13369
13507
  }
@@ -14723,7 +14861,7 @@ var STYLE_MODIFIERS = {
14723
14861
  sansserif: (s) => `\\mathsf{${s}}`,
14724
14862
  monospace: (s) => `\\mathtt{${s}}`
14725
14863
  };
14726
- var Serializer4 = class {
14864
+ var Serializer5 = class {
14727
14865
  options;
14728
14866
  dictionary;
14729
14867
  level = -1;
@@ -14738,11 +14876,18 @@ var Serializer4 = class {
14738
14876
  /**
14739
14877
  * Serialize the expression, and if the expression is an operator
14740
14878
  * of precedence less than or equal to prec, wrap it in some parens.
14741
- * @todo: don't wrap Abs, Floor, Ceil, Delimiter
14879
+ *
14880
+ * Skip wrapping for matchfix operators (Abs, Floor, Ceil, Norm, etc.)
14881
+ * and Delimiter since they already have visible delimiters.
14742
14882
  */
14743
14883
  wrap(expr, prec) {
14744
14884
  if (expr === null || expr === void 0) return "";
14745
14885
  if (prec === void 0) {
14886
+ const name2 = operator(expr);
14887
+ if (name2) {
14888
+ const def = this.dictionary.ids.get(name2);
14889
+ if (def?.kind === "matchfix") return this.serialize(expr);
14890
+ }
14746
14891
  return this.wrapString(
14747
14892
  this.serialize(expr),
14748
14893
  this.options.groupStyle(expr, this.level + 1)
@@ -15036,7 +15181,7 @@ function serializeSymbol(s, style = "auto") {
15036
15181
  return body;
15037
15182
  }
15038
15183
  function serializeLatex(expr, dict, options) {
15039
- const serializer = new Serializer4(dict, options);
15184
+ const serializer = new Serializer5(dict, options);
15040
15185
  return serializer.serialize(expr);
15041
15186
  }
15042
15187
 
@@ -15163,7 +15308,7 @@ function serialize(expr) {
15163
15308
  }
15164
15309
 
15165
15310
  // src/latex-syntax.ts
15166
- var version = "0.55.4";
15311
+ var version = "0.55.6";
15167
15312
  export {
15168
15313
  DEFINITIONS_ALGEBRA as ALGEBRA_DICTIONARY,
15169
15314
  DEFINITIONS_ARITHMETIC as ARITHMETIC_DICTIONARY,