@cortex-js/compute-engine 0.58.0 → 0.59.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (270) hide show
  1. package/README.md +4 -0
  2. package/dist/compile.esm.js +1721 -483
  3. package/dist/compile.min.esm.js +122 -74
  4. package/dist/compile.min.umd.cjs +122 -74
  5. package/dist/compile.umd.cjs +1721 -483
  6. package/dist/compute-engine.esm.js +25209 -22883
  7. package/dist/compute-engine.min.esm.js +135 -87
  8. package/dist/compute-engine.min.umd.cjs +135 -87
  9. package/dist/compute-engine.umd.cjs +24952 -22626
  10. package/dist/core.esm.js +25208 -22882
  11. package/dist/core.min.esm.js +134 -86
  12. package/dist/core.min.umd.cjs +134 -86
  13. package/dist/core.umd.cjs +24951 -22625
  14. package/dist/identities.esm.js +1921 -0
  15. package/dist/identities.min.esm.js +2 -0
  16. package/dist/identities.min.umd.cjs +4 -0
  17. package/dist/identities.umd.cjs +1946 -0
  18. package/dist/interval.esm.js +653 -330
  19. package/dist/interval.min.esm.js +8 -8
  20. package/dist/interval.min.umd.cjs +8 -8
  21. package/dist/interval.umd.cjs +653 -330
  22. package/dist/latex-syntax.esm.js +758 -512
  23. package/dist/latex-syntax.min.esm.js +7 -7
  24. package/dist/latex-syntax.min.umd.cjs +7 -7
  25. package/dist/latex-syntax.umd.cjs +758 -512
  26. package/dist/math-json.esm.js +8 -12
  27. package/dist/math-json.min.esm.js +2 -2
  28. package/dist/math-json.min.umd.cjs +2 -2
  29. package/dist/math-json.umd.cjs +8 -12
  30. package/dist/numerics.esm.js +1349 -228
  31. package/dist/numerics.min.esm.js +16 -5
  32. package/dist/numerics.min.umd.cjs +16 -5
  33. package/dist/numerics.umd.cjs +1349 -228
  34. package/dist/types/big-decimal/big-decimal.d.ts +1 -1
  35. package/dist/types/big-decimal/index.d.ts +1 -1
  36. package/dist/types/big-decimal/transcendentals.d.ts +1 -1
  37. package/dist/types/big-decimal/utils.d.ts +1 -1
  38. package/dist/types/common/ansi-codes.d.ts +1 -1
  39. package/dist/types/common/configuration-change.d.ts +1 -1
  40. package/dist/types/common/fuzzy-string-match.d.ts +1 -1
  41. package/dist/types/common/grapheme-splitter.d.ts +1 -1
  42. package/dist/types/common/interruptible.d.ts +1 -1
  43. package/dist/types/common/one-of.d.ts +1 -1
  44. package/dist/types/common/signals.d.ts +1 -1
  45. package/dist/types/common/type/ast-nodes.d.ts +1 -1
  46. package/dist/types/common/type/boxed-type.d.ts +1 -1
  47. package/dist/types/common/type/lexer.d.ts +1 -1
  48. package/dist/types/common/type/parse.d.ts +1 -208
  49. package/dist/types/common/type/parser.d.ts +124 -2
  50. package/dist/types/common/type/primitive.d.ts +5 -1
  51. package/dist/types/common/type/reduce.d.ts +1 -1
  52. package/dist/types/common/type/serialize.d.ts +1 -1
  53. package/dist/types/common/type/subtype.d.ts +18 -1
  54. package/dist/types/common/type/type-builder.d.ts +1 -1
  55. package/dist/types/common/type/types.d.ts +1 -1
  56. package/dist/types/common/type/utils.d.ts +1 -1
  57. package/dist/types/common/utils.d.ts +1 -1
  58. package/dist/types/compile.d.ts +1 -1
  59. package/dist/types/compute-engine/assume.d.ts +13 -6
  60. package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +1 -1
  61. package/dist/types/compute-engine/boxed-expression/apply.d.ts +1 -1
  62. package/dist/types/compute-engine/boxed-expression/arithmetic-add.d.ts +1 -1
  63. package/dist/types/compute-engine/boxed-expression/arithmetic-mul-div.d.ts +1 -1
  64. package/dist/types/compute-engine/boxed-expression/arithmetic-power.d.ts +1 -1
  65. package/dist/types/compute-engine/boxed-expression/ascii-math.d.ts +1 -1
  66. package/dist/types/compute-engine/boxed-expression/box.d.ts +1 -1
  67. package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +1 -1
  68. package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +1 -1
  69. package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +1 -1
  70. package/dist/types/compute-engine/boxed-expression/boxed-operator-definition.d.ts +1 -1
  71. package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +1 -1
  72. package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +1 -1
  73. package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +3 -3
  74. package/dist/types/compute-engine/boxed-expression/boxed-tensor.d.ts +1 -1
  75. package/dist/types/compute-engine/boxed-expression/boxed-value-definition.d.ts +1 -1
  76. package/dist/types/compute-engine/boxed-expression/cache.d.ts +1 -1
  77. package/dist/types/compute-engine/boxed-expression/canonical-utils.d.ts +1 -1
  78. package/dist/types/compute-engine/boxed-expression/canonical.d.ts +1 -1
  79. package/dist/types/compute-engine/boxed-expression/compare.d.ts +1 -1
  80. package/dist/types/compute-engine/boxed-expression/constants.d.ts +1 -1
  81. package/dist/types/compute-engine/boxed-expression/constraint-subject.d.ts +140 -0
  82. package/dist/types/compute-engine/boxed-expression/expand.d.ts +1 -1
  83. package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +1 -1
  84. package/dist/types/compute-engine/boxed-expression/factor.d.ts +1 -1
  85. package/dist/types/compute-engine/boxed-expression/flatten.d.ts +1 -1
  86. package/dist/types/compute-engine/boxed-expression/hold.d.ts +1 -1
  87. package/dist/types/compute-engine/boxed-expression/inequality-bounds.d.ts +14 -4
  88. package/dist/types/compute-engine/boxed-expression/init-lazy-refs.d.ts +1 -1
  89. package/dist/types/compute-engine/boxed-expression/invisible-operator.d.ts +1 -1
  90. package/dist/types/compute-engine/boxed-expression/match.d.ts +1 -1
  91. package/dist/types/compute-engine/boxed-expression/negate.d.ts +1 -1
  92. package/dist/types/compute-engine/boxed-expression/numerics.d.ts +1 -1
  93. package/dist/types/compute-engine/boxed-expression/order.d.ts +1 -1
  94. package/dist/types/compute-engine/boxed-expression/pattern-utils.d.ts +1 -1
  95. package/dist/types/compute-engine/boxed-expression/polynomial-degree.d.ts +1 -1
  96. package/dist/types/compute-engine/boxed-expression/polynomials.d.ts +1 -1
  97. package/dist/types/compute-engine/boxed-expression/predicates.d.ts +1 -1
  98. package/dist/types/compute-engine/boxed-expression/rule-index.d.ts +112 -0
  99. package/dist/types/compute-engine/boxed-expression/rules.d.ts +2 -1
  100. package/dist/types/compute-engine/boxed-expression/serialize.d.ts +1 -1
  101. package/dist/types/compute-engine/boxed-expression/sgn.d.ts +1 -1
  102. package/dist/types/compute-engine/boxed-expression/simplify.d.ts +1 -1
  103. package/dist/types/compute-engine/boxed-expression/solve-linear-system.d.ts +1 -1
  104. package/dist/types/compute-engine/boxed-expression/solve.d.ts +1 -1
  105. package/dist/types/compute-engine/boxed-expression/stochastic-equal.d.ts +1 -1
  106. package/dist/types/compute-engine/boxed-expression/trigonometry.d.ts +1 -1
  107. package/dist/types/compute-engine/boxed-expression/type-guards.d.ts +1 -1
  108. package/dist/types/compute-engine/boxed-expression/utils.d.ts +1 -1
  109. package/dist/types/compute-engine/boxed-expression/validate.d.ts +1 -1
  110. package/dist/types/compute-engine/collection-utils.d.ts +1 -1
  111. package/dist/types/compute-engine/compilation/base-compiler.d.ts +1 -1
  112. package/dist/types/compute-engine/compilation/compile-expression.d.ts +1 -1
  113. package/dist/types/compute-engine/compilation/constant-folding.d.ts +16 -1
  114. package/dist/types/compute-engine/compilation/glsl-target.d.ts +1 -1
  115. package/dist/types/compute-engine/compilation/gpu-target.d.ts +15 -5
  116. package/dist/types/compute-engine/compilation/interval-javascript-target.d.ts +4 -4
  117. package/dist/types/compute-engine/compilation/javascript-target.d.ts +1 -1
  118. package/dist/types/compute-engine/compilation/python-target.d.ts +1 -1
  119. package/dist/types/compute-engine/compilation/types.d.ts +1 -1
  120. package/dist/types/compute-engine/compilation/wgsl-target.d.ts +1 -1
  121. package/dist/types/compute-engine/cost-function.d.ts +1 -1
  122. package/dist/types/compute-engine/engine-assumptions.d.ts +1 -1
  123. package/dist/types/compute-engine/engine-cache.d.ts +1 -1
  124. package/dist/types/compute-engine/engine-common-symbols.d.ts +1 -1
  125. package/dist/types/compute-engine/engine-compilation-targets.d.ts +1 -1
  126. package/dist/types/compute-engine/engine-configuration-lifecycle.d.ts +1 -1
  127. package/dist/types/compute-engine/engine-declarations.d.ts +1 -1
  128. package/dist/types/compute-engine/engine-expression-entrypoints.d.ts +1 -1
  129. package/dist/types/compute-engine/engine-extension-contracts.d.ts +1 -1
  130. package/dist/types/compute-engine/engine-library-bootstrap.d.ts +1 -1
  131. package/dist/types/compute-engine/engine-numeric-configuration.d.ts +1 -1
  132. package/dist/types/compute-engine/engine-runtime-state.d.ts +1 -1
  133. package/dist/types/compute-engine/engine-scope.d.ts +1 -1
  134. package/dist/types/compute-engine/engine-sequences.d.ts +1 -1
  135. package/dist/types/compute-engine/engine-simplification-rules.d.ts +10 -2
  136. package/dist/types/compute-engine/engine-startup-coordinator.d.ts +1 -1
  137. package/dist/types/compute-engine/engine-type-resolver.d.ts +1 -1
  138. package/dist/types/compute-engine/engine-validation-entrypoints.d.ts +1 -1
  139. package/dist/types/compute-engine/free-functions.d.ts +1 -1
  140. package/dist/types/compute-engine/function-utils.d.ts +1 -1
  141. package/dist/types/compute-engine/fungrim/loader.d.ts +13 -0
  142. package/dist/types/compute-engine/fungrim/types.d.ts +160 -0
  143. package/dist/types/compute-engine/global-types.d.ts +1 -1
  144. package/dist/types/compute-engine/index.d.ts +48 -2
  145. package/dist/types/compute-engine/interval/arithmetic.d.ts +1 -1
  146. package/dist/types/compute-engine/interval/comparison.d.ts +1 -1
  147. package/dist/types/compute-engine/interval/elementary.d.ts +10 -2
  148. package/dist/types/compute-engine/interval/index.d.ts +2 -2
  149. package/dist/types/compute-engine/interval/trigonometric.d.ts +1 -1
  150. package/dist/types/compute-engine/interval/types.d.ts +1 -1
  151. package/dist/types/compute-engine/interval/util.d.ts +1 -1
  152. package/dist/types/compute-engine/latex-syntax/dictionary/default-dictionary.d.ts +1 -1
  153. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-algebra.d.ts +1 -1
  154. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-arithmetic.d.ts +1 -1
  155. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-calculus.d.ts +1 -1
  156. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-colors.d.ts +1 -1
  157. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-complex.d.ts +1 -1
  158. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-core.d.ts +1 -1
  159. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-linear-algebra.d.ts +1 -1
  160. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-logic.d.ts +1 -1
  161. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-other.d.ts +1 -1
  162. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-relational-operators.d.ts +1 -1
  163. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-sets.d.ts +1 -1
  164. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-statistics.d.ts +1 -1
  165. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-symbols.d.ts +1 -1
  166. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-trigonometry.d.ts +1 -1
  167. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-units.d.ts +1 -1
  168. package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +1 -1
  169. package/dist/types/compute-engine/latex-syntax/dictionary/indexed-types.d.ts +4 -1
  170. package/dist/types/compute-engine/latex-syntax/latex-syntax.d.ts +1 -1
  171. package/dist/types/compute-engine/latex-syntax/parse-number.d.ts +1 -1
  172. package/dist/types/compute-engine/latex-syntax/parse-symbol.d.ts +1 -1
  173. package/dist/types/compute-engine/latex-syntax/parse.d.ts +3 -2
  174. package/dist/types/compute-engine/latex-syntax/serialize-dms.d.ts +1 -1
  175. package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +1 -11
  176. package/dist/types/compute-engine/latex-syntax/serializer-style.d.ts +1 -1
  177. package/dist/types/compute-engine/latex-syntax/serializer.d.ts +1 -1
  178. package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +1 -1
  179. package/dist/types/compute-engine/latex-syntax/types.d.ts +1 -1
  180. package/dist/types/compute-engine/latex-syntax/utils.d.ts +1 -1
  181. package/dist/types/compute-engine/library/arithmetic.d.ts +1 -1
  182. package/dist/types/compute-engine/library/calculus.d.ts +1 -1
  183. package/dist/types/compute-engine/library/collections.d.ts +1 -1
  184. package/dist/types/compute-engine/library/colors.d.ts +1 -1
  185. package/dist/types/compute-engine/library/combinatorics.d.ts +1 -1
  186. package/dist/types/compute-engine/library/complex.d.ts +13 -1
  187. package/dist/types/compute-engine/library/control-structures.d.ts +1 -1
  188. package/dist/types/compute-engine/library/core.d.ts +1 -1
  189. package/dist/types/compute-engine/library/fractals.d.ts +1 -1
  190. package/dist/types/compute-engine/library/library.d.ts +1 -1
  191. package/dist/types/compute-engine/library/linear-algebra.d.ts +1 -1
  192. package/dist/types/compute-engine/library/logic-analysis.d.ts +1 -1
  193. package/dist/types/compute-engine/library/logic.d.ts +1 -1
  194. package/dist/types/compute-engine/library/number-theory.d.ts +1 -1
  195. package/dist/types/compute-engine/library/polynomials.d.ts +1 -1
  196. package/dist/types/compute-engine/library/quantity-arithmetic.d.ts +1 -1
  197. package/dist/types/compute-engine/library/random-expression.d.ts +1 -1
  198. package/dist/types/compute-engine/library/relational-operator.d.ts +1 -1
  199. package/dist/types/compute-engine/library/sets.d.ts +27 -1
  200. package/dist/types/compute-engine/library/statistics.d.ts +1 -1
  201. package/dist/types/compute-engine/library/trigonometry.d.ts +1 -1
  202. package/dist/types/compute-engine/library/type-handlers.d.ts +1 -1
  203. package/dist/types/compute-engine/library/unit-data.d.ts +1 -1
  204. package/dist/types/compute-engine/library/units.d.ts +1 -1
  205. package/dist/types/compute-engine/library/utils.d.ts +1 -1
  206. package/dist/types/compute-engine/numeric-value/big-numeric-value.d.ts +1 -1
  207. package/dist/types/compute-engine/numeric-value/exact-numeric-value.d.ts +7 -1
  208. package/dist/types/compute-engine/numeric-value/machine-numeric-value.d.ts +1 -1
  209. package/dist/types/compute-engine/numeric-value/types.d.ts +1 -1
  210. package/dist/types/compute-engine/numerics/bernoulli.d.ts +39 -0
  211. package/dist/types/compute-engine/numerics/bigint.d.ts +1 -1
  212. package/dist/types/compute-engine/numerics/expression.d.ts +1 -1
  213. package/dist/types/compute-engine/numerics/interval.d.ts +1 -1
  214. package/dist/types/compute-engine/numerics/linear-algebra.d.ts +1 -1
  215. package/dist/types/compute-engine/numerics/monte-carlo.d.ts +1 -1
  216. package/dist/types/compute-engine/numerics/numeric-bigint.d.ts +1 -1
  217. package/dist/types/compute-engine/numerics/numeric-bignum.d.ts +1 -1
  218. package/dist/types/compute-engine/numerics/numeric-complex.d.ts +12 -1
  219. package/dist/types/compute-engine/numerics/numeric.d.ts +1 -1
  220. package/dist/types/compute-engine/numerics/primes.d.ts +1 -1
  221. package/dist/types/compute-engine/numerics/random.d.ts +1 -1
  222. package/dist/types/compute-engine/numerics/rationals.d.ts +1 -1
  223. package/dist/types/compute-engine/numerics/richardson.d.ts +1 -1
  224. package/dist/types/compute-engine/numerics/special-functions.d.ts +78 -10
  225. package/dist/types/compute-engine/numerics/statistics.d.ts +1 -1
  226. package/dist/types/compute-engine/numerics/strings.d.ts +1 -1
  227. package/dist/types/compute-engine/numerics/types.d.ts +1 -1
  228. package/dist/types/compute-engine/numerics/unit-data.d.ts +1 -1
  229. package/dist/types/compute-engine/oeis.d.ts +1 -1
  230. package/dist/types/compute-engine/sequence.d.ts +1 -1
  231. package/dist/types/compute-engine/symbolic/antiderivative.d.ts +1 -1
  232. package/dist/types/compute-engine/symbolic/derivative.d.ts +1 -1
  233. package/dist/types/compute-engine/symbolic/distribute.d.ts +1 -1
  234. package/dist/types/compute-engine/symbolic/fu-cost.d.ts +1 -1
  235. package/dist/types/compute-engine/symbolic/fu-transforms.d.ts +1 -1
  236. package/dist/types/compute-engine/symbolic/fu.d.ts +1 -1
  237. package/dist/types/compute-engine/symbolic/logic-utils.d.ts +1 -1
  238. package/dist/types/compute-engine/symbolic/simplify-abs.d.ts +1 -1
  239. package/dist/types/compute-engine/symbolic/simplify-divide.d.ts +1 -1
  240. package/dist/types/compute-engine/symbolic/simplify-factorial.d.ts +1 -1
  241. package/dist/types/compute-engine/symbolic/simplify-hyperbolic.d.ts +1 -1
  242. package/dist/types/compute-engine/symbolic/simplify-infinity.d.ts +1 -1
  243. package/dist/types/compute-engine/symbolic/simplify-log.d.ts +1 -1
  244. package/dist/types/compute-engine/symbolic/simplify-logic.d.ts +1 -1
  245. package/dist/types/compute-engine/symbolic/simplify-power.d.ts +1 -1
  246. package/dist/types/compute-engine/symbolic/simplify-product.d.ts +1 -1
  247. package/dist/types/compute-engine/symbolic/simplify-rules.d.ts +1 -1
  248. package/dist/types/compute-engine/symbolic/simplify-sum.d.ts +1 -1
  249. package/dist/types/compute-engine/symbolic/simplify-trig.d.ts +1 -1
  250. package/dist/types/compute-engine/tensor/tensor-fields.d.ts +1 -1
  251. package/dist/types/compute-engine/tensor/tensors.d.ts +3 -3
  252. package/dist/types/compute-engine/types-definitions.d.ts +1 -1
  253. package/dist/types/compute-engine/types-engine.d.ts +19 -3
  254. package/dist/types/compute-engine/types-evaluation.d.ts +1 -1
  255. package/dist/types/compute-engine/types-expression.d.ts +17 -14
  256. package/dist/types/compute-engine/types-kernel-evaluation.d.ts +32 -1
  257. package/dist/types/compute-engine/types-kernel-serialization.d.ts +45 -3
  258. package/dist/types/compute-engine/types-serialization.d.ts +1 -1
  259. package/dist/types/compute-engine/types.d.ts +1 -1
  260. package/dist/types/compute-engine.d.ts +1 -1
  261. package/dist/types/core.d.ts +1 -1
  262. package/dist/types/identities.d.ts +3 -0
  263. package/dist/types/interval.d.ts +1 -1
  264. package/dist/types/latex-syntax.d.ts +2 -2
  265. package/dist/types/math-json/symbols.d.ts +1 -1
  266. package/dist/types/math-json/types.d.ts +1 -1
  267. package/dist/types/math-json/utils.d.ts +1 -1
  268. package/dist/types/math-json.d.ts +2 -2
  269. package/dist/types/numerics.d.ts +1 -1
  270. package/package.json +9 -3
