@danielsimonjr/mathts-functions 0.64.3 → 0.65.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 (393) hide show
  1. package/dist/algebra/decomposition/lup.d.ts +1 -1
  2. package/dist/algebra/decomposition/lup.d.ts.map +1 -1
  3. package/dist/algebra/decomposition/qr.d.ts +1 -1
  4. package/dist/algebra/decomposition/qr.d.ts.map +1 -1
  5. package/dist/algebra/decomposition/schur.d.ts +1 -1
  6. package/dist/algebra/decomposition/schur.d.ts.map +1 -1
  7. package/dist/algebra/decomposition/slu.d.ts +1 -1
  8. package/dist/algebra/decomposition/slu.d.ts.map +1 -1
  9. package/dist/algebra/leafCount.d.ts +1 -1
  10. package/dist/algebra/leafCount.d.ts.map +1 -1
  11. package/dist/algebra/lyap.d.ts +1 -1
  12. package/dist/algebra/lyap.d.ts.map +1 -1
  13. package/dist/algebra/polynomialRoot.d.ts +1 -1
  14. package/dist/algebra/polynomialRoot.d.ts.map +1 -1
  15. package/dist/algebra/rationalize.d.ts +1 -1
  16. package/dist/algebra/rationalize.d.ts.map +1 -1
  17. package/dist/algebra/resolve.d.ts +1 -1
  18. package/dist/algebra/resolve.d.ts.map +1 -1
  19. package/dist/algebra/simplifyCore.d.ts +1 -1
  20. package/dist/algebra/simplifyCore.d.ts.map +1 -1
  21. package/dist/algebra/solver/lsolve.d.ts +1 -1
  22. package/dist/algebra/solver/lsolve.d.ts.map +1 -1
  23. package/dist/algebra/solver/lsolveAll.d.ts +2 -2
  24. package/dist/algebra/solver/lsolveAll.d.ts.map +1 -1
  25. package/dist/algebra/solver/lusolve.d.ts +1 -1
  26. package/dist/algebra/solver/lusolve.d.ts.map +1 -1
  27. package/dist/algebra/solver/usolve.d.ts +1 -1
  28. package/dist/algebra/solver/usolve.d.ts.map +1 -1
  29. package/dist/algebra/solver/usolveAll.d.ts +2 -2
  30. package/dist/algebra/solver/usolveAll.d.ts.map +1 -1
  31. package/dist/algebra/sparse/csAmd.d.ts.map +1 -1
  32. package/dist/algebra/sparse/csCounts.d.ts.map +1 -1
  33. package/dist/algebra/sylvester.d.ts +1 -1
  34. package/dist/algebra/sylvester.d.ts.map +1 -1
  35. package/dist/algebra/symbolicEqual.d.ts +1 -1
  36. package/dist/algebra/symbolicEqual.d.ts.map +1 -1
  37. package/dist/arithmetic/abs.d.ts +1 -1
  38. package/dist/arithmetic/abs.d.ts.map +1 -1
  39. package/dist/arithmetic/addScalar.d.ts +1 -1
  40. package/dist/arithmetic/addScalar.d.ts.map +1 -1
  41. package/dist/arithmetic/cbrt.d.ts +1 -1
  42. package/dist/arithmetic/cbrt.d.ts.map +1 -1
  43. package/dist/arithmetic/ceil.d.ts +2 -2
  44. package/dist/arithmetic/ceil.d.ts.map +1 -1
  45. package/dist/arithmetic/cube.d.ts +1 -1
  46. package/dist/arithmetic/cube.d.ts.map +1 -1
  47. package/dist/arithmetic/divide.d.ts +2 -1
  48. package/dist/arithmetic/divide.d.ts.map +1 -1
  49. package/dist/arithmetic/divideScalar.d.ts +1 -1
  50. package/dist/arithmetic/divideScalar.d.ts.map +1 -1
  51. package/dist/arithmetic/exp.d.ts +1 -1
  52. package/dist/arithmetic/exp.d.ts.map +1 -1
  53. package/dist/arithmetic/expm1.d.ts +1 -1
  54. package/dist/arithmetic/expm1.d.ts.map +1 -1
  55. package/dist/arithmetic/fix.d.ts +2 -2
  56. package/dist/arithmetic/fix.d.ts.map +1 -1
  57. package/dist/arithmetic/floor.d.ts +2 -2
  58. package/dist/arithmetic/floor.d.ts.map +1 -1
  59. package/dist/arithmetic/gcd.d.ts.map +1 -1
  60. package/dist/arithmetic/hypot.d.ts.map +1 -1
  61. package/dist/arithmetic/log.d.ts +1 -1
  62. package/dist/arithmetic/log.d.ts.map +1 -1
  63. package/dist/arithmetic/log10.d.ts +1 -1
  64. package/dist/arithmetic/log10.d.ts.map +1 -1
  65. package/dist/arithmetic/log1p.d.ts +1 -1
  66. package/dist/arithmetic/log1p.d.ts.map +1 -1
  67. package/dist/arithmetic/log2.d.ts +1 -1
  68. package/dist/arithmetic/log2.d.ts.map +1 -1
  69. package/dist/arithmetic/mod.d.ts +1 -1
  70. package/dist/arithmetic/mod.d.ts.map +1 -1
  71. package/dist/arithmetic/multiplyScalar.d.ts +1 -1
  72. package/dist/arithmetic/multiplyScalar.d.ts.map +1 -1
  73. package/dist/arithmetic/norm.d.ts.map +1 -1
  74. package/dist/arithmetic/nthRoot.d.ts.map +1 -1
  75. package/dist/arithmetic/pow.d.ts +1 -1
  76. package/dist/arithmetic/pow.d.ts.map +1 -1
  77. package/dist/arithmetic/round.d.ts +1 -1
  78. package/dist/arithmetic/round.d.ts.map +1 -1
  79. package/dist/arithmetic/sign.d.ts +1 -1
  80. package/dist/arithmetic/sign.d.ts.map +1 -1
  81. package/dist/arithmetic/sqrt.d.ts +1 -1
  82. package/dist/arithmetic/sqrt.d.ts.map +1 -1
  83. package/dist/arithmetic/square.d.ts +1 -1
  84. package/dist/arithmetic/square.d.ts.map +1 -1
  85. package/dist/arithmetic/subtract.d.ts +1 -1
  86. package/dist/arithmetic/subtract.d.ts.map +1 -1
  87. package/dist/arithmetic/subtractScalar.d.ts +1 -1
  88. package/dist/arithmetic/subtractScalar.d.ts.map +1 -1
  89. package/dist/arithmetic/unaryMinus.d.ts +1 -1
  90. package/dist/arithmetic/unaryMinus.d.ts.map +1 -1
  91. package/dist/arithmetic/unaryPlus.d.ts +1 -1
  92. package/dist/arithmetic/unaryPlus.d.ts.map +1 -1
  93. package/dist/bitwise/bitAnd.d.ts +1 -1
  94. package/dist/bitwise/bitAnd.d.ts.map +1 -1
  95. package/dist/bitwise/bitNot.d.ts +1 -1
  96. package/dist/bitwise/bitNot.d.ts.map +1 -1
  97. package/dist/bitwise/bitOr.d.ts +1 -1
  98. package/dist/bitwise/bitOr.d.ts.map +1 -1
  99. package/dist/bitwise/bitXor.d.ts +1 -1
  100. package/dist/bitwise/bitXor.d.ts.map +1 -1
  101. package/dist/bitwise/leftShift.d.ts +1 -1
  102. package/dist/bitwise/leftShift.d.ts.map +1 -1
  103. package/dist/bitwise/rightArithShift.d.ts +1 -1
  104. package/dist/bitwise/rightArithShift.d.ts.map +1 -1
  105. package/dist/bitwise/rightLogShift.d.ts +1 -1
  106. package/dist/bitwise/rightLogShift.d.ts.map +1 -1
  107. package/dist/bitwise/useMatrixForArrayScalar.d.ts.map +1 -1
  108. package/dist/{chunk-UMUT2YEC.js → chunk-5A2EZLXV.js} +77 -181
  109. package/dist/combinatorics/bellNumbers.d.ts +1 -1
  110. package/dist/combinatorics/bellNumbers.d.ts.map +1 -1
  111. package/dist/combinatorics/catalan.d.ts +1 -1
  112. package/dist/combinatorics/catalan.d.ts.map +1 -1
  113. package/dist/combinatorics/composition.d.ts +1 -1
  114. package/dist/combinatorics/composition.d.ts.map +1 -1
  115. package/dist/combinatorics/stirlingS2.d.ts +1 -1
  116. package/dist/combinatorics/stirlingS2.d.ts.map +1 -1
  117. package/dist/complex/arg.d.ts +1 -1
  118. package/dist/complex/arg.d.ts.map +1 -1
  119. package/dist/complex/conj.d.ts +1 -1
  120. package/dist/complex/conj.d.ts.map +1 -1
  121. package/dist/complex/im.d.ts +1 -1
  122. package/dist/complex/im.d.ts.map +1 -1
  123. package/dist/complex/re.d.ts +1 -1
  124. package/dist/complex/re.d.ts.map +1 -1
  125. package/dist/core/function/typed.d.ts +11 -1
  126. package/dist/core/function/typed.d.ts.map +1 -1
  127. package/dist/factories/index.d.ts +184 -184
  128. package/dist/factories/index.d.ts.map +1 -1
  129. package/dist/geometry/distance.d.ts +1 -1
  130. package/dist/geometry/distance.d.ts.map +1 -1
  131. package/dist/geometry/intersect.d.ts +1 -1
  132. package/dist/geometry/intersect.d.ts.map +1 -1
  133. package/dist/index.d.ts +1 -0
  134. package/dist/index.d.ts.map +1 -1
  135. package/dist/index.js +66 -1927
  136. package/dist/logical/and.d.ts +1 -1
  137. package/dist/logical/and.d.ts.map +1 -1
  138. package/dist/logical/not.d.ts +1 -1
  139. package/dist/logical/not.d.ts.map +1 -1
  140. package/dist/logical/or.d.ts +1 -1
  141. package/dist/logical/or.d.ts.map +1 -1
  142. package/dist/logical/xor.d.ts +1 -1
  143. package/dist/logical/xor.d.ts.map +1 -1
  144. package/dist/matrix/column.d.ts +2 -1
  145. package/dist/matrix/column.d.ts.map +1 -1
  146. package/dist/matrix/concat.d.ts +1 -1
  147. package/dist/matrix/concat.d.ts.map +1 -1
  148. package/dist/matrix/count.d.ts +1 -1
  149. package/dist/matrix/count.d.ts.map +1 -1
  150. package/dist/matrix/cross.d.ts +1 -1
  151. package/dist/matrix/cross.d.ts.map +1 -1
  152. package/dist/matrix/ctranspose.d.ts +1 -1
  153. package/dist/matrix/ctranspose.d.ts.map +1 -1
  154. package/dist/matrix/det.d.ts +2 -1
  155. package/dist/matrix/det.d.ts.map +1 -1
  156. package/dist/matrix/diag.d.ts +1 -1
  157. package/dist/matrix/diag.d.ts.map +1 -1
  158. package/dist/matrix/diff.d.ts.map +1 -1
  159. package/dist/matrix/dot.d.ts +1 -1
  160. package/dist/matrix/dot.d.ts.map +1 -1
  161. package/dist/matrix/eigs/complexEigs.d.ts.map +1 -1
  162. package/dist/matrix/eigs/realSymmetric.d.ts.map +1 -1
  163. package/dist/matrix/eigs.d.ts +2 -1
  164. package/dist/matrix/eigs.d.ts.map +1 -1
  165. package/dist/matrix/fft.d.ts +1 -1
  166. package/dist/matrix/fft.d.ts.map +1 -1
  167. package/dist/matrix/filter.d.ts +1 -1
  168. package/dist/matrix/filter.d.ts.map +1 -1
  169. package/dist/matrix/flatten.d.ts +1 -1
  170. package/dist/matrix/flatten.d.ts.map +1 -1
  171. package/dist/matrix/forEach.d.ts +1 -1
  172. package/dist/matrix/forEach.d.ts.map +1 -1
  173. package/dist/matrix/getMatrixDataType.d.ts +1 -1
  174. package/dist/matrix/getMatrixDataType.d.ts.map +1 -1
  175. package/dist/matrix/identity.d.ts +1 -1
  176. package/dist/matrix/identity.d.ts.map +1 -1
  177. package/dist/matrix/ifft.d.ts +2 -1
  178. package/dist/matrix/ifft.d.ts.map +1 -1
  179. package/dist/matrix/inv.d.ts +2 -1
  180. package/dist/matrix/inv.d.ts.map +1 -1
  181. package/dist/matrix/kron.d.ts +2 -1
  182. package/dist/matrix/kron.d.ts.map +1 -1
  183. package/dist/matrix/map.d.ts +1 -1
  184. package/dist/matrix/map.d.ts.map +1 -1
  185. package/dist/matrix/matrixFromColumns.d.ts +2 -1
  186. package/dist/matrix/matrixFromColumns.d.ts.map +1 -1
  187. package/dist/matrix/matrixFromRows.d.ts +2 -1
  188. package/dist/matrix/matrixFromRows.d.ts.map +1 -1
  189. package/dist/matrix/ones.d.ts +1 -1
  190. package/dist/matrix/ones.d.ts.map +1 -1
  191. package/dist/matrix/partitionSelect.d.ts +2 -1
  192. package/dist/matrix/partitionSelect.d.ts.map +1 -1
  193. package/dist/matrix/range.d.ts +1 -1
  194. package/dist/matrix/range.d.ts.map +1 -1
  195. package/dist/matrix/reshape.d.ts +1 -1
  196. package/dist/matrix/reshape.d.ts.map +1 -1
  197. package/dist/matrix/resize.d.ts +1 -1
  198. package/dist/matrix/resize.d.ts.map +1 -1
  199. package/dist/matrix/row.d.ts +2 -1
  200. package/dist/matrix/row.d.ts.map +1 -1
  201. package/dist/matrix/size.d.ts +1 -1
  202. package/dist/matrix/size.d.ts.map +1 -1
  203. package/dist/matrix/sqrtm.d.ts +2 -1
  204. package/dist/matrix/sqrtm.d.ts.map +1 -1
  205. package/dist/matrix/squeeze.d.ts +1 -1
  206. package/dist/matrix/squeeze.d.ts.map +1 -1
  207. package/dist/matrix/subset.d.ts +1 -1
  208. package/dist/matrix/subset.d.ts.map +1 -1
  209. package/dist/matrix/trace.d.ts +1 -1
  210. package/dist/matrix/trace.d.ts.map +1 -1
  211. package/dist/matrix/transpose.d.ts +1 -1
  212. package/dist/matrix/transpose.d.ts.map +1 -1
  213. package/dist/matrix/utils/zerosAndOnes.d.ts +1 -1
  214. package/dist/matrix/utils/zerosAndOnes.d.ts.map +1 -1
  215. package/dist/matrix/zeros.d.ts +1 -1
  216. package/dist/matrix/zeros.d.ts.map +1 -1
  217. package/dist/numeric/solveODE.d.ts +2 -2
  218. package/dist/numeric/solveODE.d.ts.map +1 -1
  219. package/dist/probability/bernoulli.d.ts +1 -1
  220. package/dist/probability/bernoulli.d.ts.map +1 -1
  221. package/dist/probability/combinations.d.ts +1 -1
  222. package/dist/probability/combinations.d.ts.map +1 -1
  223. package/dist/probability/combinationsWithRep.d.ts +1 -1
  224. package/dist/probability/combinationsWithRep.d.ts.map +1 -1
  225. package/dist/probability/factorial.d.ts +1 -1
  226. package/dist/probability/factorial.d.ts.map +1 -1
  227. package/dist/probability/gamma.d.ts +1 -1
  228. package/dist/probability/gamma.d.ts.map +1 -1
  229. package/dist/probability/kldivergence.d.ts +1 -1
  230. package/dist/probability/kldivergence.d.ts.map +1 -1
  231. package/dist/probability/lgamma.d.ts +1 -1
  232. package/dist/probability/lgamma.d.ts.map +1 -1
  233. package/dist/probability/multinomial.d.ts +1 -1
  234. package/dist/probability/multinomial.d.ts.map +1 -1
  235. package/dist/probability/permutations.d.ts +1 -1
  236. package/dist/probability/permutations.d.ts.map +1 -1
  237. package/dist/probability/pickRandom.d.ts +1 -1
  238. package/dist/probability/pickRandom.d.ts.map +1 -1
  239. package/dist/probability/random.d.ts +2 -2
  240. package/dist/probability/random.d.ts.map +1 -1
  241. package/dist/probability/randomInt.d.ts +1 -1
  242. package/dist/probability/randomInt.d.ts.map +1 -1
  243. package/dist/relational/compare.d.ts +2 -2
  244. package/dist/relational/compare.d.ts.map +1 -1
  245. package/dist/relational/compareNatural.d.ts +1 -1
  246. package/dist/relational/compareNatural.d.ts.map +1 -1
  247. package/dist/relational/deepEqual.d.ts +1 -1
  248. package/dist/relational/deepEqual.d.ts.map +1 -1
  249. package/dist/relational/equal.d.ts +2 -2
  250. package/dist/relational/equal.d.ts.map +1 -1
  251. package/dist/relational/equalScalar.d.ts +1 -1
  252. package/dist/relational/equalScalar.d.ts.map +1 -1
  253. package/dist/relational/equalText.d.ts +1 -1
  254. package/dist/relational/equalText.d.ts.map +1 -1
  255. package/dist/relational/larger.d.ts +2 -2
  256. package/dist/relational/larger.d.ts.map +1 -1
  257. package/dist/relational/largerEq.d.ts +2 -2
  258. package/dist/relational/largerEq.d.ts.map +1 -1
  259. package/dist/relational/smaller.d.ts +2 -2
  260. package/dist/relational/smaller.d.ts.map +1 -1
  261. package/dist/relational/smallerEq.d.ts +2 -2
  262. package/dist/relational/smallerEq.d.ts.map +1 -1
  263. package/dist/relational/unequal.d.ts +2 -2
  264. package/dist/relational/unequal.d.ts.map +1 -1
  265. package/dist/set/setCartesian.d.ts +1 -1
  266. package/dist/set/setCartesian.d.ts.map +1 -1
  267. package/dist/set/setDifference.d.ts +1 -1
  268. package/dist/set/setDifference.d.ts.map +1 -1
  269. package/dist/set/setIntersect.d.ts +1 -1
  270. package/dist/set/setIntersect.d.ts.map +1 -1
  271. package/dist/set/setSymDifference.d.ts +1 -1
  272. package/dist/set/setSymDifference.d.ts.map +1 -1
  273. package/dist/set/setUnion.d.ts +1 -1
  274. package/dist/set/setUnion.d.ts.map +1 -1
  275. package/dist/signal/freqz.d.ts +2 -1
  276. package/dist/signal/freqz.d.ts.map +1 -1
  277. package/dist/signal/zpk2tf.d.ts +2 -1
  278. package/dist/signal/zpk2tf.d.ts.map +1 -1
  279. package/dist/special/erf.d.ts +1 -1
  280. package/dist/special/erf.d.ts.map +1 -1
  281. package/dist/special/zeta.d.ts +1 -1
  282. package/dist/special/zeta.d.ts.map +1 -1
  283. package/dist/statistics/corr.d.ts +1 -1
  284. package/dist/statistics/corr.d.ts.map +1 -1
  285. package/dist/statistics/cumsum.d.ts +1 -1
  286. package/dist/statistics/cumsum.d.ts.map +1 -1
  287. package/dist/statistics/mad.d.ts +1 -1
  288. package/dist/statistics/mad.d.ts.map +1 -1
  289. package/dist/statistics/max.d.ts +1 -1
  290. package/dist/statistics/max.d.ts.map +1 -1
  291. package/dist/statistics/mean.d.ts +1 -1
  292. package/dist/statistics/mean.d.ts.map +1 -1
  293. package/dist/statistics/median.d.ts +1 -1
  294. package/dist/statistics/median.d.ts.map +1 -1
  295. package/dist/statistics/min.d.ts +1 -1
  296. package/dist/statistics/min.d.ts.map +1 -1
  297. package/dist/statistics/mode.d.ts +1 -1
  298. package/dist/statistics/mode.d.ts.map +1 -1
  299. package/dist/statistics/prod.d.ts +1 -1
  300. package/dist/statistics/prod.d.ts.map +1 -1
  301. package/dist/statistics/quantileSeq.d.ts +1 -1
  302. package/dist/statistics/quantileSeq.d.ts.map +1 -1
  303. package/dist/statistics/std.d.ts +1 -1
  304. package/dist/statistics/std.d.ts.map +1 -1
  305. package/dist/statistics/sum.d.ts +1 -1
  306. package/dist/statistics/sum.d.ts.map +1 -1
  307. package/dist/statistics/variance.d.ts +1 -1
  308. package/dist/statistics/variance.d.ts.map +1 -1
  309. package/dist/string/bin.d.ts +1 -1
  310. package/dist/string/bin.d.ts.map +1 -1
  311. package/dist/string/format.d.ts +1 -1
  312. package/dist/string/format.d.ts.map +1 -1
  313. package/dist/string/hex.d.ts +1 -1
  314. package/dist/string/hex.d.ts.map +1 -1
  315. package/dist/string/oct.d.ts +1 -1
  316. package/dist/string/oct.d.ts.map +1 -1
  317. package/dist/string/print.d.ts +1 -1
  318. package/dist/string/print.d.ts.map +1 -1
  319. package/dist/trigonometry/acos.d.ts +1 -1
  320. package/dist/trigonometry/acos.d.ts.map +1 -1
  321. package/dist/trigonometry/asin.d.ts +1 -1
  322. package/dist/trigonometry/asin.d.ts.map +1 -1
  323. package/dist/trigonometry/atan.d.ts +1 -1
  324. package/dist/trigonometry/atan.d.ts.map +1 -1
  325. package/dist/trigonometry/atan2.d.ts +1 -1
  326. package/dist/trigonometry/atan2.d.ts.map +1 -1
  327. package/dist/trigonometry/cos.d.ts +1 -1
  328. package/dist/trigonometry/cos.d.ts.map +1 -1
  329. package/dist/trigonometry/sin.d.ts +1 -1
  330. package/dist/trigonometry/sin.d.ts.map +1 -1
  331. package/dist/trigonometry/tan.d.ts +1 -1
  332. package/dist/trigonometry/tan.d.ts.map +1 -1
  333. package/dist/type/matrix/function/index.d.ts +1 -1
  334. package/dist/type/matrix/function/index.d.ts.map +1 -1
  335. package/dist/type/unit/function/createUnit.d.ts +1 -1
  336. package/dist/type/unit/function/createUnit.d.ts.map +1 -1
  337. package/dist/type/unit/function/splitUnit.d.ts +1 -1
  338. package/dist/type/unit/function/splitUnit.d.ts.map +1 -1
  339. package/dist/type/unit/function/unit.d.ts +1 -1
  340. package/dist/type/unit/function/unit.d.ts.map +1 -1
  341. package/dist/type/unit/physicalConstants.d.ts +4 -7
  342. package/dist/type/unit/physicalConstants.d.ts.map +1 -1
  343. package/dist/typed/algebra.d.ts +14 -5
  344. package/dist/typed/algebra.d.ts.map +1 -1
  345. package/dist/typed/geometry.d.ts +2 -6
  346. package/dist/typed/geometry.d.ts.map +1 -1
  347. package/dist/typed/hypothesis.d.ts +13 -0
  348. package/dist/typed/hypothesis.d.ts.map +1 -1
  349. package/dist/typed/numeric.d.ts +1 -1
  350. package/dist/typed/numeric.d.ts.map +1 -1
  351. package/dist/typed/signal.d.ts +1 -1
  352. package/dist/typed/signal.d.ts.map +1 -1
  353. package/dist/unit/to.d.ts +1 -1
  354. package/dist/unit/to.d.ts.map +1 -1
  355. package/dist/unit/toBest.d.ts +1 -1
  356. package/dist/unit/toBest.d.ts.map +1 -1
  357. package/dist/utils/bignumber/bitwise.d.ts +1 -0
  358. package/dist/utils/bignumber/bitwise.d.ts.map +1 -1
  359. package/dist/utils/clone.d.ts +1 -1
  360. package/dist/utils/clone.d.ts.map +1 -1
  361. package/dist/utils/hasNumericValue.d.ts +1 -1
  362. package/dist/utils/hasNumericValue.d.ts.map +1 -1
  363. package/dist/utils/isInteger.d.ts +1 -1
  364. package/dist/utils/isInteger.d.ts.map +1 -1
  365. package/dist/utils/isNaN.d.ts +1 -1
  366. package/dist/utils/isNaN.d.ts.map +1 -1
  367. package/dist/utils/isNegative.d.ts +1 -1
  368. package/dist/utils/isNegative.d.ts.map +1 -1
  369. package/dist/utils/isPositive.d.ts +1 -1
  370. package/dist/utils/isPositive.d.ts.map +1 -1
  371. package/dist/utils/isPrime.d.ts +1 -1
  372. package/dist/utils/isPrime.d.ts.map +1 -1
  373. package/dist/utils/isZero.d.ts +1 -1
  374. package/dist/utils/isZero.d.ts.map +1 -1
  375. package/dist/utils/typeOf.d.ts +1 -1
  376. package/dist/utils/typeOf.d.ts.map +1 -1
  377. package/dist/wasm/WasmLoader.d.ts +28 -210
  378. package/dist/wasm/WasmLoader.d.ts.map +1 -1
  379. package/dist/wasm/bitwise/wasm-bridge.d.ts.map +1 -1
  380. package/dist/wasm/bridges/common.d.ts +2 -0
  381. package/dist/wasm/bridges/common.d.ts.map +1 -1
  382. package/dist/wasm/elementwise/wasm-bridge.d.ts.map +1 -1
  383. package/dist/wasm/interpolation/wasm-bridge.d.ts.map +1 -1
  384. package/dist/wasm/mathts-as.wasm +0 -0
  385. package/dist/wasm/policy.d.ts +37 -0
  386. package/dist/wasm/policy.d.ts.map +1 -0
  387. package/dist/wasm/poly/wasm-bridge.d.ts.map +1 -1
  388. package/dist/wasm/signal/wasm-bridge.d.ts.map +1 -1
  389. package/dist/wasm/sort/wasm-bridge.d.ts.map +1 -1
  390. package/dist/wasm/special/wasm-bridge.d.ts.map +1 -1
  391. package/dist/wasm/wasm-manifest.json +1 -1
  392. package/dist/{wasm-bridge-C44GQ3DS.js → wasm-bridge-74YOKWIS.js} +1 -1
  393. package/package.json +8 -8
