@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
- /** Numerics 0.58.0 */
1
+ /** Numerics 0.59.0 */
2
2
  (function(global,factory){typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'],factory):(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Numerics = {}));})(this, (function (exports) { 'use strict';
3
3
  var Numerics = (() => {
4
4
  var __defProp = Object.defineProperty;
@@ -317,6 +317,7 @@ var Numerics = (() => {
317
317
  return sum;
318
318
  }
319
319
  function fpln(x, scale) {
320
+ if (x <= 0n) throw new RangeError("fpln: input must be positive");
320
321
  if (x === scale) return 0n;
321
322
  const xNum = Number(x);
322
323
  const scaleNum = Number(scale);
@@ -966,9 +967,11 @@ var Numerics = (() => {
966
967
  if (Number.isFinite(thisExp) && Number.isFinite(otherExp)) {
967
968
  if (other.significand === 0n) return _BigDecimal.NAN;
968
969
  if (this.significand === 0n) return fromRaw(0n, 0);
969
- return this.sub(this.div(other).trunc().mul(other)).toPrecision(
970
- _BigDecimal.precision
971
- );
970
+ const ediff = thisExp - otherExp;
971
+ const num = ediff >= 0 ? this.significand * pow10(ediff) : this.significand;
972
+ const den = ediff >= 0 ? other.significand : other.significand * pow10(-ediff);
973
+ const q = num / den;
974
+ return this.sub(fromRaw(q, 0).mul(other));
972
975
  }
973
976
  if (thisExp !== thisExp || otherExp !== otherExp) return _BigDecimal.NAN;
974
977
  if (!Number.isFinite(thisExp)) return _BigDecimal.NAN;
@@ -1013,7 +1016,10 @@ var Numerics = (() => {
1013
1016
  return this.pow(n.neg()).inv();
1014
1017
  }
1015
1018
  const absSig = this.significand < 0n ? -this.significand : this.significand;
1016
- const thisLog10 = bigintDigits(absSig) + this.exponent;
1019
+ const sigDigits = bigintDigits(absSig);
1020
+ const dropped = sigDigits > 15 ? sigDigits - 15 : 0;
1021
+ const lead = dropped > 0 ? Number(absSig / 10n ** BigInt(dropped)) : Number(absSig);
1022
+ const thisLog10 = Math.log10(lead) + dropped + this.exponent;
1017
1023
  const resultLog10 = Number(expValue) * thisLog10;
1018
1024
  if (resultLog10 > 9e15) {
1019
1025
  return this.significand < 0n && expValue % 2n !== 0n ? _BigDecimal.NEGATIVE_INFINITY : _BigDecimal.POSITIVE_INFINITY;
@@ -1046,7 +1052,19 @@ var Numerics = (() => {
1046
1052
  return _BigDecimal.POSITIVE_INFINITY;
1047
1053
  }
1048
1054
  if (this.significand < 0n) return _BigDecimal.NAN;
1049
- return n.mul(this.ln()).exp();
1055
+ const baseSig = this.significand;
1056
+ const decExpBase = this.exponent + bigintDigits(baseSig) - 1;
1057
+ const nSig = n.significand < 0n ? -n.significand : n.significand;
1058
+ const decExpN = n.exponent + bigintDigits(nSig) - 1;
1059
+ const argMag = decExpN + Math.log10(Math.abs(decExpBase) * 2.303 + 3) + 1;
1060
+ const extra = Math.min(20, Math.max(2, Math.ceil(argMag) + 2));
1061
+ const savedPrec = _BigDecimal.precision;
1062
+ _BigDecimal.precision = savedPrec + extra;
1063
+ try {
1064
+ return n.mul(this.ln()).exp().toPrecision(savedPrec);
1065
+ } finally {
1066
+ _BigDecimal.precision = savedPrec;
1067
+ }
1050
1068
  }
1051
1069
  // ---------- Conversion methods ----------
1052
1070
  /** Convert to a JavaScript number. May lose precision for large values. */
@@ -1287,6 +1305,20 @@ var Numerics = (() => {
1287
1305
  const sig = negative ? -absFp : absFp;
1288
1306
  return fromRaw(sig, resultExp);
1289
1307
  }
1308
+ function decimalExponent(x) {
1309
+ const sig = x.significand < 0n ? -x.significand : x.significand;
1310
+ return x.exponent + bigintDigits(sig) - 1;
1311
+ }
1312
+ var MAX_SAFE_EXPONENT = BigInt(Number.MAX_SAFE_INTEGER);
1313
+ var _ln10Fp = null;
1314
+ var _ln10Scale = null;
1315
+ function ln10Fixed(scale) {
1316
+ if (_ln10Scale !== scale) {
1317
+ _ln10Fp = fpln(10n * scale, scale);
1318
+ _ln10Scale = scale;
1319
+ }
1320
+ return _ln10Fp;
1321
+ }
1290
1322
  BigDecimal.prototype.sqrt = function() {
1291
1323
  if (this.isNaN()) return BigDecimal.NAN;
1292
1324
  if (this.isZero()) return BigDecimal.ZERO;
@@ -1297,9 +1329,13 @@ var Numerics = (() => {
1297
1329
  if (this.significand < 0n) return BigDecimal.NAN;
1298
1330
  const targetPrec = BigDecimal.precision;
1299
1331
  const workingPrec = targetPrec + 10;
1300
- const [fp, scale] = toFixedPoint(this, workingPrec);
1332
+ const e = decimalExponent(this);
1333
+ const k = Math.floor(e / 2);
1334
+ const m = fromRaw(this.significand, this.exponent - 2 * k);
1335
+ const [fp, scale] = toFixedPoint(m, workingPrec);
1301
1336
  const sqrtFp = fpsqrt(fp, scale);
1302
- return fromFixedPoint(sqrtFp, scale, targetPrec);
1337
+ const root = fromFixedPoint(sqrtFp, scale, targetPrec);
1338
+ return fromRaw(root.significand, root.exponent + k);
1303
1339
  };
1304
1340
  BigDecimal.prototype.cbrt = function() {
1305
1341
  if (this.isNaN()) return BigDecimal.NAN;
@@ -1313,10 +1349,13 @@ var Numerics = (() => {
1313
1349
  }
1314
1350
  const targetPrec = BigDecimal.precision;
1315
1351
  const workingPrec = targetPrec + 10;
1316
- const [fp, scale] = toFixedPoint(this, workingPrec);
1352
+ const e = decimalExponent(this);
1353
+ const k = Math.floor(e / 3);
1354
+ const m = fromRaw(this.significand, this.exponent - 3 * k);
1355
+ const [fp, scale] = toFixedPoint(m, workingPrec);
1317
1356
  const C = fp * scale * scale;
1318
1357
  let x;
1319
- const numVal = this.toNumber();
1358
+ const numVal = m.toNumber();
1320
1359
  const scaleNum = Number(scale);
1321
1360
  if (Number.isFinite(numVal) && numVal > 0 && Number.isFinite(scaleNum)) {
1322
1361
  const approx = Math.cbrt(numVal);
@@ -1345,7 +1384,8 @@ var Numerics = (() => {
1345
1384
  const diffNext = bigintAbs(next * next * next - C);
1346
1385
  if (diffNext < diffX) x = next;
1347
1386
  }
1348
- return fromFixedPoint(x, scale, targetPrec);
1387
+ const root = fromFixedPoint(x, scale, targetPrec);
1388
+ return fromRaw(root.significand, root.exponent + k);
1349
1389
  };
1350
1390
  BigDecimal.sqrt = function(x) {
1351
1391
  return x.sqrt();
@@ -1360,11 +1400,27 @@ var Numerics = (() => {
1360
1400
  return BigDecimal.ZERO;
1361
1401
  }
1362
1402
  if (this.isZero()) return BigDecimal.ONE;
1403
+ if (decimalExponent(this) >= 17)
1404
+ return this.significand > 0n ? BigDecimal.POSITIVE_INFINITY : BigDecimal.ZERO;
1363
1405
  const targetPrec = BigDecimal.precision;
1364
- const workingPrec = targetPrec + 15;
1365
- const [fp, scale] = toFixedPoint(this, workingPrec);
1366
- const expFp = fpexp(fp, scale);
1367
- return fromFixedPoint(expFp, scale, targetPrec);
1406
+ const absSig = this.significand < 0n ? -this.significand : this.significand;
1407
+ const magnitude = Math.max(0, this.exponent + bigintDigits(absSig));
1408
+ const workingPrec = targetPrec + 20 + magnitude;
1409
+ const [xFp, scale] = toFixedPoint(this, workingPrec);
1410
+ const l10 = ln10Fixed(scale);
1411
+ let k = xFp / l10;
1412
+ let rFp = xFp - k * l10;
1413
+ if (rFp < 0n) {
1414
+ k -= 1n;
1415
+ rFp += l10;
1416
+ }
1417
+ if (k > MAX_SAFE_EXPONENT || k < -MAX_SAFE_EXPONENT)
1418
+ return k > 0n ? BigDecimal.POSITIVE_INFINITY : BigDecimal.ZERO;
1419
+ const expR = fromFixedPoint(fpexp(rFp, scale), scale, targetPrec);
1420
+ const newExp = expR.exponent + Number(k);
1421
+ if (!Number.isSafeInteger(newExp))
1422
+ return k > 0n ? BigDecimal.POSITIVE_INFINITY : BigDecimal.ZERO;
1423
+ return fromRaw(expR.significand, newExp);
1368
1424
  };
1369
1425
  BigDecimal.prototype.ln = function() {
1370
1426
  if (this.isNaN()) return BigDecimal.NAN;
@@ -1376,10 +1432,16 @@ var Numerics = (() => {
1376
1432
  if (this.significand < 0n) return BigDecimal.NAN;
1377
1433
  if (this.eq(1)) return BigDecimal.ZERO;
1378
1434
  const targetPrec = BigDecimal.precision;
1379
- const workingPrec = targetPrec + 15;
1380
- const [fp, scale] = toFixedPoint(this, workingPrec);
1381
- const lnFp = fpln(fp, scale);
1382
- return fromFixedPoint(lnFp, scale, targetPrec);
1435
+ const sig = this.significand;
1436
+ const digits = bigintDigits(sig);
1437
+ const e = this.exponent + digits - 1;
1438
+ const m = fromRaw(sig, -(digits - 1));
1439
+ const eDigits = Math.abs(e).toString().length;
1440
+ const workingPrec = targetPrec + 20 + eDigits;
1441
+ const [mFp, scale] = toFixedPoint(m, workingPrec);
1442
+ const l10 = ln10Fixed(scale);
1443
+ const resultFp = fpln(mFp, scale) + BigInt(e) * l10;
1444
+ return fromFixedPoint(resultFp, scale, targetPrec);
1383
1445
  };
1384
1446
  BigDecimal.prototype.log = function(base) {
1385
1447
  const b = base instanceof BigDecimal ? base : new BigDecimal(base);
@@ -1399,7 +1461,10 @@ var Numerics = (() => {
1399
1461
  if (!this.isFinite()) return BigDecimal.NAN;
1400
1462
  if (this.isZero()) return BigDecimal.ZERO;
1401
1463
  const targetPrec = BigDecimal.precision;
1402
- const workingPrec = targetPrec + 15;
1464
+ const e = decimalExponent(this);
1465
+ if (e < 0 && -2 * e >= targetPrec + 4) return this.toPrecision(targetPrec);
1466
+ const workingPrec = targetPrec + 15 + (e < 0 ? -e : 0);
1467
+ if (e > PI_DIGITS.length - workingPrec - 30) return BigDecimal.NAN;
1403
1468
  const [fp, scale] = toFixedPoint(this, workingPrec);
1404
1469
  const [sinFp] = fpsincos(fp, scale);
1405
1470
  return fromFixedPoint(sinFp, scale, targetPrec);
@@ -1410,6 +1475,8 @@ var Numerics = (() => {
1410
1475
  if (this.isZero()) return BigDecimal.ONE;
1411
1476
  const targetPrec = BigDecimal.precision;
1412
1477
  const workingPrec = targetPrec + 15;
1478
+ const e = decimalExponent(this);
1479
+ if (e > PI_DIGITS.length - workingPrec - 30) return BigDecimal.NAN;
1413
1480
  const [fp, scale] = toFixedPoint(this, workingPrec);
1414
1481
  const [, cosFp] = fpsincos(fp, scale);
1415
1482
  return fromFixedPoint(cosFp, scale, targetPrec);
@@ -1419,7 +1486,10 @@ var Numerics = (() => {
1419
1486
  if (!this.isFinite()) return BigDecimal.NAN;
1420
1487
  if (this.isZero()) return BigDecimal.ZERO;
1421
1488
  const targetPrec = BigDecimal.precision;
1422
- const workingPrec = targetPrec + 15;
1489
+ const e = decimalExponent(this);
1490
+ if (e < 0 && -2 * e >= targetPrec + 4) return this.toPrecision(targetPrec);
1491
+ const workingPrec = targetPrec + 15 + (e < 0 ? -e : 0);
1492
+ if (e > PI_DIGITS.length - workingPrec - 30) return BigDecimal.NAN;
1423
1493
  const [fp, scale] = toFixedPoint(this, workingPrec);
1424
1494
  const [sinFp, cosFp] = fpsincos(fp, scale);
1425
1495
  if (cosFp === 0n) {
@@ -1437,7 +1507,9 @@ var Numerics = (() => {
1437
1507
  return piHalf.neg();
1438
1508
  }
1439
1509
  const targetPrec = BigDecimal.precision;
1440
- const workingPrec = targetPrec + 15;
1510
+ const e = decimalExponent(this);
1511
+ if (e < 0 && -2 * e >= targetPrec + 4) return this.toPrecision(targetPrec);
1512
+ const workingPrec = targetPrec + 15 + (e < 0 ? -e : 0);
1441
1513
  const [fp, scale] = toFixedPoint(this, workingPrec);
1442
1514
  const atanFp = fpatan(fp, scale);
1443
1515
  return fromFixedPoint(atanFp, scale, targetPrec);
@@ -1454,7 +1526,9 @@ var Numerics = (() => {
1454
1526
  return this.significand > 0n ? piHalf : piHalf.neg();
1455
1527
  }
1456
1528
  const targetPrec = BigDecimal.precision;
1457
- const workingPrec = targetPrec + 20;
1529
+ const e = decimalExponent(this);
1530
+ if (e < 0 && -2 * e >= targetPrec + 4) return this.toPrecision(targetPrec);
1531
+ const workingPrec = targetPrec + 20 + (e < 0 ? -e : 0);
1458
1532
  const [xFp, scale] = toFixedPoint(this, workingPrec);
1459
1533
  const x2 = fpmul(xFp, xFp, scale);
1460
1534
  const oneMinusX2 = scale - x2;
@@ -1517,6 +1591,23 @@ var Numerics = (() => {
1517
1591
  if (this.significand > 0n) return BigDecimal.POSITIVE_INFINITY;
1518
1592
  return BigDecimal.NEGATIVE_INFINITY;
1519
1593
  }
1594
+ const targetPrec = BigDecimal.precision;
1595
+ const e = decimalExponent(this);
1596
+ if (e < 0) {
1597
+ if (-2 * e >= targetPrec + 4) return this.toPrecision(targetPrec);
1598
+ const saved = BigDecimal.precision;
1599
+ BigDecimal.precision = targetPrec - e + 5;
1600
+ try {
1601
+ const expX2 = this.exp();
1602
+ return expX2.sub(expX2.inv()).div(BigDecimal.TWO).toPrecision(targetPrec);
1603
+ } finally {
1604
+ BigDecimal.precision = saved;
1605
+ }
1606
+ }
1607
+ if (Math.abs(this.toNumber()) > 1.16 * (targetPrec + 3)) {
1608
+ const h = this.abs().exp().div(BigDecimal.TWO);
1609
+ return this.significand > 0n ? h : h.neg();
1610
+ }
1520
1611
  const expX = this.exp();
1521
1612
  const expNegX = expX.inv();
1522
1613
  return expX.sub(expNegX).div(BigDecimal.TWO);
@@ -1527,6 +1618,9 @@ var Numerics = (() => {
1527
1618
  if (!this.isFinite()) {
1528
1619
  return BigDecimal.POSITIVE_INFINITY;
1529
1620
  }
1621
+ const targetPrec = BigDecimal.precision;
1622
+ if (Math.abs(this.toNumber()) > 1.16 * (targetPrec + 3))
1623
+ return this.abs().exp().div(BigDecimal.TWO);
1530
1624
  const expX = this.exp();
1531
1625
  const expNegX = expX.inv();
1532
1626
  return expX.add(expNegX).div(BigDecimal.TWO);
@@ -1538,6 +1632,21 @@ var Numerics = (() => {
1538
1632
  if (this.significand > 0n) return BigDecimal.ONE;
1539
1633
  return BigDecimal.NEGATIVE_ONE;
1540
1634
  }
1635
+ const targetPrec = BigDecimal.precision;
1636
+ const e = decimalExponent(this);
1637
+ if (e < 0) {
1638
+ if (-2 * e >= targetPrec + 4) return this.toPrecision(targetPrec);
1639
+ const saved = BigDecimal.precision;
1640
+ BigDecimal.precision = targetPrec - e + 5;
1641
+ try {
1642
+ const exp2x2 = this.mul(BigDecimal.TWO).exp();
1643
+ return exp2x2.sub(BigDecimal.ONE).div(exp2x2.add(BigDecimal.ONE)).toPrecision(targetPrec);
1644
+ } finally {
1645
+ BigDecimal.precision = saved;
1646
+ }
1647
+ }
1648
+ if (Math.abs(this.toNumber()) > 1.16 * (targetPrec + 3))
1649
+ return this.significand > 0n ? BigDecimal.ONE : BigDecimal.NEGATIVE_ONE;
1541
1650
  const exp2x = this.mul(BigDecimal.TWO).exp();
1542
1651
  return exp2x.sub(BigDecimal.ONE).div(exp2x.add(BigDecimal.ONE));
1543
1652
  };
@@ -1624,9 +1733,7 @@ var Numerics = (() => {
1624
1733
  if (typeof a === "bigint") return a;
1625
1734
  if (typeof a === "number") {
1626
1735
  if (!Number.isInteger(a)) return null;
1627
- if (a >= Number.MAX_SAFE_INTEGER && a <= Number.MAX_SAFE_INTEGER)
1628
- return BigInt(a);
1629
- return bigint(a.toString());
1736
+ return BigInt(a);
1630
1737
  }
1631
1738
  if (a instanceof BigDecimal) {
1632
1739
  if (!a.isInteger()) return null;
@@ -2907,7 +3014,8 @@ var Numerics = (() => {
2907
3014
  [1, 5],
2908
3015
  [1, 6],
2909
3016
  [1, 7],
2910
- [1, 8],
3017
+ [2, 2],
3018
+ // √8 = 2√2
2911
3019
  [3, 1],
2912
3020
  [1, 10],
2913
3021
  [1, 11],
@@ -2919,7 +3027,8 @@ var Numerics = (() => {
2919
3027
  [1, 17],
2920
3028
  [3, 2],
2921
3029
  [1, 19],
2922
- [1, 20]
3030
+ [2, 5]
3031
+ // √20 = 2√5
2923
3032
  ][n];
2924
3033
  if (result) return result;
2925
3034
  }
@@ -2944,7 +3053,8 @@ var Numerics = (() => {
2944
3053
  }
2945
3054
  function lcm(a, b) {
2946
3055
  if (a === 0 || b === 0) return 0;
2947
- const res = BigInt(a) * BigInt(b) / BigInt(gcd(a, b));
3056
+ let res = BigInt(a) * BigInt(b) / BigInt(gcd(a, b));
3057
+ if (res < 0n) res = -res;
2948
3058
  return Number(res);
2949
3059
  }
2950
3060
  function factorial(n) {
@@ -3499,12 +3609,23 @@ var Numerics = (() => {
3499
3609
  "error",
3500
3610
  ...EXPRESSION_TYPES
3501
3611
  ];
3612
+ var NUMERIC_TYPES_SET = new Set(
3613
+ NUMERIC_TYPES
3614
+ );
3615
+ var COLLECTION_TYPES_SET = new Set(
3616
+ COLLECTION_TYPES
3617
+ );
3618
+ var SCALAR_TYPES_SET = new Set(
3619
+ SCALAR_TYPES
3620
+ );
3621
+ var PRIMITIVE_TYPES_SET = new Set(
3622
+ PRIMITIVE_TYPES
3623
+ );
3502
3624
  function isValidType(t) {
3503
- if (typeof t === "string")
3504
- return PRIMITIVE_TYPES.includes(t);
3625
+ if (typeof t === "string") return PRIMITIVE_TYPES_SET.has(t);
3505
3626
  if (typeof t !== "object") return false;
3506
3627
  if (!("kind" in t)) return false;
3507
- 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";
3628
+ 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";
3508
3629
  }
3509
3630
 
3510
3631
  // src/common/type/lexer.ts
@@ -4214,19 +4335,13 @@ var Numerics = (() => {
4214
4335
  );
4215
4336
  let dimensions;
4216
4337
  if (this.match("<")) {
4217
- dimensions = this.parseDimensionWithX();
4218
- if (!dimensions) {
4219
- dimensions = this.parseDimensions();
4220
- }
4338
+ dimensions = this.parseDimensions();
4221
4339
  if (!dimensions) {
4222
4340
  const type = this.parseUnionType();
4223
4341
  if (type) {
4224
4342
  elementType = type;
4225
4343
  if (this.match("^")) {
4226
- dimensions = this.parseDimensionWithX();
4227
- if (!dimensions) {
4228
- dimensions = this.parseDimensions();
4229
- }
4344
+ dimensions = this.parseCaretDimensions();
4230
4345
  }
4231
4346
  }
4232
4347
  }
@@ -4267,19 +4382,13 @@ var Numerics = (() => {
4267
4382
  );
4268
4383
  let dimensions;
4269
4384
  if (this.match("<")) {
4270
- dimensions = this.parseDimensionWithX();
4271
- if (!dimensions) {
4272
- dimensions = this.parseDimensions();
4273
- }
4385
+ dimensions = this.parseDimensions();
4274
4386
  if (!dimensions) {
4275
4387
  const type = this.parseUnionType();
4276
4388
  if (type) {
4277
4389
  elementType = type;
4278
4390
  if (this.match("^")) {
4279
- dimensions = this.parseDimensionWithX();
4280
- if (!dimensions) {
4281
- dimensions = this.parseDimensions();
4282
- }
4391
+ dimensions = this.parseCaretDimensions();
4283
4392
  }
4284
4393
  }
4285
4394
  }
@@ -4310,16 +4419,30 @@ var Numerics = (() => {
4310
4419
  return this.createNode("tensor", { elementType });
4311
4420
  }
4312
4421
  parseDimensions() {
4313
- const dimensions = [];
4314
4422
  const firstDim = this.parseDimension();
4315
4423
  if (!firstDim) return void 0;
4316
- dimensions.push(firstDim);
4317
- while (this.match("x")) {
4318
- const dim = this.parseDimension();
4319
- if (!dim) {
4320
- this.error("Expected dimension after x");
4424
+ const dimensions = [firstDim];
4425
+ for (; ; ) {
4426
+ const tok = this.current;
4427
+ if (tok.type === "IDENTIFIER" && /^(x\d+)+$/.test(tok.value)) {
4428
+ this.advance();
4429
+ for (const m of tok.value.match(/x(\d+)/g))
4430
+ dimensions.push(
4431
+ this.createNode("dimension", {
4432
+ size: parseInt(m.slice(1))
4433
+ })
4434
+ );
4435
+ } else if (tok.type === "IDENTIFIER" && tok.value === "x") {
4436
+ const next = this.lexer.peekToken();
4437
+ if (next.type !== "NUMBER_LITERAL" && next.type !== "?")
4438
+ this.error(
4439
+ "Expected a positive integer literal or `?` after x. For example: `2x3` or `2x?`"
4440
+ );
4441
+ this.advance();
4442
+ dimensions.push(this.parseDimension());
4443
+ } else {
4444
+ break;
4321
4445
  }
4322
- dimensions.push(dim);
4323
4446
  }
4324
4447
  return dimensions;
4325
4448
  }
@@ -4333,35 +4456,11 @@ var Numerics = (() => {
4333
4456
  }
4334
4457
  return void 0;
4335
4458
  }
4336
- parseDimensionWithX() {
4337
- if (this.current.type === "NUMBER_LITERAL") {
4338
- const dimensions = [];
4339
- const firstDim = parseInt(this.advance().value);
4340
- dimensions.push(
4341
- this.createNode("dimension", { size: firstDim })
4342
- );
4343
- if (this.current.type === "IDENTIFIER" && this.current.value.startsWith("x")) {
4344
- const dimString = this.current.value;
4345
- const matches = dimString.match(/x(\d+)/g);
4346
- if (matches && matches.join("") === dimString) {
4347
- this.advance();
4348
- for (const match of matches) {
4349
- const dimValue = parseInt(match.substring(1));
4350
- dimensions.push(
4351
- this.createNode("dimension", { size: dimValue })
4352
- );
4353
- }
4354
- } else if (dimString === "x" || dimString.startsWith("x")) {
4355
- this.error(
4356
- "Expected a positive integer literal or `?` after x. For example: `2x3` or `2x?`"
4357
- );
4358
- }
4359
- }
4360
- if (dimensions.length > 1) {
4361
- return dimensions;
4362
- }
4363
- }
4364
- return void 0;
4459
+ parseCaretDimensions() {
4460
+ const paren = this.match("(");
4461
+ const dimensions = this.parseDimensions();
4462
+ if (paren) this.expect(")");
4463
+ return dimensions;
4365
4464
  }
4366
4465
  parseTupleType() {
4367
4466
  if (this.current.type === "IDENTIFIER" && this.current.value === "tuple") {
@@ -4546,6 +4645,18 @@ var Numerics = (() => {
4546
4645
  this.expect("..");
4547
4646
  const upperBound = this.parseValue();
4548
4647
  this.expect(">");
4648
+ const lower = lowerBound?.value ?? -Infinity;
4649
+ const upper = upperBound?.value ?? Infinity;
4650
+ if (Number.isNaN(lower) || Number.isNaN(upper))
4651
+ this.error(
4652
+ "Invalid numeric type",
4653
+ "Lower and upper bounds must be valid numbers"
4654
+ );
4655
+ if (lower > upper)
4656
+ this.error(
4657
+ `Invalid range: ${lower}..${upper}`,
4658
+ "The lower bound must be less than the upper bound"
4659
+ );
4549
4660
  return this.createNode("numeric", {
4550
4661
  baseType,
4551
4662
  lowerBound,
@@ -4560,7 +4671,7 @@ var Numerics = (() => {
4560
4671
  parsePrimitiveType() {
4561
4672
  if (this.current.type === "IDENTIFIER") {
4562
4673
  const name = this.current.value;
4563
- if (PRIMITIVE_TYPES.includes(name)) {
4674
+ if (PRIMITIVE_TYPES_SET.has(name)) {
4564
4675
  this.advance();
4565
4676
  return this.createNode("primitive", { name });
4566
4677
  }
@@ -4894,14 +5005,32 @@ var Numerics = (() => {
4894
5005
  }
4895
5006
 
4896
5007
  // src/common/type/parse.ts
5008
+ var TYPE_CACHE = /* @__PURE__ */ new Map();
5009
+ var TYPE_CACHE_MAX_SIZE = 2048;
5010
+ function deepFreeze(obj) {
5011
+ if (obj === null || typeof obj !== "object") return obj;
5012
+ if (Object.isFrozen(obj)) return obj;
5013
+ Object.freeze(obj);
5014
+ for (const value of Object.values(obj)) deepFreeze(value);
5015
+ return obj;
5016
+ }
4897
5017
  function parseType(s, typeResolver) {
4898
5018
  if (s === void 0) return void 0;
4899
5019
  if (isValidType(s)) return s;
4900
5020
  if (typeof s !== "string") return void 0;
5021
+ const cacheable = typeResolver === void 0;
5022
+ if (cacheable) {
5023
+ const cached = TYPE_CACHE.get(s);
5024
+ if (cached !== void 0) return cached;
5025
+ }
4901
5026
  try {
4902
5027
  const parser = new Parser(s, { typeResolver });
4903
5028
  const ast = parser.parseType();
4904
5029
  const type = buildTypeFromAST(ast, typeResolver);
5030
+ if (cacheable) {
5031
+ if (TYPE_CACHE.size >= TYPE_CACHE_MAX_SIZE) TYPE_CACHE.clear();
5032
+ TYPE_CACHE.set(s, deepFreeze(type));
5033
+ }
4905
5034
  return type;
4906
5035
  } catch (error) {
4907
5036
  throw new Error(
@@ -4976,19 +5105,36 @@ var Numerics = (() => {
4976
5105
  color: [],
4977
5106
  expression: EXPRESSION_TYPES
4978
5107
  };
5108
+ var PRIMITIVE_SUBTYPES_CLOSURE = (() => {
5109
+ const closure = {};
5110
+ const closeOver = (t) => {
5111
+ if (closure[t]) return closure[t];
5112
+ const result = /* @__PURE__ */ new Set([t]);
5113
+ closure[t] = result;
5114
+ for (const sub of PRIMITIVE_SUBTYPES[t]) {
5115
+ if (sub === t) continue;
5116
+ for (const s of closeOver(sub)) result.add(s);
5117
+ }
5118
+ return result;
5119
+ };
5120
+ for (const t of Object.keys(PRIMITIVE_SUBTYPES))
5121
+ closeOver(t);
5122
+ return closure;
5123
+ })();
4979
5124
  function isPrimitiveSubtype(lhs, rhs) {
4980
5125
  if (rhs === "any") return true;
4981
5126
  if (lhs === "never") return true;
4982
5127
  if (lhs === "unknown" || rhs === "unknown") return false;
4983
5128
  if (lhs === rhs) return true;
4984
- return PRIMITIVE_SUBTYPES[rhs].includes(lhs);
5129
+ return PRIMITIVE_SUBTYPES_CLOSURE[rhs].has(lhs);
4985
5130
  }
4986
5131
  function isSubtype(lhs, rhs) {
4987
- if (typeof lhs === "string" && !PRIMITIVE_TYPES.includes(lhs))
5132
+ if (typeof lhs === "string" && !PRIMITIVE_TYPES_SET.has(lhs))
4988
5133
  lhs = parseType(lhs);
4989
- if (typeof rhs === "string" && !PRIMITIVE_TYPES.includes(rhs))
5134
+ if (typeof rhs === "string" && !PRIMITIVE_TYPES_SET.has(rhs))
4990
5135
  rhs = parseType(rhs);
4991
5136
  if (rhs === "any") return true;
5137
+ if (lhs === "never") return true;
4992
5138
  if (rhs === "never") return false;
4993
5139
  if (rhs === "error") return lhs === "error";
4994
5140
  if (rhs === "nothing") return lhs === "nothing";
@@ -5003,7 +5149,7 @@ var Numerics = (() => {
5003
5149
  if (typeof lhs.value === "number") {
5004
5150
  if (Number.isInteger(lhs.value))
5005
5151
  return isPrimitiveSubtype("integer", rhs);
5006
- return isPrimitiveSubtype("number", rhs);
5152
+ return isPrimitiveSubtype("real", rhs);
5007
5153
  }
5008
5154
  if (typeof lhs.value === "boolean")
5009
5155
  return isPrimitiveSubtype("boolean", rhs);
@@ -5233,7 +5379,7 @@ var Numerics = (() => {
5233
5379
  }
5234
5380
  function isNumeric(type) {
5235
5381
  if (typeof type === "string")
5236
- return NUMERIC_TYPES.includes(type);
5382
+ return NUMERIC_TYPES_SET.has(type);
5237
5383
  if (type.kind === "value") return typeof type.value === "number";
5238
5384
  if (type.kind === "numeric") return true;
5239
5385
  return false;
@@ -5241,7 +5387,7 @@ var Numerics = (() => {
5241
5387
  function isScalar(type) {
5242
5388
  if (isNumeric(type)) return true;
5243
5389
  if (typeof type === "string")
5244
- return SCALAR_TYPES.includes(type);
5390
+ return SCALAR_TYPES_SET.has(type);
5245
5391
  if (type.kind === "value")
5246
5392
  return ["string", "boolean", "number"].includes(typeof type.value);
5247
5393
  return false;
@@ -5249,7 +5395,7 @@ var Numerics = (() => {
5249
5395
  function isCollection(type) {
5250
5396
  if (isIndexedCollection(type)) return true;
5251
5397
  if (typeof type === "string")
5252
- return COLLECTION_TYPES.includes(type);
5398
+ return COLLECTION_TYPES_SET.has(type);
5253
5399
  return ["collection", "set", "record", "dictionary"].includes(type.kind);
5254
5400
  }
5255
5401
  function isIndexedCollection(type) {
@@ -5309,16 +5455,17 @@ var Numerics = (() => {
5309
5455
  ]);
5310
5456
  function unionTypes(a, b) {
5311
5457
  const members = [];
5458
+ const keys = /* @__PURE__ */ new Set();
5312
5459
  const push = (t) => {
5313
5460
  if (typeof t === "object" && t.kind === "union") {
5314
5461
  for (const m of t.types) push(m);
5315
5462
  return;
5316
5463
  }
5317
5464
  const key = typeof t === "string" ? t : JSON.stringify(t);
5318
- if (!members.some(
5319
- (m) => (typeof m === "string" ? m : JSON.stringify(m)) === key
5320
- ))
5465
+ if (!keys.has(key)) {
5466
+ keys.add(key);
5321
5467
  members.push(t);
5468
+ }
5322
5469
  };
5323
5470
  push(a);
5324
5471
  push(b);
@@ -5330,6 +5477,32 @@ var Numerics = (() => {
5330
5477
  if (types.length === 1) return types[0];
5331
5478
  return types.reduce((a, b) => widen2(a, b));
5332
5479
  }
5480
+ var SUPERTYPE_PROBE_ORDER = [
5481
+ "non_finite_number",
5482
+ "finite_integer",
5483
+ "integer",
5484
+ "finite_rational",
5485
+ "rational",
5486
+ "finite_real",
5487
+ "real",
5488
+ "imaginary",
5489
+ "finite_complex",
5490
+ "complex",
5491
+ "finite_number",
5492
+ "number",
5493
+ "list",
5494
+ "record",
5495
+ "dictionary",
5496
+ "set",
5497
+ "tuple",
5498
+ "indexed_collection",
5499
+ "collection",
5500
+ "scalar",
5501
+ "value",
5502
+ "function",
5503
+ "expression"
5504
+ ];
5505
+ var PRIMITIVE_SUPERTYPE_CACHE = /* @__PURE__ */ new Map();
5333
5506
  function superType(a, b) {
5334
5507
  if (a === b) return a;
5335
5508
  if (a === "any" || b === "any") return "any";
@@ -5339,35 +5512,26 @@ var Numerics = (() => {
5339
5512
  if (b === "unknown") return a;
5340
5513
  if (a === "nothing") return b;
5341
5514
  if (b === "nothing") return a;
5342
- if (commonSupertype(a, b, "non_finite_number")) return "non_finite_number";
5343
- if (commonSupertype(a, b, "finite_integer")) return "finite_integer";
5344
- if (commonSupertype(a, b, "integer")) return "integer";
5345
- if (commonSupertype(a, b, "finite_rational")) return "finite_rational";
5346
- if (commonSupertype(a, b, "rational")) return "rational";
5347
- if (commonSupertype(a, b, "finite_real")) return "finite_real";
5348
- if (commonSupertype(a, b, "real")) return "real";
5349
- if (commonSupertype(a, b, "imaginary")) return "imaginary";
5350
- if (commonSupertype(a, b, "finite_complex")) return "finite_complex";
5351
- if (commonSupertype(a, b, "complex")) return "complex";
5352
- if (commonSupertype(a, b, "finite_number")) return "finite_number";
5353
- if (commonSupertype(a, b, "number")) return "number";
5354
- if (commonSupertype(a, b, "list")) return "list";
5355
- if (commonSupertype(a, b, "record")) return "record";
5356
- if (commonSupertype(a, b, "dictionary")) return "dictionary";
5357
- if (commonSupertype(a, b, "set")) return "set";
5358
- if (commonSupertype(a, b, "tuple")) return "tuple";
5359
- if (commonSupertype(a, b, "indexed_collection")) return "indexed_collection";
5360
- if (commonSupertype(a, b, "collection")) return "collection";
5361
- if (commonSupertype(a, b, "scalar")) return "scalar";
5362
- if (commonSupertype(a, b, "value")) return "value";
5363
- if (commonSupertype(a, b, "function")) return "function";
5364
- if (commonSupertype(a, b, "expression")) return "expression";
5515
+ if (typeof a === "string" && typeof b === "string") {
5516
+ const key = a < b ? `${a}|${b}` : `${b}|${a}`;
5517
+ let result = PRIMITIVE_SUPERTYPE_CACHE.get(key);
5518
+ if (result === void 0) {
5519
+ result = "any";
5520
+ for (const ancestor of SUPERTYPE_PROBE_ORDER) {
5521
+ const subtypes = PRIMITIVE_SUBTYPES_CLOSURE[ancestor];
5522
+ if (subtypes.has(a) && subtypes.has(b)) {
5523
+ result = ancestor;
5524
+ break;
5525
+ }
5526
+ }
5527
+ PRIMITIVE_SUPERTYPE_CACHE.set(key, result);
5528
+ }
5529
+ return result;
5530
+ }
5531
+ for (const ancestor of SUPERTYPE_PROBE_ORDER)
5532
+ if (isSubtype(a, ancestor) && isSubtype(b, ancestor)) return ancestor;
5365
5533
  return "any";
5366
5534
  }
5367
- function commonSupertype(a, b, ancestor) {
5368
- if (isSubtype(a, ancestor) && isSubtype(b, ancestor)) return true;
5369
- return false;
5370
- }
5371
5535
 
5372
5536
  // src/compute-engine/numeric-value/exact-numeric-value.ts
5373
5537
  var ExactNumericValue = class _ExactNumericValue extends NumericValue {
@@ -5585,6 +5749,10 @@ var Numerics = (() => {
5585
5749
  });
5586
5750
  }
5587
5751
  inv() {
5752
+ if (this.isNaN) return this;
5753
+ if (this.isPositiveInfinity || this.isNegativeInfinity)
5754
+ return this.clone(0);
5755
+ if (this.isZero) return this.clone(Infinity);
5588
5756
  if (this.isOne) return this;
5589
5757
  if (this.isNegativeOne) return this;
5590
5758
  return this.clone({
@@ -5703,7 +5871,7 @@ var Numerics = (() => {
5703
5871
  } else {
5704
5872
  if (exponent instanceof _ExactNumericValue) {
5705
5873
  if (exponent.radical === 1 && exponent.rational[0] == 1)
5706
- return this.root(exponent.rational[0]);
5874
+ return this.root(Number(exponent.rational[1]));
5707
5875
  }
5708
5876
  exponent = exponent.re;
5709
5877
  }
@@ -5838,19 +6006,52 @@ var Numerics = (() => {
5838
6006
  if (this.isPositiveInfinity) return this.clone(Infinity);
5839
6007
  return this.factory(this.bignumRe).exp();
5840
6008
  }
6009
+ /**
6010
+ * Floor/ceil/round of a pure rational (`radical === 1`) computed exactly with
6011
+ * bigints. Routing through `this.re` (a float) would lose digits for
6012
+ * integers/rationals larger than 2^53.
6013
+ */
6014
+ _integerPart(mode2) {
6015
+ let n = BigInt(this.rational[0]);
6016
+ let d = BigInt(this.rational[1]);
6017
+ if (d < 0n) {
6018
+ n = -n;
6019
+ d = -d;
6020
+ }
6021
+ let q;
6022
+ if (mode2 === "round") {
6023
+ const m = 2n * n + d;
6024
+ const dd = 2n * d;
6025
+ q = m / dd;
6026
+ if (m % dd !== 0n && m < 0n) q -= 1n;
6027
+ } else {
6028
+ q = n / d;
6029
+ const r = n % d;
6030
+ if (r !== 0n) {
6031
+ if (mode2 === "floor" && n < 0n) q -= 1n;
6032
+ if (mode2 === "ceil" && n > 0n) q += 1n;
6033
+ }
6034
+ }
6035
+ return this.clone({ rational: [q, BigInt(1)], radical: 1 });
6036
+ }
6037
+ // An exact value is an integer iff it has no radical part and a unit
6038
+ // denominator. (`this.type` returns `'finite_integer'`, never `'integer'`.)
5841
6039
  floor() {
5842
6040
  if (this.isNaN) return this.clone(NaN);
5843
- if (this.type === "integer") return this;
6041
+ if (this.radical === 1 && isInteger(this.rational)) return this;
6042
+ if (this.radical === 1) return this._integerPart("floor");
5844
6043
  return this.clone(Math.floor(this.re));
5845
6044
  }
5846
6045
  ceil() {
5847
6046
  if (this.isNaN) return this.clone(NaN);
5848
- if (this.type === "integer") return this;
6047
+ if (this.radical === 1 && isInteger(this.rational)) return this;
6048
+ if (this.radical === 1) return this._integerPart("ceil");
5849
6049
  return this.clone(Math.ceil(this.re));
5850
6050
  }
5851
6051
  round() {
5852
6052
  if (this.isNaN) return this.clone(NaN);
5853
- if (this.type === "integer") return this;
6053
+ if (this.radical === 1 && isInteger(this.rational)) return this;
6054
+ if (this.radical === 1) return this._integerPart("round");
5854
6055
  return this.clone(Math.round(this.re));
5855
6056
  }
5856
6057
  eq(other) {
@@ -5949,7 +6150,7 @@ var Numerics = (() => {
5949
6150
  return a.abs();
5950
6151
  }
5951
6152
  function lcm3(a, b) {
5952
- return a.mul(b).div(gcd3(a, b));
6153
+ return a.mul(b).div(gcd3(a, b)).abs();
5953
6154
  }
5954
6155
  function* factorial22(n) {
5955
6156
  if (!n.isInteger() || n.isNegative()) return BigDecimal.NAN;
@@ -6129,8 +6330,8 @@ var Numerics = (() => {
6129
6330
  if (this.isOne) return this;
6130
6331
  if (this.isNegativeOne) return this;
6131
6332
  if (this.im === 0) return this.clone(this.decimal.inv());
6132
- const d = Math.hypot(this.re, this.im);
6133
- const bigD = this.decimal.mul(this.decimal).add(this.im * this.im).sqrt();
6333
+ const d = this.re * this.re + this.im * this.im;
6334
+ const bigD = this.decimal.mul(this.decimal).add(this.im * this.im);
6134
6335
  return this.clone({ re: this.decimal.div(bigD), im: -this.im / d });
6135
6336
  }
6136
6337
  add(other) {
@@ -6157,7 +6358,7 @@ var Numerics = (() => {
6157
6358
  if (other === 1) return this;
6158
6359
  if (other === -1) return this.neg();
6159
6360
  if (other === 0) {
6160
- if (this.isPositiveInfinity || this.isNegativeInfinity || this.isComplexInfinity)
6361
+ if (this.isNaN || this.isPositiveInfinity || this.isNegativeInfinity || this.isComplexInfinity)
6161
6362
  return this._makeExact(NaN);
6162
6363
  return this.clone(0);
6163
6364
  }
@@ -6187,7 +6388,7 @@ var Numerics = (() => {
6187
6388
  if (other.isOne) return this;
6188
6389
  if (other.isNegativeOne) return this.neg();
6189
6390
  if (other.isZero) {
6190
- if (this.isPositiveInfinity || this.isNegativeInfinity || this.isComplexInfinity)
6391
+ if (this.isNaN || this.isPositiveInfinity || this.isNegativeInfinity || this.isComplexInfinity)
6191
6392
  return this._makeExact(NaN);
6192
6393
  return this.clone(0);
6193
6394
  }
@@ -6210,7 +6411,11 @@ var Numerics = (() => {
6210
6411
  }
6211
6412
  if (other.isOne) return this;
6212
6413
  if (other.isNegativeOne) return this.neg();
6213
- if (other.isZero) return this.clone(this.isZero ? NaN : Infinity);
6414
+ if (other.isZero) {
6415
+ if (this.isZero || this.isNaN) return this.clone(NaN);
6416
+ if (this.im !== 0) return this.clone({ im: Infinity });
6417
+ return this.clone(this.decimal.isNegative() ? -Infinity : Infinity);
6418
+ }
6214
6419
  if (this.im === 0 && other.im === 0)
6215
6420
  return this.clone(this.decimal.div(other.bignumRe ?? other.re));
6216
6421
  const [a, b] = [this.re, this.im];
@@ -6244,13 +6449,18 @@ var Numerics = (() => {
6244
6449
  if (this.im === Infinity) return this.clone(NaN);
6245
6450
  if (this.isNegativeInfinity) return this.clone(0);
6246
6451
  if (this.isPositiveInfinity) return this.clone({ im: Infinity });
6247
- const zRe = this.pow(re);
6248
- const zArg = this.decimal.ln().mul(im);
6249
- const zIm = this.clone({
6250
- re: zArg.cos(),
6251
- im: chop2(zArg.sin().toNumber())
6452
+ if (this.isZero) return re > 0 ? this.clone(0) : this.clone(NaN);
6453
+ const a2 = this.decimal;
6454
+ const b2 = this.im;
6455
+ const lnMod = a2.mul(a2).add(b2 * b2).sqrt().ln();
6456
+ const arg = BigDecimal.atan2(b2, a2);
6457
+ const realExp = lnMod.mul(re).sub(arg.mul(im));
6458
+ const imagExp = arg.mul(re).add(lnMod.mul(im));
6459
+ const mag = realExp.exp();
6460
+ return this.clone({
6461
+ re: mag.mul(imagExp.cos()),
6462
+ im: chop2(mag.mul(imagExp.sin()).toNumber())
6252
6463
  });
6253
- return zRe.mul(zIm);
6254
6464
  }
6255
6465
  }
6256
6466
  if (this.isPositiveInfinity) {
@@ -6294,13 +6504,13 @@ var Numerics = (() => {
6294
6504
  if (this.decimal.isNegative()) return this._makeExact(NaN);
6295
6505
  if (exp === 2) return this.clone(this.decimal.sqrt());
6296
6506
  if (exp === 3) return this.clone(this.decimal.cbrt());
6297
- return this.clone(this.decimal.pow(1 / exp));
6507
+ return this.clone(this.decimal.ln().div(exp).exp());
6298
6508
  }
6299
6509
  const a = this.decimal;
6300
6510
  const b = this.im;
6301
6511
  const modulus = a.mul(a).add(b * b).sqrt();
6302
6512
  const argument = BigDecimal.atan2(b, a);
6303
- const newModulus = modulus.pow(1 / exp);
6513
+ const newModulus = modulus.ln().div(exp).exp();
6304
6514
  const newArgument = argument.div(exp);
6305
6515
  return this.clone({
6306
6516
  re: newModulus.mul(newArgument.cos()),
@@ -6566,7 +6776,7 @@ var Numerics = (() => {
6566
6776
  if (this.isOne) return this;
6567
6777
  if (this.isNegativeOne) return this;
6568
6778
  if (this.im === 0) return this.clone(1 / this.decimal);
6569
- const d = Math.hypot(this.re, this.im);
6779
+ const d = this.re * this.re + this.im * this.im;
6570
6780
  return this.clone({ re: this.decimal / d, im: -this.im / d });
6571
6781
  }
6572
6782
  add(other) {
@@ -6676,11 +6886,17 @@ var Numerics = (() => {
6676
6886
  if (this.im === Infinity) return this.clone(NaN);
6677
6887
  if (this.isNegativeInfinity) return this.clone(0);
6678
6888
  if (this.isPositiveInfinity) return this.clone({ im: Infinity });
6679
- const zRe = this.pow(re).re;
6680
- const zArg = Math.log(this.decimal) * im;
6889
+ if (this.isZero) return re > 0 ? this.clone(0) : this.clone(NaN);
6890
+ const a2 = this.decimal;
6891
+ const b2 = this.im;
6892
+ const lnMod = 0.5 * Math.log(a2 * a2 + b2 * b2);
6893
+ const arg = Math.atan2(b2, a2);
6894
+ const realExp = re * lnMod - im * arg;
6895
+ const imagExp = re * arg + im * lnMod;
6896
+ const mag = Math.exp(realExp);
6681
6897
  return this.clone({
6682
- re: chop3(zRe * Math.cos(zArg)),
6683
- im: chop3(zRe * Math.sin(zArg))
6898
+ re: chop3(mag * Math.cos(imagExp)),
6899
+ im: chop3(mag * Math.sin(imagExp))
6684
6900
  });
6685
6901
  }
6686
6902
  }
@@ -6699,14 +6915,15 @@ var Numerics = (() => {
6699
6915
  if (exponent > 0) return this;
6700
6916
  if (exponent < 0) return this.clone({ im: Infinity });
6701
6917
  }
6702
- if (exponent < 0) return this.clone(1 / this.decimal ** -exponent);
6918
+ if (exponent < 0 && this.im === 0)
6919
+ return this.clone(1 / this.decimal ** -exponent);
6703
6920
  if (this.im === 0) return this.clone(this.decimal ** exponent);
6704
6921
  const a = this.decimal;
6705
6922
  const b = this.im;
6706
6923
  const modulus = Math.sqrt(a * a + b * b);
6707
6924
  const argument = Math.atan2(b, a);
6708
6925
  const newModulus = modulus ** exponent;
6709
- const newArgument = argument ** exponent;
6926
+ const newArgument = argument * exponent;
6710
6927
  return this.clone({
6711
6928
  re: newModulus * Math.cos(newArgument),
6712
6929
  im: newModulus * Math.sin(newArgument)
@@ -6827,10 +7044,10 @@ var Numerics = (() => {
6827
7044
  eq(other) {
6828
7045
  if (this.isNaN) return false;
6829
7046
  if (typeof other === "number")
6830
- return this.im === 0 && this.decimal - other === 0;
7047
+ return this.im === 0 && this.decimal === other;
6831
7048
  if (other.isNaN) return false;
6832
7049
  if (!Number.isFinite(this.im)) return !Number.isFinite(other.im);
6833
- return this.decimal - other.re === 0 && this.im - other.im === 0;
7050
+ return this.decimal === other.re && this.im === other.im;
6834
7051
  }
6835
7052
  lt(other) {
6836
7053
  if (this.im !== 0) return void 0;
@@ -6912,42 +7129,20 @@ var Numerics = (() => {
6912
7129
  return void 0;
6913
7130
  }
6914
7131
  function intervalContains(int, val) {
6915
- if (int.openStart) {
6916
- if (int.start <= val) return false;
6917
- }
6918
- if (int.start < val) return false;
6919
- if (int.openEnd) {
6920
- if (int.end >= val) return false;
6921
- }
6922
- if (int.end > val) return false;
7132
+ if (int.openStart ? val <= int.start : val < int.start) return false;
7133
+ if (int.openEnd ? val >= int.end : val > int.end) return false;
6923
7134
  return true;
6924
7135
  }
6925
7136
  function intervalSubset(int1, int2) {
6926
- if (int1.openStart) {
6927
- if (int2.openStart) {
6928
- if (int1.start <= int2.start) return false;
6929
- } else {
6930
- if (int1.start < int2.start) return false;
6931
- }
7137
+ if (!int1.openStart && int2.openStart) {
7138
+ if (int1.start <= int2.start) return false;
6932
7139
  } else {
6933
- if (int2.openStart) {
6934
- if (int1.start <= int2.start) return false;
6935
- } else {
6936
- if (int1.start < int2.start) return false;
6937
- }
7140
+ if (int1.start < int2.start) return false;
6938
7141
  }
6939
- if (int1.openEnd) {
6940
- if (int2.openEnd) {
6941
- if (int1.end >= int2.end) return false;
6942
- } else {
6943
- if (int1.end > int2.end) return false;
6944
- }
7142
+ if (!int1.openEnd && int2.openEnd) {
7143
+ if (int1.end >= int2.end) return false;
6945
7144
  } else {
6946
- if (int2.openEnd) {
6947
- if (int1.end >= int2.end) return false;
6948
- } else {
6949
- if (int1.end > int2.end) return false;
6950
- }
7145
+ if (int1.end > int2.end) return false;
6951
7146
  }
6952
7147
  return true;
6953
7148
  }
@@ -7130,6 +7325,7 @@ var Numerics = (() => {
7130
7325
  function kurtosis(values) {
7131
7326
  let sum = 0;
7132
7327
  let sum2 = 0;
7328
+ let sum3 = 0;
7133
7329
  let sum4 = 0;
7134
7330
  let count = 0;
7135
7331
  for (const op of values) {
@@ -7137,16 +7333,21 @@ var Numerics = (() => {
7137
7333
  if (!Number.isFinite(v)) return NaN;
7138
7334
  sum += v;
7139
7335
  sum2 += v * v;
7336
+ sum3 += v * v * v;
7140
7337
  sum4 += v * v * v * v;
7141
7338
  count++;
7142
7339
  }
7143
7340
  if (count === 0) return NaN;
7144
- const s2 = (sum2 - sum * sum / count) / (count - 1);
7145
- return (sum4 - 4 * sum * sum2 / count + 6 * sum * sum * sum / count / count - 3 * sum * sum * sum * sum / count / count / count) / (s2 * s2);
7341
+ const n = count;
7342
+ const m = sum / n;
7343
+ const m2 = (sum2 - sum * sum / n) / n;
7344
+ const m4 = (sum4 - 4 * m * sum3 + 6 * m * m * sum2 - 4 * m * m * m * sum + n * m * m * m * m) / n;
7345
+ return m4 / (m2 * m2);
7146
7346
  }
7147
7347
  function bigKurtosis(values) {
7148
7348
  let sum = BigDecimal.ZERO;
7149
7349
  let sum2 = BigDecimal.ZERO;
7350
+ let sum3 = BigDecimal.ZERO;
7150
7351
  let sum4 = BigDecimal.ZERO;
7151
7352
  let count = 0;
7152
7353
  for (const op of values) {
@@ -7154,15 +7355,15 @@ var Numerics = (() => {
7154
7355
  if (!v.isFinite()) return BigDecimal.NAN;
7155
7356
  sum = sum.add(v);
7156
7357
  sum2 = sum2.add(v.mul(v));
7358
+ sum3 = sum3.add(v.mul(v).mul(v));
7157
7359
  sum4 = sum4.add(v.mul(v).mul(v).mul(v));
7158
7360
  count++;
7159
7361
  }
7160
7362
  if (count === 0) return BigDecimal.NAN;
7161
- const bdCount = new BigDecimal(count);
7162
- const s2 = sum2.sub(sum.mul(sum).div(bdCount)).div(new BigDecimal(count - 1));
7163
- 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(
7164
- sum.mul(sum).mul(sum).mul(sum).mul(new BigDecimal(3)).div(bdCount).div(bdCount).div(bdCount)
7165
- ).div(s2.mul(s2));
7363
+ const m = sum.div(count);
7364
+ const m2 = sum2.sub(sum.mul(sum).div(count)).div(count);
7365
+ 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);
7366
+ return m4.div(m2.mul(m2));
7166
7367
  }
7167
7368
  function skewness(values) {
7168
7369
  let sum = 0;
@@ -7178,9 +7379,11 @@ var Numerics = (() => {
7178
7379
  count++;
7179
7380
  }
7180
7381
  if (count === 0) return NaN;
7181
- const s2 = (sum2 - sum * sum / count) / (count - 1);
7182
- const s3 = (sum3 - sum2 * sum / count) / (count - 1);
7183
- return s3 / Math.pow(s2, 3 / 2) * Math.sqrt(count * 1);
7382
+ const n = count;
7383
+ const m = sum / n;
7384
+ const m2 = (sum2 - sum * sum / n) / n;
7385
+ const m3 = (sum3 - 3 * m * sum2 + 3 * m * m * sum - n * m * m * m) / n;
7386
+ return m3 / Math.pow(m2, 3 / 2);
7184
7387
  }
7185
7388
  function bigSkewness(values) {
7186
7389
  let sum = BigDecimal.ZERO;
@@ -7196,10 +7399,10 @@ var Numerics = (() => {
7196
7399
  count++;
7197
7400
  }
7198
7401
  if (count === 0) return BigDecimal.NAN;
7199
- const bdCount = new BigDecimal(count);
7200
- const s2 = sum2.sub(sum.mul(sum).div(bdCount)).div(new BigDecimal(count - 1));
7201
- const s3 = sum3.sub(sum2.mul(sum).div(bdCount)).div(new BigDecimal(count - 1));
7202
- return s3.div(s2.pow(new BigDecimal(1.5))).mul(bdCount.sqrt());
7402
+ const m = sum.div(count);
7403
+ const m2 = sum2.sub(sum.mul(sum).div(count)).div(count);
7404
+ 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);
7405
+ return m3.div(m2.mul(m2.sqrt()));
7203
7406
  }
7204
7407
  function mode(values) {
7205
7408
  const counts = {};
@@ -7250,18 +7453,12 @@ var Numerics = (() => {
7250
7453
  return [q1, q2, q3];
7251
7454
  }
7252
7455
  function interquartileRange(values) {
7253
- const sorted = [...values].sort((a, b) => a - b);
7254
- const mid = Math.floor(sorted.length / 2);
7255
- const lower = sorted.slice(0, mid);
7256
- const upper = sorted.slice(mid + 1);
7257
- return median(upper) - median(lower);
7456
+ const [q1, , q3] = quartiles(values);
7457
+ return q3 - q1;
7258
7458
  }
7259
7459
  function bigInterquartileRange(values) {
7260
- const sorted = [...values].sort((a, b) => a.cmp(b));
7261
- const mid = Math.floor(sorted.length / 2);
7262
- const lower = sorted.slice(0, mid);
7263
- const upper = sorted.slice(mid + 1);
7264
- return bigMedian(upper).sub(bigMedian(lower));
7460
+ const [q1, , q3] = bigQuartiles(values);
7461
+ return q3.sub(q1);
7265
7462
  }
7266
7463
 
7267
7464
  // src/compute-engine/numerics/unit-data.ts
@@ -7636,9 +7833,14 @@ var Numerics = (() => {
7636
7833
  ];
7637
7834
  function gammaln(z) {
7638
7835
  if (z < 0) return NaN;
7836
+ let shift = 0;
7837
+ while (z < 10) {
7838
+ shift += Math.log(z);
7839
+ z += 1;
7840
+ }
7639
7841
  const pi = Math.PI;
7640
7842
  const z3 = z * z * z;
7641
- 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);
7843
+ 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;
7642
7844
  }
7643
7845
  function gamma(z) {
7644
7846
  if (z < 0.5) return Math.PI / (Math.sin(Math.PI * z) * gamma(1 - z));
@@ -7649,31 +7851,62 @@ var Numerics = (() => {
7649
7851
  const t = z + gammaG + 0.5;
7650
7852
  return Math.sqrt(2 * Math.PI) * Math.pow(t, z + 0.5) * Math.exp(-t) * x;
7651
7853
  }
7854
+ function erfInvApprox(x) {
7855
+ const a = 0.147;
7856
+ const ln1mx2 = Math.log(1 - x * x);
7857
+ const b = 2 / (Math.PI * a) + ln1mx2 / 2;
7858
+ return Math.sign(x) * Math.sqrt(Math.sqrt(b * b - ln1mx2 / a) - b);
7859
+ }
7652
7860
  function erfInv(x) {
7653
- const pi = Math.PI;
7654
- const pi2 = pi * pi;
7655
- const pi3 = pi2 * pi;
7656
- const x2 = x * x;
7657
- const x3 = x * x2;
7658
- const x5 = x3 * x2;
7659
- const x7 = x5 * x2;
7660
- 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);
7861
+ if (Number.isNaN(x) || x < -1 || x > 1) return NaN;
7862
+ if (x === 0) return 0;
7863
+ if (x === 1) return Infinity;
7864
+ if (x === -1) return -Infinity;
7865
+ const sign = x < 0 ? -1 : 1;
7866
+ const ax = Math.abs(x);
7867
+ let y = erfInvApprox(ax);
7868
+ const c = Math.sqrt(Math.PI) / 2;
7869
+ for (let i = 0; i < 4; i++) y -= (erf(y) - ax) * c * Math.exp(y * y);
7870
+ return sign * y;
7661
7871
  }
7662
7872
  function erfc(x) {
7663
- return 1 - erf(x);
7873
+ if (Number.isNaN(x)) return NaN;
7874
+ if (!Number.isFinite(x)) return x > 0 ? 0 : 2;
7875
+ if (x < 0) return 2 - erfc(-x);
7876
+ if (x < 2) return 1 - erf(x);
7877
+ const tiny = 1e-300;
7878
+ let f = x === 0 ? tiny : x;
7879
+ let c = f;
7880
+ let d = 0;
7881
+ for (let k = 1; k <= 500; k++) {
7882
+ const a = k / 2;
7883
+ d = x + a * d;
7884
+ if (d === 0) d = tiny;
7885
+ d = 1 / d;
7886
+ c = x + a / c;
7887
+ if (c === 0) c = tiny;
7888
+ const delta = c * d;
7889
+ f *= delta;
7890
+ if (Math.abs(delta - 1) < 1e-17) break;
7891
+ }
7892
+ return Math.exp(-x * x) / (Math.sqrt(Math.PI) * f);
7664
7893
  }
7665
7894
  function erf(x) {
7666
- const a1 = 0.254829592;
7667
- const a2 = -0.284496736;
7668
- const a3 = 1.421413741;
7669
- const a4 = -1.453152027;
7670
- const a5 = 1.061405429;
7671
- const p = 0.3275911;
7895
+ if (Number.isNaN(x)) return NaN;
7896
+ if (x === 0) return 0;
7897
+ if (!Number.isFinite(x)) return x > 0 ? 1 : -1;
7672
7898
  const sign = x < 0 ? -1 : 1;
7673
- x = Math.abs(x);
7674
- const t = 1 / (1 + p * x);
7675
- const y = ((((a5 * t + a4) * t + a3) * t + a2) * t + a1) * t;
7676
- return sign * (1 - y * Math.exp(-x * x));
7899
+ const ax = Math.abs(x);
7900
+ if (ax >= 6) return sign;
7901
+ const x2 = ax * ax;
7902
+ let term = ax;
7903
+ let sum = ax;
7904
+ for (let n = 1; n < 200; n++) {
7905
+ term *= 2 * x2 / (2 * n + 1);
7906
+ sum += term;
7907
+ if (term < sum * 1e-18) break;
7908
+ }
7909
+ return sign * (2 / Math.sqrt(Math.PI)) * Math.exp(-x2) * sum;
7677
7910
  }
7678
7911
  function bigGammaln(ce, z) {
7679
7912
  if (!z.isFinite()) return BigDecimal.NAN;
@@ -8623,7 +8856,7 @@ var Numerics = (() => {
8623
8856
  const t = x2 * x2;
8624
8857
  return sign * x * x2 * polevl(t, SN) / polevl(t, SD);
8625
8858
  }
8626
- if (x < 36) {
8859
+ if (x < 36974) {
8627
8860
  const x2 = x * x;
8628
8861
  const t = Math.PI * x2;
8629
8862
  const u = 1 / (t * t);
@@ -8648,7 +8881,7 @@ var Numerics = (() => {
8648
8881
  const t = x2 * x2;
8649
8882
  return sign * x * polevl(t, CN) / polevl(t, CD);
8650
8883
  }
8651
- if (x < 36) {
8884
+ if (x < 36974) {
8652
8885
  const x2 = x * x;
8653
8886
  const t = Math.PI * x2;
8654
8887
  const u = 1 / (t * t);
@@ -8665,16 +8898,904 @@ var Numerics = (() => {
8665
8898
  return x === 0 ? 1 : Math.sin(x) / x;
8666
8899
  }
8667
8900
 
8901
+ // node_modules/complex-esm/dist/src/complex.js
8902
+ var cosh = Math.cosh || function(x) {
8903
+ return Math.abs(x) < 1e-9 ? 1 - x : (Math.exp(x) + Math.exp(-x)) * 0.5;
8904
+ };
8905
+ var sinh = Math.sinh || function(x) {
8906
+ return Math.abs(x) < 1e-9 ? x : (Math.exp(x) - Math.exp(-x)) * 0.5;
8907
+ };
8908
+ var cosm1 = function(x) {
8909
+ var b = Math.PI / 4;
8910
+ if (-b > x || x > b) {
8911
+ return Math.cos(x) - 1;
8912
+ }
8913
+ var xx = x * x;
8914
+ return xx * (xx * (xx * (xx * (xx * (xx * (xx * (xx / 20922789888e3 - 1 / 87178291200) + 1 / 479001600) - 1 / 3628800) + 1 / 40320) - 1 / 720) + 1 / 24) - 1 / 2);
8915
+ };
8916
+ var hypot = function(x, y) {
8917
+ var a = Math.abs(x);
8918
+ var b = Math.abs(y);
8919
+ if (a < 3e3 && b < 3e3) {
8920
+ return Math.sqrt(a * a + b * b);
8921
+ }
8922
+ if (a < b) {
8923
+ a = b;
8924
+ b = x / y;
8925
+ } else {
8926
+ b = y / x;
8927
+ }
8928
+ return a * Math.sqrt(1 + b * b);
8929
+ };
8930
+ var parser_exit = function() {
8931
+ throw SyntaxError("Invalid Param");
8932
+ };
8933
+ function logHypot(a, b) {
8934
+ var _a = Math.abs(a);
8935
+ var _b = Math.abs(b);
8936
+ if (a === 0) {
8937
+ return Math.log(_b);
8938
+ }
8939
+ if (b === 0) {
8940
+ return Math.log(_a);
8941
+ }
8942
+ if (_a < 3e3 && _b < 3e3) {
8943
+ return Math.log(a * a + b * b) * 0.5;
8944
+ }
8945
+ a = a / 2;
8946
+ b = b / 2;
8947
+ return 0.5 * Math.log(a * a + b * b) + Math.LN2;
8948
+ }
8949
+ var parse = function(a, b) {
8950
+ var z = { "re": 0, "im": 0 };
8951
+ if (a === void 0 || a === null) {
8952
+ z["re"] = z["im"] = 0;
8953
+ } else if (b !== void 0) {
8954
+ z["re"] = a;
8955
+ z["im"] = b;
8956
+ } else
8957
+ switch (typeof a) {
8958
+ case "object":
8959
+ if ("im" in a && "re" in a) {
8960
+ z["re"] = a["re"];
8961
+ z["im"] = a["im"];
8962
+ } else if ("abs" in a && "arg" in a) {
8963
+ if (!Number.isFinite(a["abs"]) && Number.isFinite(a["arg"])) {
8964
+ return Complex["INFINITY"];
8965
+ }
8966
+ z["re"] = a["abs"] * Math.cos(a["arg"]);
8967
+ z["im"] = a["abs"] * Math.sin(a["arg"]);
8968
+ } else if ("r" in a && "phi" in a) {
8969
+ if (!Number.isFinite(a["r"]) && Number.isFinite(a["phi"])) {
8970
+ return Complex["INFINITY"];
8971
+ }
8972
+ z["re"] = a["r"] * Math.cos(a["phi"]);
8973
+ z["im"] = a["r"] * Math.sin(a["phi"]);
8974
+ } else if (a.length === 2) {
8975
+ z["re"] = a[0];
8976
+ z["im"] = a[1];
8977
+ } else {
8978
+ parser_exit();
8979
+ }
8980
+ break;
8981
+ case "string":
8982
+ z["im"] = /* void */
8983
+ z["re"] = 0;
8984
+ var tokens = a.match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g);
8985
+ var plus = 1;
8986
+ var minus = 0;
8987
+ if (tokens === null) {
8988
+ parser_exit();
8989
+ }
8990
+ for (var i = 0; i < tokens.length; i++) {
8991
+ var c = tokens[i];
8992
+ if (c === " " || c === " " || c === "\n") {
8993
+ } else if (c === "+") {
8994
+ plus++;
8995
+ } else if (c === "-") {
8996
+ minus++;
8997
+ } else if (c === "i" || c === "I") {
8998
+ if (plus + minus === 0) {
8999
+ parser_exit();
9000
+ }
9001
+ if (tokens[i + 1] !== " " && !isNaN(Number(tokens[i + 1]))) {
9002
+ z["im"] += parseFloat((minus % 2 ? "-" : "") + tokens[i + 1]);
9003
+ i++;
9004
+ } else {
9005
+ z["im"] += parseFloat((minus % 2 ? "-" : "") + "1");
9006
+ }
9007
+ plus = minus = 0;
9008
+ } else {
9009
+ if (plus + minus === 0 || isNaN(Number(c))) {
9010
+ parser_exit();
9011
+ }
9012
+ if (tokens[i + 1] === "i" || tokens[i + 1] === "I") {
9013
+ z["im"] += parseFloat((minus % 2 ? "-" : "") + c);
9014
+ i++;
9015
+ } else {
9016
+ z["re"] += parseFloat((minus % 2 ? "-" : "") + c);
9017
+ }
9018
+ plus = minus = 0;
9019
+ }
9020
+ }
9021
+ if (plus + minus > 0) {
9022
+ parser_exit();
9023
+ }
9024
+ break;
9025
+ case "number":
9026
+ z["im"] = 0;
9027
+ z["re"] = a;
9028
+ break;
9029
+ default:
9030
+ parser_exit();
9031
+ }
9032
+ if (isNaN(z["re"]) || isNaN(z["im"])) {
9033
+ }
9034
+ return z;
9035
+ };
9036
+ var Complex = class _Complex {
9037
+ constructor(a, b) {
9038
+ this.re = 0;
9039
+ this.im = 0;
9040
+ var z = parse(a, b);
9041
+ this["re"] = z["re"];
9042
+ this["im"] = z["im"];
9043
+ }
9044
+ /**
9045
+ * Calculates the sign of a complex number, which is a normalized complex
9046
+ *
9047
+ * @returns {Complex}
9048
+ */
9049
+ sign() {
9050
+ var abs = this["abs"]();
9051
+ return new _Complex(this["re"] / abs, this["im"] / abs);
9052
+ }
9053
+ /**
9054
+ * Adds two complex numbers
9055
+ *
9056
+ * @returns {Complex}
9057
+ */
9058
+ add(a, b) {
9059
+ var z = new _Complex(a, b);
9060
+ if (this["isInfinite"]() && z["isInfinite"]()) {
9061
+ return _Complex["NAN"];
9062
+ }
9063
+ if (this["isInfinite"]() || z["isInfinite"]()) {
9064
+ return _Complex["INFINITY"];
9065
+ }
9066
+ return new _Complex(this["re"] + z["re"], this["im"] + z["im"]);
9067
+ }
9068
+ /**
9069
+ * Subtracts two complex numbers
9070
+ *
9071
+ * @returns {Complex}
9072
+ */
9073
+ sub(a, b) {
9074
+ var z = new _Complex(a, b);
9075
+ if (this["isInfinite"]() && z["isInfinite"]()) {
9076
+ return _Complex["NAN"];
9077
+ }
9078
+ if (this["isInfinite"]() || z["isInfinite"]()) {
9079
+ return _Complex["INFINITY"];
9080
+ }
9081
+ return new _Complex(this["re"] - z["re"], this["im"] - z["im"]);
9082
+ }
9083
+ /**
9084
+ * Multiplies two complex numbers
9085
+ *
9086
+ * @returns {Complex}
9087
+ */
9088
+ mul(a, b) {
9089
+ var z = new _Complex(a, b);
9090
+ if (this["isInfinite"]() && z["isZero"]() || this["isZero"]() && z["isInfinite"]()) {
9091
+ return _Complex["NAN"];
9092
+ }
9093
+ if (this["isInfinite"]() || z["isInfinite"]()) {
9094
+ return _Complex["INFINITY"];
9095
+ }
9096
+ if (z["im"] === 0 && this["im"] === 0) {
9097
+ return new _Complex(this["re"] * z["re"], 0);
9098
+ }
9099
+ return new _Complex(this["re"] * z["re"] - this["im"] * z["im"], this["re"] * z["im"] + this["im"] * z["re"]);
9100
+ }
9101
+ /**
9102
+ * Divides two complex numbers
9103
+ *
9104
+ * @returns {Complex}
9105
+ */
9106
+ div(a, b) {
9107
+ var z = new _Complex(a, b);
9108
+ if (this["isZero"]() && z["isZero"]() || this["isInfinite"]() && z["isInfinite"]()) {
9109
+ return _Complex["NAN"];
9110
+ }
9111
+ if (this["isInfinite"]() || z["isZero"]()) {
9112
+ return _Complex["INFINITY"];
9113
+ }
9114
+ if (this["isZero"]() || z["isInfinite"]()) {
9115
+ return _Complex["ZERO"];
9116
+ }
9117
+ a = this["re"];
9118
+ b = this["im"];
9119
+ var c = z["re"];
9120
+ var d = z["im"];
9121
+ var t, x;
9122
+ if (0 === d) {
9123
+ return new _Complex(a / c, b / c);
9124
+ }
9125
+ if (Math.abs(c) < Math.abs(d)) {
9126
+ x = c / d;
9127
+ t = c * x + d;
9128
+ return new _Complex((a * x + b) / t, (b * x - a) / t);
9129
+ } else {
9130
+ x = d / c;
9131
+ t = d * x + c;
9132
+ return new _Complex((a + b * x) / t, (b - a * x) / t);
9133
+ }
9134
+ }
9135
+ /**
9136
+ * Calculate the power of two complex numbers
9137
+ *
9138
+ * @returns {Complex}
9139
+ */
9140
+ pow(a, b) {
9141
+ var z = new _Complex(a, b);
9142
+ a = this["re"];
9143
+ b = this["im"];
9144
+ if (z["isZero"]()) {
9145
+ return _Complex["ONE"];
9146
+ }
9147
+ if (z["im"] === 0) {
9148
+ if (b === 0 && a > 0) {
9149
+ return new _Complex(Math.pow(a, z["re"]), 0);
9150
+ } else if (a === 0) {
9151
+ switch ((z["re"] % 4 + 4) % 4) {
9152
+ case 0:
9153
+ return new _Complex(Math.pow(b, z["re"]), 0);
9154
+ case 1:
9155
+ return new _Complex(0, Math.pow(b, z["re"]));
9156
+ case 2:
9157
+ return new _Complex(-Math.pow(b, z["re"]), 0);
9158
+ case 3:
9159
+ return new _Complex(0, -Math.pow(b, z["re"]));
9160
+ }
9161
+ }
9162
+ }
9163
+ if (a === 0 && b === 0 && z["re"] > 0 && z["im"] >= 0) {
9164
+ return _Complex["ZERO"];
9165
+ }
9166
+ var arg = Math.atan2(b, a);
9167
+ var loh = logHypot(a, b);
9168
+ a = Math.exp(z["re"] * loh - z["im"] * arg);
9169
+ b = z["im"] * loh + z["re"] * arg;
9170
+ return new _Complex(a * Math.cos(b), a * Math.sin(b));
9171
+ }
9172
+ /**
9173
+ * Calculate the complex square root
9174
+ *
9175
+ * @returns {Complex}
9176
+ */
9177
+ sqrt() {
9178
+ var a = this["re"];
9179
+ var b = this["im"];
9180
+ var r = this["abs"]();
9181
+ var re, im;
9182
+ if (a >= 0) {
9183
+ if (b === 0) {
9184
+ return new _Complex(Math.sqrt(a), 0);
9185
+ }
9186
+ re = 0.5 * Math.sqrt(2 * (r + a));
9187
+ } else {
9188
+ re = Math.abs(b) / Math.sqrt(2 * (r - a));
9189
+ }
9190
+ if (a <= 0) {
9191
+ im = 0.5 * Math.sqrt(2 * (r - a));
9192
+ } else {
9193
+ im = Math.abs(b) / Math.sqrt(2 * (r + a));
9194
+ }
9195
+ return new _Complex(re, b < 0 ? -im : im);
9196
+ }
9197
+ /**
9198
+ * Calculate the complex exponent
9199
+ *
9200
+ * @returns {Complex}
9201
+ */
9202
+ exp() {
9203
+ var tmp = Math.exp(this["re"]);
9204
+ if (this["im"] === 0) {
9205
+ }
9206
+ return new _Complex(tmp * Math.cos(this["im"]), tmp * Math.sin(this["im"]));
9207
+ }
9208
+ /**
9209
+ * Calculate the complex exponent and subtracts one.
9210
+ *
9211
+ * This may be more accurate than `Complex(x).exp().sub(1)` if
9212
+ * `x` is small.
9213
+ *
9214
+ * @returns {Complex}
9215
+ */
9216
+ expm1() {
9217
+ var a = this["re"];
9218
+ var b = this["im"];
9219
+ return new _Complex(Math.expm1(a) * Math.cos(b) + cosm1(b), Math.exp(a) * Math.sin(b));
9220
+ }
9221
+ /**
9222
+ * Calculate the natural log
9223
+ *
9224
+ * @returns {Complex}
9225
+ */
9226
+ log() {
9227
+ var a = this["re"];
9228
+ var b = this["im"];
9229
+ if (b === 0 && a > 0) {
9230
+ }
9231
+ return new _Complex(logHypot(a, b), Math.atan2(b, a));
9232
+ }
9233
+ /**
9234
+ * Calculate the magnitude of the complex number
9235
+ *
9236
+ * @returns {number}
9237
+ */
9238
+ abs() {
9239
+ return hypot(this["re"], this["im"]);
9240
+ }
9241
+ /**
9242
+ * Calculate the angle of the complex number
9243
+ *
9244
+ * @returns {number}
9245
+ */
9246
+ arg() {
9247
+ return Math.atan2(this["im"], this["re"]);
9248
+ }
9249
+ /**
9250
+ * Calculate the sine of the complex number
9251
+ *
9252
+ * @returns {Complex}
9253
+ */
9254
+ sin() {
9255
+ var a = this["re"];
9256
+ var b = this["im"];
9257
+ return new _Complex(Math.sin(a) * cosh(b), Math.cos(a) * sinh(b));
9258
+ }
9259
+ /**
9260
+ * Calculate the cosine
9261
+ *
9262
+ * @returns {Complex}
9263
+ */
9264
+ cos() {
9265
+ var a = this["re"];
9266
+ var b = this["im"];
9267
+ return new _Complex(Math.cos(a) * cosh(b), -Math.sin(a) * sinh(b));
9268
+ }
9269
+ /**
9270
+ * Calculate the tangent
9271
+ *
9272
+ * @returns {Complex}
9273
+ */
9274
+ tan() {
9275
+ var a = 2 * this["re"];
9276
+ var b = 2 * this["im"];
9277
+ var d = Math.cos(a) + cosh(b);
9278
+ return new _Complex(Math.sin(a) / d, sinh(b) / d);
9279
+ }
9280
+ /**
9281
+ * Calculate the cotangent
9282
+ *
9283
+ * @returns {Complex}
9284
+ */
9285
+ cot() {
9286
+ var a = 2 * this["re"];
9287
+ var b = 2 * this["im"];
9288
+ var d = Math.cos(a) - cosh(b);
9289
+ return new _Complex(-Math.sin(a) / d, sinh(b) / d);
9290
+ }
9291
+ /**
9292
+ * Calculate the secant
9293
+ *
9294
+ * @returns {Complex}
9295
+ */
9296
+ sec() {
9297
+ var a = this["re"];
9298
+ var b = this["im"];
9299
+ var d = 0.5 * cosh(2 * b) + 0.5 * Math.cos(2 * a);
9300
+ return new _Complex(Math.cos(a) * cosh(b) / d, Math.sin(a) * sinh(b) / d);
9301
+ }
9302
+ /**
9303
+ * Calculate the cosecans
9304
+ *
9305
+ * @returns {Complex}
9306
+ */
9307
+ csc() {
9308
+ var a = this["re"];
9309
+ var b = this["im"];
9310
+ var d = 0.5 * cosh(2 * b) - 0.5 * Math.cos(2 * a);
9311
+ return new _Complex(Math.sin(a) * cosh(b) / d, -Math.cos(a) * sinh(b) / d);
9312
+ }
9313
+ /**
9314
+ * Calculate the complex arcus sinus
9315
+ *
9316
+ * @returns {Complex}
9317
+ */
9318
+ asin() {
9319
+ var a = this["re"];
9320
+ var b = this["im"];
9321
+ var t1 = new _Complex(b * b - a * a + 1, -2 * a * b)["sqrt"]();
9322
+ var t2 = new _Complex(t1["re"] - b, t1["im"] + a)["log"]();
9323
+ return new _Complex(t2["im"], -t2["re"]);
9324
+ }
9325
+ /**
9326
+ * Calculate the complex arcus cosinus
9327
+ *
9328
+ * @returns {Complex}
9329
+ */
9330
+ acos() {
9331
+ var a = this["re"];
9332
+ var b = this["im"];
9333
+ var t1 = new _Complex(b * b - a * a + 1, -2 * a * b)["sqrt"]();
9334
+ var t2 = new _Complex(t1["re"] - b, t1["im"] + a)["log"]();
9335
+ return new _Complex(Math.PI / 2 - t2["im"], t2["re"]);
9336
+ }
9337
+ /**
9338
+ * Calculate the complex arcus tangent
9339
+ *
9340
+ * @returns {Complex}
9341
+ */
9342
+ atan() {
9343
+ var a = this["re"];
9344
+ var b = this["im"];
9345
+ if (a === 0) {
9346
+ if (b === 1) {
9347
+ return new _Complex(0, Infinity);
9348
+ }
9349
+ if (b === -1) {
9350
+ return new _Complex(0, -Infinity);
9351
+ }
9352
+ }
9353
+ var d = a * a + (1 - b) * (1 - b);
9354
+ var t1 = new _Complex((1 - b * b - a * a) / d, -2 * a / d).log();
9355
+ return new _Complex(-0.5 * t1["im"], 0.5 * t1["re"]);
9356
+ }
9357
+ /**
9358
+ * Calculate the complex arcus cotangent
9359
+ *
9360
+ * @returns {Complex}
9361
+ */
9362
+ acot() {
9363
+ var a = this["re"];
9364
+ var b = this["im"];
9365
+ if (b === 0) {
9366
+ return new _Complex(Math.atan2(1, a), 0);
9367
+ }
9368
+ var d = a * a + b * b;
9369
+ return d !== 0 ? new _Complex(a / d, -b / d).atan() : new _Complex(a !== 0 ? a / 0 : 0, b !== 0 ? -b / 0 : 0).atan();
9370
+ }
9371
+ /**
9372
+ * Calculate the complex arcus secant
9373
+ *
9374
+ * @returns {Complex}
9375
+ */
9376
+ asec() {
9377
+ var a = this["re"];
9378
+ var b = this["im"];
9379
+ if (a === 0 && b === 0) {
9380
+ return new _Complex(0, Infinity);
9381
+ }
9382
+ var d = a * a + b * b;
9383
+ return d !== 0 ? new _Complex(a / d, -b / d).acos() : new _Complex(a !== 0 ? a / 0 : 0, b !== 0 ? -b / 0 : 0).acos();
9384
+ }
9385
+ /**
9386
+ * Calculate the complex arcus cosecans
9387
+ *
9388
+ * @returns {Complex}
9389
+ */
9390
+ acsc() {
9391
+ var a = this["re"];
9392
+ var b = this["im"];
9393
+ if (a === 0 && b === 0) {
9394
+ return new _Complex(Math.PI / 2, Infinity);
9395
+ }
9396
+ var d = a * a + b * b;
9397
+ return d !== 0 ? new _Complex(a / d, -b / d).asin() : new _Complex(a !== 0 ? a / 0 : 0, b !== 0 ? -b / 0 : 0).asin();
9398
+ }
9399
+ /**
9400
+ * Calculate the complex sinh
9401
+ *
9402
+ * @returns {Complex}
9403
+ */
9404
+ sinh() {
9405
+ var a = this["re"];
9406
+ var b = this["im"];
9407
+ return new _Complex(sinh(a) * Math.cos(b), cosh(a) * Math.sin(b));
9408
+ }
9409
+ /**
9410
+ * Calculate the complex cosh
9411
+ *
9412
+ * @returns {Complex}
9413
+ */
9414
+ cosh() {
9415
+ var a = this["re"];
9416
+ var b = this["im"];
9417
+ return new _Complex(cosh(a) * Math.cos(b), sinh(a) * Math.sin(b));
9418
+ }
9419
+ /**
9420
+ * Calculate the complex tanh
9421
+ *
9422
+ * @returns {Complex}
9423
+ */
9424
+ tanh() {
9425
+ var a = 2 * this["re"];
9426
+ var b = 2 * this["im"];
9427
+ var d = cosh(a) + Math.cos(b);
9428
+ return new _Complex(sinh(a) / d, Math.sin(b) / d);
9429
+ }
9430
+ /**
9431
+ * Calculate the complex coth
9432
+ *
9433
+ * @returns {Complex}
9434
+ */
9435
+ coth() {
9436
+ var a = 2 * this["re"];
9437
+ var b = 2 * this["im"];
9438
+ var d = cosh(a) - Math.cos(b);
9439
+ return new _Complex(sinh(a) / d, -Math.sin(b) / d);
9440
+ }
9441
+ /**
9442
+ * Calculate the complex coth
9443
+ *
9444
+ * @returns {Complex}
9445
+ */
9446
+ csch() {
9447
+ var a = this["re"];
9448
+ var b = this["im"];
9449
+ var d = Math.cos(2 * b) - cosh(2 * a);
9450
+ return new _Complex(-2 * sinh(a) * Math.cos(b) / d, 2 * cosh(a) * Math.sin(b) / d);
9451
+ }
9452
+ /**
9453
+ * Calculate the complex sech
9454
+ *
9455
+ * @returns {Complex}
9456
+ */
9457
+ sech() {
9458
+ var a = this["re"];
9459
+ var b = this["im"];
9460
+ var d = Math.cos(2 * b) + cosh(2 * a);
9461
+ return new _Complex(2 * cosh(a) * Math.cos(b) / d, -2 * sinh(a) * Math.sin(b) / d);
9462
+ }
9463
+ /**
9464
+ * Calculate the complex asinh
9465
+ *
9466
+ * @returns {Complex}
9467
+ */
9468
+ asinh() {
9469
+ var tmp = this["im"];
9470
+ this["im"] = -this["re"];
9471
+ this["re"] = tmp;
9472
+ var res = this["asin"]();
9473
+ this["re"] = -this["im"];
9474
+ this["im"] = tmp;
9475
+ tmp = res["re"];
9476
+ res["re"] = -res["im"];
9477
+ res["im"] = tmp;
9478
+ return res;
9479
+ }
9480
+ /**
9481
+ * Calculate the complex acosh
9482
+ *
9483
+ * @returns {Complex}
9484
+ */
9485
+ acosh() {
9486
+ var res = this["acos"]();
9487
+ if (res["im"] <= 0) {
9488
+ var tmp = res["re"];
9489
+ res["re"] = -res["im"];
9490
+ res["im"] = tmp;
9491
+ } else {
9492
+ var tmp = res["im"];
9493
+ res["im"] = -res["re"];
9494
+ res["re"] = tmp;
9495
+ }
9496
+ return res;
9497
+ }
9498
+ /**
9499
+ * Calculate the complex atanh
9500
+ *
9501
+ * @returns {Complex}
9502
+ */
9503
+ atanh() {
9504
+ var a = this["re"];
9505
+ var b = this["im"];
9506
+ var noIM = a > 1 && b === 0;
9507
+ var oneMinus = 1 - a;
9508
+ var onePlus = 1 + a;
9509
+ var d = oneMinus * oneMinus + b * b;
9510
+ 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);
9511
+ var temp = x["re"];
9512
+ x["re"] = logHypot(x["re"], x["im"]) / 2;
9513
+ x["im"] = Math.atan2(x["im"], temp) / 2;
9514
+ if (noIM) {
9515
+ x["im"] = -x["im"];
9516
+ }
9517
+ return x;
9518
+ }
9519
+ /**
9520
+ * Calculate the complex acoth
9521
+ *
9522
+ * @returns {Complex}
9523
+ */
9524
+ acoth() {
9525
+ var a = this["re"];
9526
+ var b = this["im"];
9527
+ if (a === 0 && b === 0) {
9528
+ return new _Complex(0, Math.PI / 2);
9529
+ }
9530
+ var d = a * a + b * b;
9531
+ return d !== 0 ? new _Complex(a / d, -b / d).atanh() : new _Complex(a !== 0 ? a / 0 : 0, b !== 0 ? -b / 0 : 0).atanh();
9532
+ }
9533
+ /**
9534
+ * Calculate the complex acsch
9535
+ *
9536
+ * @returns {Complex}
9537
+ */
9538
+ acsch() {
9539
+ var a = this["re"];
9540
+ var b = this["im"];
9541
+ if (b === 0) {
9542
+ return new _Complex(a !== 0 ? Math.log(a + Math.sqrt(a * a + 1)) : Infinity, 0);
9543
+ }
9544
+ var d = a * a + b * b;
9545
+ return d !== 0 ? new _Complex(a / d, -b / d).asinh() : new _Complex(a !== 0 ? a / 0 : 0, b !== 0 ? -b / 0 : 0).asinh();
9546
+ }
9547
+ /**
9548
+ * Calculate the complex asech
9549
+ *
9550
+ * @returns {Complex}
9551
+ */
9552
+ asech() {
9553
+ var a = this["re"];
9554
+ var b = this["im"];
9555
+ if (this["isZero"]()) {
9556
+ return _Complex["INFINITY"];
9557
+ }
9558
+ var d = a * a + b * b;
9559
+ return d !== 0 ? new _Complex(a / d, -b / d).acosh() : new _Complex(a !== 0 ? a / 0 : 0, b !== 0 ? -b / 0 : 0).acosh();
9560
+ }
9561
+ /**
9562
+ * Calculate the complex inverse 1/z
9563
+ *
9564
+ * @returns {Complex}
9565
+ */
9566
+ inverse() {
9567
+ if (this["isZero"]()) {
9568
+ return _Complex["INFINITY"];
9569
+ }
9570
+ if (this["isInfinite"]()) {
9571
+ return _Complex["ZERO"];
9572
+ }
9573
+ var a = this["re"];
9574
+ var b = this["im"];
9575
+ var d = a * a + b * b;
9576
+ return new _Complex(a / d, -b / d);
9577
+ }
9578
+ /**
9579
+ * Returns the complex conjugate
9580
+ *
9581
+ * @returns {Complex}
9582
+ */
9583
+ conjugate() {
9584
+ return new _Complex(this["re"], -this["im"]);
9585
+ }
9586
+ /**
9587
+ * Gets the negated complex number
9588
+ *
9589
+ * @returns {Complex}
9590
+ */
9591
+ neg() {
9592
+ return new _Complex(-this["re"], -this["im"]);
9593
+ }
9594
+ /**
9595
+ * Ceils the actual complex number
9596
+ *
9597
+ * @returns {Complex}
9598
+ */
9599
+ ceil(places) {
9600
+ places = Math.pow(10, places || 0);
9601
+ return new _Complex(Math.ceil(this["re"] * places) / places, Math.ceil(this["im"] * places) / places);
9602
+ }
9603
+ /**
9604
+ * Floors the actual complex number
9605
+ *
9606
+ * @returns {Complex}
9607
+ */
9608
+ floor(places) {
9609
+ places = Math.pow(10, places || 0);
9610
+ return new _Complex(Math.floor(this["re"] * places) / places, Math.floor(this["im"] * places) / places);
9611
+ }
9612
+ /**
9613
+ * Ceils the actual complex number
9614
+ *
9615
+ * @returns {Complex}
9616
+ */
9617
+ round(places) {
9618
+ places = Math.pow(10, places || 0);
9619
+ return new _Complex(Math.round(this["re"] * places) / places, Math.round(this["im"] * places) / places);
9620
+ }
9621
+ /**
9622
+ * Compares two complex numbers
9623
+ *
9624
+ * **Note:** new Complex(Infinity).equals(Infinity) === false
9625
+ *
9626
+ * @returns {boolean}
9627
+ */
9628
+ equals(a, b) {
9629
+ var z = new _Complex(a, b);
9630
+ return Math.abs(z["re"] - this["re"]) <= _Complex["EPSILON"] && Math.abs(z["im"] - this["im"]) <= _Complex["EPSILON"];
9631
+ }
9632
+ /**
9633
+ * Clones the actual object
9634
+ *
9635
+ * @returns {Complex}
9636
+ */
9637
+ clone() {
9638
+ return new _Complex(this["re"], this["im"]);
9639
+ }
9640
+ /**
9641
+ * Gets a string of the actual complex number
9642
+ *
9643
+ * @returns {string}
9644
+ */
9645
+ toString() {
9646
+ var a = this["re"];
9647
+ var b = this["im"];
9648
+ var ret = "";
9649
+ if (this["isNaN"]()) {
9650
+ return "NaN";
9651
+ }
9652
+ if (this["isInfinite"]()) {
9653
+ return "Infinity";
9654
+ }
9655
+ if (Math.abs(a) < _Complex["EPSILON"]) {
9656
+ a = 0;
9657
+ }
9658
+ if (Math.abs(b) < _Complex["EPSILON"]) {
9659
+ b = 0;
9660
+ }
9661
+ if (b === 0) {
9662
+ return ret + a;
9663
+ }
9664
+ if (a !== 0) {
9665
+ ret += a;
9666
+ ret += " ";
9667
+ if (b < 0) {
9668
+ b = -b;
9669
+ ret += "-";
9670
+ } else {
9671
+ ret += "+";
9672
+ }
9673
+ ret += " ";
9674
+ } else if (b < 0) {
9675
+ b = -b;
9676
+ ret += "-";
9677
+ }
9678
+ if (1 !== b) {
9679
+ ret += b;
9680
+ }
9681
+ return ret + "i";
9682
+ }
9683
+ /**
9684
+ * Returns the actual number as a vector
9685
+ *
9686
+ * @returns {Array}
9687
+ */
9688
+ toVector() {
9689
+ return [this["re"], this["im"]];
9690
+ }
9691
+ /**
9692
+ * Returns the actual real value of the current object
9693
+ *
9694
+ * @returns {number|null}
9695
+ */
9696
+ valueOf() {
9697
+ if (this["im"] === 0) {
9698
+ return this["re"];
9699
+ }
9700
+ return null;
9701
+ }
9702
+ /**
9703
+ * Determines whether a complex number is not on the Riemann sphere.
9704
+ *
9705
+ * @returns {boolean}
9706
+ */
9707
+ isNaN() {
9708
+ return isNaN(this["re"]) || isNaN(this["im"]);
9709
+ }
9710
+ /**
9711
+ * Determines whether or not a complex number is at the zero pole of the
9712
+ * Riemann sphere.
9713
+ *
9714
+ * @returns {boolean}
9715
+ */
9716
+ isZero() {
9717
+ return this["im"] === 0 && this["re"] === 0;
9718
+ }
9719
+ /**
9720
+ * Determines whether a complex number is not at the infinity pole of the
9721
+ * Riemann sphere.
9722
+ *
9723
+ * @returns {boolean}
9724
+ */
9725
+ isFinite() {
9726
+ return isFinite(this["re"]) && isFinite(this["im"]);
9727
+ }
9728
+ /**
9729
+ * Determines whether or not a complex number is at the infinity pole of the
9730
+ * Riemann sphere.
9731
+ *
9732
+ * @returns {boolean}
9733
+ */
9734
+ isInfinite() {
9735
+ return !(this["isNaN"]() || this["isFinite"]());
9736
+ }
9737
+ };
9738
+ Complex["ZERO"] = new Complex(0, 0);
9739
+ Complex["ONE"] = new Complex(1, 0);
9740
+ Complex["I"] = new Complex(0, 1);
9741
+ Complex["PI"] = new Complex(Math.PI, 0);
9742
+ Complex["E"] = new Complex(Math.E, 0);
9743
+ Complex["INFINITY"] = new Complex(Infinity, Infinity);
9744
+ Complex["NAN"] = new Complex(NaN, NaN);
9745
+ Complex["EPSILON"] = 1e-15;
9746
+
8668
9747
  // src/compute-engine/numerics/numeric-complex.ts
9748
+ var LANCZOS_G = 7;
9749
+ var LANCZOS_P = [
9750
+ 0.9999999999998099,
9751
+ 676.5203681218851,
9752
+ -1259.1392167224028,
9753
+ 771.3234287776531,
9754
+ -176.6150291621406,
9755
+ 12.507343278686905,
9756
+ -0.13857109526572012,
9757
+ 9984369578019572e-21,
9758
+ 15056327351493116e-23
9759
+ ];
9760
+ var SQRT_2PI = Math.sqrt(2 * Math.PI);
9761
+ var HALF_LOG_2PI = 0.5 * Math.log(2 * Math.PI);
8669
9762
  function gamma2(c) {
8670
- return c;
9763
+ if (c.re < 0.5) {
9764
+ const sinPiZ = c.mul(Math.PI).sin();
9765
+ return new Complex(Math.PI, 0).div(sinPiZ.mul(gamma2(new Complex(1, 0).sub(c))));
9766
+ }
9767
+ const z = c.sub(1);
9768
+ let x = new Complex(LANCZOS_P[0], 0);
9769
+ for (let i = 1; i < LANCZOS_G + 2; i++)
9770
+ x = x.add(new Complex(LANCZOS_P[i], 0).div(z.add(i)));
9771
+ const t = z.add(LANCZOS_G + 0.5);
9772
+ return new Complex(SQRT_2PI, 0).mul(t.pow(z.add(0.5))).mul(t.neg().exp()).mul(x);
8671
9773
  }
8672
9774
  function gammaln2(c) {
8673
- return c;
9775
+ if (c.re < 0.5) {
9776
+ const sinPiZ = c.mul(Math.PI).sin();
9777
+ return new Complex(Math.PI, 0).div(sinPiZ).log().sub(gammaln2(new Complex(1, 0).sub(c)));
9778
+ }
9779
+ const z = c.sub(1);
9780
+ let x = new Complex(LANCZOS_P[0], 0);
9781
+ for (let i = 1; i < LANCZOS_G + 2; i++)
9782
+ x = x.add(new Complex(LANCZOS_P[i], 0).div(z.add(i)));
9783
+ const t = z.add(LANCZOS_G + 0.5);
9784
+ return new Complex(HALF_LOG_2PI, 0).add(z.add(0.5).mul(t.log())).sub(t).add(x.log());
8674
9785
  }
8675
9786
 
8676
9787
  // src/numerics.ts
8677
- var version = "0.58.0";
9788
+ var version = "0.59.0";
8678
9789
  return __toCommonJS(numerics_exports);
8679
9790
  })();
9791
+ /*! Bundled license information:
9792
+
9793
+ complex-esm/dist/src/complex.js:
9794
+ (**
9795
+ * @license Complex.js v2.1.1 12/05/2020
9796
+ *
9797
+ * Copyright (c) 2020, Robert Eisele (robert@xarg.org)
9798
+ * Dual licensed under the MIT or GPL Version 2 licenses.
9799
+ **)
9800
+ */
8680
9801
  Object.assign(exports, Numerics); Object.defineProperty(exports, '__esModule', { value: true });}));