@@ -1,4 +1,4 @@
1
- /** Compute Engine 0.58.0 */
1
+ /** Compute Engine 0.59.0 */
2
2
 
3
3
  // src/compute-engine/numeric-value/types.ts
4
4
  var NumericValue = class {
@@ -153,6 +153,7 @@ function fpexp(x, scale) {
153
153
  return sum;
154
154
  }
155
155
  function fpln(x, scale) {
156
+ if (x <= 0n) throw new RangeError("fpln: input must be positive");
156
157
  if (x === scale) return 0n;
157
158
  const xNum = Number(x);
158
159
  const scaleNum = Number(scale);
@@ -802,9 +803,11 @@ var BigDecimal = class _BigDecimal {
802
803
  if (Number.isFinite(thisExp) && Number.isFinite(otherExp)) {
803
804
  if (other.significand === 0n) return _BigDecimal.NAN;
804
805
  if (this.significand === 0n) return fromRaw(0n, 0);
805
- return this.sub(this.div(other).trunc().mul(other)).toPrecision(
806
- _BigDecimal.precision
807
- );
806
+ const ediff = thisExp - otherExp;
807
+ const num = ediff >= 0 ? this.significand * pow10(ediff) : this.significand;
808
+ const den = ediff >= 0 ? other.significand : other.significand * pow10(-ediff);
809
+ const q = num / den;
810
+ return this.sub(fromRaw(q, 0).mul(other));
808
811
  }
809
812
  if (thisExp !== thisExp || otherExp !== otherExp) return _BigDecimal.NAN;
810
813
  if (!Number.isFinite(thisExp)) return _BigDecimal.NAN;
@@ -849,7 +852,10 @@ var BigDecimal = class _BigDecimal {
849
852
  return this.pow(n.neg()).inv();
850
853
  }
851
854
  const absSig = this.significand < 0n ? -this.significand : this.significand;
852
- const thisLog10 = bigintDigits(absSig) + this.exponent;
855
+ const sigDigits = bigintDigits(absSig);
856
+ const dropped = sigDigits > 15 ? sigDigits - 15 : 0;
857
+ const lead = dropped > 0 ? Number(absSig / 10n ** BigInt(dropped)) : Number(absSig);
858
+ const thisLog10 = Math.log10(lead) + dropped + this.exponent;
853
859
  const resultLog10 = Number(expValue) * thisLog10;
854
860
  if (resultLog10 > 9e15) {
855
861
  return this.significand < 0n && expValue % 2n !== 0n ? _BigDecimal.NEGATIVE_INFINITY : _BigDecimal.POSITIVE_INFINITY;
@@ -882,7 +888,19 @@ var BigDecimal = class _BigDecimal {
882
888
  return _BigDecimal.POSITIVE_INFINITY;
883
889
  }
884
890
  if (this.significand < 0n) return _BigDecimal.NAN;
885
- return n.mul(this.ln()).exp();
891
+ const baseSig = this.significand;
892
+ const decExpBase = this.exponent + bigintDigits(baseSig) - 1;
893
+ const nSig = n.significand < 0n ? -n.significand : n.significand;
894
+ const decExpN = n.exponent + bigintDigits(nSig) - 1;
895
+ const argMag = decExpN + Math.log10(Math.abs(decExpBase) * 2.303 + 3) + 1;
896
+ const extra = Math.min(20, Math.max(2, Math.ceil(argMag) + 2));
897
+ const savedPrec = _BigDecimal.precision;
898
+ _BigDecimal.precision = savedPrec + extra;
899
+ try {
900
+ return n.mul(this.ln()).exp().toPrecision(savedPrec);
901
+ } finally {
902
+ _BigDecimal.precision = savedPrec;
903
+ }
886
904
  }
887
905
  // ---------- Conversion methods ----------
888
906
  /** Convert to a JavaScript number. May lose precision for large values. */
@@ -1123,6 +1141,20 @@ function fromFixedPoint(fp, scale, targetPrecision) {
1123
1141
  const sig = negative ? -absFp : absFp;
1124
1142
  return fromRaw(sig, resultExp);
1125
1143
  }
1144
+ function decimalExponent(x) {
1145
+ const sig = x.significand < 0n ? -x.significand : x.significand;
1146
+ return x.exponent + bigintDigits(sig) - 1;
1147
+ }
1148
+ var MAX_SAFE_EXPONENT = BigInt(Number.MAX_SAFE_INTEGER);
1149
+ var _ln10Fp = null;
1150
+ var _ln10Scale = null;
1151
+ function ln10Fixed(scale) {
1152
+ if (_ln10Scale !== scale) {
1153
+ _ln10Fp = fpln(10n * scale, scale);
1154
+ _ln10Scale = scale;
1155
+ }
1156
+ return _ln10Fp;
1157
+ }
1126
1158
  BigDecimal.prototype.sqrt = function() {
1127
1159
  if (this.isNaN()) return BigDecimal.NAN;
1128
1160
  if (this.isZero()) return BigDecimal.ZERO;
@@ -1133,9 +1165,13 @@ BigDecimal.prototype.sqrt = function() {
1133
1165
  if (this.significand < 0n) return BigDecimal.NAN;
1134
1166
  const targetPrec = BigDecimal.precision;
1135
1167
  const workingPrec = targetPrec + 10;
1136
- const [fp, scale] = toFixedPoint(this, workingPrec);
1168
+ const e = decimalExponent(this);
1169
+ const k = Math.floor(e / 2);
1170
+ const m = fromRaw(this.significand, this.exponent - 2 * k);
1171
+ const [fp, scale] = toFixedPoint(m, workingPrec);
1137
1172
  const sqrtFp = fpsqrt(fp, scale);
1138
- return fromFixedPoint(sqrtFp, scale, targetPrec);
1173
+ const root = fromFixedPoint(sqrtFp, scale, targetPrec);
1174
+ return fromRaw(root.significand, root.exponent + k);
1139
1175
  };
1140
1176
  BigDecimal.prototype.cbrt = function() {
1141
1177
  if (this.isNaN()) return BigDecimal.NAN;
@@ -1149,10 +1185,13 @@ BigDecimal.prototype.cbrt = function() {
1149
1185
  }
1150
1186
  const targetPrec = BigDecimal.precision;
1151
1187
  const workingPrec = targetPrec + 10;
1152
- const [fp, scale] = toFixedPoint(this, workingPrec);
1188
+ const e = decimalExponent(this);
1189
+ const k = Math.floor(e / 3);
1190
+ const m = fromRaw(this.significand, this.exponent - 3 * k);
1191
+ const [fp, scale] = toFixedPoint(m, workingPrec);
1153
1192
  const C = fp * scale * scale;
1154
1193
  let x;
1155
- const numVal = this.toNumber();
1194
+ const numVal = m.toNumber();
1156
1195
  const scaleNum = Number(scale);
1157
1196
  if (Number.isFinite(numVal) && numVal > 0 && Number.isFinite(scaleNum)) {
1158
1197
  const approx = Math.cbrt(numVal);
@@ -1181,7 +1220,8 @@ BigDecimal.prototype.cbrt = function() {
1181
1220
  const diffNext = bigintAbs(next * next * next - C);
1182
1221
  if (diffNext < diffX) x = next;
1183
1222
  }
1184
- return fromFixedPoint(x, scale, targetPrec);
1223
+ const root = fromFixedPoint(x, scale, targetPrec);
1224
+ return fromRaw(root.significand, root.exponent + k);
1185
1225
  };
1186
1226
  BigDecimal.sqrt = function(x) {
1187
1227
  return x.sqrt();
@@ -1196,11 +1236,27 @@ BigDecimal.prototype.exp = function() {
1196
1236
  return BigDecimal.ZERO;
1197
1237
  }
1198
1238
  if (this.isZero()) return BigDecimal.ONE;
1239
+ if (decimalExponent(this) >= 17)
1240
+ return this.significand > 0n ? BigDecimal.POSITIVE_INFINITY : BigDecimal.ZERO;
1199
1241
  const targetPrec = BigDecimal.precision;
1200
- const workingPrec = targetPrec + 15;
1201
- const [fp, scale] = toFixedPoint(this, workingPrec);
1202
- const expFp = fpexp(fp, scale);
1203
- return fromFixedPoint(expFp, scale, targetPrec);
1242
+ const absSig = this.significand < 0n ? -this.significand : this.significand;
1243
+ const magnitude = Math.max(0, this.exponent + bigintDigits(absSig));
1244
+ const workingPrec = targetPrec + 20 + magnitude;
1245
+ const [xFp, scale] = toFixedPoint(this, workingPrec);
1246
+ const l10 = ln10Fixed(scale);
1247
+ let k = xFp / l10;
1248
+ let rFp = xFp - k * l10;
1249
+ if (rFp < 0n) {
1250
+ k -= 1n;
1251
+ rFp += l10;
1252
+ }
1253
+ if (k > MAX_SAFE_EXPONENT || k < -MAX_SAFE_EXPONENT)
1254
+ return k > 0n ? BigDecimal.POSITIVE_INFINITY : BigDecimal.ZERO;
1255
+ const expR = fromFixedPoint(fpexp(rFp, scale), scale, targetPrec);
1256
+ const newExp = expR.exponent + Number(k);
1257
+ if (!Number.isSafeInteger(newExp))
1258
+ return k > 0n ? BigDecimal.POSITIVE_INFINITY : BigDecimal.ZERO;
1259
+ return fromRaw(expR.significand, newExp);
1204
1260
  };
1205
1261
  BigDecimal.prototype.ln = function() {
1206
1262
  if (this.isNaN()) return BigDecimal.NAN;
@@ -1212,10 +1268,16 @@ BigDecimal.prototype.ln = function() {
1212
1268
  if (this.significand < 0n) return BigDecimal.NAN;
1213
1269
  if (this.eq(1)) return BigDecimal.ZERO;
1214
1270
  const targetPrec = BigDecimal.precision;
1215
- const workingPrec = targetPrec + 15;
1216
- const [fp, scale] = toFixedPoint(this, workingPrec);
1217
- const lnFp = fpln(fp, scale);
1218
- return fromFixedPoint(lnFp, scale, targetPrec);
1271
+ const sig = this.significand;
1272
+ const digits = bigintDigits(sig);
1273
+ const e = this.exponent + digits - 1;
1274
+ const m = fromRaw(sig, -(digits - 1));
1275
+ const eDigits = Math.abs(e).toString().length;
1276
+ const workingPrec = targetPrec + 20 + eDigits;
1277
+ const [mFp, scale] = toFixedPoint(m, workingPrec);
1278
+ const l10 = ln10Fixed(scale);
1279
+ const resultFp = fpln(mFp, scale) + BigInt(e) * l10;
1280
+ return fromFixedPoint(resultFp, scale, targetPrec);
1219
1281
  };
1220
1282
  BigDecimal.prototype.log = function(base) {
1221
1283
  const b = base instanceof BigDecimal ? base : new BigDecimal(base);
@@ -1235,7 +1297,10 @@ BigDecimal.prototype.sin = function() {
1235
1297
  if (!this.isFinite()) return BigDecimal.NAN;
1236
1298
  if (this.isZero()) return BigDecimal.ZERO;
1237
1299
  const targetPrec = BigDecimal.precision;
1238
- const workingPrec = targetPrec + 15;
1300
+ const e = decimalExponent(this);
1301
+ if (e < 0 && -2 * e >= targetPrec + 4) return this.toPrecision(targetPrec);
1302
+ const workingPrec = targetPrec + 15 + (e < 0 ? -e : 0);
1303
+ if (e > PI_DIGITS.length - workingPrec - 30) return BigDecimal.NAN;
1239
1304
  const [fp, scale] = toFixedPoint(this, workingPrec);
1240
1305
  const [sinFp] = fpsincos(fp, scale);
1241
1306
  return fromFixedPoint(sinFp, scale, targetPrec);
@@ -1246,6 +1311,8 @@ BigDecimal.prototype.cos = function() {
1246
1311
  if (this.isZero()) return BigDecimal.ONE;
1247
1312
  const targetPrec = BigDecimal.precision;
1248
1313
  const workingPrec = targetPrec + 15;
1314
+ const e = decimalExponent(this);
1315
+ if (e > PI_DIGITS.length - workingPrec - 30) return BigDecimal.NAN;
1249
1316
  const [fp, scale] = toFixedPoint(this, workingPrec);
1250
1317
  const [, cosFp] = fpsincos(fp, scale);
1251
1318
  return fromFixedPoint(cosFp, scale, targetPrec);
@@ -1255,7 +1322,10 @@ BigDecimal.prototype.tan = function() {
1255
1322
  if (!this.isFinite()) return BigDecimal.NAN;
1256
1323
  if (this.isZero()) return BigDecimal.ZERO;
1257
1324
  const targetPrec = BigDecimal.precision;
1258
- const workingPrec = targetPrec + 15;
1325
+ const e = decimalExponent(this);
1326
+ if (e < 0 && -2 * e >= targetPrec + 4) return this.toPrecision(targetPrec);
1327
+ const workingPrec = targetPrec + 15 + (e < 0 ? -e : 0);
1328
+ if (e > PI_DIGITS.length - workingPrec - 30) return BigDecimal.NAN;
1259
1329
  const [fp, scale] = toFixedPoint(this, workingPrec);
1260
1330
  const [sinFp, cosFp] = fpsincos(fp, scale);
1261
1331
  if (cosFp === 0n) {
@@ -1273,7 +1343,9 @@ BigDecimal.prototype.atan = function() {
1273
1343
  return piHalf.neg();
1274
1344
  }
1275
1345
  const targetPrec = BigDecimal.precision;
1276
- const workingPrec = targetPrec + 15;
1346
+ const e = decimalExponent(this);
1347
+ if (e < 0 && -2 * e >= targetPrec + 4) return this.toPrecision(targetPrec);
1348
+ const workingPrec = targetPrec + 15 + (e < 0 ? -e : 0);
1277
1349
  const [fp, scale] = toFixedPoint(this, workingPrec);
1278
1350
  const atanFp = fpatan(fp, scale);
1279
1351
  return fromFixedPoint(atanFp, scale, targetPrec);
@@ -1290,7 +1362,9 @@ BigDecimal.prototype.asin = function() {
1290
1362
  return this.significand > 0n ? piHalf : piHalf.neg();
1291
1363
  }
1292
1364
  const targetPrec = BigDecimal.precision;
1293
- const workingPrec = targetPrec + 20;
1365
+ const e = decimalExponent(this);
1366
+ if (e < 0 && -2 * e >= targetPrec + 4) return this.toPrecision(targetPrec);
1367
+ const workingPrec = targetPrec + 20 + (e < 0 ? -e : 0);
1294
1368
  const [xFp, scale] = toFixedPoint(this, workingPrec);
1295
1369
  const x2 = fpmul(xFp, xFp, scale);
1296
1370
  const oneMinusX2 = scale - x2;
@@ -1353,6 +1427,23 @@ BigDecimal.prototype.sinh = function() {
1353
1427
  if (this.significand > 0n) return BigDecimal.POSITIVE_INFINITY;
1354
1428
  return BigDecimal.NEGATIVE_INFINITY;
1355
1429
  }
1430
+ const targetPrec = BigDecimal.precision;
1431
+ const e = decimalExponent(this);
1432
+ if (e < 0) {
1433
+ if (-2 * e >= targetPrec + 4) return this.toPrecision(targetPrec);
1434
+ const saved = BigDecimal.precision;
1435
+ BigDecimal.precision = targetPrec - e + 5;
1436
+ try {
1437
+ const expX2 = this.exp();
1438
+ return expX2.sub(expX2.inv()).div(BigDecimal.TWO).toPrecision(targetPrec);
1439
+ } finally {
1440
+ BigDecimal.precision = saved;
1441
+ }
1442
+ }
1443
+ if (Math.abs(this.toNumber()) > 1.16 * (targetPrec + 3)) {
1444
+ const h = this.abs().exp().div(BigDecimal.TWO);
1445
+ return this.significand > 0n ? h : h.neg();
1446
+ }
1356
1447
  const expX = this.exp();
1357
1448
  const expNegX = expX.inv();
1358
1449
  return expX.sub(expNegX).div(BigDecimal.TWO);
@@ -1363,6 +1454,9 @@ BigDecimal.prototype.cosh = function() {
1363
1454
  if (!this.isFinite()) {
1364
1455
  return BigDecimal.POSITIVE_INFINITY;
1365
1456
  }
1457
+ const targetPrec = BigDecimal.precision;
1458
+ if (Math.abs(this.toNumber()) > 1.16 * (targetPrec + 3))
1459
+ return this.abs().exp().div(BigDecimal.TWO);
1366
1460
  const expX = this.exp();
1367
1461
  const expNegX = expX.inv();
1368
1462
  return expX.add(expNegX).div(BigDecimal.TWO);
@@ -1374,6 +1468,21 @@ BigDecimal.prototype.tanh = function() {
1374
1468
  if (this.significand > 0n) return BigDecimal.ONE;
1375
1469
  return BigDecimal.NEGATIVE_ONE;
1376
1470
  }
1471
+ const targetPrec = BigDecimal.precision;
1472
+ const e = decimalExponent(this);
1473
+ if (e < 0) {
1474
+ if (-2 * e >= targetPrec + 4) return this.toPrecision(targetPrec);
1475
+ const saved = BigDecimal.precision;
1476
+ BigDecimal.precision = targetPrec - e + 5;
1477
+ try {
1478
+ const exp2x2 = this.mul(BigDecimal.TWO).exp();
1479
+ return exp2x2.sub(BigDecimal.ONE).div(exp2x2.add(BigDecimal.ONE)).toPrecision(targetPrec);
1480
+ } finally {
1481
+ BigDecimal.precision = saved;
1482
+ }
1483
+ }
1484
+ if (Math.abs(this.toNumber()) > 1.16 * (targetPrec + 3))
1485
+ return this.significand > 0n ? BigDecimal.ONE : BigDecimal.NEGATIVE_ONE;
1377
1486
  const exp2x = this.mul(BigDecimal.TWO).exp();
1378
1487
  return exp2x.sub(BigDecimal.ONE).div(exp2x.add(BigDecimal.ONE));
1379
1488
  };
@@ -1460,9 +1569,7 @@ function bigint(a) {
1460
1569
  if (typeof a === "bigint") return a;
1461
1570
  if (typeof a === "number") {
1462
1571
  if (!Number.isInteger(a)) return null;
1463
- if (a >= Number.MAX_SAFE_INTEGER && a <= Number.MAX_SAFE_INTEGER)
1464
- return BigInt(a);
1465
- return bigint(a.toString());
1572
+ return BigInt(a);
1466
1573
  }
1467
1574
  if (a instanceof BigDecimal) {
1468
1575
  if (!a.isInteger()) return null;
@@ -2743,7 +2850,8 @@ function canonicalInteger(n, exponent) {
2743
2850
  [1, 5],
2744
2851
  [1, 6],
2745
2852
  [1, 7],
2746
- [1, 8],
2853
+ [2, 2],
2854
+ // √8 = 2√2
2747
2855
  [3, 1],
2748
2856
  [1, 10],
2749
2857
  [1, 11],
@@ -2755,7 +2863,8 @@ function canonicalInteger(n, exponent) {
2755
2863
  [1, 17],
2756
2864
  [3, 2],
2757
2865
  [1, 19],
2758
- [1, 20]
2866
+ [2, 5]
2867
+ // √20 = 2√5
2759
2868
  ][n];
2760
2869
  if (result) return result;
2761
2870
  }
@@ -2780,7 +2889,8 @@ function gcd(a, b) {
2780
2889
  }
2781
2890
  function lcm(a, b) {
2782
2891
  if (a === 0 || b === 0) return 0;
2783
- const res = BigInt(a) * BigInt(b) / BigInt(gcd(a, b));
2892
+ let res = BigInt(a) * BigInt(b) / BigInt(gcd(a, b));
2893
+ if (res < 0n) res = -res;
2784
2894
  return Number(res);
2785
2895
  }
2786
2896
  function factorial(n) {
@@ -3335,12 +3445,23 @@ var PRIMITIVE_TYPES = [
3335
3445
  "error",
3336
3446
  ...EXPRESSION_TYPES
3337
3447
  ];
3448
+ var NUMERIC_TYPES_SET = new Set(
3449
+ NUMERIC_TYPES
3450
+ );
3451
+ var COLLECTION_TYPES_SET = new Set(
3452
+ COLLECTION_TYPES
3453
+ );
3454
+ var SCALAR_TYPES_SET = new Set(
3455
+ SCALAR_TYPES
3456
+ );
3457
+ var PRIMITIVE_TYPES_SET = new Set(
3458
+ PRIMITIVE_TYPES
3459
+ );
3338
3460
  function isValidType(t) {
3339
- if (typeof t === "string")
3340
- return PRIMITIVE_TYPES.includes(t);
3461
+ if (typeof t === "string") return PRIMITIVE_TYPES_SET.has(t);
3341
3462
  if (typeof t !== "object") return false;
3342
3463
  if (!("kind" in t)) return false;
3343
- return t.kind === "signature" || t.kind === "union" || t.kind === "intersection" || t.kind === "negation" || t.kind === "tuple" || t.kind === "list" || t.kind === "record" || t.kind === "dictionary" || t.kind === "set" || t.kind === "function" || t.kind === "collection" || t.kind === "indexed_collection" || t.kind === "reference";
3464
+ return t.kind === "signature" || t.kind === "union" || t.kind === "intersection" || t.kind === "negation" || t.kind === "value" || t.kind === "tuple" || t.kind === "list" || t.kind === "record" || t.kind === "dictionary" || t.kind === "set" || t.kind === "symbol" || t.kind === "expression" || t.kind === "numeric" || t.kind === "collection" || t.kind === "indexed_collection" || t.kind === "reference";
3344
3465
  }
3345
3466
 
3346
3467
  // src/common/type/lexer.ts
@@ -4050,19 +4171,13 @@ var Parser = class {
4050
4171
  );
4051
4172
  let dimensions;
4052
4173
  if (this.match("<")) {
4053
- dimensions = this.parseDimensionWithX();
4054
- if (!dimensions) {
4055
- dimensions = this.parseDimensions();
4056
- }
4174
+ dimensions = this.parseDimensions();
4057
4175
  if (!dimensions) {
4058
4176
  const type = this.parseUnionType();
4059
4177
  if (type) {
4060
4178
  elementType = type;
4061
4179
  if (this.match("^")) {
4062
- dimensions = this.parseDimensionWithX();
4063
- if (!dimensions) {
4064
- dimensions = this.parseDimensions();
4065
- }
4180
+ dimensions = this.parseCaretDimensions();
4066
4181
  }
4067
4182
  }
4068
4183
  }
@@ -4103,19 +4218,13 @@ var Parser = class {
4103
4218
  );
4104
4219
  let dimensions;
4105
4220
  if (this.match("<")) {
4106
- dimensions = this.parseDimensionWithX();
4107
- if (!dimensions) {
4108
- dimensions = this.parseDimensions();
4109
- }
4221
+ dimensions = this.parseDimensions();
4110
4222
  if (!dimensions) {
4111
4223
  const type = this.parseUnionType();
4112
4224
  if (type) {
4113
4225
  elementType = type;
4114
4226
  if (this.match("^")) {
4115
- dimensions = this.parseDimensionWithX();
4116
- if (!dimensions) {
4117
- dimensions = this.parseDimensions();
4118
- }
4227
+ dimensions = this.parseCaretDimensions();
4119
4228
  }
4120
4229
  }
4121
4230
  }
@@ -4146,16 +4255,30 @@ var Parser = class {
4146
4255
  return this.createNode("tensor", { elementType });
4147
4256
  }
4148
4257
  parseDimensions() {
4149
- const dimensions = [];
4150
4258
  const firstDim = this.parseDimension();
4151
4259
  if (!firstDim) return void 0;
4152
- dimensions.push(firstDim);
4153
- while (this.match("x")) {
4154
- const dim = this.parseDimension();
4155
- if (!dim) {
4156
- this.error("Expected dimension after x");
4260
+ const dimensions = [firstDim];
4261
+ for (; ; ) {
4262
+ const tok = this.current;
4263
+ if (tok.type === "IDENTIFIER" && /^(x\d+)+$/.test(tok.value)) {
4264
+ this.advance();
4265
+ for (const m of tok.value.match(/x(\d+)/g))
4266
+ dimensions.push(
4267
+ this.createNode("dimension", {
4268
+ size: parseInt(m.slice(1))
4269
+ })
4270
+ );
4271
+ } else if (tok.type === "IDENTIFIER" && tok.value === "x") {
4272
+ const next = this.lexer.peekToken();
4273
+ if (next.type !== "NUMBER_LITERAL" && next.type !== "?")
4274
+ this.error(
4275
+ "Expected a positive integer literal or `?` after x. For example: `2x3` or `2x?`"
4276
+ );
4277
+ this.advance();
4278
+ dimensions.push(this.parseDimension());
4279
+ } else {
4280
+ break;
4157
4281
  }
4158
- dimensions.push(dim);
4159
4282
  }
4160
4283
  return dimensions;
4161
4284
  }
@@ -4169,35 +4292,11 @@ var Parser = class {
4169
4292
  }
4170
4293
  return void 0;
4171
4294
  }
4172
- parseDimensionWithX() {
4173
- if (this.current.type === "NUMBER_LITERAL") {
4174
- const dimensions = [];
4175
- const firstDim = parseInt(this.advance().value);
4176
- dimensions.push(
4177
- this.createNode("dimension", { size: firstDim })
4178
- );
4179
- if (this.current.type === "IDENTIFIER" && this.current.value.startsWith("x")) {
4180
- const dimString = this.current.value;
4181
- const matches = dimString.match(/x(\d+)/g);
4182
- if (matches && matches.join("") === dimString) {
4183
- this.advance();
4184
- for (const match of matches) {
4185
- const dimValue = parseInt(match.substring(1));
4186
- dimensions.push(
4187
- this.createNode("dimension", { size: dimValue })
4188
- );
4189
- }
4190
- } else if (dimString === "x" || dimString.startsWith("x")) {
4191
- this.error(
4192
- "Expected a positive integer literal or `?` after x. For example: `2x3` or `2x?`"
4193
- );
4194
- }
4195
- }
4196
- if (dimensions.length > 1) {
4197
- return dimensions;
4198
- }
4199
- }
4200
- return void 0;
4295
+ parseCaretDimensions() {
4296
+ const paren = this.match("(");
4297
+ const dimensions = this.parseDimensions();
4298
+ if (paren) this.expect(")");
4299
+ return dimensions;
4201
4300
  }
4202
4301
  parseTupleType() {
4203
4302
  if (this.current.type === "IDENTIFIER" && this.current.value === "tuple") {
@@ -4382,6 +4481,18 @@ var Parser = class {
4382
4481
  this.expect("..");
4383
4482
  const upperBound = this.parseValue();
4384
4483
  this.expect(">");
4484
+ const lower = lowerBound?.value ?? -Infinity;
4485
+ const upper = upperBound?.value ?? Infinity;
4486
+ if (Number.isNaN(lower) || Number.isNaN(upper))
4487
+ this.error(
4488
+ "Invalid numeric type",
4489
+ "Lower and upper bounds must be valid numbers"
4490
+ );
4491
+ if (lower > upper)
4492
+ this.error(
4493
+ `Invalid range: ${lower}..${upper}`,
4494
+ "The lower bound must be less than the upper bound"
4495
+ );
4385
4496
  return this.createNode("numeric", {
4386
4497
  baseType,
4387
4498
  lowerBound,
@@ -4396,7 +4507,7 @@ var Parser = class {
4396
4507
  parsePrimitiveType() {
4397
4508
  if (this.current.type === "IDENTIFIER") {
4398
4509
  const name = this.current.value;
4399
- if (PRIMITIVE_TYPES.includes(name)) {
4510
+ if (PRIMITIVE_TYPES_SET.has(name)) {
4400
4511
  this.advance();
4401
4512
  return this.createNode("primitive", { name });
4402
4513
  }
@@ -4730,14 +4841,32 @@ function buildTypeFromAST(node, typeResolver) {
4730
4841
  }
4731
4842
 
4732
4843
  // src/common/type/parse.ts
4844
+ var TYPE_CACHE = /* @__PURE__ */ new Map();
4845
+ var TYPE_CACHE_MAX_SIZE = 2048;
4846
+ function deepFreeze(obj) {
4847
+ if (obj === null || typeof obj !== "object") return obj;
4848
+ if (Object.isFrozen(obj)) return obj;
4849
+ Object.freeze(obj);
4850
+ for (const value of Object.values(obj)) deepFreeze(value);
4851
+ return obj;
4852
+ }
4733
4853
  function parseType(s, typeResolver) {
4734
4854
  if (s === void 0) return void 0;
4735
4855
  if (isValidType(s)) return s;
4736
4856
  if (typeof s !== "string") return void 0;
4857
+ const cacheable = typeResolver === void 0;
4858
+ if (cacheable) {
4859
+ const cached = TYPE_CACHE.get(s);
4860
+ if (cached !== void 0) return cached;
4861
+ }
4737
4862
  try {
4738
4863
  const parser = new Parser(s, { typeResolver });
4739
4864
  const ast = parser.parseType();
4740
4865
  const type = buildTypeFromAST(ast, typeResolver);
4866
+ if (cacheable) {
4867
+ if (TYPE_CACHE.size >= TYPE_CACHE_MAX_SIZE) TYPE_CACHE.clear();
4868
+ TYPE_CACHE.set(s, deepFreeze(type));
4869
+ }
4741
4870
  return type;
4742
4871
  } catch (error) {
4743
4872
  throw new Error(
@@ -4812,19 +4941,36 @@ var PRIMITIVE_SUBTYPES = {
4812
4941
  color: [],
4813
4942
  expression: EXPRESSION_TYPES
4814
4943
  };
4944
+ var PRIMITIVE_SUBTYPES_CLOSURE = (() => {
4945
+ const closure = {};
4946
+ const closeOver = (t) => {
4947
+ if (closure[t]) return closure[t];
4948
+ const result = /* @__PURE__ */ new Set([t]);
4949
+ closure[t] = result;
4950
+ for (const sub of PRIMITIVE_SUBTYPES[t]) {
4951
+ if (sub === t) continue;
4952
+ for (const s of closeOver(sub)) result.add(s);
4953
+ }
4954
+ return result;
4955
+ };
4956
+ for (const t of Object.keys(PRIMITIVE_SUBTYPES))
4957
+ closeOver(t);
4958
+ return closure;
4959
+ })();
4815
4960
  function isPrimitiveSubtype(lhs, rhs) {
4816
4961
  if (rhs === "any") return true;
4817
4962
  if (lhs === "never") return true;
4818
4963
  if (lhs === "unknown" || rhs === "unknown") return false;
4819
4964
  if (lhs === rhs) return true;
4820
- return PRIMITIVE_SUBTYPES[rhs].includes(lhs);
4965
+ return PRIMITIVE_SUBTYPES_CLOSURE[rhs].has(lhs);
4821
4966
  }
4822
4967
  function isSubtype(lhs, rhs) {
4823
- if (typeof lhs === "string" && !PRIMITIVE_TYPES.includes(lhs))
4968
+ if (typeof lhs === "string" && !PRIMITIVE_TYPES_SET.has(lhs))
4824
4969
  lhs = parseType(lhs);
4825
- if (typeof rhs === "string" && !PRIMITIVE_TYPES.includes(rhs))
4970
+ if (typeof rhs === "string" && !PRIMITIVE_TYPES_SET.has(rhs))
4826
4971
  rhs = parseType(rhs);
4827
4972
  if (rhs === "any") return true;
4973
+ if (lhs === "never") return true;
4828
4974
  if (rhs === "never") return false;
4829
4975
  if (rhs === "error") return lhs === "error";
4830
4976
  if (rhs === "nothing") return lhs === "nothing";
@@ -4839,7 +4985,7 @@ function isSubtype(lhs, rhs) {
4839
4985
  if (typeof lhs.value === "number") {
4840
4986
  if (Number.isInteger(lhs.value))
4841
4987
  return isPrimitiveSubtype("integer", rhs);
4842
- return isPrimitiveSubtype("number", rhs);
4988
+ return isPrimitiveSubtype("real", rhs);
4843
4989
  }
4844
4990
  if (typeof lhs.value === "boolean")
4845
4991
  return isPrimitiveSubtype("boolean", rhs);
@@ -5069,7 +5215,7 @@ function isSubtype(lhs, rhs) {
5069
5215
  }
5070
5216
  function isNumeric(type) {
5071
5217
  if (typeof type === "string")
5072
- return NUMERIC_TYPES.includes(type);
5218
+ return NUMERIC_TYPES_SET.has(type);
5073
5219
  if (type.kind === "value") return typeof type.value === "number";
5074
5220
  if (type.kind === "numeric") return true;
5075
5221
  return false;
@@ -5077,7 +5223,7 @@ function isNumeric(type) {
5077
5223
  function isScalar(type) {
5078
5224
  if (isNumeric(type)) return true;
5079
5225
  if (typeof type === "string")
5080
- return SCALAR_TYPES.includes(type);
5226
+ return SCALAR_TYPES_SET.has(type);
5081
5227
  if (type.kind === "value")
5082
5228
  return ["string", "boolean", "number"].includes(typeof type.value);
5083
5229
  return false;
@@ -5085,7 +5231,7 @@ function isScalar(type) {
5085
5231
  function isCollection(type) {
5086
5232
  if (isIndexedCollection(type)) return true;
5087
5233
  if (typeof type === "string")
5088
- return COLLECTION_TYPES.includes(type);
5234
+ return COLLECTION_TYPES_SET.has(type);
5089
5235
  return ["collection", "set", "record", "dictionary"].includes(type.kind);
5090
5236
  }
5091
5237
  function isIndexedCollection(type) {
@@ -5145,16 +5291,17 @@ var LOSSY_SUPERTYPE = /* @__PURE__ */ new Set([
5145
5291
  ]);
5146
5292
  function unionTypes(a, b) {
5147
5293
  const members = [];
5294
+ const keys = /* @__PURE__ */ new Set();
5148
5295
  const push = (t) => {
5149
5296
  if (typeof t === "object" && t.kind === "union") {
5150
5297
  for (const m of t.types) push(m);
5151
5298
  return;
5152
5299
  }
5153
5300
  const key = typeof t === "string" ? t : JSON.stringify(t);
5154
- if (!members.some(
5155
- (m) => (typeof m === "string" ? m : JSON.stringify(m)) === key
5156
- ))
5301
+ if (!keys.has(key)) {
5302
+ keys.add(key);
5157
5303
  members.push(t);
5304
+ }
5158
5305
  };
5159
5306
  push(a);
5160
5307
  push(b);
@@ -5166,6 +5313,32 @@ function widen(...types) {
5166
5313
  if (types.length === 1) return types[0];
5167
5314
  return types.reduce((a, b) => widen2(a, b));
5168
5315
  }
5316
+ var SUPERTYPE_PROBE_ORDER = [
5317
+ "non_finite_number",
5318
+ "finite_integer",
5319
+ "integer",
5320
+ "finite_rational",
5321
+ "rational",
5322
+ "finite_real",
5323
+ "real",
5324
+ "imaginary",
5325
+ "finite_complex",
5326
+ "complex",
5327
+ "finite_number",
5328
+ "number",
5329
+ "list",
5330
+ "record",
5331
+ "dictionary",
5332
+ "set",
5333
+ "tuple",
5334
+ "indexed_collection",
5335
+ "collection",
5336
+ "scalar",
5337
+ "value",
5338
+ "function",
5339
+ "expression"
5340
+ ];
5341
+ var PRIMITIVE_SUPERTYPE_CACHE = /* @__PURE__ */ new Map();
5169
5342
  function superType(a, b) {
5170
5343
  if (a === b) return a;
5171
5344
  if (a === "any" || b === "any") return "any";
@@ -5175,35 +5348,26 @@ function superType(a, b) {
5175
5348
  if (b === "unknown") return a;
5176
5349
  if (a === "nothing") return b;
5177
5350
  if (b === "nothing") return a;
5178
- if (commonSupertype(a, b, "non_finite_number")) return "non_finite_number";
5179
- if (commonSupertype(a, b, "finite_integer")) return "finite_integer";
5180
- if (commonSupertype(a, b, "integer")) return "integer";
5181
- if (commonSupertype(a, b, "finite_rational")) return "finite_rational";
5182
- if (commonSupertype(a, b, "rational")) return "rational";
5183
- if (commonSupertype(a, b, "finite_real")) return "finite_real";
5184
- if (commonSupertype(a, b, "real")) return "real";
5185
- if (commonSupertype(a, b, "imaginary")) return "imaginary";
5186
- if (commonSupertype(a, b, "finite_complex")) return "finite_complex";
5187
- if (commonSupertype(a, b, "complex")) return "complex";
5188
- if (commonSupertype(a, b, "finite_number")) return "finite_number";
5189
- if (commonSupertype(a, b, "number")) return "number";
5190
- if (commonSupertype(a, b, "list")) return "list";
5191
- if (commonSupertype(a, b, "record")) return "record";
5192
- if (commonSupertype(a, b, "dictionary")) return "dictionary";
5193
- if (commonSupertype(a, b, "set")) return "set";
5194
- if (commonSupertype(a, b, "tuple")) return "tuple";
5195
- if (commonSupertype(a, b, "indexed_collection")) return "indexed_collection";
5196
- if (commonSupertype(a, b, "collection")) return "collection";
5197
- if (commonSupertype(a, b, "scalar")) return "scalar";
5198
- if (commonSupertype(a, b, "value")) return "value";
5199
- if (commonSupertype(a, b, "function")) return "function";
5200
- if (commonSupertype(a, b, "expression")) return "expression";
5351
+ if (typeof a === "string" && typeof b === "string") {
5352
+ const key = a < b ? `${a}|${b}` : `${b}|${a}`;
5353
+ let result = PRIMITIVE_SUPERTYPE_CACHE.get(key);
5354
+ if (result === void 0) {
5355
+ result = "any";
5356
+ for (const ancestor of SUPERTYPE_PROBE_ORDER) {
5357
+ const subtypes = PRIMITIVE_SUBTYPES_CLOSURE[ancestor];
5358
+ if (subtypes.has(a) && subtypes.has(b)) {
5359
+ result = ancestor;
5360
+ break;
5361
+ }
5362
+ }
5363
+ PRIMITIVE_SUPERTYPE_CACHE.set(key, result);
5364
+ }
5365
+ return result;
5366
+ }
5367
+ for (const ancestor of SUPERTYPE_PROBE_ORDER)
5368
+ if (isSubtype(a, ancestor) && isSubtype(b, ancestor)) return ancestor;
5201
5369
  return "any";
5202
5370
  }
5203
- function commonSupertype(a, b, ancestor) {
5204
- if (isSubtype(a, ancestor) && isSubtype(b, ancestor)) return true;
5205
- return false;
5206
- }
5207
5371
 
5208
5372
  // src/compute-engine/numeric-value/exact-numeric-value.ts
5209
5373
  var ExactNumericValue = class _ExactNumericValue extends NumericValue {
@@ -5421,6 +5585,10 @@ var ExactNumericValue = class _ExactNumericValue extends NumericValue {
5421
5585
  });
5422
5586
  }
5423
5587
  inv() {
5588
+ if (this.isNaN) return this;
5589
+ if (this.isPositiveInfinity || this.isNegativeInfinity)
5590
+ return this.clone(0);
5591
+ if (this.isZero) return this.clone(Infinity);
5424
5592
  if (this.isOne) return this;
5425
5593
  if (this.isNegativeOne) return this;
5426
5594
  return this.clone({
@@ -5539,7 +5707,7 @@ var ExactNumericValue = class _ExactNumericValue extends NumericValue {
5539
5707
  } else {
5540
5708
  if (exponent instanceof _ExactNumericValue) {
5541
5709
  if (exponent.radical === 1 && exponent.rational[0] == 1)
5542
- return this.root(exponent.rational[0]);
5710
+ return this.root(Number(exponent.rational[1]));
5543
5711
  }
5544
5712
  exponent = exponent.re;
5545
5713
  }
@@ -5674,19 +5842,52 @@ var ExactNumericValue = class _ExactNumericValue extends NumericValue {
5674
5842
  if (this.isPositiveInfinity) return this.clone(Infinity);
5675
5843
  return this.factory(this.bignumRe).exp();
5676
5844
  }
5845
+ /**
5846
+ * Floor/ceil/round of a pure rational (`radical === 1`) computed exactly with
5847
+ * bigints. Routing through `this.re` (a float) would lose digits for
5848
+ * integers/rationals larger than 2^53.
5849
+ */
5850
+ _integerPart(mode2) {
5851
+ let n = BigInt(this.rational[0]);
5852
+ let d = BigInt(this.rational[1]);
5853
+ if (d < 0n) {
5854
+ n = -n;
5855
+ d = -d;
5856
+ }
5857
+ let q;
5858
+ if (mode2 === "round") {
5859
+ const m = 2n * n + d;
5860
+ const dd = 2n * d;
5861
+ q = m / dd;
5862
+ if (m % dd !== 0n && m < 0n) q -= 1n;
5863
+ } else {
5864
+ q = n / d;
5865
+ const r = n % d;
5866
+ if (r !== 0n) {
5867
+ if (mode2 === "floor" && n < 0n) q -= 1n;
5868
+ if (mode2 === "ceil" && n > 0n) q += 1n;
5869
+ }
5870
+ }
5871
+ return this.clone({ rational: [q, BigInt(1)], radical: 1 });
5872
+ }
5873
+ // An exact value is an integer iff it has no radical part and a unit
5874
+ // denominator. (`this.type` returns `'finite_integer'`, never `'integer'`.)
5677
5875
  floor() {
5678
5876
  if (this.isNaN) return this.clone(NaN);
5679
- if (this.type === "integer") return this;
5877
+ if (this.radical === 1 && isInteger(this.rational)) return this;
5878
+ if (this.radical === 1) return this._integerPart("floor");
5680
5879
  return this.clone(Math.floor(this.re));
5681
5880
  }
5682
5881
  ceil() {
5683
5882
  if (this.isNaN) return this.clone(NaN);
5684
- if (this.type === "integer") return this;
5883
+ if (this.radical === 1 && isInteger(this.rational)) return this;
5884
+ if (this.radical === 1) return this._integerPart("ceil");
5685
5885
  return this.clone(Math.ceil(this.re));
5686
5886
  }
5687
5887
  round() {
5688
5888
  if (this.isNaN) return this.clone(NaN);
5689
- if (this.type === "integer") return this;
5889
+ if (this.radical === 1 && isInteger(this.rational)) return this;
5890
+ if (this.radical === 1) return this._integerPart("round");
5690
5891
  return this.clone(Math.round(this.re));
5691
5892
  }
5692
5893
  eq(other) {
@@ -5785,7 +5986,7 @@ function gcd3(a, b) {
5785
5986
  return a.abs();
5786
5987
  }
5787
5988
  function lcm3(a, b) {
5788
- return a.mul(b).div(gcd3(a, b));
5989
+ return a.mul(b).div(gcd3(a, b)).abs();
5789
5990
  }
5790
5991
  function* factorial22(n) {
5791
5992
  if (!n.isInteger() || n.isNegative()) return BigDecimal.NAN;
@@ -5965,8 +6166,8 @@ var BigNumericValue = class _BigNumericValue extends NumericValue {
5965
6166
  if (this.isOne) return this;
5966
6167
  if (this.isNegativeOne) return this;
5967
6168
  if (this.im === 0) return this.clone(this.decimal.inv());
5968
- const d = Math.hypot(this.re, this.im);
5969
- const bigD = this.decimal.mul(this.decimal).add(this.im * this.im).sqrt();
6169
+ const d = this.re * this.re + this.im * this.im;
6170
+ const bigD = this.decimal.mul(this.decimal).add(this.im * this.im);
5970
6171
  return this.clone({ re: this.decimal.div(bigD), im: -this.im / d });
5971
6172
  }
5972
6173
  add(other) {
@@ -5993,7 +6194,7 @@ var BigNumericValue = class _BigNumericValue extends NumericValue {
5993
6194
  if (other === 1) return this;
5994
6195
  if (other === -1) return this.neg();
5995
6196
  if (other === 0) {
5996
- if (this.isPositiveInfinity || this.isNegativeInfinity || this.isComplexInfinity)
6197
+ if (this.isNaN || this.isPositiveInfinity || this.isNegativeInfinity || this.isComplexInfinity)
5997
6198
  return this._makeExact(NaN);
5998
6199
  return this.clone(0);
5999
6200
  }
@@ -6023,7 +6224,7 @@ var BigNumericValue = class _BigNumericValue extends NumericValue {
6023
6224
  if (other.isOne) return this;
6024
6225
  if (other.isNegativeOne) return this.neg();
6025
6226
  if (other.isZero) {
6026
- if (this.isPositiveInfinity || this.isNegativeInfinity || this.isComplexInfinity)
6227
+ if (this.isNaN || this.isPositiveInfinity || this.isNegativeInfinity || this.isComplexInfinity)
6027
6228
  return this._makeExact(NaN);
6028
6229
  return this.clone(0);
6029
6230
  }
@@ -6046,7 +6247,11 @@ var BigNumericValue = class _BigNumericValue extends NumericValue {
6046
6247
  }
6047
6248
  if (other.isOne) return this;
6048
6249
  if (other.isNegativeOne) return this.neg();
6049
- if (other.isZero) return this.clone(this.isZero ? NaN : Infinity);
6250
+ if (other.isZero) {
6251
+ if (this.isZero || this.isNaN) return this.clone(NaN);
6252
+ if (this.im !== 0) return this.clone({ im: Infinity });
6253
+ return this.clone(this.decimal.isNegative() ? -Infinity : Infinity);
6254
+ }
6050
6255
  if (this.im === 0 && other.im === 0)
6051
6256
  return this.clone(this.decimal.div(other.bignumRe ?? other.re));
6052
6257
  const [a, b] = [this.re, this.im];
@@ -6080,13 +6285,18 @@ var BigNumericValue = class _BigNumericValue extends NumericValue {
6080
6285
  if (this.im === Infinity) return this.clone(NaN);
6081
6286
  if (this.isNegativeInfinity) return this.clone(0);
6082
6287
  if (this.isPositiveInfinity) return this.clone({ im: Infinity });
6083
- const zRe = this.pow(re);
6084
- const zArg = this.decimal.ln().mul(im);
6085
- const zIm = this.clone({
6086
- re: zArg.cos(),
6087
- im: chop2(zArg.sin().toNumber())
6288
+ if (this.isZero) return re > 0 ? this.clone(0) : this.clone(NaN);
6289
+ const a2 = this.decimal;
6290
+ const b2 = this.im;
6291
+ const lnMod = a2.mul(a2).add(b2 * b2).sqrt().ln();
6292
+ const arg = BigDecimal.atan2(b2, a2);
6293
+ const realExp = lnMod.mul(re).sub(arg.mul(im));
6294
+ const imagExp = arg.mul(re).add(lnMod.mul(im));
6295
+ const mag = realExp.exp();
6296
+ return this.clone({
6297
+ re: mag.mul(imagExp.cos()),
6298
+ im: chop2(mag.mul(imagExp.sin()).toNumber())
6088
6299
  });
6089
- return zRe.mul(zIm);
6090
6300
  }
6091
6301
  }
6092
6302
  if (this.isPositiveInfinity) {
@@ -6130,13 +6340,13 @@ var BigNumericValue = class _BigNumericValue extends NumericValue {
6130
6340
  if (this.decimal.isNegative()) return this._makeExact(NaN);
6131
6341
  if (exp === 2) return this.clone(this.decimal.sqrt());
6132
6342
  if (exp === 3) return this.clone(this.decimal.cbrt());
6133
- return this.clone(this.decimal.pow(1 / exp));
6343
+ return this.clone(this.decimal.ln().div(exp).exp());
6134
6344
  }
6135
6345
  const a = this.decimal;
6136
6346
  const b = this.im;
6137
6347
  const modulus = a.mul(a).add(b * b).sqrt();
6138
6348
  const argument = BigDecimal.atan2(b, a);
6139
- const newModulus = modulus.pow(1 / exp);
6349
+ const newModulus = modulus.ln().div(exp).exp();
6140
6350
  const newArgument = argument.div(exp);
6141
6351
  return this.clone({
6142
6352
  re: newModulus.mul(newArgument.cos()),
@@ -6402,7 +6612,7 @@ var MachineNumericValue = class _MachineNumericValue extends NumericValue {
6402
6612
  if (this.isOne) return this;
6403
6613
  if (this.isNegativeOne) return this;
6404
6614
  if (this.im === 0) return this.clone(1 / this.decimal);
6405
- const d = Math.hypot(this.re, this.im);
6615
+ const d = this.re * this.re + this.im * this.im;
6406
6616
  return this.clone({ re: this.decimal / d, im: -this.im / d });
6407
6617
  }
6408
6618
  add(other) {
@@ -6512,11 +6722,17 @@ var MachineNumericValue = class _MachineNumericValue extends NumericValue {
6512
6722
  if (this.im === Infinity) return this.clone(NaN);
6513
6723
  if (this.isNegativeInfinity) return this.clone(0);
6514
6724
  if (this.isPositiveInfinity) return this.clone({ im: Infinity });
6515
- const zRe = this.pow(re).re;
6516
- const zArg = Math.log(this.decimal) * im;
6725
+ if (this.isZero) return re > 0 ? this.clone(0) : this.clone(NaN);
6726
+ const a2 = this.decimal;
6727
+ const b2 = this.im;
6728
+ const lnMod = 0.5 * Math.log(a2 * a2 + b2 * b2);
6729
+ const arg = Math.atan2(b2, a2);
6730
+ const realExp = re * lnMod - im * arg;
6731
+ const imagExp = re * arg + im * lnMod;
6732
+ const mag = Math.exp(realExp);
6517
6733
  return this.clone({
6518
- re: chop3(zRe * Math.cos(zArg)),
6519
- im: chop3(zRe * Math.sin(zArg))
6734
+ re: chop3(mag * Math.cos(imagExp)),
6735
+ im: chop3(mag * Math.sin(imagExp))
6520
6736
  });
6521
6737
  }
6522
6738
  }
@@ -6535,14 +6751,15 @@ var MachineNumericValue = class _MachineNumericValue extends NumericValue {
6535
6751
  if (exponent > 0) return this;
6536
6752
  if (exponent < 0) return this.clone({ im: Infinity });
6537
6753
  }
6538
- if (exponent < 0) return this.clone(1 / this.decimal ** -exponent);
6754
+ if (exponent < 0 && this.im === 0)
6755
+ return this.clone(1 / this.decimal ** -exponent);
6539
6756
  if (this.im === 0) return this.clone(this.decimal ** exponent);
6540
6757
  const a = this.decimal;
6541
6758
  const b = this.im;
6542
6759
  const modulus = Math.sqrt(a * a + b * b);
6543
6760
  const argument = Math.atan2(b, a);
6544
6761
  const newModulus = modulus ** exponent;
6545
- const newArgument = argument ** exponent;
6762
+ const newArgument = argument * exponent;
6546
6763
  return this.clone({
6547
6764
  re: newModulus * Math.cos(newArgument),
6548
6765
  im: newModulus * Math.sin(newArgument)
@@ -6663,10 +6880,10 @@ var MachineNumericValue = class _MachineNumericValue extends NumericValue {
6663
6880
  eq(other) {
6664
6881
  if (this.isNaN) return false;
6665
6882
  if (typeof other === "number")
6666
- return this.im === 0 && this.decimal - other === 0;
6883
+ return this.im === 0 && this.decimal === other;
6667
6884
  if (other.isNaN) return false;
6668
6885
  if (!Number.isFinite(this.im)) return !Number.isFinite(other.im);
6669
- return this.decimal - other.re === 0 && this.im - other.im === 0;
6886
+ return this.decimal === other.re && this.im === other.im;
6670
6887
  }
6671
6888
  lt(other) {
6672
6889
  if (this.im !== 0) return void 0;
@@ -6748,42 +6965,20 @@ function interval(expr) {
6748
6965
  return void 0;
6749
6966
  }
6750
6967
  function intervalContains(int, val) {
6751
- if (int.openStart) {
6752
- if (int.start <= val) return false;
6753
- }
6754
- if (int.start < val) return false;
6755
- if (int.openEnd) {
6756
- if (int.end >= val) return false;
6757
- }
6758
- if (int.end > val) return false;
6968
+ if (int.openStart ? val <= int.start : val < int.start) return false;
6969
+ if (int.openEnd ? val >= int.end : val > int.end) return false;
6759
6970
  return true;
6760
6971
  }
6761
6972
  function intervalSubset(int1, int2) {
6762
- if (int1.openStart) {
6763
- if (int2.openStart) {
6764
- if (int1.start <= int2.start) return false;
6765
- } else {
6766
- if (int1.start < int2.start) return false;
6767
- }
6973
+ if (!int1.openStart && int2.openStart) {
6974
+ if (int1.start <= int2.start) return false;
6768
6975
  } else {
6769
- if (int2.openStart) {
6770
- if (int1.start <= int2.start) return false;
6771
- } else {
6772
- if (int1.start < int2.start) return false;
6773
- }
6976
+ if (int1.start < int2.start) return false;
6774
6977
  }
6775
- if (int1.openEnd) {
6776
- if (int2.openEnd) {
6777
- if (int1.end >= int2.end) return false;
6778
- } else {
6779
- if (int1.end > int2.end) return false;
6780
- }
6978
+ if (!int1.openEnd && int2.openEnd) {
6979
+ if (int1.end >= int2.end) return false;
6781
6980
  } else {
6782
- if (int2.openEnd) {
6783
- if (int1.end >= int2.end) return false;
6784
- } else {
6785
- if (int1.end > int2.end) return false;
6786
- }
6981
+ if (int1.end > int2.end) return false;
6787
6982
  }
6788
6983
  return true;
6789
6984
  }
@@ -6966,6 +7161,7 @@ function bigPopulationStandardDeviation(values) {
6966
7161
  function kurtosis(values) {
6967
7162
  let sum = 0;
6968
7163
  let sum2 = 0;
7164
+ let sum3 = 0;
6969
7165
  let sum4 = 0;
6970
7166
  let count = 0;
6971
7167
  for (const op of values) {
@@ -6973,16 +7169,21 @@ function kurtosis(values) {
6973
7169
  if (!Number.isFinite(v)) return NaN;
6974
7170
  sum += v;
6975
7171
  sum2 += v * v;
7172
+ sum3 += v * v * v;
6976
7173
  sum4 += v * v * v * v;
6977
7174
  count++;
6978
7175
  }
6979
7176
  if (count === 0) return NaN;
6980
- const s2 = (sum2 - sum * sum / count) / (count - 1);
6981
- return (sum4 - 4 * sum * sum2 / count + 6 * sum * sum * sum / count / count - 3 * sum * sum * sum * sum / count / count / count) / (s2 * s2);
7177
+ const n = count;
7178
+ const m = sum / n;
7179
+ const m2 = (sum2 - sum * sum / n) / n;
7180
+ const m4 = (sum4 - 4 * m * sum3 + 6 * m * m * sum2 - 4 * m * m * m * sum + n * m * m * m * m) / n;
7181
+ return m4 / (m2 * m2);
6982
7182
  }
6983
7183
  function bigKurtosis(values) {
6984
7184
  let sum = BigDecimal.ZERO;
6985
7185
  let sum2 = BigDecimal.ZERO;
7186
+ let sum3 = BigDecimal.ZERO;
6986
7187
  let sum4 = BigDecimal.ZERO;
6987
7188
  let count = 0;
6988
7189
  for (const op of values) {
@@ -6990,15 +7191,15 @@ function bigKurtosis(values) {
6990
7191
  if (!v.isFinite()) return BigDecimal.NAN;
6991
7192
  sum = sum.add(v);
6992
7193
  sum2 = sum2.add(v.mul(v));
7194
+ sum3 = sum3.add(v.mul(v).mul(v));
6993
7195
  sum4 = sum4.add(v.mul(v).mul(v).mul(v));
6994
7196
  count++;
6995
7197
  }
6996
7198
  if (count === 0) return BigDecimal.NAN;
6997
- const bdCount = new BigDecimal(count);
6998
- const s2 = sum2.sub(sum.mul(sum).div(bdCount)).div(new BigDecimal(count - 1));
6999
- return sum4.sub(sum.mul(sum2).mul(new BigDecimal(4)).div(bdCount)).add(sum.mul(sum).mul(sum).mul(new BigDecimal(6)).div(bdCount).div(bdCount)).sub(
7000
- sum.mul(sum).mul(sum).mul(sum).mul(new BigDecimal(3)).div(bdCount).div(bdCount).div(bdCount)
7001
- ).div(s2.mul(s2));
7199
+ const m = sum.div(count);
7200
+ const m2 = sum2.sub(sum.mul(sum).div(count)).div(count);
7201
+ const m4 = sum4.sub(m.mul(sum3).mul(4)).add(m.mul(m).mul(sum2).mul(6)).sub(m.mul(m).mul(m).mul(sum).mul(4)).add(m.mul(m).mul(m).mul(m).mul(count)).div(count);
7202
+ return m4.div(m2.mul(m2));
7002
7203
  }
7003
7204
  function skewness(values) {
7004
7205
  let sum = 0;
@@ -7014,9 +7215,11 @@ function skewness(values) {
7014
7215
  count++;
7015
7216
  }
7016
7217
  if (count === 0) return NaN;
7017
- const s2 = (sum2 - sum * sum / count) / (count - 1);
7018
- const s3 = (sum3 - sum2 * sum / count) / (count - 1);
7019
- return s3 / Math.pow(s2, 3 / 2) * Math.sqrt(count * 1);
7218
+ const n = count;
7219
+ const m = sum / n;
7220
+ const m2 = (sum2 - sum * sum / n) / n;
7221
+ const m3 = (sum3 - 3 * m * sum2 + 3 * m * m * sum - n * m * m * m) / n;
7222
+ return m3 / Math.pow(m2, 3 / 2);
7020
7223
  }
7021
7224
  function bigSkewness(values) {
7022
7225
  let sum = BigDecimal.ZERO;
@@ -7032,10 +7235,10 @@ function bigSkewness(values) {
7032
7235
  count++;
7033
7236
  }
7034
7237
  if (count === 0) return BigDecimal.NAN;
7035
- const bdCount = new BigDecimal(count);
7036
- const s2 = sum2.sub(sum.mul(sum).div(bdCount)).div(new BigDecimal(count - 1));
7037
- const s3 = sum3.sub(sum2.mul(sum).div(bdCount)).div(new BigDecimal(count - 1));
7038
- return s3.div(s2.pow(new BigDecimal(1.5))).mul(bdCount.sqrt());
7238
+ const m = sum.div(count);
7239
+ const m2 = sum2.sub(sum.mul(sum).div(count)).div(count);
7240
+ const m3 = sum3.sub(m.mul(sum2).mul(3)).add(m.mul(m).mul(sum).mul(3)).sub(m.mul(m).mul(m).mul(count)).div(count);
7241
+ return m3.div(m2.mul(m2.sqrt()));
7039
7242
  }
7040
7243
  function mode(values) {
7041
7244
  const counts = {};
@@ -7086,18 +7289,12 @@ function bigQuartiles(values) {
7086
7289
  return [q1, q2, q3];
7087
7290
  }
7088
7291
  function interquartileRange(values) {
7089
- const sorted = [...values].sort((a, b) => a - b);
7090
- const mid = Math.floor(sorted.length / 2);
7091
- const lower = sorted.slice(0, mid);
7092
- const upper = sorted.slice(mid + 1);
7093
- return median(upper) - median(lower);
7292
+ const [q1, , q3] = quartiles(values);
7293
+ return q3 - q1;
7094
7294
  }
7095
7295
  function bigInterquartileRange(values) {
7096
- const sorted = [...values].sort((a, b) => a.cmp(b));
7097
- const mid = Math.floor(sorted.length / 2);
7098
- const lower = sorted.slice(0, mid);
7099
- const upper = sorted.slice(mid + 1);
7100
- return bigMedian(upper).sub(bigMedian(lower));
7296
+ const [q1, , q3] = bigQuartiles(values);
7297
+ return q3.sub(q1);
7101
7298
  }
7102
7299
 
7103
7300
  // src/compute-engine/numerics/unit-data.ts
@@ -7472,9 +7669,14 @@ var lanczos_7_c = [
7472
7669
  ];
7473
7670
  function gammaln(z) {
7474
7671
  if (z < 0) return NaN;
7672
+ let shift = 0;
7673
+ while (z < 10) {
7674
+ shift += Math.log(z);
7675
+ z += 1;
7676
+ }
7475
7677
  const pi = Math.PI;
7476
7678
  const z3 = z * z * z;
7477
- return z * Math.log(z) - z - 0.5 * Math.log(z) + 0.5 * Math.log(2 * pi) + 1 / (12 * z) - 1 / (360 * z3) + 1 / (1260 * z3 * z * z);
7679
+ return z * Math.log(z) - z - 0.5 * Math.log(z) + 0.5 * Math.log(2 * pi) + 1 / (12 * z) - 1 / (360 * z3) + 1 / (1260 * z3 * z * z) - shift;
7478
7680
  }
7479
7681
  function gamma(z) {
7480
7682
  if (z < 0.5) return Math.PI / (Math.sin(Math.PI * z) * gamma(1 - z));
@@ -7485,31 +7687,62 @@ function gamma(z) {
7485
7687
  const t = z + gammaG + 0.5;
7486
7688
  return Math.sqrt(2 * Math.PI) * Math.pow(t, z + 0.5) * Math.exp(-t) * x;
7487
7689
  }
7690
+ function erfInvApprox(x) {
7691
+ const a = 0.147;
7692
+ const ln1mx2 = Math.log(1 - x * x);
7693
+ const b = 2 / (Math.PI * a) + ln1mx2 / 2;
7694
+ return Math.sign(x) * Math.sqrt(Math.sqrt(b * b - ln1mx2 / a) - b);
7695
+ }
7488
7696
  function erfInv(x) {
7489
- const pi = Math.PI;
7490
- const pi2 = pi * pi;
7491
- const pi3 = pi2 * pi;
7492
- const x2 = x * x;
7493
- const x3 = x * x2;
7494
- const x5 = x3 * x2;
7495
- const x7 = x5 * x2;
7496
- return Math.sqrt(pi) / 2 * (x + pi / 12 * x3 + 7 * pi2 / 480 * x5 + 127 * pi3 / 40320 * x7 + 4369 * pi2 * pi2 / 5806080 * x7 * x2 + 34807 * pi3 * pi2 / 182476800 * x7 * x2 * x2);
7697
+ if (Number.isNaN(x) || x < -1 || x > 1) return NaN;
7698
+ if (x === 0) return 0;
7699
+ if (x === 1) return Infinity;
7700
+ if (x === -1) return -Infinity;
7701
+ const sign = x < 0 ? -1 : 1;
7702
+ const ax = Math.abs(x);
7703
+ let y = erfInvApprox(ax);
7704
+ const c = Math.sqrt(Math.PI) / 2;
7705
+ for (let i = 0; i < 4; i++) y -= (erf(y) - ax) * c * Math.exp(y * y);
7706
+ return sign * y;
7497
7707
  }
7498
7708
  function erfc(x) {
7499
- return 1 - erf(x);
7709
+ if (Number.isNaN(x)) return NaN;
7710
+ if (!Number.isFinite(x)) return x > 0 ? 0 : 2;
7711
+ if (x < 0) return 2 - erfc(-x);
7712
+ if (x < 2) return 1 - erf(x);
7713
+ const tiny = 1e-300;
7714
+ let f = x === 0 ? tiny : x;
7715
+ let c = f;
7716
+ let d = 0;
7717
+ for (let k = 1; k <= 500; k++) {
7718
+ const a = k / 2;
7719
+ d = x + a * d;
7720
+ if (d === 0) d = tiny;
7721
+ d = 1 / d;
7722
+ c = x + a / c;
7723
+ if (c === 0) c = tiny;
7724
+ const delta = c * d;
7725
+ f *= delta;
7726
+ if (Math.abs(delta - 1) < 1e-17) break;
7727
+ }
7728
+ return Math.exp(-x * x) / (Math.sqrt(Math.PI) * f);
7500
7729
  }
7501
7730
  function erf(x) {
7502
- const a1 = 0.254829592;
7503
- const a2 = -0.284496736;
7504
- const a3 = 1.421413741;
7505
- const a4 = -1.453152027;
7506
- const a5 = 1.061405429;
7507
- const p = 0.3275911;
7731
+ if (Number.isNaN(x)) return NaN;
7732
+ if (x === 0) return 0;
7733
+ if (!Number.isFinite(x)) return x > 0 ? 1 : -1;
7508
7734
  const sign = x < 0 ? -1 : 1;
7509
- x = Math.abs(x);
7510
- const t = 1 / (1 + p * x);
7511
- const y = ((((a5 * t + a4) * t + a3) * t + a2) * t + a1) * t;
7512
- return sign * (1 - y * Math.exp(-x * x));
7735
+ const ax = Math.abs(x);
7736
+ if (ax >= 6) return sign;
7737
+ const x2 = ax * ax;
7738
+ let term = ax;
7739
+ let sum = ax;
7740
+ for (let n = 1; n < 200; n++) {
7741
+ term *= 2 * x2 / (2 * n + 1);
7742
+ sum += term;
7743
+ if (term < sum * 1e-18) break;
7744
+ }
7745
+ return sign * (2 / Math.sqrt(Math.PI)) * Math.exp(-x2) * sum;
7513
7746
  }
7514
7747
  function bigGammaln(ce, z) {
7515
7748
  if (!z.isFinite()) return BigDecimal.NAN;
@@ -8459,7 +8692,7 @@ function fresnelS(x) {
8459
8692
  const t = x2 * x2;
8460
8693
  return sign * x * x2 * polevl(t, SN) / polevl(t, SD);
8461
8694
  }
8462
- if (x < 36) {
8695
+ if (x < 36974) {
8463
8696
  const x2 = x * x;
8464
8697
  const t = Math.PI * x2;
8465
8698
  const u = 1 / (t * t);
@@ -8484,7 +8717,7 @@ function fresnelC(x) {
8484
8717
  const t = x2 * x2;
8485
8718
  return sign * x * polevl(t, CN) / polevl(t, CD);
8486
8719
  }
8487
- if (x < 36) {
8720
+ if (x < 36974) {
8488
8721
  const x2 = x * x;
8489
8722
  const t = Math.PI * x2;
8490
8723
  const u = 1 / (t * t);
@@ -8501,16 +8734,894 @@ function sinc(x) {
8501
8734
  return x === 0 ? 1 : Math.sin(x) / x;
8502
8735
  }
8503
8736
 
8737
+ // node_modules/complex-esm/dist/src/complex.js
8738
+ var cosh = Math.cosh || function(x) {
8739
+ return Math.abs(x) < 1e-9 ? 1 - x : (Math.exp(x) + Math.exp(-x)) * 0.5;
8740
+ };
8741
+ var sinh = Math.sinh || function(x) {
8742
+ return Math.abs(x) < 1e-9 ? x : (Math.exp(x) - Math.exp(-x)) * 0.5;
8743
+ };
8744
+ var cosm1 = function(x) {
8745
+ var b = Math.PI / 4;
8746
+ if (-b > x || x > b) {
8747
+ return Math.cos(x) - 1;
8748
+ }
8749
+ var xx = x * x;
8750
+ return xx * (xx * (xx * (xx * (xx * (xx * (xx * (xx / 20922789888e3 - 1 / 87178291200) + 1 / 479001600) - 1 / 3628800) + 1 / 40320) - 1 / 720) + 1 / 24) - 1 / 2);
8751
+ };
8752
+ var hypot = function(x, y) {
8753
+ var a = Math.abs(x);
8754
+ var b = Math.abs(y);
8755
+ if (a < 3e3 && b < 3e3) {
8756
+ return Math.sqrt(a * a + b * b);
8757
+ }
8758
+ if (a < b) {
8759
+ a = b;
8760
+ b = x / y;
8761
+ } else {
8762
+ b = y / x;
8763
+ }
8764
+ return a * Math.sqrt(1 + b * b);
8765
+ };
8766
+ var parser_exit = function() {
8767
+ throw SyntaxError("Invalid Param");
8768
+ };
8769
+ function logHypot(a, b) {
8770
+ var _a = Math.abs(a);
8771
+ var _b = Math.abs(b);
8772
+ if (a === 0) {
8773
+ return Math.log(_b);
8774
+ }
8775
+ if (b === 0) {
8776
+ return Math.log(_a);
8777
+ }
8778
+ if (_a < 3e3 && _b < 3e3) {
8779
+ return Math.log(a * a + b * b) * 0.5;
8780
+ }
8781
+ a = a / 2;
8782
+ b = b / 2;
8783
+ return 0.5 * Math.log(a * a + b * b) + Math.LN2;
8784
+ }
8785
+ var parse = function(a, b) {
8786
+ var z = { "re": 0, "im": 0 };
8787
+ if (a === void 0 || a === null) {
8788
+ z["re"] = z["im"] = 0;
8789
+ } else if (b !== void 0) {
8790
+ z["re"] = a;
8791
+ z["im"] = b;
8792
+ } else
8793
+ switch (typeof a) {
8794
+ case "object":
8795
+ if ("im" in a && "re" in a) {
8796
+ z["re"] = a["re"];
8797
+ z["im"] = a["im"];
8798
+ } else if ("abs" in a && "arg" in a) {
8799
+ if (!Number.isFinite(a["abs"]) && Number.isFinite(a["arg"])) {
8800
+ return Complex["INFINITY"];
8801
+ }
8802
+ z["re"] = a["abs"] * Math.cos(a["arg"]);
8803
+ z["im"] = a["abs"] * Math.sin(a["arg"]);
8804
+ } else if ("r" in a && "phi" in a) {
8805
+ if (!Number.isFinite(a["r"]) && Number.isFinite(a["phi"])) {
8806
+ return Complex["INFINITY"];
8807
+ }
8808
+ z["re"] = a["r"] * Math.cos(a["phi"]);
8809
+ z["im"] = a["r"] * Math.sin(a["phi"]);
8810
+ } else if (a.length === 2) {
8811
+ z["re"] = a[0];
8812
+ z["im"] = a[1];
8813
+ } else {
8814
+ parser_exit();
8815
+ }
8816
+ break;
8817
+ case "string":
8818
+ z["im"] = /* void */
8819
+ z["re"] = 0;
8820
+ var tokens = a.match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g);
8821
+ var plus = 1;
8822
+ var minus = 0;
8823
+ if (tokens === null) {
8824
+ parser_exit();
8825
+ }
8826
+ for (var i = 0; i < tokens.length; i++) {
8827
+ var c = tokens[i];
8828
+ if (c === " " || c === " " || c === "\n") {
8829
+ } else if (c === "+") {
8830
+ plus++;
8831
+ } else if (c === "-") {
8832
+ minus++;
8833
+ } else if (c === "i" || c === "I") {
8834
+ if (plus + minus === 0) {
8835
+ parser_exit();
8836
+ }
8837
+ if (tokens[i + 1] !== " " && !isNaN(Number(tokens[i + 1]))) {
8838
+ z["im"] += parseFloat((minus % 2 ? "-" : "") + tokens[i + 1]);
8839
+ i++;
8840
+ } else {
8841
+ z["im"] += parseFloat((minus % 2 ? "-" : "") + "1");
8842
+ }
8843
+ plus = minus = 0;
8844
+ } else {
8845
+ if (plus + minus === 0 || isNaN(Number(c))) {
8846
+ parser_exit();
8847
+ }
8848
+ if (tokens[i + 1] === "i" || tokens[i + 1] === "I") {
8849
+ z["im"] += parseFloat((minus % 2 ? "-" : "") + c);
8850
+ i++;
8851
+ } else {
8852
+ z["re"] += parseFloat((minus % 2 ? "-" : "") + c);
8853
+ }
8854
+ plus = minus = 0;
8855
+ }
8856
+ }
8857
+ if (plus + minus > 0) {
8858
+ parser_exit();
8859
+ }
8860
+ break;
8861
+ case "number":
8862
+ z["im"] = 0;
8863
+ z["re"] = a;
8864
+ break;
8865
+ default:
8866
+ parser_exit();
8867
+ }
8868
+ if (isNaN(z["re"]) || isNaN(z["im"])) {
8869
+ }
8870
+ return z;
8871
+ };
8872
+ var Complex = class _Complex {
8873
+ constructor(a, b) {
8874
+ this.re = 0;
8875
+ this.im = 0;
8876
+ var z = parse(a, b);
8877
+ this["re"] = z["re"];
8878
+ this["im"] = z["im"];
8879
+ }
8880
+ /**
8881
+ * Calculates the sign of a complex number, which is a normalized complex
8882
+ *
8883
+ * @returns {Complex}
8884
+ */
8885
+ sign() {
8886
+ var abs = this["abs"]();
8887
+ return new _Complex(this["re"] / abs, this["im"] / abs);
8888
+ }
8889
+ /**
8890
+ * Adds two complex numbers
8891
+ *
8892
+ * @returns {Complex}
8893
+ */
8894
+ add(a, b) {
8895
+ var z = new _Complex(a, b);
8896
+ if (this["isInfinite"]() && z["isInfinite"]()) {
8897
+ return _Complex["NAN"];
8898
+ }
8899
+ if (this["isInfinite"]() || z["isInfinite"]()) {
8900
+ return _Complex["INFINITY"];
8901
+ }
8902
+ return new _Complex(this["re"] + z["re"], this["im"] + z["im"]);
8903
+ }
8904
+ /**
8905
+ * Subtracts two complex numbers
8906
+ *
8907
+ * @returns {Complex}
8908
+ */
8909
+ sub(a, b) {
8910
+ var z = new _Complex(a, b);
8911
+ if (this["isInfinite"]() && z["isInfinite"]()) {
8912
+ return _Complex["NAN"];
8913
+ }
8914
+ if (this["isInfinite"]() || z["isInfinite"]()) {
8915
+ return _Complex["INFINITY"];
8916
+ }
8917
+ return new _Complex(this["re"] - z["re"], this["im"] - z["im"]);
8918
+ }
8919
+ /**
8920
+ * Multiplies two complex numbers
8921
+ *
8922
+ * @returns {Complex}
8923
+ */
8924
+ mul(a, b) {
8925
+ var z = new _Complex(a, b);
8926
+ if (this["isInfinite"]() && z["isZero"]() || this["isZero"]() && z["isInfinite"]()) {
8927
+ return _Complex["NAN"];
8928
+ }
8929
+ if (this["isInfinite"]() || z["isInfinite"]()) {
8930
+ return _Complex["INFINITY"];
8931
+ }
8932
+ if (z["im"] === 0 && this["im"] === 0) {
8933
+ return new _Complex(this["re"] * z["re"], 0);
8934
+ }
8935
+ return new _Complex(this["re"] * z["re"] - this["im"] * z["im"], this["re"] * z["im"] + this["im"] * z["re"]);
8936
+ }
8937
+ /**
8938
+ * Divides two complex numbers
8939
+ *
8940
+ * @returns {Complex}
8941
+ */
8942
+ div(a, b) {
8943
+ var z = new _Complex(a, b);
8944
+ if (this["isZero"]() && z["isZero"]() || this["isInfinite"]() && z["isInfinite"]()) {
8945
+ return _Complex["NAN"];
8946
+ }
8947
+ if (this["isInfinite"]() || z["isZero"]()) {
8948
+ return _Complex["INFINITY"];
8949
+ }
8950
+ if (this["isZero"]() || z["isInfinite"]()) {
8951
+ return _Complex["ZERO"];
8952
+ }
8953
+ a = this["re"];
8954
+ b = this["im"];
8955
+ var c = z["re"];
8956
+ var d = z["im"];
8957
+ var t, x;
8958
+ if (0 === d) {
8959
+ return new _Complex(a / c, b / c);
8960
+ }
8961
+ if (Math.abs(c) < Math.abs(d)) {
8962
+ x = c / d;
8963
+ t = c * x + d;
8964
+ return new _Complex((a * x + b) / t, (b * x - a) / t);
8965
+ } else {
8966
+ x = d / c;
8967
+ t = d * x + c;
8968
+ return new _Complex((a + b * x) / t, (b - a * x) / t);
8969
+ }
8970
+ }
8971
+ /**
8972
+ * Calculate the power of two complex numbers
8973
+ *
8974
+ * @returns {Complex}
8975
+ */
8976
+ pow(a, b) {
8977
+ var z = new _Complex(a, b);
8978
+ a = this["re"];
8979
+ b = this["im"];
8980
+ if (z["isZero"]()) {
8981
+ return _Complex["ONE"];
8982
+ }
8983
+ if (z["im"] === 0) {
8984
+ if (b === 0 && a > 0) {
8985
+ return new _Complex(Math.pow(a, z["re"]), 0);
8986
+ } else if (a === 0) {
8987
+ switch ((z["re"] % 4 + 4) % 4) {
8988
+ case 0:
8989
+ return new _Complex(Math.pow(b, z["re"]), 0);
8990
+ case 1:
8991
+ return new _Complex(0, Math.pow(b, z["re"]));
8992
+ case 2:
8993
+ return new _Complex(-Math.pow(b, z["re"]), 0);
8994
+ case 3:
8995
+ return new _Complex(0, -Math.pow(b, z["re"]));
8996
+ }
8997
+ }
8998
+ }
8999
+ if (a === 0 && b === 0 && z["re"] > 0 && z["im"] >= 0) {
9000
+ return _Complex["ZERO"];
9001
+ }
9002
+ var arg = Math.atan2(b, a);
9003
+ var loh = logHypot(a, b);
9004
+ a = Math.exp(z["re"] * loh - z["im"] * arg);
9005
+ b = z["im"] * loh + z["re"] * arg;
9006
+ return new _Complex(a * Math.cos(b), a * Math.sin(b));
9007
+ }
9008
+ /**
9009
+ * Calculate the complex square root
9010
+ *
9011
+ * @returns {Complex}
9012
+ */
9013
+ sqrt() {
9014
+ var a = this["re"];
9015
+ var b = this["im"];
9016
+ var r = this["abs"]();
9017
+ var re, im;
9018
+ if (a >= 0) {
9019
+ if (b === 0) {
9020
+ return new _Complex(Math.sqrt(a), 0);
9021
+ }
9022
+ re = 0.5 * Math.sqrt(2 * (r + a));
9023
+ } else {
9024
+ re = Math.abs(b) / Math.sqrt(2 * (r - a));
9025
+ }
9026
+ if (a <= 0) {
9027
+ im = 0.5 * Math.sqrt(2 * (r - a));
9028
+ } else {
9029
+ im = Math.abs(b) / Math.sqrt(2 * (r + a));
9030
+ }
9031
+ return new _Complex(re, b < 0 ? -im : im);
9032
+ }
9033
+ /**
9034
+ * Calculate the complex exponent
9035
+ *
9036
+ * @returns {Complex}
9037
+ */
9038
+ exp() {
9039
+ var tmp = Math.exp(this["re"]);
9040
+ if (this["im"] === 0) {
9041
+ }
9042
+ return new _Complex(tmp * Math.cos(this["im"]), tmp * Math.sin(this["im"]));
9043
+ }
9044
+ /**
9045
+ * Calculate the complex exponent and subtracts one.
9046
+ *
9047
+ * This may be more accurate than `Complex(x).exp().sub(1)` if
9048
+ * `x` is small.
9049
+ *
9050
+ * @returns {Complex}
9051
+ */
9052
+ expm1() {
9053
+ var a = this["re"];
9054
+ var b = this["im"];
9055
+ return new _Complex(Math.expm1(a) * Math.cos(b) + cosm1(b), Math.exp(a) * Math.sin(b));
9056
+ }
9057
+ /**
9058
+ * Calculate the natural log
9059
+ *
9060
+ * @returns {Complex}
9061
+ */
9062
+ log() {
9063
+ var a = this["re"];
9064
+ var b = this["im"];
9065
+ if (b === 0 && a > 0) {
9066
+ }
9067
+ return new _Complex(logHypot(a, b), Math.atan2(b, a));
9068
+ }
9069
+ /**
9070
+ * Calculate the magnitude of the complex number
9071
+ *
9072
+ * @returns {number}
9073
+ */
9074
+ abs() {
9075
+ return hypot(this["re"], this["im"]);
9076
+ }
9077
+ /**
9078
+ * Calculate the angle of the complex number
9079
+ *
9080
+ * @returns {number}
9081
+ */
9082
+ arg() {
9083
+ return Math.atan2(this["im"], this["re"]);
9084
+ }
9085
+ /**
9086
+ * Calculate the sine of the complex number
9087
+ *
9088
+ * @returns {Complex}
9089
+ */
9090
+ sin() {
9091
+ var a = this["re"];
9092
+ var b = this["im"];
9093
+ return new _Complex(Math.sin(a) * cosh(b), Math.cos(a) * sinh(b));
9094
+ }
9095
+ /**
9096
+ * Calculate the cosine
9097
+ *
9098
+ * @returns {Complex}
9099
+ */
9100
+ cos() {
9101
+ var a = this["re"];
9102
+ var b = this["im"];
9103
+ return new _Complex(Math.cos(a) * cosh(b), -Math.sin(a) * sinh(b));
9104
+ }
9105
+ /**
9106
+ * Calculate the tangent
9107
+ *
9108
+ * @returns {Complex}
9109
+ */
9110
+ tan() {
9111
+ var a = 2 * this["re"];
9112
+ var b = 2 * this["im"];
9113
+ var d = Math.cos(a) + cosh(b);
9114
+ return new _Complex(Math.sin(a) / d, sinh(b) / d);
9115
+ }
9116
+ /**
9117
+ * Calculate the cotangent
9118
+ *
9119
+ * @returns {Complex}
9120
+ */
9121
+ cot() {
9122
+ var a = 2 * this["re"];
9123
+ var b = 2 * this["im"];
9124
+ var d = Math.cos(a) - cosh(b);
9125
+ return new _Complex(-Math.sin(a) / d, sinh(b) / d);
9126
+ }
9127
+ /**
9128
+ * Calculate the secant
9129
+ *
9130
+ * @returns {Complex}
9131
+ */
9132
+ sec() {
9133
+ var a = this["re"];
9134
+ var b = this["im"];
9135
+ var d = 0.5 * cosh(2 * b) + 0.5 * Math.cos(2 * a);
9136
+ return new _Complex(Math.cos(a) * cosh(b) / d, Math.sin(a) * sinh(b) / d);
9137
+ }
9138
+ /**
9139
+ * Calculate the cosecans
9140
+ *
9141
+ * @returns {Complex}
9142
+ */
9143
+ csc() {
9144
+ var a = this["re"];
9145
+ var b = this["im"];
9146
+ var d = 0.5 * cosh(2 * b) - 0.5 * Math.cos(2 * a);
9147
+ return new _Complex(Math.sin(a) * cosh(b) / d, -Math.cos(a) * sinh(b) / d);
9148
+ }
9149
+ /**
9150
+ * Calculate the complex arcus sinus
9151
+ *
9152
+ * @returns {Complex}
9153
+ */
9154
+ asin() {
9155
+ var a = this["re"];
9156
+ var b = this["im"];
9157
+ var t1 = new _Complex(b * b - a * a + 1, -2 * a * b)["sqrt"]();
9158
+ var t2 = new _Complex(t1["re"] - b, t1["im"] + a)["log"]();
9159
+ return new _Complex(t2["im"], -t2["re"]);
9160
+ }
9161
+ /**
9162
+ * Calculate the complex arcus cosinus
9163
+ *
9164
+ * @returns {Complex}
9165
+ */
9166
+ acos() {
9167
+ var a = this["re"];
9168
+ var b = this["im"];
9169
+ var t1 = new _Complex(b * b - a * a + 1, -2 * a * b)["sqrt"]();
9170
+ var t2 = new _Complex(t1["re"] - b, t1["im"] + a)["log"]();
9171
+ return new _Complex(Math.PI / 2 - t2["im"], t2["re"]);
9172
+ }
9173
+ /**
9174
+ * Calculate the complex arcus tangent
9175
+ *
9176
+ * @returns {Complex}
9177
+ */
9178
+ atan() {
9179
+ var a = this["re"];
9180
+ var b = this["im"];
9181
+ if (a === 0) {
9182
+ if (b === 1) {
9183
+ return new _Complex(0, Infinity);
9184
+ }
9185
+ if (b === -1) {
9186
+ return new _Complex(0, -Infinity);
9187
+ }
9188
+ }
9189
+ var d = a * a + (1 - b) * (1 - b);
9190
+ var t1 = new _Complex((1 - b * b - a * a) / d, -2 * a / d).log();
9191
+ return new _Complex(-0.5 * t1["im"], 0.5 * t1["re"]);
9192
+ }
9193
+ /**
9194
+ * Calculate the complex arcus cotangent
9195
+ *
9196
+ * @returns {Complex}
9197
+ */
9198
+ acot() {
9199
+ var a = this["re"];
9200
+ var b = this["im"];
9201
+ if (b === 0) {
9202
+ return new _Complex(Math.atan2(1, a), 0);
9203
+ }
9204
+ var d = a * a + b * b;
9205
+ return d !== 0 ? new _Complex(a / d, -b / d).atan() : new _Complex(a !== 0 ? a / 0 : 0, b !== 0 ? -b / 0 : 0).atan();
9206
+ }
9207
+ /**
9208
+ * Calculate the complex arcus secant
9209
+ *
9210
+ * @returns {Complex}
9211
+ */
9212
+ asec() {
9213
+ var a = this["re"];
9214
+ var b = this["im"];
9215
+ if (a === 0 && b === 0) {
9216
+ return new _Complex(0, Infinity);
9217
+ }
9218
+ var d = a * a + b * b;
9219
+ return d !== 0 ? new _Complex(a / d, -b / d).acos() : new _Complex(a !== 0 ? a / 0 : 0, b !== 0 ? -b / 0 : 0).acos();
9220
+ }
9221
+ /**
9222
+ * Calculate the complex arcus cosecans
9223
+ *
9224
+ * @returns {Complex}
9225
+ */
9226
+ acsc() {
9227
+ var a = this["re"];
9228
+ var b = this["im"];
9229
+ if (a === 0 && b === 0) {
9230
+ return new _Complex(Math.PI / 2, Infinity);
9231
+ }
9232
+ var d = a * a + b * b;
9233
+ return d !== 0 ? new _Complex(a / d, -b / d).asin() : new _Complex(a !== 0 ? a / 0 : 0, b !== 0 ? -b / 0 : 0).asin();
9234
+ }
9235
+ /**
9236
+ * Calculate the complex sinh
9237
+ *
9238
+ * @returns {Complex}
9239
+ */
9240
+ sinh() {
9241
+ var a = this["re"];
9242
+ var b = this["im"];
9243
+ return new _Complex(sinh(a) * Math.cos(b), cosh(a) * Math.sin(b));
9244
+ }
9245
+ /**
9246
+ * Calculate the complex cosh
9247
+ *
9248
+ * @returns {Complex}
9249
+ */
9250
+ cosh() {
9251
+ var a = this["re"];
9252
+ var b = this["im"];
9253
+ return new _Complex(cosh(a) * Math.cos(b), sinh(a) * Math.sin(b));
9254
+ }
9255
+ /**
9256
+ * Calculate the complex tanh
9257
+ *
9258
+ * @returns {Complex}
9259
+ */
9260
+ tanh() {
9261
+ var a = 2 * this["re"];
9262
+ var b = 2 * this["im"];
9263
+ var d = cosh(a) + Math.cos(b);
9264
+ return new _Complex(sinh(a) / d, Math.sin(b) / d);
9265
+ }
9266
+ /**
9267
+ * Calculate the complex coth
9268
+ *
9269
+ * @returns {Complex}
9270
+ */
9271
+ coth() {
9272
+ var a = 2 * this["re"];
9273
+ var b = 2 * this["im"];
9274
+ var d = cosh(a) - Math.cos(b);
9275
+ return new _Complex(sinh(a) / d, -Math.sin(b) / d);
9276
+ }
9277
+ /**
9278
+ * Calculate the complex coth
9279
+ *
9280
+ * @returns {Complex}
9281
+ */
9282
+ csch() {
9283
+ var a = this["re"];
9284
+ var b = this["im"];
9285
+ var d = Math.cos(2 * b) - cosh(2 * a);
9286
+ return new _Complex(-2 * sinh(a) * Math.cos(b) / d, 2 * cosh(a) * Math.sin(b) / d);
9287
+ }
9288
+ /**
9289
+ * Calculate the complex sech
9290
+ *
9291
+ * @returns {Complex}
9292
+ */
9293
+ sech() {
9294
+ var a = this["re"];
9295
+ var b = this["im"];
9296
+ var d = Math.cos(2 * b) + cosh(2 * a);
9297
+ return new _Complex(2 * cosh(a) * Math.cos(b) / d, -2 * sinh(a) * Math.sin(b) / d);
9298
+ }
9299
+ /**
9300
+ * Calculate the complex asinh
9301
+ *
9302
+ * @returns {Complex}
9303
+ */
9304
+ asinh() {
9305
+ var tmp = this["im"];
9306
+ this["im"] = -this["re"];
9307
+ this["re"] = tmp;
9308
+ var res = this["asin"]();
9309
+ this["re"] = -this["im"];
9310
+ this["im"] = tmp;
9311
+ tmp = res["re"];
9312
+ res["re"] = -res["im"];
9313
+ res["im"] = tmp;
9314
+ return res;
9315
+ }
9316
+ /**
9317
+ * Calculate the complex acosh
9318
+ *
9319
+ * @returns {Complex}
9320
+ */
9321
+ acosh() {
9322
+ var res = this["acos"]();
9323
+ if (res["im"] <= 0) {
9324
+ var tmp = res["re"];
9325
+ res["re"] = -res["im"];
9326
+ res["im"] = tmp;
9327
+ } else {
9328
+ var tmp = res["im"];
9329
+ res["im"] = -res["re"];
9330
+ res["re"] = tmp;
9331
+ }
9332
+ return res;
9333
+ }
9334
+ /**
9335
+ * Calculate the complex atanh
9336
+ *
9337
+ * @returns {Complex}
9338
+ */
9339
+ atanh() {
9340
+ var a = this["re"];
9341
+ var b = this["im"];
9342
+ var noIM = a > 1 && b === 0;
9343
+ var oneMinus = 1 - a;
9344
+ var onePlus = 1 + a;
9345
+ var d = oneMinus * oneMinus + b * b;
9346
+ var x = d !== 0 ? new _Complex((onePlus * oneMinus - b * b) / d, (b * oneMinus + onePlus * b) / d) : new _Complex(a !== -1 ? a / 0 : 0, b !== 0 ? b / 0 : 0);
9347
+ var temp = x["re"];
9348
+ x["re"] = logHypot(x["re"], x["im"]) / 2;
9349
+ x["im"] = Math.atan2(x["im"], temp) / 2;
9350
+ if (noIM) {
9351
+ x["im"] = -x["im"];
9352
+ }
9353
+ return x;
9354
+ }
9355
+ /**
9356
+ * Calculate the complex acoth
9357
+ *
9358
+ * @returns {Complex}
9359
+ */
9360
+ acoth() {
9361
+ var a = this["re"];
9362
+ var b = this["im"];
9363
+ if (a === 0 && b === 0) {
9364
+ return new _Complex(0, Math.PI / 2);
9365
+ }
9366
+ var d = a * a + b * b;
9367
+ return d !== 0 ? new _Complex(a / d, -b / d).atanh() : new _Complex(a !== 0 ? a / 0 : 0, b !== 0 ? -b / 0 : 0).atanh();
9368
+ }
9369
+ /**
9370
+ * Calculate the complex acsch
9371
+ *
9372
+ * @returns {Complex}
9373
+ */
9374
+ acsch() {
9375
+ var a = this["re"];
9376
+ var b = this["im"];
9377
+ if (b === 0) {
9378
+ return new _Complex(a !== 0 ? Math.log(a + Math.sqrt(a * a + 1)) : Infinity, 0);
9379
+ }
9380
+ var d = a * a + b * b;
9381
+ return d !== 0 ? new _Complex(a / d, -b / d).asinh() : new _Complex(a !== 0 ? a / 0 : 0, b !== 0 ? -b / 0 : 0).asinh();
9382
+ }
9383
+ /**
9384
+ * Calculate the complex asech
9385
+ *
9386
+ * @returns {Complex}
9387
+ */
9388
+ asech() {
9389
+ var a = this["re"];
9390
+ var b = this["im"];
9391
+ if (this["isZero"]()) {
9392
+ return _Complex["INFINITY"];
9393
+ }
9394
+ var d = a * a + b * b;
9395
+ return d !== 0 ? new _Complex(a / d, -b / d).acosh() : new _Complex(a !== 0 ? a / 0 : 0, b !== 0 ? -b / 0 : 0).acosh();
9396
+ }
9397
+ /**
9398
+ * Calculate the complex inverse 1/z
9399
+ *
9400
+ * @returns {Complex}
9401
+ */
9402
+ inverse() {
9403
+ if (this["isZero"]()) {
9404
+ return _Complex["INFINITY"];
9405
+ }
9406
+ if (this["isInfinite"]()) {
9407
+ return _Complex["ZERO"];
9408
+ }
9409
+ var a = this["re"];
9410
+ var b = this["im"];
9411
+ var d = a * a + b * b;
9412
+ return new _Complex(a / d, -b / d);
9413
+ }
9414
+ /**
9415
+ * Returns the complex conjugate
9416
+ *
9417
+ * @returns {Complex}
9418
+ */
9419
+ conjugate() {
9420
+ return new _Complex(this["re"], -this["im"]);
9421
+ }
9422
+ /**
9423
+ * Gets the negated complex number
9424
+ *
9425
+ * @returns {Complex}
9426
+ */
9427
+ neg() {
9428
+ return new _Complex(-this["re"], -this["im"]);
9429
+ }
9430
+ /**
9431
+ * Ceils the actual complex number
9432
+ *
9433
+ * @returns {Complex}
9434
+ */
9435
+ ceil(places) {
9436
+ places = Math.pow(10, places || 0);
9437
+ return new _Complex(Math.ceil(this["re"] * places) / places, Math.ceil(this["im"] * places) / places);
9438
+ }
9439
+ /**
9440
+ * Floors the actual complex number
9441
+ *
9442
+ * @returns {Complex}
9443
+ */
9444
+ floor(places) {
9445
+ places = Math.pow(10, places || 0);
9446
+ return new _Complex(Math.floor(this["re"] * places) / places, Math.floor(this["im"] * places) / places);
9447
+ }
9448
+ /**
9449
+ * Ceils the actual complex number
9450
+ *
9451
+ * @returns {Complex}
9452
+ */
9453
+ round(places) {
9454
+ places = Math.pow(10, places || 0);
9455
+ return new _Complex(Math.round(this["re"] * places) / places, Math.round(this["im"] * places) / places);
9456
+ }
9457
+ /**
9458
+ * Compares two complex numbers
9459
+ *
9460
+ * **Note:** new Complex(Infinity).equals(Infinity) === false
9461
+ *
9462
+ * @returns {boolean}
9463
+ */
9464
+ equals(a, b) {
9465
+ var z = new _Complex(a, b);
9466
+ return Math.abs(z["re"] - this["re"]) <= _Complex["EPSILON"] && Math.abs(z["im"] - this["im"]) <= _Complex["EPSILON"];
9467
+ }
9468
+ /**
9469
+ * Clones the actual object
9470
+ *
9471
+ * @returns {Complex}
9472
+ */
9473
+ clone() {
9474
+ return new _Complex(this["re"], this["im"]);
9475
+ }
9476
+ /**
9477
+ * Gets a string of the actual complex number
9478
+ *
9479
+ * @returns {string}
9480
+ */
9481
+ toString() {
9482
+ var a = this["re"];
9483
+ var b = this["im"];
9484
+ var ret = "";
9485
+ if (this["isNaN"]()) {
9486
+ return "NaN";
9487
+ }
9488
+ if (this["isInfinite"]()) {
9489
+ return "Infinity";
9490
+ }
9491
+ if (Math.abs(a) < _Complex["EPSILON"]) {
9492
+ a = 0;
9493
+ }
9494
+ if (Math.abs(b) < _Complex["EPSILON"]) {
9495
+ b = 0;
9496
+ }
9497
+ if (b === 0) {
9498
+ return ret + a;
9499
+ }
9500
+ if (a !== 0) {
9501
+ ret += a;
9502
+ ret += " ";
9503
+ if (b < 0) {
9504
+ b = -b;
9505
+ ret += "-";
9506
+ } else {
9507
+ ret += "+";
9508
+ }
9509
+ ret += " ";
9510
+ } else if (b < 0) {
9511
+ b = -b;
9512
+ ret += "-";
9513
+ }
9514
+ if (1 !== b) {
9515
+ ret += b;
9516
+ }
9517
+ return ret + "i";
9518
+ }
9519
+ /**
9520
+ * Returns the actual number as a vector
9521
+ *
9522
+ * @returns {Array}
9523
+ */
9524
+ toVector() {
9525
+ return [this["re"], this["im"]];
9526
+ }
9527
+ /**
9528
+ * Returns the actual real value of the current object
9529
+ *
9530
+ * @returns {number|null}
9531
+ */
9532
+ valueOf() {
9533
+ if (this["im"] === 0) {
9534
+ return this["re"];
9535
+ }
9536
+ return null;
9537
+ }
9538
+ /**
9539
+ * Determines whether a complex number is not on the Riemann sphere.
9540
+ *
9541
+ * @returns {boolean}
9542
+ */
9543
+ isNaN() {
9544
+ return isNaN(this["re"]) || isNaN(this["im"]);
9545
+ }
9546
+ /**
9547
+ * Determines whether or not a complex number is at the zero pole of the
9548
+ * Riemann sphere.
9549
+ *
9550
+ * @returns {boolean}
9551
+ */
9552
+ isZero() {
9553
+ return this["im"] === 0 && this["re"] === 0;
9554
+ }
9555
+ /**
9556
+ * Determines whether a complex number is not at the infinity pole of the
9557
+ * Riemann sphere.
9558
+ *
9559
+ * @returns {boolean}
9560
+ */
9561
+ isFinite() {
9562
+ return isFinite(this["re"]) && isFinite(this["im"]);
9563
+ }
9564
+ /**
9565
+ * Determines whether or not a complex number is at the infinity pole of the
9566
+ * Riemann sphere.
9567
+ *
9568
+ * @returns {boolean}
9569
+ */
9570
+ isInfinite() {
9571
+ return !(this["isNaN"]() || this["isFinite"]());
9572
+ }
9573
+ };
9574
+ Complex["ZERO"] = new Complex(0, 0);
9575
+ Complex["ONE"] = new Complex(1, 0);
9576
+ Complex["I"] = new Complex(0, 1);
9577
+ Complex["PI"] = new Complex(Math.PI, 0);
9578
+ Complex["E"] = new Complex(Math.E, 0);
9579
+ Complex["INFINITY"] = new Complex(Infinity, Infinity);
9580
+ Complex["NAN"] = new Complex(NaN, NaN);
9581
+ Complex["EPSILON"] = 1e-15;
9582
+
8504
9583
  // src/compute-engine/numerics/numeric-complex.ts
9584
+ var LANCZOS_G = 7;
9585
+ var LANCZOS_P = [
9586
+ 0.9999999999998099,
9587
+ 676.5203681218851,
9588
+ -1259.1392167224028,
9589
+ 771.3234287776531,
9590
+ -176.6150291621406,
9591
+ 12.507343278686905,
9592
+ -0.13857109526572012,
9593
+ 9984369578019572e-21,
9594
+ 15056327351493116e-23
9595
+ ];
9596
+ var SQRT_2PI = Math.sqrt(2 * Math.PI);
9597
+ var HALF_LOG_2PI = 0.5 * Math.log(2 * Math.PI);
8505
9598
  function gamma2(c) {
8506
- return c;
9599
+ if (c.re < 0.5) {
9600
+ const sinPiZ = c.mul(Math.PI).sin();
9601
+ return new Complex(Math.PI, 0).div(sinPiZ.mul(gamma2(new Complex(1, 0).sub(c))));
9602
+ }
9603
+ const z = c.sub(1);
9604
+ let x = new Complex(LANCZOS_P[0], 0);
9605
+ for (let i = 1; i < LANCZOS_G + 2; i++)
9606
+ x = x.add(new Complex(LANCZOS_P[i], 0).div(z.add(i)));
9607
+ const t = z.add(LANCZOS_G + 0.5);
9608
+ return new Complex(SQRT_2PI, 0).mul(t.pow(z.add(0.5))).mul(t.neg().exp()).mul(x);
8507
9609
  }
8508
9610
  function gammaln2(c) {
8509
- return c;
9611
+ if (c.re < 0.5) {
9612
+ const sinPiZ = c.mul(Math.PI).sin();
9613
+ return new Complex(Math.PI, 0).div(sinPiZ).log().sub(gammaln2(new Complex(1, 0).sub(c)));
9614
+ }
9615
+ const z = c.sub(1);
9616
+ let x = new Complex(LANCZOS_P[0], 0);
9617
+ for (let i = 1; i < LANCZOS_G + 2; i++)
9618
+ x = x.add(new Complex(LANCZOS_P[i], 0).div(z.add(i)));
9619
+ const t = z.add(LANCZOS_G + 0.5);
9620
+ return new Complex(HALF_LOG_2PI, 0).add(z.add(0.5).mul(t.log())).sub(t).add(x.log());
8510
9621
  }
8511
9622
 
8512
9623
  // src/numerics.ts
8513
- var version = "0.58.0";
9624
+ var version = "0.59.0";
8514
9625
  export {
8515
9626
  BigNumericValue,
8516
9627
  DEFAULT_PRECISION,
@@ -8653,3 +9764,13 @@ export {
8653
9764
  version,
8654
9765
  zeta
8655
9766
  };
9767
+ /*! Bundled license information:
9768
+
9769
+ complex-esm/dist/src/complex.js:
9770
+ (**
9771
+ * @license Complex.js v2.1.1 12/05/2020
9772
+ *
9773
+ * Copyright (c) 2020, Robert Eisele (robert@xarg.org)
9774
+ * Dual licensed under the MIT or GPL Version 2 licenses.
9775
+ **)
9776
+ */