package/dist/index.js CHANGED
@@ -6,14 +6,16 @@ import {
6
6
  asReadReturnedI32,
7
7
  getWasm,
8
8
  isAsWasm,
9
+ isWasmLoaded,
10
+ loadWasm,
9
11
  makeUnaryArrayDispatch,
10
12
  runChainPtr,
11
13
  runUnaryPtr,
12
14
  sortF64Dispatch,
13
- wasmLoader,
15
+ wasmPolicyAllows,
14
16
  withAsF64,
15
17
  withAsI32
16
- } from "./chunk-UMUT2YEC.js";
18
+ } from "./chunk-5A2EZLXV.js";
17
19
 
18
20
  // src/typed/index.ts
19
21
  var typed_exports = {};
@@ -1342,7 +1344,7 @@ var WASM_ELEMENTWISE_THRESHOLD = 1024;
1342
1344
  var kernelName = (op) => `array_${op}_ptr`;
1343
1345
  function elementwiseUnaryDispatch(op, xs) {
1344
1346
  const n = xs.length;
1345
- if (n < WASM_ELEMENTWISE_THRESHOLD) return null;
1347
+ if (n < WASM_ELEMENTWISE_THRESHOLD || !wasmPolicyAllows(kernelName(op), n)) return null;
1346
1348
  const wasm = getWasm();
1347
1349
  if (!wasm) return null;
1348
1350
  const fn = wasm[kernelName(op)];
@@ -1353,6 +1355,7 @@ function elementwiseUnaryDispatch(op, xs) {
1353
1355
  function elementwiseChainDispatch(ops, xs) {
1354
1356
  const n = xs.length;
1355
1357
  if (ops.length === 0 || n < WASM_ELEMENTWISE_THRESHOLD) return null;
1358
+ if (!wasmPolicyAllows("fused_chain", n)) return null;
1356
1359
  const wasm = getWasm();
1357
1360
  if (!wasm) return null;
1358
1361
  const mem = wasm.memory;
@@ -3681,7 +3684,7 @@ function chirpZTransformJS(samples, m, phiStartRe, phiStartIm, phiStepRe, phiSte
3681
3684
  }
3682
3685
  function applyWindowDispatch(samples, windowName) {
3683
3686
  const wt = windowTypeCode(windowName);
3684
- const wasm = getWasm();
3687
+ const wasm = wasmPolicyAllows("apply_window_f64", samples.length) ? getWasm() : null;
3685
3688
  if (wasm && isAsWasm(wasm)) {
3686
3689
  try {
3687
3690
  const out = withAsF64(wasm, [samples], (mod3, [h]) => {
@@ -3700,7 +3703,7 @@ function applyWindowDispatch(samples, windowName) {
3700
3703
  function welchPSDDispatch(samples, frameLength, overlap, windowName) {
3701
3704
  const n = samples.length;
3702
3705
  const wt = windowTypeCode(windowName);
3703
- if (n >= WASM_SIGNAL_THRESHOLD && n >= frameLength) {
3706
+ if (n >= WASM_SIGNAL_THRESHOLD && n >= frameLength && wasmPolicyAllows("welch_psd_f64", n)) {
3704
3707
  const wasm = getWasm();
3705
3708
  if (wasm && isAsWasm(wasm)) {
3706
3709
  try {
@@ -3726,7 +3729,7 @@ function welchPSDDispatch(samples, frameLength, overlap, windowName) {
3726
3729
  }
3727
3730
  function bartlettPSDDispatch(samples, frameLength) {
3728
3731
  const n = samples.length;
3729
- if (n >= WASM_SIGNAL_THRESHOLD && n >= frameLength) {
3732
+ if (n >= WASM_SIGNAL_THRESHOLD && n >= frameLength && wasmPolicyAllows("bartlett_psd_f64", n)) {
3730
3733
  const wasm = getWasm();
3731
3734
  if (wasm && isAsWasm(wasm)) {
3732
3735
  try {
@@ -3747,7 +3750,7 @@ function bartlettPSDDispatch(samples, frameLength) {
3747
3750
  }
3748
3751
  function goertzelDispatch(samples, targetFreq, sampleRate) {
3749
3752
  const n = samples.length;
3750
- if (n >= WASM_SIGNAL_THRESHOLD) {
3753
+ if (n >= WASM_SIGNAL_THRESHOLD && wasmPolicyAllows("goertzel_f64", n)) {
3751
3754
  const wasm = getWasm();
3752
3755
  if (wasm && isAsWasm(wasm)) {
3753
3756
  try {
@@ -3769,7 +3772,7 @@ function goertzelDispatch(samples, targetFreq, sampleRate) {
3769
3772
  }
3770
3773
  function chirpZTransformDispatch(samples, m, phiStartRe, phiStartIm, phiStepRe, phiStepIm) {
3771
3774
  const n = samples.length;
3772
- if (Math.max(n, m) >= WASM_SIGNAL_THRESHOLD) {
3775
+ if (Math.max(n, m) >= WASM_SIGNAL_THRESHOLD && wasmPolicyAllows("chirp_z_transform_f64", Math.max(n, m))) {
3773
3776
  const wasm = getWasm();
3774
3777
  if (wasm && isAsWasm(wasm)) {
3775
3778
  try {
@@ -3931,7 +3934,6 @@ function idwtPeriodization(approx, detail, wavelet) {
3931
3934
  }
3932
3935
 
3933
3936
  // src/typed/signal.ts
3934
- var WASM_THRESHOLD = 64;
3935
3937
  function isPowerOf22(n) {
3936
3938
  return n > 0 && (n & n - 1) === 0;
3937
3939
  }
@@ -4212,23 +4214,6 @@ function unwrapPhase(phase) {
4212
4214
  }
4213
4215
  function dct(x) {
4214
4216
  const N2 = x.length;
4215
- if (N2 >= WASM_THRESHOLD) {
4216
- const wasm = wasmLoader.getModule();
4217
- if (wasm) {
4218
- try {
4219
- const inAlloc = wasmLoader.allocateFloat64Array(x);
4220
- const outAlloc = wasmLoader.allocateFloat64ArrayEmpty(N2);
4221
- try {
4222
- wasm.dct_wasm(inAlloc.ptr, outAlloc.ptr, N2);
4223
- return Array.from(outAlloc.array);
4224
- } finally {
4225
- wasmLoader.free(inAlloc.ptr);
4226
- wasmLoader.free(outAlloc.ptr);
4227
- }
4228
- } catch {
4229
- }
4230
- }
4231
- }
4232
4217
  const result = new Array(N2);
4233
4218
  for (let k = 0; k < N2; k++) {
4234
4219
  let sum3 = 0;
@@ -4241,23 +4226,6 @@ function dct(x) {
4241
4226
  }
4242
4227
  function idct(X) {
4243
4228
  const N2 = X.length;
4244
- if (N2 >= WASM_THRESHOLD) {
4245
- const wasm = wasmLoader.getModule();
4246
- if (wasm) {
4247
- try {
4248
- const inAlloc = wasmLoader.allocateFloat64Array(X);
4249
- const outAlloc = wasmLoader.allocateFloat64ArrayEmpty(N2);
4250
- try {
4251
- wasm.idct_wasm(inAlloc.ptr, outAlloc.ptr, N2);
4252
- return Array.from(outAlloc.array);
4253
- } finally {
4254
- wasmLoader.free(inAlloc.ptr);
4255
- wasmLoader.free(outAlloc.ptr);
4256
- }
4257
- } catch {
4258
- }
4259
- }
4260
- }
4261
4229
  const result = new Array(N2);
4262
4230
  for (let n = 0; n < N2; n++) {
4263
4231
  let sum3 = X[0] * Math.sqrt(1 / N2);
@@ -4270,23 +4238,6 @@ function idct(X) {
4270
4238
  }
4271
4239
  function dst(x) {
4272
4240
  const N2 = x.length;
4273
- if (N2 >= WASM_THRESHOLD) {
4274
- const wasm = wasmLoader.getModule();
4275
- if (wasm) {
4276
- try {
4277
- const inAlloc = wasmLoader.allocateFloat64Array(x);
4278
- const outAlloc = wasmLoader.allocateFloat64ArrayEmpty(N2);
4279
- try {
4280
- wasm.dst_wasm(inAlloc.ptr, outAlloc.ptr, N2);
4281
- return Array.from(outAlloc.array);
4282
- } finally {
4283
- wasmLoader.free(inAlloc.ptr);
4284
- wasmLoader.free(outAlloc.ptr);
4285
- }
4286
- } catch {
4287
- }
4288
- }
4289
- }
4290
4241
  const result = new Array(N2);
4291
4242
  for (let k = 0; k < N2; k++) {
4292
4243
  let sum3 = 0;
@@ -4299,23 +4250,6 @@ function dst(x) {
4299
4250
  }
4300
4251
  function idst(X) {
4301
4252
  const N2 = X.length;
4302
- if (N2 >= WASM_THRESHOLD) {
4303
- const wasm = wasmLoader.getModule();
4304
- if (wasm) {
4305
- try {
4306
- const inAlloc = wasmLoader.allocateFloat64Array(X);
4307
- const outAlloc = wasmLoader.allocateFloat64ArrayEmpty(N2);
4308
- try {
4309
- wasm.idst_wasm(inAlloc.ptr, outAlloc.ptr, N2);
4310
- return Array.from(outAlloc.array);
4311
- } finally {
4312
- wasmLoader.free(inAlloc.ptr);
4313
- wasmLoader.free(outAlloc.ptr);
4314
- }
4315
- } catch {
4316
- }
4317
- }
4318
- }
4319
4253
  const result = new Array(N2);
4320
4254
  for (let n = 0; n < N2; n++) {
4321
4255
  let sum3 = 0;
@@ -4332,28 +4266,6 @@ function dwt(x, wavelet = "haar") {
4332
4266
  if (n < 2) throw new Error("dwt: signal must have at least 2 samples");
4333
4267
  const half = Math.floor(n / 2);
4334
4268
  if (wavelet === "haar" || wavelet === "db1") {
4335
- if (n >= WASM_THRESHOLD && n % 2 === 0) {
4336
- const wasm = wasmLoader.getModule();
4337
- if (wasm) {
4338
- try {
4339
- const inAlloc = wasmLoader.allocateFloat64Array(x);
4340
- const approxAlloc = wasmLoader.allocateFloat64ArrayEmpty(half);
4341
- const detailAlloc = wasmLoader.allocateFloat64ArrayEmpty(half);
4342
- try {
4343
- wasm.dwt_wasm(inAlloc.ptr, approxAlloc.ptr, detailAlloc.ptr, n);
4344
- return {
4345
- approx: Array.from(approxAlloc.array),
4346
- detail: Array.from(detailAlloc.array)
4347
- };
4348
- } finally {
4349
- wasmLoader.free(inAlloc.ptr);
4350
- wasmLoader.free(approxAlloc.ptr);
4351
- wasmLoader.free(detailAlloc.ptr);
4352
- }
4353
- } catch {
4354
- }
4355
- }
4356
- }
4357
4269
  const approx = new Array(half);
4358
4270
  const detail = new Array(half);
4359
4271
  const s = 1 / Math.SQRT2;
@@ -4469,30 +4381,6 @@ function invFourier(F, omega, t) {
4469
4381
  function hilbertTransform(x) {
4470
4382
  const n = x.length;
4471
4383
  const N2 = nextPowerOf2(n);
4472
- if (N2 >= WASM_THRESHOLD) {
4473
- const wasm = wasmLoader.getModule();
4474
- if (wasm) {
4475
- try {
4476
- const paddedInput = new Array(N2).fill(0);
4477
- for (let i = 0; i < n; i++) paddedInput[i] = x[i];
4478
- const zeros4 = new Array(N2).fill(0);
4479
- const inReAlloc = wasmLoader.allocateFloat64Array(paddedInput);
4480
- const inImAlloc = wasmLoader.allocateFloat64Array(zeros4);
4481
- const outReAlloc = wasmLoader.allocateFloat64ArrayEmpty(N2);
4482
- const outImAlloc = wasmLoader.allocateFloat64ArrayEmpty(N2);
4483
- try {
4484
- wasm.hilbert_wasm(inReAlloc.ptr, inImAlloc.ptr, outReAlloc.ptr, outImAlloc.ptr, N2);
4485
- return Array.from(outImAlloc.array.slice(0, n));
4486
- } finally {
4487
- wasmLoader.free(inReAlloc.ptr);
4488
- wasmLoader.free(inImAlloc.ptr);
4489
- wasmLoader.free(outReAlloc.ptr);
4490
- wasmLoader.free(outImAlloc.ptr);
4491
- }
4492
- } catch {
4493
- }
4494
- }
4495
- }
4496
4384
  const real = new Float64Array(N2);
4497
4385
  const imag = new Float64Array(N2);
4498
4386
  for (let i = 0; i < n; i++) real[i] = x[i];
@@ -4519,39 +4407,6 @@ async function spectrogram(x, opts) {
4519
4407
  const winType = opts?.window ?? "hann";
4520
4408
  const nfft = nextPowerOf2(windowSize);
4521
4409
  const nFreqs = nfft / 2 + 1;
4522
- if (x.length >= WASM_THRESHOLD && (winType === "hann" || winType === "hanning")) {
4523
- const wasm = wasmLoader.getModule();
4524
- if (wasm) {
4525
- try {
4526
- const numFrames = Math.floor((x.length - windowSize) / hopSize) + 1;
4527
- if (numFrames > 0) {
4528
- const inAlloc = wasmLoader.allocateFloat64Array(x);
4529
- const outAlloc = wasmLoader.allocateFloat64ArrayEmpty(numFrames * nFreqs);
4530
- try {
4531
- const frames = wasm.spectrogram_wasm(
4532
- inAlloc.ptr,
4533
- outAlloc.ptr,
4534
- x.length,
4535
- windowSize,
4536
- hopSize
4537
- );
4538
- const magnitude2 = [];
4539
- const times2 = [];
4540
- const frequencies2 = Array.from({ length: nFreqs }, (_, i) => i / nfft);
4541
- for (let f = 0; f < frames; f++) {
4542
- magnitude2.push(Array.from(outAlloc.array.slice(f * nFreqs, (f + 1) * nFreqs)));
4543
- times2.push(f * hopSize + windowSize / 2);
4544
- }
4545
- return { magnitude: magnitude2, frequencies: frequencies2, times: times2 };
4546
- } finally {
4547
- wasmLoader.free(inAlloc.ptr);
4548
- wasmLoader.free(outAlloc.ptr);
4549
- }
4550
- }
4551
- } catch {
4552
- }
4553
- }
4554
- }
4555
4410
  const win = windowFunction(windowSize, winType);
4556
4411
  const magnitude = [];
4557
4412
  const times = [];
@@ -4609,26 +4464,6 @@ async function spectrogram(x, opts) {
4609
4464
  function periodogram(x, opts) {
4610
4465
  const nfft = opts?.nfft ?? nextPowerOf2(x.length);
4611
4466
  const winType = opts?.window ?? "hann";
4612
- if (x.length >= WASM_THRESHOLD && (winType === "hann" || winType === "hanning") && nfft === nextPowerOf2(x.length)) {
4613
- const wasm = wasmLoader.getModule();
4614
- if (wasm) {
4615
- try {
4616
- const nFreqs2 = nfft / 2 + 1;
4617
- const inAlloc = wasmLoader.allocateFloat64Array(x);
4618
- const outAlloc = wasmLoader.allocateFloat64ArrayEmpty(nFreqs2);
4619
- try {
4620
- wasm.periodogram_wasm(inAlloc.ptr, outAlloc.ptr, x.length);
4621
- const psd2 = Array.from(outAlloc.array);
4622
- const frequencies2 = Array.from({ length: nFreqs2 }, (_, i) => i / nfft);
4623
- return { psd: psd2, frequencies: frequencies2 };
4624
- } finally {
4625
- wasmLoader.free(inAlloc.ptr);
4626
- wasmLoader.free(outAlloc.ptr);
4627
- }
4628
- } catch {
4629
- }
4630
- }
4631
- }
4632
4467
  const win = windowFunction(x.length, winType);
4633
4468
  let winPower = 0;
4634
4469
  for (let i = 0; i < x.length; i++) winPower += win[i] * win[i];
@@ -4686,25 +4521,6 @@ function _sincFilter(order, cutoff, type) {
4686
4521
  function _convolve(x, h) {
4687
4522
  const n = x.length;
4688
4523
  const m = h.length;
4689
- if (n >= WASM_THRESHOLD) {
4690
- const wasm = wasmLoader.getModule();
4691
- if (wasm) {
4692
- try {
4693
- const inAlloc = wasmLoader.allocateFloat64Array(x);
4694
- const coeffAlloc = wasmLoader.allocateFloat64Array(h);
4695
- const outAlloc = wasmLoader.allocateFloat64ArrayEmpty(n);
4696
- try {
4697
- wasm.fir_filter_wasm(inAlloc.ptr, coeffAlloc.ptr, outAlloc.ptr, n, m);
4698
- return Array.from(outAlloc.array);
4699
- } finally {
4700
- wasmLoader.free(inAlloc.ptr);
4701
- wasmLoader.free(coeffAlloc.ptr);
4702
- wasmLoader.free(outAlloc.ptr);
4703
- }
4704
- } catch {
4705
- }
4706
- }
4707
- }
4708
4524
  const offset = Math.floor(m / 2);
4709
4525
  const result = new Array(n).fill(0);
4710
4526
  for (let i = 0; i < n; i++) {
@@ -4917,10 +4733,11 @@ var UNARY_OPS = {
4917
4733
  };
4918
4734
  function runBinaryBitwiseWasm(op, a, b) {
4919
4735
  if (a.length !== b.length) return null;
4736
+ const names = BINARY_OPS[op];
4737
+ if (!wasmPolicyAllows(names.as, a.length)) return null;
4920
4738
  const wasm = getWasm();
4921
4739
  if (!wasm || !isAsWasm(wasm)) return null;
4922
4740
  const n = a.length;
4923
- const names = BINARY_OPS[op];
4924
4741
  try {
4925
4742
  return withAsI32(wasm, [a, b, new Int32Array(n)], (mod3, [ha, hb, hr]) => {
4926
4743
  mod3[names.as](ha, hb, hr);
@@ -4931,10 +4748,11 @@ function runBinaryBitwiseWasm(op, a, b) {
4931
4748
  }
4932
4749
  }
4933
4750
  function runUnaryBitwiseWasm(op, a) {
4751
+ const names = UNARY_OPS[op];
4752
+ if (!wasmPolicyAllows(names.as, a.length)) return null;
4934
4753
  const wasm = getWasm();
4935
4754
  if (!wasm || !isAsWasm(wasm)) return null;
4936
4755
  const n = a.length;
4937
- const names = UNARY_OPS[op];
4938
4756
  try {
4939
4757
  return withAsI32(wasm, [a, new Int32Array(n)], (mod3, [ha, hr]) => {
4940
4758
  mod3[names.as](ha, hr);
@@ -6657,7 +6475,7 @@ var besselJ1Dispatch = makeUnaryArrayDispatch({
6657
6475
  });
6658
6476
  function besselOrderDispatch(order, xs, asName, js) {
6659
6477
  const n = xs.length;
6660
- if (n >= WASM_SPECIAL_THRESHOLD) {
6478
+ if (n >= WASM_SPECIAL_THRESHOLD && wasmPolicyAllows(asName, n)) {
6661
6479
  const wasm = getWasm();
6662
6480
  if (wasm && isAsWasm(wasm)) {
6663
6481
  try {
@@ -6919,7 +6737,7 @@ function ellipticPiIncompleteScalar(n, phi, m) {
6919
6737
  }
6920
6738
  function multiArrayDispatch(name254, inputs, js) {
6921
6739
  const n = inputs[0].length;
6922
- if (n >= WASM_SPECIAL_THRESHOLD) {
6740
+ if (n >= WASM_SPECIAL_THRESHOLD && wasmPolicyAllows(name254, n)) {
6923
6741
  const wasm = getWasm();
6924
6742
  if (wasm && isAsWasm(wasm)) {
6925
6743
  try {
@@ -8573,8 +8391,6 @@ var typedDistributions = {
8573
8391
 
8574
8392
  // src/typed/geometry.ts
8575
8393
  import { computePool as computePool7 } from "@danielsimonjr/mathts-parallel";
8576
- var GEOMETRY_WASM_THRESHOLD = 32;
8577
- var HULL3D_WASM_THRESHOLD = 1024;
8578
8394
  function angle2D(v1, v2) {
8579
8395
  const dot9 = v1[0] * v2[0] + v1[1] * v2[1];
8580
8396
  const mag1 = Math.sqrt(v1[0] ** 2 + v1[1] ** 2);
@@ -8925,49 +8741,6 @@ function voronoiDiagram(points, bounds) {
8925
8741
  "voronoiDiagram: bounds must be a [xMin, yMin, xMax, yMax] tuple (the clipping box)"
8926
8742
  );
8927
8743
  }
8928
- const n = points.length;
8929
- if (n >= GEOMETRY_WASM_THRESHOLD) {
8930
- const wasm = wasmLoader.getModule();
8931
- if (wasm) {
8932
- try {
8933
- const flat = new Float64Array(n * 2);
8934
- for (let i = 0; i < n; i++) {
8935
- flat[i * 2] = points[i][0];
8936
- flat[i * 2 + 1] = points[i][1];
8937
- }
8938
- const ptsAlloc = wasmLoader.allocateFloat64Array(flat);
8939
- const boundsAlloc = wasmLoader.allocateFloat64Array(new Float64Array(bounds));
8940
- const maxVerts = 2 * n;
8941
- const maxEdges = 6 * n;
8942
- const vertsAlloc = wasmLoader.allocateFloat64ArrayEmpty(maxVerts * 2);
8943
- const edgesAlloc = wasmLoader.allocateInt32ArrayEmpty(maxEdges * 2);
8944
- try {
8945
- const packed = wasm.voronoi_wasm(
8946
- ptsAlloc.ptr,
8947
- n,
8948
- boundsAlloc.ptr,
8949
- vertsAlloc.ptr,
8950
- edgesAlloc.ptr,
8951
- maxVerts,
8952
- maxEdges
8953
- );
8954
- const numVerts = packed & 65535;
8955
- const vertices2 = [];
8956
- for (let i = 0; i < numVerts; i++) {
8957
- vertices2.push([vertsAlloc.array[i * 2], vertsAlloc.array[i * 2 + 1]]);
8958
- }
8959
- const regions2 = Array.from({ length: n }, () => []);
8960
- return { vertices: vertices2, regions: regions2 };
8961
- } finally {
8962
- wasmLoader.free(ptsAlloc.ptr);
8963
- wasmLoader.free(boundsAlloc.ptr);
8964
- wasmLoader.free(vertsAlloc.ptr);
8965
- wasmLoader.free(edgesAlloc.ptr);
8966
- }
8967
- } catch {
8968
- }
8969
- }
8970
- }
8971
8744
  const triangles = delaunayTriangulation(points);
8972
8745
  const vertices = [];
8973
8746
  const triCircumcenters = /* @__PURE__ */ new Map();
@@ -9045,46 +8818,6 @@ function distanceNDSq(a, b) {
9045
8818
  function nearestNeighbor(points, query) {
9046
8819
  const n = points.length;
9047
8820
  if (n === 0) return null;
9048
- const dims = points[0].length;
9049
- if (n >= GEOMETRY_WASM_THRESHOLD) {
9050
- const wasm = wasmLoader.getModule();
9051
- if (wasm) {
9052
- try {
9053
- const flat = new Float64Array(n * dims);
9054
- for (let i = 0; i < n; i++) {
9055
- for (let d = 0; d < dims; d++) {
9056
- flat[i * dims + d] = points[i][d];
9057
- }
9058
- }
9059
- const ptsAlloc = wasmLoader.allocateFloat64Array(flat);
9060
- const stride = 3 + dims;
9061
- const treeAlloc = wasmLoader.allocateFloat64ArrayEmpty(n * stride);
9062
- const queryAlloc = wasmLoader.allocateFloat64Array(new Float64Array(query));
9063
- try {
9064
- const treeSize = wasm.kdtree_build_wasm(ptsAlloc.ptr, n, dims, treeAlloc.ptr);
9065
- const nearestIdx = wasm.kdtree_nearest_wasm(
9066
- treeAlloc.ptr,
9067
- queryAlloc.ptr,
9068
- dims,
9069
- treeSize
9070
- );
9071
- if (nearestIdx >= 0 && nearestIdx < n) {
9072
- const pt = points[nearestIdx];
9073
- let distSq = 0;
9074
- for (let d = 0; d < dims; d++) {
9075
- distSq += (pt[d] - query[d]) ** 2;
9076
- }
9077
- return { point: pt, index: nearestIdx, distance: Math.sqrt(distSq) };
9078
- }
9079
- } finally {
9080
- wasmLoader.free(ptsAlloc.ptr);
9081
- wasmLoader.free(treeAlloc.ptr);
9082
- wasmLoader.free(queryAlloc.ptr);
9083
- }
9084
- } catch {
9085
- }
9086
- }
9087
- }
9088
8821
  const root2 = kdTree(points);
9089
8822
  return kdTreeNearest(root2, query);
9090
8823
  }
@@ -9093,45 +8826,6 @@ function convexHull3D(points) {
9093
8826
  if (n < 4) {
9094
8827
  throw new Error("convexHull3D: at least 4 non-coplanar points are required");
9095
8828
  }
9096
- if (n >= HULL3D_WASM_THRESHOLD) {
9097
- const wasm = wasmLoader.getModule();
9098
- if (wasm) {
9099
- try {
9100
- const flat = new Float64Array(n * 3);
9101
- for (let i = 0; i < n; i++) {
9102
- flat[i * 3] = points[i][0];
9103
- flat[i * 3 + 1] = points[i][1];
9104
- flat[i * 3 + 2] = points[i][2];
9105
- }
9106
- const ptsAlloc = wasmLoader.allocateFloat64Array(flat);
9107
- const maxFaces = 4 * n;
9108
- const facesAlloc = wasmLoader.allocateInt32ArrayEmpty(maxFaces * 3);
9109
- try {
9110
- const nFaces = wasm.convex_hull_3d_wasm(ptsAlloc.ptr, n, facesAlloc.ptr, maxFaces);
9111
- if (nFaces === -1) {
9112
- throw new Error("convexHull3D: WASM output buffer overflow \u2014 retrying with JS");
9113
- }
9114
- if (nFaces === 0) {
9115
- throw new Error("convexHull3D: degenerate input (all points co-planar or collinear)");
9116
- }
9117
- const result = [];
9118
- for (let i = 0; i < nFaces; i++) {
9119
- result.push([
9120
- facesAlloc.array[i * 3],
9121
- facesAlloc.array[i * 3 + 1],
9122
- facesAlloc.array[i * 3 + 2]
9123
- ]);
9124
- }
9125
- return result;
9126
- } finally {
9127
- wasmLoader.free(ptsAlloc.ptr);
9128
- wasmLoader.free(facesAlloc.ptr);
9129
- }
9130
- } catch (err) {
9131
- if (err instanceof Error && err.message.includes("degenerate")) throw err;
9132
- }
9133
- }
9134
- }
9135
8829
  return convexHull3DJS(points);
9136
8830
  }
9137
8831
  function convexHull3DJS(points) {
@@ -9309,7 +9003,7 @@ function polyDivModJS(num2, den) {
9309
9003
  }
9310
9004
  function polyMulDispatch(a, b) {
9311
9005
  const bigEnough = a.length >= WASM_POLY_THRESHOLD || b.length >= WASM_POLY_THRESHOLD;
9312
- if (bigEnough) {
9006
+ if (bigEnough && wasmPolicyAllows("poly_mul_f64", Math.max(a.length, b.length))) {
9313
9007
  const wasm = getWasm();
9314
9008
  if (wasm && isAsWasm(wasm)) {
9315
9009
  try {
@@ -9328,7 +9022,7 @@ function polyMulDispatch(a, b) {
9328
9022
  function polyDivModDispatch(num2, den) {
9329
9023
  if (den.length === 0) throw new Error("Division by zero polynomial");
9330
9024
  const bigEnough = num2.length >= WASM_POLY_THRESHOLD;
9331
- if (bigEnough) {
9025
+ if (bigEnough && wasmPolicyAllows("poly_div_mod_f64", num2.length)) {
9332
9026
  const wasm = getWasm();
9333
9027
  if (wasm && isAsWasm(wasm)) {
9334
9028
  try {
@@ -9431,7 +9125,7 @@ function discriminantJS(p) {
9431
9125
  }
9432
9126
  function resultantDispatch(p, q) {
9433
9127
  const bigEnough = p.length >= WASM_POLY_THRESHOLD || q.length >= WASM_POLY_THRESHOLD;
9434
- if (bigEnough) {
9128
+ if (bigEnough && wasmPolicyAllows("poly_resultant_f64", Math.max(p.length, q.length))) {
9435
9129
  const wasm = getWasm();
9436
9130
  if (wasm && isAsWasm(wasm)) {
9437
9131
  try {
@@ -9449,7 +9143,7 @@ function resultantDispatch(p, q) {
9449
9143
  }
9450
9144
  function discriminantDispatch(p) {
9451
9145
  const bigEnough = p.length >= WASM_POLY_THRESHOLD;
9452
- if (bigEnough) {
9146
+ if (bigEnough && wasmPolicyAllows("poly_discriminant_f64", p.length)) {
9453
9147
  const wasm = getWasm();
9454
9148
  if (wasm && isAsWasm(wasm)) {
9455
9149
  try {
@@ -9562,7 +9256,7 @@ function legendreFitJSFallback(xs, ys, degree3) {
9562
9256
  }
9563
9257
  function fitDispatch(xs, ys, degree3, asName, jsFallback) {
9564
9258
  if (xs.length !== ys.length) throw new Error("xs and ys must have the same length");
9565
- if (xs.length >= WASM_POLY_FIT_THRESHOLD) {
9259
+ if (xs.length >= WASM_POLY_FIT_THRESHOLD && wasmPolicyAllows(asName, xs.length)) {
9566
9260
  const wasm = getWasm();
9567
9261
  if (wasm && isAsWasm(wasm)) {
9568
9262
  try {
@@ -11402,6 +11096,9 @@ function polyder(coeffs, n = 1) {
11402
11096
  return result;
11403
11097
  }
11404
11098
  function polynomialGCD(a, b) {
11099
+ if (a.every(Number.isSafeInteger) && b.every(Number.isSafeInteger)) {
11100
+ return integerPolynomialGCD(a, b);
11101
+ }
11405
11102
  let r0 = trimPoly([...a]);
11406
11103
  let r1 = trimPoly([...b]);
11407
11104
  while (r1.length > 1 || r1[0] !== 0) {
@@ -11415,6 +11112,12 @@ function polynomialGCD(a, b) {
11415
11112
  }
11416
11113
  return r0;
11417
11114
  }
11115
+ function integerPolynomialGCD(a, b) {
11116
+ const g = polyGcdZ(a.map(BigInt), b.map(BigInt));
11117
+ if (g.length === 0) return [0];
11118
+ const lead = Number(g[g.length - 1]);
11119
+ return g.map((c) => Number(c) / lead);
11120
+ }
11418
11121
  function polynomialLCM(a, b) {
11419
11122
  const gcd2 = polynomialGCD(a, b);
11420
11123
  const [quotient] = polyDivMod(polymul(a, b), gcd2);
@@ -12583,7 +12286,7 @@ function tridiagSolveJS(diag2, lower, upper, rhs) {
12583
12286
  }
12584
12287
  function tridiagSolveDispatch(diag2, lower, upper, rhs) {
12585
12288
  const n = diag2.length;
12586
- if (n >= WASM_TRIDIAG_THRESHOLD) {
12289
+ if (n >= WASM_TRIDIAG_THRESHOLD && wasmPolicyAllows("tridiag_solve_f64", n)) {
12587
12290
  const wasm = getWasm();
12588
12291
  if (wasm && isAsWasm(wasm)) {
12589
12292
  try {
@@ -12624,7 +12327,7 @@ function dividedDifferenceJS(xs, ys) {
12624
12327
  }
12625
12328
  function dividedDifferenceDispatch(xs, ys) {
12626
12329
  const n = xs.length;
12627
- if (n >= WASM_INTERP_THRESHOLD) {
12330
+ if (n >= WASM_INTERP_THRESHOLD && wasmPolicyAllows("divided_difference_f64", n)) {
12628
12331
  const wasm = getWasm();
12629
12332
  if (wasm && isAsWasm(wasm)) {
12630
12333
  try {
@@ -13221,7 +12924,6 @@ function factory(name254, dependencies254, create, meta) {
13221
12924
 
13222
12925
  // src/numeric/solveODE.ts
13223
12926
  import { DenseMatrix as DenseMatrix3, lu, luSolve } from "@danielsimonjr/mathts-matrix";
13224
- var WASM_ODE_THRESHOLD = 10;
13225
12927
  var name = "solveODE";
13226
12928
  var dependencies = [
13227
12929
  "typed",
@@ -14092,6 +13794,8 @@ function radauSolve(f, tspan, y0raw, options = {}) {
14092
13794
  var createSolveODE = /* @__PURE__ */ factory(
14093
13795
  name,
14094
13796
  dependencies,
13797
+ // The deps are untyped (`any`), so the result is declared: without it the export
13798
+ // inherits `any` from `typed(...)` instead of being a TypedFunction like the rest.
14095
13799
  ({
14096
13800
  typed: typed3,
14097
13801
  add: add5,
@@ -14109,143 +13813,6 @@ var createSolveODE = /* @__PURE__ */ factory(
14109
13813
  bignumber: bignumber2,
14110
13814
  unaryMinus: unaryMinus2
14111
13815
  }) => {
14112
- function _isPlainNumberArray(y0) {
14113
- if (!Array.isArray(y0) || y0.length < WASM_ODE_THRESHOLD) return false;
14114
- for (let i = 0; i < y0.length; i++) {
14115
- if (typeof y0[i] !== "number") return false;
14116
- }
14117
- return true;
14118
- }
14119
- function _rkWasmLoop(f, tspan, y0, options, butcherTableau) {
14120
- const wasm = wasmLoader.getModule();
14121
- if (!wasm) return null;
14122
- const dim = y0.length;
14123
- const a = butcherTableau.a;
14124
- const c = butcherTableau.c;
14125
- const b = butcherTableau.b;
14126
- const bp = butcherTableau.bp;
14127
- const numStages = c.length;
14128
- const t0 = tspan[0];
14129
- const tf = tspan[1];
14130
- const isForwards = tf > t0;
14131
- const tol = options.tol ? options.tol : 1e-4;
14132
- const minDelta = options.minDelta ? options.minDelta : 0.2;
14133
- const maxDelta = options.maxDelta ? options.maxDelta : 5;
14134
- const maxIter = options.maxIter ? options.maxIter : 1e4;
14135
- let h;
14136
- if (options.firstStep) {
14137
- h = isForwards ? options.firstStep : -options.firstStep;
14138
- } else {
14139
- const f0 = f(t0, y0);
14140
- const d0 = _rmsNorm(y0);
14141
- const d1 = _rmsNorm(Array.isArray(f0) ? f0 : [f0]);
14142
- const h0 = d0 < 1e-5 || d1 < 1e-5 ? 1e-6 : 0.01 * (d0 / d1);
14143
- const hMag = Math.min(h0, Math.abs(tf - t0));
14144
- h = isForwards ? hMag : -hMag;
14145
- }
14146
- const maxStepVal = options.maxStep;
14147
- const minStepVal = options.minStep;
14148
- const deltaB = new Float64Array(numStages);
14149
- for (let i = 0; i < numStages; i++) {
14150
- deltaB[i] = b[i] - bp[i];
14151
- }
14152
- const yAlloc = wasmLoader.allocateFloat64Array(y0);
14153
- const yNewAlloc = wasmLoader.allocateFloat64ArrayEmpty(dim);
14154
- const errorAlloc = wasmLoader.allocateFloat64ArrayEmpty(dim);
14155
- const tempAlloc = wasmLoader.allocateFloat64ArrayEmpty(dim);
14156
- const stageAlloc = wasmLoader.allocateFloat64ArrayEmpty(numStages * dim);
14157
- try {
14158
- let readVec2 = function(alloc) {
14159
- const arr10 = new Float64Array(wasm.memory.buffer, alloc.ptr, dim);
14160
- const result = new Array(dim);
14161
- for (let i = 0; i < dim; i++) {
14162
- result[i] = arr10[i];
14163
- }
14164
- return result;
14165
- }, writeVec2 = function(alloc, data) {
14166
- const arr10 = new Float64Array(wasm.memory.buffer, alloc.ptr, dim);
14167
- for (let i = 0; i < dim; i++) {
14168
- arr10[i] = data[i];
14169
- }
14170
- }, writeStage2 = function(stageIdx, data) {
14171
- const offset = stageIdx * dim;
14172
- const arr10 = new Float64Array(wasm.memory.buffer, stageAlloc.ptr, numStages * dim);
14173
- for (let i = 0; i < dim; i++) {
14174
- arr10[offset + i] = data[i];
14175
- }
14176
- }, trimStepNum2 = function(tn, tfn, hn) {
14177
- const next = tn + hn;
14178
- if (isForwards ? next > tfn : next < tfn) {
14179
- return tfn - tn;
14180
- }
14181
- return hn;
14182
- }, ongoing2 = function(tn, tfn) {
14183
- return isForwards ? tn < tfn : tn > tfn;
14184
- };
14185
- var readVec = readVec2, writeVec = writeVec2, writeStage = writeStage2, trimStepNum = trimStepNum2, ongoing = ongoing2;
14186
- const t = [t0];
14187
- const y = [y0.slice()];
14188
- let n = 0;
14189
- let iter = 0;
14190
- while (ongoing2(t[n], tf)) {
14191
- h = trimStepNum2(t[n], tf, h);
14192
- writeVec2(yAlloc, y[n]);
14193
- const k0 = f(t[n], y[n]);
14194
- writeStage2(0, k0);
14195
- for (let s = 1; s < numStages; s++) {
14196
- wasm.vectorCopy(yAlloc.ptr, dim, tempAlloc.ptr);
14197
- for (let j = 0; j < a[s].length; j++) {
14198
- const aCoeff = a[s][j];
14199
- if (aCoeff === 0) continue;
14200
- const kjPtr = stageAlloc.ptr + j * dim * 8;
14201
- wasm.vectorScale(kjPtr, h * aCoeff, dim, yNewAlloc.ptr);
14202
- wasm.vectorAdd(tempAlloc.ptr, yNewAlloc.ptr, dim, tempAlloc.ptr);
14203
- }
14204
- const tStage = t[n] + c[s] * h;
14205
- const yStage = readVec2(tempAlloc);
14206
- const ks = f(tStage, yStage);
14207
- writeStage2(s, ks);
14208
- }
14209
- wasm.vectorCopy(yAlloc.ptr, dim, yNewAlloc.ptr);
14210
- new Float64Array(wasm.memory.buffer, errorAlloc.ptr, dim).fill(0);
14211
- for (let s = 0; s < numStages; s++) {
14212
- const ksPtr = stageAlloc.ptr + s * dim * 8;
14213
- if (b[s] !== 0) {
14214
- wasm.vectorScale(ksPtr, h * b[s], dim, tempAlloc.ptr);
14215
- wasm.vectorAdd(yNewAlloc.ptr, tempAlloc.ptr, dim, yNewAlloc.ptr);
14216
- }
14217
- if (deltaB[s] !== 0) {
14218
- wasm.vectorScale(ksPtr, deltaB[s], dim, tempAlloc.ptr);
14219
- wasm.vectorAdd(errorAlloc.ptr, tempAlloc.ptr, dim, errorAlloc.ptr);
14220
- }
14221
- }
14222
- const TE = wasm.maxError(errorAlloc.ptr, dim);
14223
- if (TE < tol && tol / TE > 1 / 4) {
14224
- t.push(t[n] + h);
14225
- y.push(readVec2(yNewAlloc));
14226
- n++;
14227
- }
14228
- const delta = wasm.computeStepAdjustment(TE, tol, 5, minDelta, maxDelta);
14229
- h = h * delta;
14230
- if (maxStepVal !== void 0 && Math.abs(h) > maxStepVal) {
14231
- h = isForwards ? maxStepVal : -maxStepVal;
14232
- } else if (minStepVal !== void 0 && Math.abs(h) < minStepVal) {
14233
- h = isForwards ? minStepVal : -minStepVal;
14234
- }
14235
- iter++;
14236
- if (iter > maxIter) {
14237
- throw new Error("Maximum number of iterations reached, try changing options");
14238
- }
14239
- }
14240
- return { t, y };
14241
- } finally {
14242
- wasmLoader.free(yAlloc.ptr);
14243
- wasmLoader.free(yNewAlloc.ptr);
14244
- wasmLoader.free(errorAlloc.ptr);
14245
- wasmLoader.free(tempAlloc.ptr);
14246
- wasmLoader.free(stageAlloc.ptr);
14247
- }
14248
- }
14249
13816
  function _rk(butcherTableau) {
14250
13817
  return function(f, tspan, y0, options) {
14251
13818
  const wrongTSpan = !(tspan.length === 2 && (tspan.every(isNumOrBig) || tspan.every(isUnit)));
@@ -14274,13 +13841,6 @@ var createSolveODE = /* @__PURE__ */ factory(
14274
13841
  throw new Error('Inconsistent type of "t" dependant variables');
14275
13842
  }
14276
13843
  const hasBigNumbers = [t0, tf, ...y0, maxStep, minStep].some(isBigNumber);
14277
- if (!hasBigNumbers && !tspan.some(isUnit) && _isPlainNumberArray(y0)) {
14278
- try {
14279
- const wasmResult = _rkWasmLoop(f, tspan, y0, options, butcherTableau);
14280
- if (wasmResult !== null) return wasmResult;
14281
- } catch {
14282
- }
14283
- }
14284
13844
  const steps = 1;
14285
13845
  const tol = options.tol ? options.tol : 1e-4;
14286
13846
  const minDelta = options.minDelta ? options.minDelta : 0.2;
@@ -15122,7 +14682,6 @@ function solveDDE(f, tspan, history, delays, options = {}) {
15122
14682
  }
15123
14683
 
15124
14684
  // src/typed/numeric.ts
15125
- var NUMERIC_WASM_THRESHOLD = 16;
15126
14685
  function findRoot(f, a, b, opts) {
15127
14686
  const tol = opts?.tol ?? 1e-12;
15128
14687
  const maxIter = opts?.maxIter ?? 100;
@@ -15312,27 +14871,6 @@ function globalMinimize(f, bounds, opts) {
15312
14871
  function leastSquares(A, b) {
15313
14872
  const m = A.length;
15314
14873
  const n = A[0].length;
15315
- if (m >= NUMERIC_WASM_THRESHOLD) {
15316
- const wasm = wasmLoader.getModule();
15317
- if (wasm) {
15318
- try {
15319
- const flatA = new Float64Array(m * n);
15320
- for (let i = 0; i < m; i++) for (let j = 0; j < n; j++) flatA[i * n + j] = A[i][j];
15321
- const aAlloc = wasmLoader.allocateFloat64Array(flatA);
15322
- const bAlloc = wasmLoader.allocateFloat64Array(new Float64Array(b));
15323
- const xAlloc = wasmLoader.allocateFloat64Array(new Float64Array(n));
15324
- try {
15325
- wasm.least_squares_wasm(aAlloc.ptr, bAlloc.ptr, m, n, xAlloc.ptr);
15326
- return Array.from(xAlloc.array);
15327
- } finally {
15328
- wasmLoader.free(aAlloc.ptr);
15329
- wasmLoader.free(bAlloc.ptr);
15330
- wasmLoader.free(xAlloc.ptr);
15331
- }
15332
- } catch {
15333
- }
15334
- }
15335
- }
15336
14874
  const AtA = Array.from({ length: n }, () => new Array(n).fill(0));
15337
14875
  for (let i = 0; i < n; i++) {
15338
14876
  for (let j = 0; j < n; j++) {
@@ -15475,28 +15013,6 @@ function pchip(xs, ys, x) {
15475
15013
  }
15476
15014
  function bezierCurve(controlPoints, t) {
15477
15015
  if (controlPoints.length === 0) throw new Error("bezierCurve: need at least 1 control point");
15478
- const nPts = controlPoints.length;
15479
- const dims = controlPoints[0].length;
15480
- if (nPts >= NUMERIC_WASM_THRESHOLD) {
15481
- const wasm = wasmLoader.getModule();
15482
- if (wasm) {
15483
- try {
15484
- const flat = new Float64Array(nPts * dims);
15485
- for (let i = 0; i < nPts; i++)
15486
- for (let d = 0; d < dims; d++) flat[i * dims + d] = controlPoints[i][d];
15487
- const ctrlAlloc = wasmLoader.allocateFloat64Array(flat);
15488
- const resultAlloc = wasmLoader.allocateFloat64Array(new Float64Array(dims));
15489
- try {
15490
- wasm.bezier_eval_wasm(ctrlAlloc.ptr, nPts, dims, t, resultAlloc.ptr);
15491
- return Array.from(resultAlloc.array);
15492
- } finally {
15493
- wasmLoader.free(ctrlAlloc.ptr);
15494
- wasmLoader.free(resultAlloc.ptr);
15495
- }
15496
- } catch {
15497
- }
15498
- }
15499
- }
15500
15016
  let points = controlPoints.map((p) => p.slice());
15501
15017
  while (points.length > 1) {
15502
15018
  const next = [];
@@ -15546,23 +15062,6 @@ function bspline(controlPoints, degree3, t) {
15546
15062
  }
15547
15063
  function loess(xs, ys, x, bandwidth = 0.3) {
15548
15064
  const n = xs.length;
15549
- if (n >= NUMERIC_WASM_THRESHOLD) {
15550
- const wasm = wasmLoader.getModule();
15551
- if (wasm) {
15552
- try {
15553
- const xsAlloc = wasmLoader.allocateFloat64Array(new Float64Array(xs));
15554
- const ysAlloc = wasmLoader.allocateFloat64Array(new Float64Array(ys));
15555
- try {
15556
- const result = wasm.loess_wasm(xsAlloc.ptr, ysAlloc.ptr, n, x, bandwidth);
15557
- return result;
15558
- } finally {
15559
- wasmLoader.free(xsAlloc.ptr);
15560
- wasmLoader.free(ysAlloc.ptr);
15561
- }
15562
- } catch {
15563
- }
15564
- }
15565
- }
15566
15065
  const k = Math.max(2, Math.ceil(bandwidth * n));
15567
15066
  const dists = xs.map((xi, i) => ({ dist: Math.abs(xi - x), i }));
15568
15067
  dists.sort((a2, b2) => a2.dist - b2.dist);
@@ -15589,63 +15088,6 @@ function loess(xs, ys, x, bandwidth = 0.3) {
15589
15088
  return a + b * x;
15590
15089
  }
15591
15090
  function griddata(points, values, xi, yi) {
15592
- const n = points.length;
15593
- if (n >= NUMERIC_WASM_THRESHOLD) {
15594
- const wasm = wasmLoader.getModule();
15595
- if (wasm) {
15596
- try {
15597
- const flatPts = new Float64Array(n * 2);
15598
- for (let i = 0; i < n; i++) {
15599
- flatPts[i * 2] = points[i][0];
15600
- flatPts[i * 2 + 1] = points[i][1];
15601
- }
15602
- const ni = xi.length * yi.length;
15603
- const flatXi = new Float64Array(ni);
15604
- const flatYi = new Float64Array(ni);
15605
- let idx = 0;
15606
- for (let j = 0; j < yi.length; j++) {
15607
- for (let i = 0; i < xi.length; i++) {
15608
- flatXi[idx] = xi[i];
15609
- flatYi[idx] = yi[j];
15610
- idx++;
15611
- }
15612
- }
15613
- const ptsAlloc = wasmLoader.allocateFloat64Array(flatPts);
15614
- const valsAlloc = wasmLoader.allocateFloat64Array(new Float64Array(values));
15615
- const xiAlloc = wasmLoader.allocateFloat64Array(flatXi);
15616
- const yiAlloc = wasmLoader.allocateFloat64Array(flatYi);
15617
- const resultAlloc = wasmLoader.allocateFloat64Array(new Float64Array(ni));
15618
- try {
15619
- wasm.griddata_wasm(
15620
- ptsAlloc.ptr,
15621
- valsAlloc.ptr,
15622
- n,
15623
- xiAlloc.ptr,
15624
- yiAlloc.ptr,
15625
- ni,
15626
- resultAlloc.ptr
15627
- );
15628
- const result2d = [];
15629
- let k = 0;
15630
- for (let j = 0; j < yi.length; j++) {
15631
- const row2 = [];
15632
- for (let i = 0; i < xi.length; i++) {
15633
- row2.push(resultAlloc.array[k++]);
15634
- }
15635
- result2d.push(row2);
15636
- }
15637
- return result2d;
15638
- } finally {
15639
- wasmLoader.free(ptsAlloc.ptr);
15640
- wasmLoader.free(valsAlloc.ptr);
15641
- wasmLoader.free(xiAlloc.ptr);
15642
- wasmLoader.free(yiAlloc.ptr);
15643
- wasmLoader.free(resultAlloc.ptr);
15644
- }
15645
- } catch {
15646
- }
15647
- }
15648
- }
15649
15091
  const result = [];
15650
15092
  const p = 2;
15651
15093
  for (let j = 0; j < yi.length; j++) {
@@ -15677,41 +15119,6 @@ function griddata(points, values, xi, yi) {
15677
15119
  function rbfInterpolate(points, values, xi, kernel = "gaussian") {
15678
15120
  const n = points.length;
15679
15121
  const dim = points[0].length;
15680
- if (kernel === "gaussian" && n >= NUMERIC_WASM_THRESHOLD) {
15681
- const wasm = wasmLoader.getModule();
15682
- if (wasm) {
15683
- try {
15684
- const ni = xi.length;
15685
- const flatPts = new Float64Array(n * dim);
15686
- for (let i = 0; i < n; i++)
15687
- for (let d = 0; d < dim; d++) flatPts[i * dim + d] = points[i][d];
15688
- const flatXi = new Float64Array(ni * dim);
15689
- for (let i = 0; i < ni; i++) for (let d = 0; d < dim; d++) flatXi[i * dim + d] = xi[i][d];
15690
- const ptsAlloc = wasmLoader.allocateFloat64Array(flatPts);
15691
- const valsAlloc = wasmLoader.allocateFloat64Array(new Float64Array(values));
15692
- const xiAlloc = wasmLoader.allocateFloat64Array(flatXi);
15693
- const resultAlloc = wasmLoader.allocateFloat64Array(new Float64Array(ni));
15694
- try {
15695
- wasm.rbf_interp_wasm(
15696
- ptsAlloc.ptr,
15697
- valsAlloc.ptr,
15698
- n,
15699
- dim,
15700
- xiAlloc.ptr,
15701
- ni,
15702
- resultAlloc.ptr
15703
- );
15704
- return Array.from(resultAlloc.array);
15705
- } finally {
15706
- wasmLoader.free(ptsAlloc.ptr);
15707
- wasmLoader.free(valsAlloc.ptr);
15708
- wasmLoader.free(xiAlloc.ptr);
15709
- wasmLoader.free(resultAlloc.ptr);
15710
- }
15711
- } catch {
15712
- }
15713
- }
15714
- }
15715
15122
  let sumDist = 0;
15716
15123
  let count2 = 0;
15717
15124
  for (let i = 0; i < Math.min(n, 50); i++) {
@@ -15963,40 +15370,9 @@ function solveODESystem(f, y0, tspan, opts) {
15963
15370
  const k2 = f(t + h / 2, vadd(y, k1, h / 2));
15964
15371
  const k3 = f(t + h / 2, vadd(y, k2, h / 2));
15965
15372
  const k4 = f(t + h, vadd(y, k3, h));
15966
- let yNew;
15967
- const wasmMod = n >= 4 ? wasmLoader.getModule() : null;
15968
- if (wasmMod) {
15969
- try {
15970
- const yArr = new Float64Array(y);
15971
- const kPacked = new Float64Array(4 * n);
15972
- for (let i = 0; i < n; i++) {
15973
- kPacked[i] = k1[i];
15974
- kPacked[n + i] = k2[i];
15975
- kPacked[2 * n + i] = k3[i];
15976
- kPacked[3 * n + i] = k4[i];
15977
- }
15978
- const yAlloc = wasmLoader.allocateFloat64Array(yArr);
15979
- const kAlloc = wasmLoader.allocateFloat64Array(kPacked);
15980
- const rAlloc = wasmLoader.allocateFloat64Array(new Float64Array(n));
15981
- try {
15982
- wasmMod.ode_system_rk4_step_wasm(yAlloc.ptr, kAlloc.ptr, h, n, rAlloc.ptr);
15983
- yNew = Array.from(rAlloc.array);
15984
- } finally {
15985
- wasmLoader.free(yAlloc.ptr);
15986
- wasmLoader.free(kAlloc.ptr);
15987
- wasmLoader.free(rAlloc.ptr);
15988
- }
15989
- } catch {
15990
- yNew = new Array(n);
15991
- for (let i = 0; i < n; i++) {
15992
- yNew[i] = y[i] + h / 6 * (k1[i] + 2 * k2[i] + 2 * k3[i] + k4[i]);
15993
- }
15994
- }
15995
- } else {
15996
- yNew = new Array(n);
15997
- for (let i = 0; i < n; i++) {
15998
- yNew[i] = y[i] + h / 6 * (k1[i] + 2 * k2[i] + 2 * k3[i] + k4[i]);
15999
- }
15373
+ const yNew = new Array(n);
15374
+ for (let i = 0; i < n; i++) {
15375
+ yNew[i] = y[i] + h / 6 * (k1[i] + 2 * k2[i] + 2 * k3[i] + k4[i]);
16000
15376
  }
16001
15377
  t += h;
16002
15378
  y = yNew;
@@ -16153,23 +15529,6 @@ function rank(A, tol = 1e-10) {
16153
15529
  const m = A.length;
16154
15530
  if (m === 0) return 0;
16155
15531
  const n = A[0].length;
16156
- if (m >= NUMERIC_WASM_THRESHOLD) {
16157
- const wasm = wasmLoader.getModule();
16158
- if (wasm) {
16159
- try {
16160
- const flat = new Float64Array(m * n);
16161
- for (let i = 0; i < m; i++) for (let j = 0; j < n; j++) flat[i * n + j] = A[i][j];
16162
- const aAlloc = wasmLoader.allocateFloat64Array(flat);
16163
- try {
16164
- const result = wasm.matrix_rank_wasm(aAlloc.ptr, m, n, tol);
16165
- return result;
16166
- } finally {
16167
- wasmLoader.free(aAlloc.ptr);
16168
- }
16169
- } catch {
16170
- }
16171
- }
16172
- }
16173
15532
  const M = A.map((row2) => row2.slice());
16174
15533
  let r = 0;
16175
15534
  for (let col = 0; col < n && r < m; col++) {
@@ -19305,7 +18664,7 @@ async function mannWhitneyTest(sample1, sample2, opts) {
19305
18664
  if (nTotal >= WASM_SORT_THRESHOLD) {
19306
18665
  const vals = new Float64Array(nTotal);
19307
18666
  for (let k = 0; k < nTotal; k++) vals[k] = combined[k].value;
19308
- const { argsortF64Dispatch: argsortF64Dispatch2 } = await import("./wasm-bridge-C44GQ3DS.js");
18667
+ const { argsortF64Dispatch: argsortF64Dispatch2 } = await import("./wasm-bridge-74YOKWIS.js");
19309
18668
  const idx = argsortF64Dispatch2(vals);
19310
18669
  const sortedCombined = new Array(nTotal);
19311
18670
  for (let k = 0; k < nTotal; k++) sortedCombined[k] = combined[idx[k]];
@@ -23164,22 +22523,6 @@ var createLgamma = /* @__PURE__ */ factory(
23164
22523
  ];
23165
22524
  return typed3(name30, {
23166
22525
  Array: function(arr10) {
23167
- const wasm = wasmLoader.getModule();
23168
- if (wasm && arr10.length >= 100 && arr10.every((x) => typeof x === "number")) {
23169
- try {
23170
- const input = new Float64Array(arr10);
23171
- const inputAlloc = wasmLoader.allocateFloat64Array(input);
23172
- const resultAlloc = wasmLoader.allocateFloat64ArrayEmpty(arr10.length);
23173
- try {
23174
- wasm.lgammaArray(inputAlloc.ptr, arr10.length, resultAlloc.ptr);
23175
- return Array.from(resultAlloc.array);
23176
- } finally {
23177
- wasmLoader.free(inputAlloc.ptr);
23178
- wasmLoader.free(resultAlloc.ptr);
23179
- }
23180
- } catch {
23181
- }
23182
- }
23183
22526
  return arr10.map((x) => lgammaNumber(x));
23184
22527
  },
23185
22528
  number: lgammaNumber,
@@ -23516,27 +22859,7 @@ var createErf = /* @__PURE__ */ factory(
23516
22859
  return typed3("name", {
23517
22860
  number: erfNumber,
23518
22861
  "Array | Matrix": typed3.referToSelf(
23519
- (self) => (n) => {
23520
- if (Array.isArray(n) && n.length >= 100 && n.every((x) => typeof x === "number")) {
23521
- const wasm = wasmLoader.getModule();
23522
- if (wasm) {
23523
- try {
23524
- const input = new Float64Array(n);
23525
- const inputAlloc = wasmLoader.allocateFloat64Array(input);
23526
- const resultAlloc = wasmLoader.allocateFloat64ArrayEmpty(n.length);
23527
- try {
23528
- wasm.erfArray(inputAlloc.ptr, n.length, resultAlloc.ptr);
23529
- return Array.from(resultAlloc.array);
23530
- } finally {
23531
- wasmLoader.free(inputAlloc.ptr);
23532
- wasmLoader.free(resultAlloc.ptr);
23533
- }
23534
- } catch {
23535
- }
23536
- }
23537
- }
23538
- return deepMap(n, self);
23539
- }
22862
+ (self) => (n) => deepMap(n, self)
23540
22863
  )
23541
22864
  // TODO: For complex numbers, use the approximation for the Faddeeva function
23542
22865
  // from "More Efficient Computation of the Complex Error Function" (AMS)
@@ -24808,15 +24131,6 @@ function improveErrorMessage(err, fnName, value) {
24808
24131
  }
24809
24132
 
24810
24133
  // src/statistics/prod.ts
24811
- var WASM_PROD_THRESHOLD = 100;
24812
- function isFlatNumberArray(arr10) {
24813
- for (let i = 0; i < arr10.length; i++) {
24814
- if (typeof arr10[i] !== "number") {
24815
- return false;
24816
- }
24817
- }
24818
- return true;
24819
- }
24820
24134
  var name76 = "prod";
24821
24135
  var dependencies76 = ["typed", "config", "multiplyScalar", "numeric", "parseNumberWithConfig"];
24822
24136
  var createProd = /* @__PURE__ */ factory(
@@ -24844,22 +24158,6 @@ var createProd = /* @__PURE__ */ factory(
24844
24158
  }
24845
24159
  });
24846
24160
  function _prod(array) {
24847
- if (Array.isArray(array) && array.length >= WASM_PROD_THRESHOLD) {
24848
- if (isFlatNumberArray(array)) {
24849
- const wasm = wasmLoader.getModule();
24850
- if (wasm) {
24851
- try {
24852
- const alloc = wasmLoader.allocateFloat64Array(array);
24853
- try {
24854
- return wasm.statsProd(alloc.ptr, array.length);
24855
- } finally {
24856
- wasmLoader.free(alloc.ptr);
24857
- }
24858
- } catch {
24859
- }
24860
- }
24861
- }
24862
- }
24863
24161
  let prod2;
24864
24162
  deepForEach(array, function(value) {
24865
24163
  try {
@@ -25045,27 +24343,6 @@ var createParseNumberWithConfig = /* @__PURE__ */ factory(
25045
24343
  );
25046
24344
 
25047
24345
  // src/matrix/transpose.ts
25048
- var WASM_TRANSPOSE_THRESHOLD = 100;
25049
- function isPlainNumberMatrix(matrix2) {
25050
- for (let i = 0; i < matrix2.length; i++) {
25051
- const row2 = matrix2[i];
25052
- for (let j = 0; j < row2.length; j++) {
25053
- if (typeof row2[j] !== "number") {
25054
- return false;
25055
- }
25056
- }
25057
- }
25058
- return true;
25059
- }
25060
- function flattenToFloat64(matrix2, rows, cols) {
25061
- const result = new Float64Array(rows * cols);
25062
- for (let i = 0; i < rows; i++) {
25063
- for (let j = 0; j < cols; j++) {
25064
- result[i * cols + j] = matrix2[i][j];
25065
- }
25066
- }
25067
- return result;
25068
- }
25069
24346
  var name84 = "transpose";
25070
24347
  var dependencies84 = ["typed", "matrix"];
25071
24348
  var createTranspose = /* @__PURE__ */ factory(
@@ -25113,34 +24390,6 @@ var createTranspose = /* @__PURE__ */ factory(
25113
24390
  }
25114
24391
  function _denseTranspose(m, rows, columns) {
25115
24392
  const data = m._data;
25116
- const wasm = wasmLoader.getModule();
25117
- if (wasm && rows * columns >= WASM_TRANSPOSE_THRESHOLD && isPlainNumberMatrix(data)) {
25118
- try {
25119
- const flat = flattenToFloat64(data, rows, columns);
25120
- const input = wasmLoader.allocateFloat64Array(flat);
25121
- const output = wasmLoader.allocateFloat64ArrayEmpty(rows * columns);
25122
- try {
25123
- wasm.transpose(input.ptr, rows, columns, output.ptr);
25124
- const transposed2 = [];
25125
- for (let j = 0; j < columns; j++) {
25126
- const row2 = [];
25127
- for (let i = 0; i < rows; i++) {
25128
- row2[i] = output.array[j * rows + i];
25129
- }
25130
- transposed2[j] = row2;
25131
- }
25132
- return m.createDenseMatrix({
25133
- data: transposed2,
25134
- size: [columns, rows],
25135
- datatype: m._datatype
25136
- });
25137
- } finally {
25138
- wasmLoader.free(input.ptr);
25139
- wasmLoader.free(output.ptr);
25140
- }
25141
- } catch {
25142
- }
25143
- }
25144
24393
  const transposed = [];
25145
24394
  let transposedRow;
25146
24395
  for (let j = 0; j < columns; j++) {
@@ -25465,38 +24714,6 @@ var createDiag = /* @__PURE__ */ factory(
25465
24714
  );
25466
24715
 
25467
24716
  // src/matrix/kron.ts
25468
- var WASM_KRON_THRESHOLD = 64;
25469
- function isPlainNumber2D(arr10) {
25470
- for (let i = 0; i < arr10.length; i++) {
25471
- const row2 = arr10[i];
25472
- for (let j = 0; j < row2.length; j++) {
25473
- if (typeof row2[j] !== "number") {
25474
- return false;
25475
- }
25476
- }
25477
- }
25478
- return true;
25479
- }
25480
- function flatten2D(arr10, rows, cols) {
25481
- const result = new Float64Array(rows * cols);
25482
- for (let i = 0; i < rows; i++) {
25483
- for (let j = 0; j < cols; j++) {
25484
- result[i * cols + j] = arr10[i][j];
25485
- }
25486
- }
25487
- return result;
25488
- }
25489
- function unflatten2D(flat, rows, cols) {
25490
- const result = [];
25491
- for (let i = 0; i < rows; i++) {
25492
- const row2 = [];
25493
- for (let j = 0; j < cols; j++) {
25494
- row2.push(flat[i * cols + j]);
25495
- }
25496
- result.push(row2);
25497
- }
25498
- return result;
25499
- }
25500
24717
  var name90 = "kron";
25501
24718
  var dependencies90 = ["typed", "matrix", "multiplyScalar"];
25502
24719
  var createKron = /* @__PURE__ */ factory(
@@ -25527,37 +24744,6 @@ var createKron = /* @__PURE__ */ factory(
25527
24744
  while (bdim++ < d) b = [b];
25528
24745
  }
25529
24746
  if (d === 1) return _kron1d(a, b);
25530
- if (d === 2) {
25531
- const aSize = arraySize(a);
25532
- const bSize = arraySize(b);
25533
- const aRows = aSize[0];
25534
- const aCols = aSize[1];
25535
- const bRows = bSize[0];
25536
- const bCols = bSize[1];
25537
- const totalElements = aRows * aCols * bRows * bCols;
25538
- const wasm = wasmLoader.getModule();
25539
- if (wasm && totalElements >= WASM_KRON_THRESHOLD && isPlainNumber2D(a) && isPlainNumber2D(b)) {
25540
- try {
25541
- const aFlat = flatten2D(a, aRows, aCols);
25542
- const bFlat = flatten2D(b, bRows, bCols);
25543
- const aAlloc = wasmLoader.allocateFloat64Array(aFlat);
25544
- const bAlloc = wasmLoader.allocateFloat64Array(bFlat);
25545
- const resultRows = aRows * bRows;
25546
- const resultCols = aCols * bCols;
25547
- const resultAlloc = wasmLoader.allocateFloat64ArrayEmpty(resultRows * resultCols);
25548
- try {
25549
- wasm.laKron(aAlloc.ptr, aRows, aCols, bAlloc.ptr, bRows, bCols);
25550
- const resultFlat = new Float64Array(resultAlloc.array);
25551
- return unflatten2D(resultFlat, resultRows, resultCols);
25552
- } finally {
25553
- wasmLoader.free(aAlloc.ptr);
25554
- wasmLoader.free(bAlloc.ptr);
25555
- wasmLoader.free(resultAlloc.ptr);
25556
- }
25557
- } catch {
25558
- }
25559
- }
25560
- }
25561
24747
  return a.flatMap(
25562
24748
  (aSlice) => b.map((bSlice) => _kron(aSlice, bSlice, d - 1))
25563
24749
  );
@@ -25962,8 +25148,7 @@ var createTrace = /* @__PURE__ */ factory(
25962
25148
  );
25963
25149
 
25964
25150
  // src/matrix/det.ts
25965
- var WASM_DET_THRESHOLD = 25;
25966
- function isPlainNumberMatrix2(matrix2) {
25151
+ function isPlainNumberMatrix(matrix2) {
25967
25152
  for (let i = 0; i < matrix2.length; i++) {
25968
25153
  const row2 = matrix2[i];
25969
25154
  for (let j = 0; j < row2.length; j++) {
@@ -25974,15 +25159,6 @@ function isPlainNumberMatrix2(matrix2) {
25974
25159
  }
25975
25160
  return true;
25976
25161
  }
25977
- function flattenToFloat642(matrix2, rows, cols) {
25978
- const result = new Float64Array(rows * cols);
25979
- for (let i = 0; i < rows; i++) {
25980
- for (let j = 0; j < cols; j++) {
25981
- result[i * cols + j] = matrix2[i][j];
25982
- }
25983
- }
25984
- return result;
25985
- }
25986
25162
  var name96 = "det";
25987
25163
  var dependencies96 = [
25988
25164
  "typed",
@@ -26045,22 +25221,6 @@ var createDet = /* @__PURE__ */ factory(
26045
25221
  }
26046
25222
  });
26047
25223
  function _det(matrix3, rows, _cols) {
26048
- const wasm = wasmLoader.getModule();
26049
- if (wasm && rows * rows >= WASM_DET_THRESHOLD && isPlainNumberMatrix2(matrix3)) {
26050
- try {
26051
- const flat = flattenToFloat642(matrix3, rows, rows);
26052
- const a = wasmLoader.allocateFloat64Array(flat);
26053
- const work = wasmLoader.allocateFloat64ArrayEmpty(rows * rows);
26054
- try {
26055
- const result = wasm.laDet(a.ptr, rows, work.ptr);
26056
- return result;
26057
- } finally {
26058
- wasmLoader.free(a.ptr);
26059
- wasmLoader.free(work.ptr);
26060
- }
26061
- } catch {
26062
- }
26063
- }
26064
25224
  if (rows === 1) {
26065
25225
  return clone(matrix3[0][0]);
26066
25226
  } else if (rows === 2) {
@@ -26068,12 +25228,12 @@ var createDet = /* @__PURE__ */ factory(
26068
25228
  multiply2(matrix3[0][0], matrix3[1][1]),
26069
25229
  multiply2(matrix3[1][0], matrix3[0][1])
26070
25230
  );
26071
- } else if (rows === 3 && isPlainNumberMatrix2(matrix3)) {
25231
+ } else if (rows === 3 && isPlainNumberMatrix(matrix3)) {
26072
25232
  const a = matrix3[0][0], b = matrix3[0][1], c = matrix3[0][2];
26073
25233
  const d = matrix3[1][0], e = matrix3[1][1], f = matrix3[1][2];
26074
25234
  const g = matrix3[2][0], h = matrix3[2][1], i = matrix3[2][2];
26075
25235
  return a * (e * i - f * h) - b * (d * i - f * g) + c * (d * h - e * g);
26076
- } else if (rows === 4 && isPlainNumberMatrix2(matrix3)) {
25236
+ } else if (rows === 4 && isPlainNumberMatrix(matrix3)) {
26077
25237
  const a00 = matrix3[0][0], a01 = matrix3[0][1];
26078
25238
  const a02 = matrix3[0][2], a03 = matrix3[0][3];
26079
25239
  const a10 = matrix3[1][0], a11 = matrix3[1][1];
@@ -26306,42 +25466,12 @@ function csTdfs(j, k, w, head, next, post, stack) {
26306
25466
  }
26307
25467
 
26308
25468
  // src/algebra/sparse/csAmd.ts
26309
- var WASM_AMD_THRESHOLD = 100;
26310
25469
  var name98 = "csAmd";
26311
25470
  var dependencies98 = ["add", "multiply", "transpose"];
26312
25471
  var createCsAmd = /* @__PURE__ */ factory(
26313
25472
  name98,
26314
25473
  dependencies98,
26315
25474
  ({ add: add5, multiply: multiply2, transpose: transpose5 }) => {
26316
- function _tryWasmAmd(a, n) {
26317
- const wasm = wasmLoader.getModule();
26318
- if (!wasm || !a._ptr || !a._index) return null;
26319
- const nnz = a._ptr[n];
26320
- if (nnz < WASM_AMD_THRESHOLD) return null;
26321
- try {
26322
- const colPtr = new Int32Array(a._ptr);
26323
- const rowIdx = new Int32Array(a._index);
26324
- const colPtrAlloc = wasmLoader.allocateInt32Array(colPtr);
26325
- const rowIdxAlloc = wasmLoader.allocateInt32Array(rowIdx);
26326
- const permAlloc = wasmLoader.allocateInt32ArrayEmpty(n);
26327
- const workAlloc = wasmLoader.allocateInt32ArrayEmpty(8 * (n + 1));
26328
- try {
26329
- wasm.amd(colPtrAlloc.ptr, rowIdxAlloc.ptr, n, permAlloc.ptr, workAlloc.ptr);
26330
- const perm = new Array(n);
26331
- for (let i = 0; i < n; i++) {
26332
- perm[i] = permAlloc.array[i];
26333
- }
26334
- return perm;
26335
- } finally {
26336
- wasmLoader.free(colPtrAlloc.ptr);
26337
- wasmLoader.free(rowIdxAlloc.ptr);
26338
- wasmLoader.free(permAlloc.ptr);
26339
- wasmLoader.free(workAlloc.ptr);
26340
- }
26341
- } catch {
26342
- }
26343
- return null;
26344
- }
26345
25475
  return function csAmd2(order, a) {
26346
25476
  if (!a || order <= 0 || order > 3) {
26347
25477
  return null;
@@ -26349,8 +25479,6 @@ var createCsAmd = /* @__PURE__ */ factory(
26349
25479
  const asize = a._size;
26350
25480
  const m = asize[0];
26351
25481
  const n = asize[1];
26352
- const wasmResult = _tryWasmAmd(a, n);
26353
- if (wasmResult !== null) return wasmResult;
26354
25482
  let lemax = 0;
26355
25483
  let dense = Math.max(16, 10 * Math.sqrt(n));
26356
25484
  dense = Math.min(n - 2, dense);
@@ -26720,50 +25848,12 @@ function csLeaf(i, j, w, first, maxfirst, prevleaf, ancestor) {
26720
25848
  }
26721
25849
 
26722
25850
  // src/algebra/sparse/csCounts.ts
26723
- var WASM_COUNTS_THRESHOLD = 50;
26724
25851
  var name99 = "csCounts";
26725
25852
  var dependencies99 = ["transpose"];
26726
25853
  var createCsCounts = /* @__PURE__ */ factory(
26727
25854
  name99,
26728
25855
  dependencies99,
26729
25856
  ({ transpose: transpose5 }) => {
26730
- function _tryWasmCounts(a, parent, post, n) {
26731
- const wasm = wasmLoader.getModule();
26732
- if (!wasm || n < WASM_COUNTS_THRESHOLD || !a._index || !a._ptr) return null;
26733
- try {
26734
- const indexAlloc = wasmLoader.allocateInt32Array(new Int32Array(a._index));
26735
- const ptrAlloc = wasmLoader.allocateInt32Array(new Int32Array(a._ptr));
26736
- const parentAlloc = wasmLoader.allocateInt32Array(new Int32Array(parent));
26737
- const postAlloc = wasmLoader.allocateInt32Array(new Int32Array(post));
26738
- const colCountAlloc = wasmLoader.allocateInt32ArrayEmpty(n);
26739
- const workAlloc = wasmLoader.allocateInt32ArrayEmpty(3 * n);
26740
- try {
26741
- wasm.symbolicCholesky(
26742
- indexAlloc.ptr,
26743
- ptrAlloc.ptr,
26744
- n,
26745
- parentAlloc.ptr,
26746
- postAlloc.ptr,
26747
- colCountAlloc.ptr,
26748
- workAlloc.ptr
26749
- );
26750
- const colcount = new Array(n);
26751
- for (let i = 0; i < n; i++) {
26752
- colcount[i] = colCountAlloc.array[i];
26753
- }
26754
- return colcount;
26755
- } finally {
26756
- wasmLoader.free(indexAlloc.ptr);
26757
- wasmLoader.free(ptrAlloc.ptr);
26758
- wasmLoader.free(parentAlloc.ptr);
26759
- wasmLoader.free(postAlloc.ptr);
26760
- wasmLoader.free(colCountAlloc.ptr);
26761
- wasmLoader.free(workAlloc.ptr);
26762
- }
26763
- } catch {
26764
- }
26765
- return null;
26766
- }
26767
25857
  return function csCounts2(a, parent, post, ata) {
26768
25858
  if (!a || !parent || !post) {
26769
25859
  return null;
@@ -26771,10 +25861,6 @@ var createCsCounts = /* @__PURE__ */ factory(
26771
25861
  const asize = a._size;
26772
25862
  const m = asize[0];
26773
25863
  const n = asize[1];
26774
- if (!ata) {
26775
- const wasmResult = _tryWasmCounts(a, parent, post, n);
26776
- if (wasmResult !== null) return wasmResult;
26777
- }
26778
25864
  let i, j, k, J, p, p0, p1;
26779
25865
  const s = 4 * n + (ata ? n + m + 1 : 0);
26780
25866
  const w = [];
@@ -27239,42 +26325,6 @@ function createSolveValidation({ DenseMatrix: DenseMatrix7 }) {
27239
26325
  }
27240
26326
 
27241
26327
  // src/algebra/solver/lsolve.ts
27242
- var WASM_LSOLVE_THRESHOLD = 16;
27243
- function isPlainNumberMatrix3(matrix2) {
27244
- for (let i = 0; i < matrix2.length; i++) {
27245
- const row2 = matrix2[i];
27246
- for (let j = 0; j < row2.length; j++) {
27247
- if (typeof row2[j] !== "number") {
27248
- return false;
27249
- }
27250
- }
27251
- }
27252
- return true;
27253
- }
27254
- function isPlainNumberVector(vec) {
27255
- for (let i = 0; i < vec.length; i++) {
27256
- if (typeof vec[i][0] !== "number") {
27257
- return false;
27258
- }
27259
- }
27260
- return true;
27261
- }
27262
- function flattenToFloat643(matrix2, rows, cols) {
27263
- const result = new Float64Array(rows * cols);
27264
- for (let i = 0; i < rows; i++) {
27265
- for (let j = 0; j < cols; j++) {
27266
- result[i * cols + j] = matrix2[i][j];
27267
- }
27268
- }
27269
- return result;
27270
- }
27271
- function vectorToFloat64(vec) {
27272
- const result = new Float64Array(vec.length);
27273
- for (let i = 0; i < vec.length; i++) {
27274
- result[i] = vec[i][0];
27275
- }
27276
- return result;
27277
- }
27278
26328
  var name102 = "lsolve";
27279
26329
  var dependencies102 = [
27280
26330
  "typed",
@@ -27319,38 +26369,6 @@ var createLsolve = /* @__PURE__ */ factory(
27319
26369
  const rows = m._size[0];
27320
26370
  const columns = m._size[1];
27321
26371
  const mdata = m._data;
27322
- const wasm = wasmLoader.getModule();
27323
- if (wasm && rows === columns && rows * rows >= WASM_LSOLVE_THRESHOLD && isPlainNumberMatrix3(mdata) && isPlainNumberVector(bdata)) {
27324
- try {
27325
- const lFlat = flattenToFloat643(mdata, rows, columns);
27326
- const bFlat = vectorToFloat64(bdata);
27327
- const lAlloc = wasmLoader.allocateFloat64Array(lFlat);
27328
- const bAlloc = wasmLoader.allocateFloat64Array(bFlat);
27329
- const resultAlloc = wasmLoader.allocateFloat64ArrayEmpty(rows);
27330
- try {
27331
- const success = wasm.laLsolve(lAlloc.ptr, bAlloc.ptr, rows, resultAlloc.ptr);
27332
- if (success === 0) {
27333
- throw new Error("Linear system cannot be solved since matrix is singular");
27334
- }
27335
- const x2 = [];
27336
- for (let i = 0; i < rows; i++) {
27337
- x2[i] = [resultAlloc.array[i]];
27338
- }
27339
- return new DenseMatrix7({
27340
- data: x2,
27341
- size: [rows, 1]
27342
- });
27343
- } finally {
27344
- wasmLoader.free(lAlloc.ptr);
27345
- wasmLoader.free(bAlloc.ptr);
27346
- wasmLoader.free(resultAlloc.ptr);
27347
- }
27348
- } catch (e) {
27349
- if (e instanceof Error && e.message.includes("singular")) {
27350
- throw e;
27351
- }
27352
- }
27353
- }
27354
26372
  const x = [];
27355
26373
  for (let j = 0; j < columns; j++) {
27356
26374
  const bj = bdata[j][0] || 0;
@@ -27564,42 +26582,6 @@ var createLsolveAll = /* @__PURE__ */ factory(
27564
26582
  );
27565
26583
 
27566
26584
  // src/algebra/solver/usolve.ts
27567
- var WASM_USOLVE_THRESHOLD = 16;
27568
- function isPlainNumberMatrix4(matrix2) {
27569
- for (let i = 0; i < matrix2.length; i++) {
27570
- const row2 = matrix2[i];
27571
- for (let j = 0; j < row2.length; j++) {
27572
- if (typeof row2[j] !== "number") {
27573
- return false;
27574
- }
27575
- }
27576
- }
27577
- return true;
27578
- }
27579
- function isPlainNumberVector2(vec) {
27580
- for (let i = 0; i < vec.length; i++) {
27581
- if (typeof vec[i][0] !== "number") {
27582
- return false;
27583
- }
27584
- }
27585
- return true;
27586
- }
27587
- function flattenToFloat644(matrix2, rows, cols) {
27588
- const result = new Float64Array(rows * cols);
27589
- for (let i = 0; i < rows; i++) {
27590
- for (let j = 0; j < cols; j++) {
27591
- result[i * cols + j] = matrix2[i][j];
27592
- }
27593
- }
27594
- return result;
27595
- }
27596
- function vectorToFloat642(vec) {
27597
- const result = new Float64Array(vec.length);
27598
- for (let i = 0; i < vec.length; i++) {
27599
- result[i] = vec[i][0];
27600
- }
27601
- return result;
27602
- }
27603
26585
  var name104 = "usolve";
27604
26586
  var dependencies104 = [
27605
26587
  "typed",
@@ -27644,38 +26626,6 @@ var createUsolve = /* @__PURE__ */ factory(
27644
26626
  const rows = m._size[0];
27645
26627
  const columns = m._size[1];
27646
26628
  const mdata = m._data;
27647
- const wasm = wasmLoader.getModule();
27648
- if (wasm && rows === columns && rows * rows >= WASM_USOLVE_THRESHOLD && isPlainNumberMatrix4(mdata) && isPlainNumberVector2(bdata)) {
27649
- try {
27650
- const uFlat = flattenToFloat644(mdata, rows, columns);
27651
- const bFlat = vectorToFloat642(bdata);
27652
- const uAlloc = wasmLoader.allocateFloat64Array(uFlat);
27653
- const bAlloc = wasmLoader.allocateFloat64Array(bFlat);
27654
- const resultAlloc = wasmLoader.allocateFloat64ArrayEmpty(rows);
27655
- try {
27656
- const success = wasm.laUsolve(uAlloc.ptr, bAlloc.ptr, rows, resultAlloc.ptr);
27657
- if (success === 0) {
27658
- throw new Error("Linear system cannot be solved since matrix is singular");
27659
- }
27660
- const x2 = [];
27661
- for (let i = 0; i < rows; i++) {
27662
- x2[i] = [resultAlloc.array[i]];
27663
- }
27664
- return new DenseMatrix7({
27665
- data: x2,
27666
- size: [rows, 1]
27667
- });
27668
- } finally {
27669
- wasmLoader.free(uAlloc.ptr);
27670
- wasmLoader.free(bAlloc.ptr);
27671
- wasmLoader.free(resultAlloc.ptr);
27672
- }
27673
- } catch (e) {
27674
- if (e instanceof Error && e.message.includes("singular")) {
27675
- throw e;
27676
- }
27677
- }
27678
- }
27679
26629
  const x = [];
27680
26630
  for (let j = columns - 1; j >= 0; j--) {
27681
26631
  const bj = bdata[j][0] || 0;
@@ -28645,27 +27595,6 @@ var createConcat = /* @__PURE__ */ factory(
28645
27595
  );
28646
27596
 
28647
27597
  // src/matrix/inv.ts
28648
- var WASM_INV_THRESHOLD = 16;
28649
- function isPlainNumberMatrix5(matrix2) {
28650
- for (let i = 0; i < matrix2.length; i++) {
28651
- const row2 = matrix2[i];
28652
- for (let j = 0; j < row2.length; j++) {
28653
- if (typeof row2[j] !== "number") {
28654
- return false;
28655
- }
28656
- }
28657
- }
28658
- return true;
28659
- }
28660
- function flattenToFloat645(matrix2, rows, cols) {
28661
- const result = new Float64Array(rows * cols);
28662
- for (let i = 0; i < rows; i++) {
28663
- for (let j = 0; j < cols; j++) {
28664
- result[i * cols + j] = matrix2[i][j];
28665
- }
28666
- }
28667
- return result;
28668
- }
28669
27598
  var name116 = "inv";
28670
27599
  var dependencies116 = [
28671
27600
  "typed",
@@ -28734,38 +27663,6 @@ var createInv = /* @__PURE__ */ factory(
28734
27663
  });
28735
27664
  function _inv4(mat, rows, cols) {
28736
27665
  let r, s, f, value, temp;
28737
- const wasm = wasmLoader.getModule();
28738
- if (wasm && rows >= 3 && rows * rows >= WASM_INV_THRESHOLD && isPlainNumberMatrix5(mat)) {
28739
- try {
28740
- const flat = flattenToFloat645(mat, rows, rows);
28741
- const input = wasmLoader.allocateFloat64Array(flat);
28742
- const result = wasmLoader.allocateFloat64ArrayEmpty(rows * rows);
28743
- const work = wasmLoader.allocateFloat64ArrayEmpty(rows * 2 * rows);
28744
- try {
28745
- const success = wasm.laInv(input.ptr, rows, result.ptr, work.ptr);
28746
- if (success === 0) {
28747
- throw Error("Cannot calculate inverse, determinant is zero");
28748
- }
28749
- const invMatrix = [];
28750
- for (let i = 0; i < rows; i++) {
28751
- const row2 = [];
28752
- for (let j = 0; j < rows; j++) {
28753
- row2[j] = result.array[i * rows + j];
28754
- }
28755
- invMatrix[i] = row2;
28756
- }
28757
- return invMatrix;
28758
- } finally {
28759
- wasmLoader.free(input.ptr);
28760
- wasmLoader.free(result.ptr);
28761
- wasmLoader.free(work.ptr);
28762
- }
28763
- } catch (e) {
28764
- if (e instanceof Error && e.message.includes("determinant is zero")) {
28765
- throw e;
28766
- }
28767
- }
28768
- }
28769
27666
  if (rows === 1) {
28770
27667
  value = mat[0][0];
28771
27668
  if (value === 0) {
@@ -29826,6 +28723,8 @@ var dependencies127 = ["typed", "add", "multiply", "Complex", "number"];
29826
28723
  var createZpk2tf = /* @__PURE__ */ factory(
29827
28724
  name127,
29828
28725
  dependencies127,
28726
+ // The deps are untyped (`any`), so the result is declared: without it the export
28727
+ // inherits `any` from `typed(...)` instead of being a TypedFunction like the rest.
29829
28728
  ({ typed: typed3, add: add5, multiply: multiply2, Complex: Complex13, number: number2 }) => {
29830
28729
  return typed3(name127, {
29831
28730
  "Array,Array,number": function(z, p, k) {
@@ -29885,7 +28784,7 @@ import { _switch as _switch2 } from "@danielsimonjr/mathts-core/internal";
29885
28784
 
29886
28785
  // src/statistics/cumsum.ts
29887
28786
  import { neumaierCumsum as neumaierCumsum2 } from "@danielsimonjr/mathts-core";
29888
- function isFlatNumberArray2(arr10) {
28787
+ function isFlatNumberArray(arr10) {
29889
28788
  for (let i = 0; i < arr10.length; i++) {
29890
28789
  if (typeof arr10[i] !== "number") {
29891
28790
  return false;
@@ -29932,7 +28831,7 @@ var createCumSum = /* @__PURE__ */ factory(
29932
28831
  if (array.length === 0) {
29933
28832
  return [];
29934
28833
  }
29935
- if (isFlatNumberArray2(array)) {
28834
+ if (isFlatNumberArray(array)) {
29936
28835
  const result = new Array(array.length);
29937
28836
  neumaierCumsum2(array, result);
29938
28837
  return result;
@@ -29984,7 +28883,7 @@ var createCumSum = /* @__PURE__ */ factory(
29984
28883
 
29985
28884
  // src/statistics/sum.ts
29986
28885
  import { pairwiseSum as pairwiseSum2 } from "@danielsimonjr/mathts-core";
29987
- function isFlatNumberArray3(arr10) {
28886
+ function isFlatNumberArray2(arr10) {
29988
28887
  for (let i = 0; i < arr10.length; i++) {
29989
28888
  if (typeof arr10[i] !== "number") {
29990
28889
  return false;
@@ -30016,7 +28915,7 @@ var createSum = /* @__PURE__ */ factory(
30016
28915
  }
30017
28916
  });
30018
28917
  function _sum(array) {
30019
- if (Array.isArray(array) && isFlatNumberArray3(array)) {
28918
+ if (Array.isArray(array) && isFlatNumberArray2(array)) {
30020
28919
  return pairwiseSum2(array);
30021
28920
  }
30022
28921
  let sum3;
@@ -30824,7 +29723,6 @@ var createMatAlgo10xSids = /* @__PURE__ */ factory(
30824
29723
  );
30825
29724
 
30826
29725
  // src/arithmetic/gcd.ts
30827
- var WASM_GCD_ARRAY_THRESHOLD = 50;
30828
29726
  var name140 = "gcd";
30829
29727
  var dependencies140 = [
30830
29728
  "typed",
@@ -30898,14 +29796,9 @@ var createGcd = /* @__PURE__ */ factory(
30898
29796
  ),
30899
29797
  Array: typed3.referToSelf((self) => (array) => {
30900
29798
  if (array.length === 1 && Array.isArray(array[0]) && is1d(array[0])) {
30901
- const flat = array[0];
30902
- const wasmResult = _tryWasmGcdArray(flat);
30903
- if (wasmResult !== null) return wasmResult;
30904
- return self(...flat);
29799
+ return self(...array[0]);
30905
29800
  }
30906
29801
  if (is1d(array)) {
30907
- const wasmResult = _tryWasmGcdArray(array);
30908
- if (wasmResult !== null) return wasmResult;
30909
29802
  return self(...array);
30910
29803
  }
30911
29804
  throw new Error("gcd() supports only 1d matrices!");
@@ -30915,27 +29808,6 @@ var createGcd = /* @__PURE__ */ factory(
30915
29808
  })
30916
29809
  }
30917
29810
  );
30918
- function _tryWasmGcdArray(array) {
30919
- if (array.length < WASM_GCD_ARRAY_THRESHOLD) return null;
30920
- const wasm = wasmLoader.getModule();
30921
- if (!wasm) return null;
30922
- const n = array.length;
30923
- const data = new Float64Array(n);
30924
- for (let i = 0; i < n; i++) {
30925
- if (typeof array[i] !== "number" || !isInteger(array[i])) {
30926
- return null;
30927
- }
30928
- data[i] = array[i];
30929
- }
30930
- const alloc = wasmLoader.allocateFloat64Array(data);
30931
- try {
30932
- return wasm.gcdArray(alloc.ptr, n);
30933
- } catch {
30934
- return null;
30935
- } finally {
30936
- wasmLoader.free(alloc.ptr);
30937
- }
30938
- }
30939
29811
  function _gcdNumber(a, b) {
30940
29812
  if (!isInteger(a) || !isInteger(b)) {
30941
29813
  throw new Error("Parameters in function gcd must be integer numbers");
@@ -32988,15 +31860,6 @@ var createComposition = /* @__PURE__ */ factory(
32988
31860
  );
32989
31861
 
32990
31862
  // src/matrix/partitionSelect.ts
32991
- var WASM_PARTITION_SELECT_THRESHOLD = 100;
32992
- function isFlatNumberArray4(arr10) {
32993
- for (let i = 0; i < arr10.length; i++) {
32994
- if (typeof arr10[i] !== "number") {
32995
- return false;
32996
- }
32997
- }
32998
- return true;
32999
- }
33000
31863
  var name171 = "partitionSelect";
33001
31864
  var dependencies171 = ["typed", "isNumeric", "isNaN", "compare"];
33002
31865
  var createPartitionSelect = /* @__PURE__ */ factory(
@@ -33042,29 +31905,6 @@ var createPartitionSelect = /* @__PURE__ */ factory(
33042
31905
  return arr10[i];
33043
31906
  }
33044
31907
  }
33045
- const wasm = wasmLoader.getModule();
33046
- if (wasm && arr10.length >= WASM_PARTITION_SELECT_THRESHOLD && isFlatNumberArray4(arr10)) {
33047
- const isAsc = compare3 === asc;
33048
- const isDesc = compare3 === desc;
33049
- if (isAsc || isDesc) {
33050
- try {
33051
- const effectiveK = isDesc ? arr10.length - 1 - k : k;
33052
- const data = wasmLoader.allocateFloat64Array(arr10);
33053
- const work = wasmLoader.allocateFloat64ArrayEmpty(arr10.length);
33054
- try {
33055
- const result = wasm.partitionSelect(data.ptr, arr10.length, effectiveK, work.ptr);
33056
- for (let i = 0; i < arr10.length; i++) {
33057
- arr10[i] = work.array[i];
33058
- }
33059
- return result;
33060
- } finally {
33061
- wasmLoader.free(data.ptr);
33062
- wasmLoader.free(work.ptr);
33063
- }
33064
- } catch {
33065
- }
33066
- }
33067
- }
33068
31908
  let from = 0;
33069
31909
  let to3 = arr10.length - 1;
33070
31910
  while (from < to3) {
@@ -33233,27 +32073,6 @@ var createPinv = /* @__PURE__ */ factory(
33233
32073
  );
33234
32074
 
33235
32075
  // src/algebra/decomposition/qr.ts
33236
- var WASM_QR_THRESHOLD = 16;
33237
- function isPlainNumberMatrix6(matrix2) {
33238
- for (let i = 0; i < matrix2.length; i++) {
33239
- const row2 = matrix2[i];
33240
- for (let j = 0; j < row2.length; j++) {
33241
- if (typeof row2[j] !== "number") {
33242
- return false;
33243
- }
33244
- }
33245
- }
33246
- return true;
33247
- }
33248
- function flattenToFloat646(matrix2, rows, cols) {
33249
- const result = new Float64Array(rows * cols);
33250
- for (let i = 0; i < rows; i++) {
33251
- for (let j = 0; j < cols; j++) {
33252
- result[i * cols + j] = matrix2[i][j];
33253
- }
33254
- }
33255
- return result;
33256
- }
33257
32076
  var name173 = "qr";
33258
32077
  var dependencies173 = [
33259
32078
  "typed",
@@ -33313,44 +32132,6 @@ var createQr = /* @__PURE__ */ factory(
33313
32132
  function _denseQRimpl(m) {
33314
32133
  const rows = m._size[0];
33315
32134
  const cols = m._size[1];
33316
- const wasm = wasmLoader.getModule();
33317
- if (wasm && rows * cols >= WASM_QR_THRESHOLD && isPlainNumberMatrix6(m._data)) {
33318
- try {
33319
- const flat = flattenToFloat646(m._data, rows, cols);
33320
- const aAlloc = wasmLoader.allocateFloat64Array(flat);
33321
- const qAlloc = wasmLoader.allocateFloat64ArrayEmpty(rows * rows);
33322
- try {
33323
- wasm.qrDecomposition(aAlloc.ptr, rows, cols, qAlloc.ptr);
33324
- const Rdata2 = [];
33325
- for (let i2 = 0; i2 < rows; i2++) {
33326
- Rdata2[i2] = [];
33327
- for (let j2 = 0; j2 < cols; j2++) {
33328
- Rdata2[i2][j2] = aAlloc.array[i2 * cols + j2];
33329
- }
33330
- }
33331
- const Qdata2 = [];
33332
- for (let i2 = 0; i2 < rows; i2++) {
33333
- Qdata2[i2] = [];
33334
- for (let j2 = 0; j2 < rows; j2++) {
33335
- Qdata2[i2][j2] = qAlloc.array[i2 * rows + j2];
33336
- }
33337
- }
33338
- const Q3 = matrix2(Qdata2);
33339
- const R2 = matrix2(Rdata2);
33340
- return {
33341
- Q: Q3,
33342
- R: R2,
33343
- toString: function() {
33344
- return "Q: " + this.Q.toString() + "\nR: " + this.R.toString();
33345
- }
33346
- };
33347
- } finally {
33348
- wasmLoader.free(aAlloc.ptr);
33349
- wasmLoader.free(qAlloc.ptr);
33350
- }
33351
- } catch {
33352
- }
33353
- }
33354
32135
  const Q2 = identity2([rows], "dense");
33355
32136
  const Qdata = Q2._data;
33356
32137
  const R = m.clone();
@@ -33843,15 +32624,6 @@ var createEqualText = /* @__PURE__ */ factory(
33843
32624
  );
33844
32625
 
33845
32626
  // src/statistics/max.ts
33846
- var WASM_MAX_THRESHOLD = 100;
33847
- function isFlatNumberArray5(arr10) {
33848
- for (let i = 0; i < arr10.length; i++) {
33849
- if (typeof arr10[i] !== "number") {
33850
- return false;
33851
- }
33852
- }
33853
- return true;
33854
- }
33855
32627
  var name178 = "max";
33856
32628
  var dependencies178 = ["typed", "config", "numeric", "larger", "isNaN"];
33857
32629
  var createMax = /* @__PURE__ */ factory(
@@ -33882,22 +32654,6 @@ var createMax = /* @__PURE__ */ factory(
33882
32654
  }
33883
32655
  }
33884
32656
  function _max(array) {
33885
- if (Array.isArray(array) && array.length >= WASM_MAX_THRESHOLD) {
33886
- if (isFlatNumberArray5(array)) {
33887
- const wasm = wasmLoader.getModule();
33888
- if (wasm) {
33889
- try {
33890
- const alloc = wasmLoader.allocateFloat64Array(array);
33891
- try {
33892
- return wasm.statsMax(alloc.ptr, array.length);
33893
- } finally {
33894
- wasmLoader.free(alloc.ptr);
33895
- }
33896
- } catch {
33897
- }
33898
- }
33899
- }
33900
- }
33901
32657
  let res;
33902
32658
  deepForEach(array, function(value) {
33903
32659
  try {
@@ -33922,15 +32678,6 @@ var createMax = /* @__PURE__ */ factory(
33922
32678
  );
33923
32679
 
33924
32680
  // src/statistics/min.ts
33925
- var WASM_MIN_THRESHOLD = 100;
33926
- function isFlatNumberArray6(arr10) {
33927
- for (let i = 0; i < arr10.length; i++) {
33928
- if (typeof arr10[i] !== "number") {
33929
- return false;
33930
- }
33931
- }
33932
- return true;
33933
- }
33934
32681
  var name179 = "min";
33935
32682
  var dependencies179 = ["typed", "config", "numeric", "smaller", "isNaN"];
33936
32683
  var createMin = /* @__PURE__ */ factory(
@@ -33961,22 +32708,6 @@ var createMin = /* @__PURE__ */ factory(
33961
32708
  }
33962
32709
  }
33963
32710
  function _min(array) {
33964
- if (Array.isArray(array) && array.length >= WASM_MIN_THRESHOLD) {
33965
- if (isFlatNumberArray6(array)) {
33966
- const wasm = wasmLoader.getModule();
33967
- if (wasm) {
33968
- try {
33969
- const alloc = wasmLoader.allocateFloat64Array(array);
33970
- try {
33971
- return wasm.statsMin(alloc.ptr, array.length);
33972
- } finally {
33973
- wasmLoader.free(alloc.ptr);
33974
- }
33975
- } catch {
33976
- }
33977
- }
33978
- }
33979
- }
33980
32711
  let min2;
33981
32712
  deepForEach(array, function(value) {
33982
32713
  try {
@@ -34092,7 +32823,6 @@ var createNullish = /* @__PURE__ */ factory(
34092
32823
  );
34093
32824
 
34094
32825
  // src/arithmetic/hypot.ts
34095
- var WASM_HYPOT_THRESHOLD = 50;
34096
32826
  var name181 = "hypot";
34097
32827
  var dependencies181 = [
34098
32828
  "typed",
@@ -34122,28 +32852,7 @@ var createHypot = /* @__PURE__ */ factory(
34122
32852
  Array: _hypot,
34123
32853
  Matrix: (M) => _hypot(flatten2(M.toArray(), true))
34124
32854
  });
34125
- function _tryWasmHypot(args) {
34126
- if (args.length < WASM_HYPOT_THRESHOLD) return null;
34127
- const wasm = wasmLoader.getModule();
34128
- if (!wasm) return null;
34129
- const n = args.length;
34130
- const data = new Float64Array(n);
34131
- for (let i = 0; i < n; i++) {
34132
- if (typeof args[i] !== "number") return null;
34133
- data[i] = args[i];
34134
- }
34135
- const alloc = wasmLoader.allocateFloat64Array(data);
34136
- try {
34137
- return wasm.hypotArray(alloc.ptr, n);
34138
- } catch {
34139
- return null;
34140
- } finally {
34141
- wasmLoader.free(alloc.ptr);
34142
- }
34143
- }
34144
32855
  function _hypot(args) {
34145
- const wasmResult = _tryWasmHypot(args);
34146
- if (wasmResult !== null) return wasmResult;
34147
32856
  let result = 0;
34148
32857
  let largest = 0;
34149
32858
  for (let i = 0; i < args.length; i++) {
@@ -34472,8 +33181,6 @@ var createDistance = /* @__PURE__ */ factory(
34472
33181
  return sqrt2(result);
34473
33182
  }
34474
33183
  function _distancePairwise(a) {
34475
- const wasmResult = _tryWasmPairwise(a);
34476
- if (wasmResult !== null) return wasmResult;
34477
33184
  const result = [];
34478
33185
  let pointA = [];
34479
33186
  let pointB = [];
@@ -34491,37 +33198,6 @@ var createDistance = /* @__PURE__ */ factory(
34491
33198
  }
34492
33199
  return result;
34493
33200
  }
34494
- function _tryWasmPairwise(a) {
34495
- const wasm = wasmLoader.getModule();
34496
- if (!wasm) return null;
34497
- const numPoints = a.length;
34498
- const dims = a[0].length;
34499
- for (let i = 0; i < numPoints; i++) {
34500
- for (let d = 0; d < dims; d++) {
34501
- if (typeof a[i][d] !== "number") return null;
34502
- }
34503
- }
34504
- const p1Alloc = wasmLoader.allocateFloat64ArrayEmpty(dims);
34505
- const p2Alloc = wasmLoader.allocateFloat64ArrayEmpty(dims);
34506
- try {
34507
- const result = [];
34508
- for (let i = 0; i < numPoints - 1; i++) {
34509
- for (let d = 0; d < dims; d++) {
34510
- p1Alloc.array[d] = a[i][d];
34511
- }
34512
- for (let j = i + 1; j < numPoints; j++) {
34513
- for (let d = 0; d < dims; d++) {
34514
- p2Alloc.array[d] = a[j][d];
34515
- }
34516
- result.push(wasm.distanceND(p1Alloc.ptr, p2Alloc.ptr, dims));
34517
- }
34518
- }
34519
- return result;
34520
- } finally {
34521
- wasmLoader.free(p1Alloc.ptr);
34522
- wasmLoader.free(p2Alloc.ptr);
34523
- }
34524
- }
34525
33201
  }
34526
33202
  );
34527
33203
 
@@ -37158,11 +35834,14 @@ var createDiff = /* @__PURE__ */ factory(
37158
35834
  return _recursive(arr10, dim);
37159
35835
  }
37160
35836
  },
37161
- // typed-function's runtime `referTo` is single-call variadic
37162
- // (`referTo(...signatures, callback)`); the imported TypedFunction interface
37163
- // models it curried, so narrow to the real contract via `unknown`.
37164
- "Array, BigNumber": typed3.referTo("Array,number", (selfAn) => (arr10, dim) => selfAn(arr10, number2(dim))),
37165
- "Matrix, BigNumber": typed3.referTo("Matrix,number", (selfMn) => (arr10, dim) => selfMn(arr10, number2(dim)))
35837
+ "Array, BigNumber": typed3.referTo(
35838
+ "Array,number",
35839
+ (selfAn) => (arr10, dim) => selfAn(arr10, number2(dim))
35840
+ ),
35841
+ "Matrix, BigNumber": typed3.referTo(
35842
+ "Matrix,number",
35843
+ (selfMn) => (arr10, dim) => selfMn(arr10, number2(dim))
35844
+ )
37166
35845
  });
37167
35846
  function _recursive(arr10, dim) {
37168
35847
  if (isMatrix(arr10)) {
@@ -37219,7 +35898,6 @@ var createDiff = /* @__PURE__ */ factory(
37219
35898
  );
37220
35899
 
37221
35900
  // src/matrix/sqrtm.ts
37222
- var WASM_SQRTM_THRESHOLD = 16;
37223
35901
  var name211 = "sqrtm";
37224
35902
  var dependencies211 = [
37225
35903
  "typed",
@@ -37240,62 +35918,6 @@ var createSqrtm = /* @__PURE__ */ factory(
37240
35918
  ({ typed: typed3, abs: abs2, add: add5, multiply: multiply2, map: map3, sqrt: sqrt2, subtract: subtract3, inv: inv3, size: size2, max: max2, identity: identity2 }) => {
37241
35919
  const _maxIterations = 1e3;
37242
35920
  const _tolerance = 1e-6;
37243
- function _tryWasmSqrtm(A, n) {
37244
- const wasm = wasmLoader.getModule();
37245
- if (!wasm || n * n < WASM_SQRTM_THRESHOLD) return null;
37246
- const data = isMatrix(A) ? A._data : A;
37247
- if (!data || !Array.isArray(data)) return null;
37248
- try {
37249
- const flat = new Float64Array(n * n);
37250
- for (let i = 0; i < n; i++) {
37251
- const row2 = data[i];
37252
- if (!Array.isArray(row2)) return null;
37253
- for (let j = 0; j < n; j++) {
37254
- const val = row2[j];
37255
- if (typeof val !== "number") return null;
37256
- flat[i * n + j] = val;
37257
- }
37258
- }
37259
- const matrixAlloc = wasmLoader.allocateFloat64Array(flat);
37260
- const resultAlloc = wasmLoader.allocateFloat64ArrayEmpty(n * n);
37261
- const workAlloc = wasmLoader.allocateFloat64ArrayEmpty(5 * n * n);
37262
- try {
37263
- const status = wasm.sqrtm(
37264
- matrixAlloc.ptr,
37265
- n,
37266
- resultAlloc.ptr,
37267
- _tolerance,
37268
- _maxIterations,
37269
- workAlloc.ptr
37270
- );
37271
- if (status > 0) {
37272
- const result = [];
37273
- for (let i = 0; i < n; i++) {
37274
- const row2 = [];
37275
- for (let j = 0; j < n; j++) {
37276
- row2[j] = resultAlloc.array[i * n + j];
37277
- }
37278
- result[i] = row2;
37279
- }
37280
- if (isMatrix(A)) {
37281
- const matA = A;
37282
- return matA.createDenseMatrix({
37283
- data: result,
37284
- size: [n, n],
37285
- datatype: matA._datatype
37286
- });
37287
- }
37288
- return result;
37289
- }
37290
- } finally {
37291
- wasmLoader.free(matrixAlloc.ptr);
37292
- wasmLoader.free(resultAlloc.ptr);
37293
- wasmLoader.free(workAlloc.ptr);
37294
- }
37295
- } catch {
37296
- }
37297
- return null;
37298
- }
37299
35921
  function _denmanBeavers(A) {
37300
35922
  let error;
37301
35923
  let iterations = 0;
@@ -37328,8 +35950,6 @@ var createSqrtm = /* @__PURE__ */ factory(
37328
35950
  const rows = sizeArray[0];
37329
35951
  const cols = sizeArray[1];
37330
35952
  if (rows === cols) {
37331
- const wasmResult = _tryWasmSqrtm(A, rows);
37332
- if (wasmResult !== null) return wasmResult;
37333
35953
  return _denmanBeavers(A);
37334
35954
  } else {
37335
35955
  throw new RangeError(
@@ -37348,27 +35968,6 @@ var createSqrtm = /* @__PURE__ */ factory(
37348
35968
  );
37349
35969
 
37350
35970
  // src/algebra/decomposition/lup.ts
37351
- var WASM_LUP_THRESHOLD = 16;
37352
- function isPlainNumberMatrix7(matrix2) {
37353
- for (let i = 0; i < matrix2.length; i++) {
37354
- const row2 = matrix2[i];
37355
- for (let j = 0; j < row2.length; j++) {
37356
- if (typeof row2[j] !== "number") {
37357
- return false;
37358
- }
37359
- }
37360
- }
37361
- return true;
37362
- }
37363
- function flattenToFloat647(matrix2, rows, cols) {
37364
- const result = new Float64Array(rows * cols);
37365
- for (let i = 0; i < rows; i++) {
37366
- for (let j = 0; j < cols; j++) {
37367
- result[i * cols + j] = matrix2[i][j];
37368
- }
37369
- }
37370
- return result;
37371
- }
37372
35971
  var name212 = "lup";
37373
35972
  var dependencies212 = [
37374
35973
  "typed",
@@ -37424,66 +36023,6 @@ var createLup = /* @__PURE__ */ factory(
37424
36023
  const rows = m._size[0];
37425
36024
  const columns = m._size[1];
37426
36025
  let n = Math.min(rows, columns);
37427
- const wasm = wasmLoader.getModule();
37428
- if (wasm && rows === columns && rows * rows >= WASM_LUP_THRESHOLD && isPlainNumberMatrix7(m._data)) {
37429
- try {
37430
- const flat = flattenToFloat647(m._data, rows, columns);
37431
- const aAlloc = wasmLoader.allocateFloat64Array(flat);
37432
- const permAlloc = wasmLoader.allocateInt32ArrayEmpty(rows);
37433
- try {
37434
- const result = wasm.luDecomposition(aAlloc.ptr, rows, permAlloc.ptr);
37435
- if (result !== 0) {
37436
- throw new Error("Matrix is singular and cannot be decomposed");
37437
- }
37438
- const ldata2 = [];
37439
- const udata2 = [];
37440
- for (let i2 = 0; i2 < rows; i2++) {
37441
- ldata2[i2] = [];
37442
- udata2[i2] = [];
37443
- for (let j2 = 0; j2 < columns; j2++) {
37444
- const val = aAlloc.array[i2 * columns + j2];
37445
- if (i2 > j2) {
37446
- ldata2[i2][j2] = val;
37447
- udata2[i2][j2] = 0;
37448
- } else if (i2 === j2) {
37449
- ldata2[i2][j2] = 1;
37450
- udata2[i2][j2] = val;
37451
- } else {
37452
- ldata2[i2][j2] = 0;
37453
- udata2[i2][j2] = val;
37454
- }
37455
- }
37456
- }
37457
- const p2 = [];
37458
- for (let i2 = 0; i2 < rows; i2++) {
37459
- p2[i2] = permAlloc.array[i2];
37460
- }
37461
- const l2 = new DenseMatrix7({
37462
- data: ldata2,
37463
- size: [rows, n]
37464
- });
37465
- const u2 = new DenseMatrix7({
37466
- data: udata2,
37467
- size: [n, columns]
37468
- });
37469
- return {
37470
- L: l2,
37471
- U: u2,
37472
- p: p2,
37473
- toString: function() {
37474
- return "L: " + this.L.toString() + "\nU: " + this.U.toString() + "\nP: " + this.p;
37475
- }
37476
- };
37477
- } finally {
37478
- wasmLoader.free(aAlloc.ptr);
37479
- wasmLoader.free(permAlloc.ptr);
37480
- }
37481
- } catch (e) {
37482
- if (e instanceof Error && e.message.includes("singular")) {
37483
- throw e;
37484
- }
37485
- }
37486
- }
37487
36026
  const data = clone(m._data);
37488
36027
  const ldata = [];
37489
36028
  const lsize = [rows, n];
@@ -38367,8 +36906,6 @@ var createIntersect = /* @__PURE__ */ factory(
38367
36906
  return x.length === 4 && isNumeric2(x[0]) && isNumeric2(x[1]) && isNumeric2(x[2]) && isNumeric2(x[3]);
38368
36907
  }
38369
36908
  function _intersect2d(p1a, p1b, p2a, p2b) {
38370
- const wasmResult = _tryWasmIntersect2d(p1a, p1b, p2a, p2b);
38371
- if (wasmResult !== void 0) return wasmResult;
38372
36909
  const o1 = p1a;
38373
36910
  const o2 = p2a;
38374
36911
  const d1 = subtract3(o1, p1b);
@@ -38394,34 +36931,6 @@ var createIntersect = /* @__PURE__ */ factory(
38394
36931
  );
38395
36932
  return add5(multiply2(d1, t), o1);
38396
36933
  }
38397
- function _tryWasmIntersect2d(p1a, p1b, p2a, p2b) {
38398
- const wasm = wasmLoader.getModule();
38399
- if (!wasm) return void 0;
38400
- if (typeof p1a[0] !== "number" || typeof p1a[1] !== "number" || typeof p1b[0] !== "number" || typeof p1b[1] !== "number" || typeof p2a[0] !== "number" || typeof p2a[1] !== "number" || typeof p2b[0] !== "number" || typeof p2b[1] !== "number") {
38401
- return void 0;
38402
- }
38403
- const resultAlloc = wasmLoader.allocateFloat64ArrayEmpty(3);
38404
- try {
38405
- wasm.intersect2DInfiniteLines(
38406
- p1a[0],
38407
- p1a[1],
38408
- p1b[0],
38409
- p1b[1],
38410
- p2a[0],
38411
- p2a[1],
38412
- p2b[0],
38413
- p2b[1],
38414
- resultAlloc.ptr
38415
- );
38416
- const exists = resultAlloc.array[2];
38417
- if (exists === 0) {
38418
- return null;
38419
- }
38420
- return [resultAlloc.array[0], resultAlloc.array[1]];
38421
- } finally {
38422
- wasmLoader.free(resultAlloc.ptr);
38423
- }
38424
- }
38425
36934
  function _intersect3dHelper(a, b, c, d, e, f, g, h, i, j, k, l) {
38426
36935
  const add1 = multiplyScalar2(
38427
36936
  subtract3(a, b),
@@ -38503,15 +37012,6 @@ var createIntersect = /* @__PURE__ */ factory(
38503
37012
  );
38504
37013
 
38505
37014
  // src/statistics/mean.ts
38506
- var WASM_MEAN_THRESHOLD = 100;
38507
- function isFlatNumberArray7(arr10) {
38508
- for (let i = 0; i < arr10.length; i++) {
38509
- if (typeof arr10[i] !== "number") {
38510
- return false;
38511
- }
38512
- }
38513
- return true;
38514
- }
38515
37015
  var name219 = "mean";
38516
37016
  var dependencies219 = ["typed", "add", "divide"];
38517
37017
  var createMean = /* @__PURE__ */ factory(
@@ -38542,22 +37042,6 @@ var createMean = /* @__PURE__ */ factory(
38542
37042
  }
38543
37043
  }
38544
37044
  function _mean2(array) {
38545
- if (Array.isArray(array) && array.length >= WASM_MEAN_THRESHOLD) {
38546
- if (isFlatNumberArray7(array)) {
38547
- const wasm = wasmLoader.getModule();
38548
- if (wasm) {
38549
- try {
38550
- const alloc = wasmLoader.allocateFloat64Array(array);
38551
- try {
38552
- return wasm.statsMean(alloc.ptr, array.length);
38553
- } finally {
38554
- wasmLoader.free(alloc.ptr);
38555
- }
38556
- } catch {
38557
- }
38558
- }
38559
- }
38560
- }
38561
37045
  let sum3;
38562
37046
  let num2 = 0;
38563
37047
  deepForEach(array, function(value) {
@@ -38642,7 +37126,7 @@ var createMedian = /* @__PURE__ */ factory(
38642
37126
 
38643
37127
  // src/statistics/variance.ts
38644
37128
  import { sumSquaredDeviations as sumSquaredDeviations2 } from "@danielsimonjr/mathts-core";
38645
- function isFlatNumberArray8(arr10) {
37129
+ function isFlatNumberArray3(arr10) {
38646
37130
  for (let i = 0; i < arr10.length; i++) {
38647
37131
  if (typeof arr10[i] !== "number") {
38648
37132
  return false;
@@ -38687,7 +37171,7 @@ var createVariance = /* @__PURE__ */ factory(
38687
37171
  if (array.length === 0) {
38688
37172
  throw new SyntaxError("Function variance requires one or more parameters (0 provided)");
38689
37173
  }
38690
- if (Array.isArray(array) && isFlatNumberArray8(array)) {
37174
+ if (Array.isArray(array) && isFlatNumberArray3(array)) {
38691
37175
  const nn = array.length;
38692
37176
  const ssd = sumSquaredDeviations2(array);
38693
37177
  switch (normalization) {
@@ -39015,12 +37499,13 @@ var createMultinomial = /* @__PURE__ */ factory(
39015
37499
  );
39016
37500
 
39017
37501
  // src/signal/freqz.ts
39018
- var WASM_FREQZ_THRESHOLD = 32;
39019
37502
  var name225 = "freqz";
39020
37503
  var dependencies225 = ["typed", "add", "multiply", "Complex", "divide", "matrix"];
39021
37504
  var createFreqz = /* @__PURE__ */ factory(
39022
37505
  name225,
39023
37506
  dependencies225,
37507
+ // The deps are untyped (`any`), so the result is declared: without it the export
37508
+ // inherits `any` from `typed(...)` instead of being a TypedFunction like the rest.
39024
37509
  ({ typed: typed3, add: add5, multiply: multiply2, Complex: Complex13, divide: divide2, matrix: matrix2 }) => {
39025
37510
  return typed3(name225, {
39026
37511
  "Array, Array": function(b, a) {
@@ -39068,47 +37553,7 @@ var createFreqz = /* @__PURE__ */ factory(
39068
37553
  };
39069
37554
  }
39070
37555
  });
39071
- function _tryWasmFreqz(b, a, w) {
39072
- const wasm = wasmLoader.getModule();
39073
- if (!wasm || w.length < WASM_FREQZ_THRESHOLD) return null;
39074
- try {
39075
- const bAlloc = wasmLoader.allocateFloat64Array(b);
39076
- const aAlloc = wasmLoader.allocateFloat64Array(a);
39077
- const wAlloc = wasmLoader.allocateFloat64Array(w);
39078
- const hRealAlloc = wasmLoader.allocateFloat64ArrayEmpty(w.length);
39079
- const hImagAlloc = wasmLoader.allocateFloat64ArrayEmpty(w.length);
39080
- try {
39081
- wasm.freqz(
39082
- bAlloc.ptr,
39083
- b.length,
39084
- aAlloc.ptr,
39085
- a.length,
39086
- wAlloc.ptr,
39087
- w.length,
39088
- hRealAlloc.ptr,
39089
- hImagAlloc.ptr
39090
- );
39091
- const h = [];
39092
- for (let i = 0; i < w.length; i++) {
39093
- h.push(Complex13(hRealAlloc.array[i], hImagAlloc.array[i]));
39094
- }
39095
- return { h, w };
39096
- } finally {
39097
- wasmLoader.free(bAlloc.ptr);
39098
- wasmLoader.free(aAlloc.ptr);
39099
- wasmLoader.free(wAlloc.ptr);
39100
- wasmLoader.free(hRealAlloc.ptr);
39101
- wasmLoader.free(hImagAlloc.ptr);
39102
- }
39103
- } catch {
39104
- }
39105
- return null;
39106
- }
39107
37556
  function _freqz(b, a, w) {
39108
- const wasmResult = _tryWasmFreqz(b, a, w);
39109
- if (wasmResult !== null) {
39110
- return wasmResult;
39111
- }
39112
37557
  const num2 = [];
39113
37558
  const den = [];
39114
37559
  for (let i = 0; i < w.length; i++) {
@@ -40220,16 +38665,6 @@ var createIndex = /* @__PURE__ */ factory(
40220
38665
  );
40221
38666
 
40222
38667
  // src/matrix/eigs/complexEigs.ts
40223
- var WASM_EIGS_THRESHOLD = 16;
40224
- function flattenToFloat648(matrix2, rows, cols) {
40225
- const result = new Float64Array(rows * cols);
40226
- for (let i = 0; i < rows; i++) {
40227
- for (let j = 0; j < cols; j++) {
40228
- result[i * cols + j] = matrix2[i][j];
40229
- }
40230
- }
40231
- return result;
40232
- }
40233
38668
  function createComplexEigs({
40234
38669
  addScalar: addScalar2,
40235
38670
  subtract: subtract3,
@@ -40255,54 +38690,6 @@ function createComplexEigs({
40255
38690
  dot: dot9
40256
38691
  }) {
40257
38692
  function complexEigs(arr10, N2, prec, type, findVectors = true) {
40258
- if (!findVectors && type === "number" && N2 * N2 >= WASM_EIGS_THRESHOLD) {
40259
- const wasm = wasmLoader.getModule();
40260
- if (wasm) {
40261
- try {
40262
- const flat = flattenToFloat648(arr10, N2, N2);
40263
- const matrixAlloc = wasmLoader.allocateFloat64Array(flat);
40264
- const eigenvaluesRealAlloc = wasmLoader.allocateFloat64ArrayEmpty(N2);
40265
- const eigenvaluesImagAlloc = wasmLoader.allocateFloat64ArrayEmpty(N2);
40266
- const workAlloc = wasmLoader.allocateFloat64ArrayEmpty(N2 * N2);
40267
- try {
40268
- const iterations = wasm.qrAlgorithm(
40269
- matrixAlloc.ptr,
40270
- N2,
40271
- eigenvaluesRealAlloc.ptr,
40272
- eigenvaluesImagAlloc.ptr,
40273
- workAlloc.ptr,
40274
- 1e3,
40275
- // maxIterations
40276
- typeof prec === "number" ? prec : 1e-12
40277
- );
40278
- if (iterations >= 0) {
40279
- const values2 = [];
40280
- for (let i = 0; i < N2; i++) {
40281
- const re3 = eigenvaluesRealAlloc.array[i];
40282
- const im3 = eigenvaluesImagAlloc.array[i];
40283
- if (Math.abs(im3) < 1e-14) {
40284
- values2.push(re3);
40285
- } else {
40286
- values2.push(complex3(re3, im3));
40287
- }
40288
- }
40289
- values2.sort((a, b) => {
40290
- const absA = typeof a === "number" ? Math.abs(a) : Math.sqrt(a.re ** 2 + a.im ** 2);
40291
- const absB = typeof b === "number" ? Math.abs(b) : Math.sqrt(b.re ** 2 + b.im ** 2);
40292
- return absA - absB;
40293
- });
40294
- return { values: values2 };
40295
- }
40296
- } finally {
40297
- wasmLoader.free(matrixAlloc.ptr);
40298
- wasmLoader.free(eigenvaluesRealAlloc.ptr);
40299
- wasmLoader.free(eigenvaluesImagAlloc.ptr);
40300
- wasmLoader.free(workAlloc.ptr);
40301
- }
40302
- } catch {
40303
- }
40304
- }
40305
- }
40306
38693
  const R = balance(arr10, N2, prec, type, findVectors);
40307
38694
  reduceToHessenberg(arr10, N2, prec, type, findVectors, R);
40308
38695
  const { values, C } = iterateUntilTriangular(arr10, N2, prec, type, findVectors);
@@ -40713,16 +39100,6 @@ function createComplexEigs({
40713
39100
  }
40714
39101
 
40715
39102
  // src/matrix/eigs/realSymmetric.ts
40716
- var WASM_EIGS_THRESHOLD2 = 16;
40717
- function flattenToFloat649(matrix2, rows, cols) {
40718
- const result = new Float64Array(rows * cols);
40719
- for (let i = 0; i < rows; i++) {
40720
- for (let j = 0; j < cols; j++) {
40721
- result[i * cols + j] = matrix2[i][j];
40722
- }
40723
- }
40724
- return result;
40725
- }
40726
39103
  function createRealSymmetric({
40727
39104
  config: config2,
40728
39105
  addScalar: addScalar2,
@@ -40760,62 +39137,6 @@ function createRealSymmetric({
40760
39137
  }
40761
39138
  function diag2(x, precision, computeVectors) {
40762
39139
  const N2 = x.length;
40763
- const wasm = wasmLoader.getModule();
40764
- if (wasm && N2 * N2 >= WASM_EIGS_THRESHOLD2) {
40765
- try {
40766
- const flat = flattenToFloat649(x, N2, N2);
40767
- const matrixAlloc = wasmLoader.allocateFloat64Array(flat);
40768
- const eigenvaluesAlloc = wasmLoader.allocateFloat64ArrayEmpty(N2);
40769
- const eigenvectorsAlloc = computeVectors ? wasmLoader.allocateFloat64ArrayEmpty(N2 * N2) : { ptr: 0, array: new Float64Array(0) };
40770
- const workAlloc = wasmLoader.allocateFloat64ArrayEmpty(N2 * N2);
40771
- try {
40772
- const iterations = wasm.eigsSymmetric(
40773
- matrixAlloc.ptr,
40774
- N2,
40775
- eigenvaluesAlloc.ptr,
40776
- eigenvectorsAlloc.ptr,
40777
- workAlloc.ptr,
40778
- 1e3,
40779
- // maxIterations
40780
- precision
40781
- );
40782
- if (iterations >= 0) {
40783
- const values = Array(N2);
40784
- for (let i = 0; i < N2; i++) {
40785
- values[i] = eigenvaluesAlloc.array[i];
40786
- }
40787
- if (!computeVectors) {
40788
- const sortedValues = values.map((v, i) => ({ v, i })).sort((a, b) => Math.abs(a.v) - Math.abs(b.v)).map((x2) => x2.v);
40789
- return { values: sortedValues };
40790
- }
40791
- const eigenvectors = [];
40792
- const sortedIndices = values.map((v, i) => ({ v, i })).sort((a, b) => Math.abs(a.v) - Math.abs(b.v)).map((x2) => x2.i);
40793
- for (const origIdx of sortedIndices) {
40794
- const vector = Array(N2);
40795
- for (let i = 0; i < N2; i++) {
40796
- vector[i] = eigenvectorsAlloc.array[i * N2 + origIdx];
40797
- }
40798
- eigenvectors.push({
40799
- value: values[origIdx],
40800
- vector
40801
- });
40802
- }
40803
- return {
40804
- values: sortedIndices.map((i) => values[i]),
40805
- eigenvectors
40806
- };
40807
- }
40808
- } finally {
40809
- wasmLoader.free(matrixAlloc.ptr);
40810
- wasmLoader.free(eigenvaluesAlloc.ptr);
40811
- if (computeVectors) {
40812
- wasmLoader.free(eigenvectorsAlloc.ptr);
40813
- }
40814
- wasmLoader.free(workAlloc.ptr);
40815
- }
40816
- } catch {
40817
- }
40818
- }
40819
39140
  const e0 = Math.abs(precision / N2);
40820
39141
  let psi;
40821
39142
  let Sij;
@@ -41338,42 +39659,6 @@ function csIpvec(p, b) {
41338
39659
  }
41339
39660
 
41340
39661
  // src/algebra/solver/lusolve.ts
41341
- var WASM_LUSOLVE_THRESHOLD = 16;
41342
- function isPlainNumberMatrix8(matrix2) {
41343
- for (let i = 0; i < matrix2.length; i++) {
41344
- const row2 = matrix2[i];
41345
- for (let j = 0; j < row2.length; j++) {
41346
- if (typeof row2[j] !== "number") {
41347
- return false;
41348
- }
41349
- }
41350
- }
41351
- return true;
41352
- }
41353
- function isPlainNumberVector3(vec) {
41354
- for (let i = 0; i < vec.length; i++) {
41355
- if (typeof vec[i][0] !== "number") {
41356
- return false;
41357
- }
41358
- }
41359
- return true;
41360
- }
41361
- function flattenToFloat6410(matrix2, rows, cols) {
41362
- const result = new Float64Array(rows * cols);
41363
- for (let i = 0; i < rows; i++) {
41364
- for (let j = 0; j < cols; j++) {
41365
- result[i * cols + j] = matrix2[i][j];
41366
- }
41367
- }
41368
- return result;
41369
- }
41370
- function vectorToFloat643(vec) {
41371
- const result = new Float64Array(vec.length);
41372
- for (let i = 0; i < vec.length; i++) {
41373
- result[i] = vec[i][0];
41374
- }
41375
- return result;
41376
- }
41377
39662
  var name238 = "lusolve";
41378
39663
  var dependencies238 = ["typed", "matrix", "lup", "slu", "usolve", "lsolve", "DenseMatrix"];
41379
39664
  var createLusolve = /* @__PURE__ */ factory(
@@ -41385,102 +39670,12 @@ var createLusolve = /* @__PURE__ */ factory(
41385
39670
  });
41386
39671
  return typed3(name238, {
41387
39672
  "Array, Array | Matrix": function(a, b) {
41388
- const rows = a.length;
41389
- const columns = a[0]?.length || 0;
41390
- const wasm = wasmLoader.getModule();
41391
- if (wasm && rows === columns && rows * rows >= WASM_LUSOLVE_THRESHOLD && isPlainNumberMatrix8(a)) {
41392
- const aMatrix2 = matrix2(a);
41393
- const bMatrix = solveValidation(aMatrix2, b, true);
41394
- const bdata = bMatrix._data;
41395
- if (isPlainNumberVector3(bdata) && bdata.length === rows) {
41396
- try {
41397
- const aFlat = flattenToFloat6410(a, rows, columns);
41398
- const bFlat = vectorToFloat643(bdata);
41399
- const aAlloc = wasmLoader.allocateFloat64Array(aFlat);
41400
- const bAlloc = wasmLoader.allocateFloat64Array(bFlat);
41401
- const resultAlloc = wasmLoader.allocateFloat64ArrayEmpty(rows);
41402
- const workAlloc = wasmLoader.allocateFloat64ArrayEmpty(rows * rows);
41403
- try {
41404
- const success = wasm.laSolve(
41405
- aAlloc.ptr,
41406
- bAlloc.ptr,
41407
- rows,
41408
- resultAlloc.ptr,
41409
- workAlloc.ptr
41410
- );
41411
- if (success === 0) {
41412
- throw new Error("Linear system cannot be solved since matrix is singular");
41413
- }
41414
- const x2 = [];
41415
- for (let i = 0; i < rows; i++) {
41416
- x2[i] = [resultAlloc.array[i]];
41417
- }
41418
- return x2;
41419
- } finally {
41420
- wasmLoader.free(aAlloc.ptr);
41421
- wasmLoader.free(bAlloc.ptr);
41422
- wasmLoader.free(resultAlloc.ptr);
41423
- wasmLoader.free(workAlloc.ptr);
41424
- }
41425
- } catch (e) {
41426
- if (e instanceof Error && e.message.includes("singular")) {
41427
- throw e;
41428
- }
41429
- }
41430
- }
41431
- }
41432
39673
  const aMatrix = matrix2(a);
41433
39674
  const d = lup2(aMatrix);
41434
39675
  const x = _lusolve(d.L, d.U, d.p, null, b);
41435
39676
  return x.valueOf();
41436
39677
  },
41437
39678
  "DenseMatrix, Array | Matrix": function(a, b) {
41438
- const rows = a._size[0];
41439
- const columns = a._size[1];
41440
- const wasm = wasmLoader.getModule();
41441
- if (wasm && rows === columns && rows * rows >= WASM_LUSOLVE_THRESHOLD && isPlainNumberMatrix8(a._data)) {
41442
- const bMatrix = solveValidation(a, b, true);
41443
- const bdata = bMatrix._data;
41444
- if (isPlainNumberVector3(bdata) && bdata.length === rows) {
41445
- try {
41446
- const aFlat = flattenToFloat6410(a._data, rows, columns);
41447
- const bFlat = vectorToFloat643(bdata);
41448
- const aAlloc = wasmLoader.allocateFloat64Array(aFlat);
41449
- const bAlloc = wasmLoader.allocateFloat64Array(bFlat);
41450
- const resultAlloc = wasmLoader.allocateFloat64ArrayEmpty(rows);
41451
- const workAlloc = wasmLoader.allocateFloat64ArrayEmpty(rows * rows);
41452
- try {
41453
- const success = wasm.laSolve(
41454
- aAlloc.ptr,
41455
- bAlloc.ptr,
41456
- rows,
41457
- resultAlloc.ptr,
41458
- workAlloc.ptr
41459
- );
41460
- if (success === 0) {
41461
- throw new Error("Linear system cannot be solved since matrix is singular");
41462
- }
41463
- const x = [];
41464
- for (let i = 0; i < rows; i++) {
41465
- x[i] = [resultAlloc.array[i]];
41466
- }
41467
- return new DenseMatrix7({
41468
- data: x,
41469
- size: [rows, 1]
41470
- });
41471
- } finally {
41472
- wasmLoader.free(aAlloc.ptr);
41473
- wasmLoader.free(bAlloc.ptr);
41474
- wasmLoader.free(resultAlloc.ptr);
41475
- wasmLoader.free(workAlloc.ptr);
41476
- }
41477
- } catch (e) {
41478
- if (e instanceof Error && e.message.includes("singular")) {
41479
- throw e;
41480
- }
41481
- }
41482
- }
41483
- }
41484
39679
  const d = lup2(a);
41485
39680
  return _lusolve(d.L, d.U, d.p, null, b);
41486
39681
  },
@@ -41603,15 +39798,6 @@ var createCorr = /* @__PURE__ */ factory(
41603
39798
  );
41604
39799
 
41605
39800
  // src/statistics/mad.ts
41606
- var WASM_MAD_THRESHOLD = 500;
41607
- function isPlainNumberArray2(arr10) {
41608
- for (let i = 0; i < arr10.length; i++) {
41609
- if (typeof arr10[i] !== "number") {
41610
- return false;
41611
- }
41612
- }
41613
- return true;
41614
- }
41615
39801
  var name240 = "mad";
41616
39802
  var dependencies240 = ["typed", "abs", "map", "median", "subtract"];
41617
39803
  var createMad = /* @__PURE__ */ factory(
@@ -41631,19 +39817,6 @@ var createMad = /* @__PURE__ */ factory(
41631
39817
  if (flat.length === 0) {
41632
39818
  throw new Error("Cannot calculate median absolute deviation (mad) of an empty array");
41633
39819
  }
41634
- const wasm = wasmLoader.getModule();
41635
- if (wasm && flat.length >= WASM_MAD_THRESHOLD && isPlainNumberArray2(flat)) {
41636
- try {
41637
- const aAlloc = wasmLoader.allocateFloat64Array(flat);
41638
- try {
41639
- const result = wasm.statsMad(aAlloc.ptr, flat.length);
41640
- return result;
41641
- } finally {
41642
- wasmLoader.free(aAlloc.ptr);
41643
- }
41644
- } catch {
41645
- }
41646
- }
41647
39820
  try {
41648
39821
  const med = median2(flat);
41649
39822
  return median2(
@@ -43146,7 +41319,6 @@ var createDerivative = /* @__PURE__ */ factory(
43146
41319
 
43147
41320
  // src/arithmetic/norm.ts
43148
41321
  import { norm2 as norm23 } from "@danielsimonjr/mathts-core";
43149
- var WASM_NORM_THRESHOLD = 100;
43150
41322
  var name245 = "norm";
43151
41323
  var dependencies245 = [
43152
41324
  "typed",
@@ -43205,39 +41377,6 @@ var createNorm = /* @__PURE__ */ factory(
43205
41377
  return _norm(x, p);
43206
41378
  }
43207
41379
  });
43208
- function _tryWasmVectorNorm(x, p) {
43209
- const size2 = x.size();
43210
- if (size2.length !== 1 || size2[0] < WASM_NORM_THRESHOLD) return null;
43211
- const wasm = wasmLoader.getModule();
43212
- if (!wasm) return null;
43213
- const arr10 = x.toArray();
43214
- const n = arr10.length;
43215
- const data = new Float64Array(n);
43216
- for (let i = 0; i < n; i++) {
43217
- if (typeof arr10[i] !== "number") return null;
43218
- data[i] = arr10[i];
43219
- }
43220
- const alloc = wasmLoader.allocateFloat64Array(data);
43221
- try {
43222
- if (p === 1) {
43223
- return wasm.norm1(alloc.ptr, n);
43224
- }
43225
- if (p === 2) {
43226
- return wasm.norm2(alloc.ptr, n);
43227
- }
43228
- if (p === Number.POSITIVE_INFINITY || p === "inf") {
43229
- return wasm.normInf(alloc.ptr, n);
43230
- }
43231
- if (typeof p === "number" && !isNaN(p) && p !== 0) {
43232
- return wasm.normP(alloc.ptr, n, p);
43233
- }
43234
- return null;
43235
- } catch {
43236
- return null;
43237
- } finally {
43238
- wasmLoader.free(alloc.ptr);
43239
- }
43240
- }
43241
41380
  function _vectorNormPlusInfinity(x) {
43242
41381
  let pinf = 0;
43243
41382
  x.forEach(function(value) {
@@ -43259,8 +41398,6 @@ var createNorm = /* @__PURE__ */ factory(
43259
41398
  return ninf || 0;
43260
41399
  }
43261
41400
  function _vectorNorm(x, p) {
43262
- const wasmResult = _tryWasmVectorNorm(x, p);
43263
- if (wasmResult !== null) return wasmResult;
43264
41401
  if (p === Number.POSITIVE_INFINITY || p === "inf") {
43265
41402
  return _vectorNormPlusInfinity(x);
43266
41403
  }
@@ -44021,7 +42158,7 @@ var createRotationMatrix = /* @__PURE__ */ factory(
44021
42158
 
44022
42159
  // src/algebra/decomposition/schur.ts
44023
42160
  import { matrixSchur, DenseMatrix as NativeDenseMatrix } from "@danielsimonjr/mathts-matrix";
44024
- function isPlainNumberMatrix9(matrix2) {
42161
+ function isPlainNumberMatrix2(matrix2) {
44025
42162
  for (let i = 0; i < matrix2.length; i++) {
44026
42163
  const row2 = matrix2[i];
44027
42164
  for (let j = 0; j < row2.length; j++) {
@@ -44051,7 +42188,7 @@ var createSchur = /* @__PURE__ */ factory(
44051
42188
  }
44052
42189
  });
44053
42190
  function _schur(data) {
44054
- if (!isPlainNumberMatrix9(data)) {
42191
+ if (!isPlainNumberMatrix2(data)) {
44055
42192
  throw new TypeError("schur: only real (number) matrices are supported");
44056
42193
  }
44057
42194
  const n = data.length;
@@ -57661,6 +55798,7 @@ export {
57661
55798
  isNumeric,
57662
55799
  isPositive,
57663
55800
  isPrime2 as isPrime,
55801
+ isWasmLoaded,
57664
55802
  isZero3 as isZero,
57665
55803
  istft,
57666
55804
  jacobiCN,
@@ -57726,6 +55864,7 @@ export {
57726
55864
  linregress,
57727
55865
  linsolve,
57728
55866
  ljungBox,
55867
+ loadWasm,
57729
55868
  loess,
57730
55869
  log,
57731
55870
  log10,