@danielsimonjr/mathts-functions 0.64.2 → 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.
- package/README.md +21 -21
- package/dist/algebra/decomposition/lup.d.ts +1 -1
- package/dist/algebra/decomposition/lup.d.ts.map +1 -1
- package/dist/algebra/decomposition/qr.d.ts +1 -1
- package/dist/algebra/decomposition/qr.d.ts.map +1 -1
- package/dist/algebra/decomposition/schur.d.ts +1 -1
- package/dist/algebra/decomposition/schur.d.ts.map +1 -1
- package/dist/algebra/decomposition/slu.d.ts +1 -1
- package/dist/algebra/decomposition/slu.d.ts.map +1 -1
- package/dist/algebra/leafCount.d.ts +1 -1
- package/dist/algebra/leafCount.d.ts.map +1 -1
- package/dist/algebra/lyap.d.ts +1 -1
- package/dist/algebra/lyap.d.ts.map +1 -1
- package/dist/algebra/polynomialRoot.d.ts +1 -1
- package/dist/algebra/polynomialRoot.d.ts.map +1 -1
- package/dist/algebra/rationalize.d.ts +1 -1
- package/dist/algebra/rationalize.d.ts.map +1 -1
- package/dist/algebra/resolve.d.ts +1 -1
- package/dist/algebra/resolve.d.ts.map +1 -1
- package/dist/algebra/simplify/util.d.ts.map +1 -1
- package/dist/algebra/simplifyConstant.d.ts.map +1 -1
- package/dist/algebra/simplifyCore.d.ts +1 -1
- package/dist/algebra/simplifyCore.d.ts.map +1 -1
- package/dist/algebra/solver/lsolve.d.ts +1 -1
- package/dist/algebra/solver/lsolve.d.ts.map +1 -1
- package/dist/algebra/solver/lsolveAll.d.ts +2 -2
- package/dist/algebra/solver/lsolveAll.d.ts.map +1 -1
- package/dist/algebra/solver/lusolve.d.ts +1 -1
- package/dist/algebra/solver/lusolve.d.ts.map +1 -1
- package/dist/algebra/solver/usolve.d.ts +1 -1
- package/dist/algebra/solver/usolve.d.ts.map +1 -1
- package/dist/algebra/solver/usolveAll.d.ts +2 -2
- package/dist/algebra/solver/usolveAll.d.ts.map +1 -1
- package/dist/algebra/sparse/csAmd.d.ts.map +1 -1
- package/dist/algebra/sparse/csCounts.d.ts.map +1 -1
- package/dist/algebra/sylvester.d.ts +1 -1
- package/dist/algebra/sylvester.d.ts.map +1 -1
- package/dist/algebra/symbolicEqual.d.ts +1 -1
- package/dist/algebra/symbolicEqual.d.ts.map +1 -1
- package/dist/arithmetic/abs.d.ts +1 -1
- package/dist/arithmetic/abs.d.ts.map +1 -1
- package/dist/arithmetic/addScalar.d.ts +1 -1
- package/dist/arithmetic/addScalar.d.ts.map +1 -1
- package/dist/arithmetic/cbrt.d.ts +1 -1
- package/dist/arithmetic/cbrt.d.ts.map +1 -1
- package/dist/arithmetic/ceil.d.ts +2 -2
- package/dist/arithmetic/ceil.d.ts.map +1 -1
- package/dist/arithmetic/cube.d.ts +1 -1
- package/dist/arithmetic/cube.d.ts.map +1 -1
- package/dist/arithmetic/divide.d.ts +2 -1
- package/dist/arithmetic/divide.d.ts.map +1 -1
- package/dist/arithmetic/divideScalar.d.ts +1 -1
- package/dist/arithmetic/divideScalar.d.ts.map +1 -1
- package/dist/arithmetic/exp.d.ts +1 -1
- package/dist/arithmetic/exp.d.ts.map +1 -1
- package/dist/arithmetic/expm1.d.ts +1 -1
- package/dist/arithmetic/expm1.d.ts.map +1 -1
- package/dist/arithmetic/fix.d.ts +2 -2
- package/dist/arithmetic/fix.d.ts.map +1 -1
- package/dist/arithmetic/floor.d.ts +2 -2
- package/dist/arithmetic/floor.d.ts.map +1 -1
- package/dist/arithmetic/gcd.d.ts.map +1 -1
- package/dist/arithmetic/hypot.d.ts.map +1 -1
- package/dist/arithmetic/log.d.ts +1 -1
- package/dist/arithmetic/log.d.ts.map +1 -1
- package/dist/arithmetic/log10.d.ts +1 -1
- package/dist/arithmetic/log10.d.ts.map +1 -1
- package/dist/arithmetic/log1p.d.ts +1 -1
- package/dist/arithmetic/log1p.d.ts.map +1 -1
- package/dist/arithmetic/log2.d.ts +1 -1
- package/dist/arithmetic/log2.d.ts.map +1 -1
- package/dist/arithmetic/mod.d.ts +1 -1
- package/dist/arithmetic/mod.d.ts.map +1 -1
- package/dist/arithmetic/multiplyScalar.d.ts +1 -1
- package/dist/arithmetic/multiplyScalar.d.ts.map +1 -1
- package/dist/arithmetic/norm.d.ts.map +1 -1
- package/dist/arithmetic/nthRoot.d.ts.map +1 -1
- package/dist/arithmetic/pow.d.ts +1 -1
- package/dist/arithmetic/pow.d.ts.map +1 -1
- package/dist/arithmetic/round.d.ts +1 -1
- package/dist/arithmetic/round.d.ts.map +1 -1
- package/dist/arithmetic/sign.d.ts +1 -1
- package/dist/arithmetic/sign.d.ts.map +1 -1
- package/dist/arithmetic/sqrt.d.ts +1 -1
- package/dist/arithmetic/sqrt.d.ts.map +1 -1
- package/dist/arithmetic/square.d.ts +1 -1
- package/dist/arithmetic/square.d.ts.map +1 -1
- package/dist/arithmetic/subtract.d.ts +1 -1
- package/dist/arithmetic/subtract.d.ts.map +1 -1
- package/dist/arithmetic/subtractScalar.d.ts +1 -1
- package/dist/arithmetic/subtractScalar.d.ts.map +1 -1
- package/dist/arithmetic/unaryMinus.d.ts +1 -1
- package/dist/arithmetic/unaryMinus.d.ts.map +1 -1
- package/dist/arithmetic/unaryPlus.d.ts +1 -1
- package/dist/arithmetic/unaryPlus.d.ts.map +1 -1
- package/dist/bitwise/bitAnd.d.ts +1 -1
- package/dist/bitwise/bitAnd.d.ts.map +1 -1
- package/dist/bitwise/bitNot.d.ts +1 -1
- package/dist/bitwise/bitNot.d.ts.map +1 -1
- package/dist/bitwise/bitOr.d.ts +1 -1
- package/dist/bitwise/bitOr.d.ts.map +1 -1
- package/dist/bitwise/bitXor.d.ts +1 -1
- package/dist/bitwise/bitXor.d.ts.map +1 -1
- package/dist/bitwise/leftShift.d.ts +1 -1
- package/dist/bitwise/leftShift.d.ts.map +1 -1
- package/dist/bitwise/rightArithShift.d.ts +1 -1
- package/dist/bitwise/rightArithShift.d.ts.map +1 -1
- package/dist/bitwise/rightLogShift.d.ts +1 -1
- package/dist/bitwise/rightLogShift.d.ts.map +1 -1
- package/dist/bitwise/useMatrixForArrayScalar.d.ts.map +1 -1
- package/dist/calculus-extra.d.ts.map +1 -1
- package/dist/{chunk-UMUT2YEC.js → chunk-5A2EZLXV.js} +77 -181
- package/dist/combinatorics/bellNumbers.d.ts +1 -1
- package/dist/combinatorics/bellNumbers.d.ts.map +1 -1
- package/dist/combinatorics/catalan.d.ts +1 -1
- package/dist/combinatorics/catalan.d.ts.map +1 -1
- package/dist/combinatorics/composition.d.ts +1 -1
- package/dist/combinatorics/composition.d.ts.map +1 -1
- package/dist/combinatorics/stirlingS2.d.ts +1 -1
- package/dist/combinatorics/stirlingS2.d.ts.map +1 -1
- package/dist/complex/arg.d.ts +1 -1
- package/dist/complex/arg.d.ts.map +1 -1
- package/dist/complex/conj.d.ts +1 -1
- package/dist/complex/conj.d.ts.map +1 -1
- package/dist/complex/im.d.ts +1 -1
- package/dist/complex/im.d.ts.map +1 -1
- package/dist/complex/re.d.ts +1 -1
- package/dist/complex/re.d.ts.map +1 -1
- package/dist/core/function/typed.d.ts +11 -1
- package/dist/core/function/typed.d.ts.map +1 -1
- package/dist/distribution-functions.d.ts.map +1 -1
- package/dist/factories/index.d.ts +184 -184
- package/dist/factories/index.d.ts.map +1 -1
- package/dist/geometry/distance.d.ts +1 -1
- package/dist/geometry/distance.d.ts.map +1 -1
- package/dist/geometry/intersect.d.ts +1 -1
- package/dist/geometry/intersect.d.ts.map +1 -1
- package/dist/geometry-extra.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +399 -2016
- package/dist/logical/and.d.ts +1 -1
- package/dist/logical/and.d.ts.map +1 -1
- package/dist/logical/not.d.ts +1 -1
- package/dist/logical/not.d.ts.map +1 -1
- package/dist/logical/nullish.d.ts.map +1 -1
- package/dist/logical/or.d.ts +1 -1
- package/dist/logical/or.d.ts.map +1 -1
- package/dist/logical/xor.d.ts +1 -1
- package/dist/logical/xor.d.ts.map +1 -1
- package/dist/matrix/column.d.ts +2 -1
- package/dist/matrix/column.d.ts.map +1 -1
- package/dist/matrix/concat.d.ts +1 -1
- package/dist/matrix/concat.d.ts.map +1 -1
- package/dist/matrix/count.d.ts +1 -1
- package/dist/matrix/count.d.ts.map +1 -1
- package/dist/matrix/cross.d.ts +1 -1
- package/dist/matrix/cross.d.ts.map +1 -1
- package/dist/matrix/ctranspose.d.ts +1 -1
- package/dist/matrix/ctranspose.d.ts.map +1 -1
- package/dist/matrix/det.d.ts +3 -2
- package/dist/matrix/det.d.ts.map +1 -1
- package/dist/matrix/diag.d.ts +1 -1
- package/dist/matrix/diag.d.ts.map +1 -1
- package/dist/matrix/diff.d.ts.map +1 -1
- package/dist/matrix/dot.d.ts +1 -1
- package/dist/matrix/dot.d.ts.map +1 -1
- package/dist/matrix/eigs/complexEigs.d.ts +1 -1
- package/dist/matrix/eigs/complexEigs.d.ts.map +1 -1
- package/dist/matrix/eigs/realSymmetric.d.ts.map +1 -1
- package/dist/matrix/eigs.d.ts +3 -2
- package/dist/matrix/eigs.d.ts.map +1 -1
- package/dist/matrix/fft.d.ts +1 -1
- package/dist/matrix/fft.d.ts.map +1 -1
- package/dist/matrix/filter.d.ts +1 -1
- package/dist/matrix/filter.d.ts.map +1 -1
- package/dist/matrix/flatten.d.ts +1 -1
- package/dist/matrix/flatten.d.ts.map +1 -1
- package/dist/matrix/forEach.d.ts +1 -1
- package/dist/matrix/forEach.d.ts.map +1 -1
- package/dist/matrix/getMatrixDataType.d.ts +1 -1
- package/dist/matrix/getMatrixDataType.d.ts.map +1 -1
- package/dist/matrix/identity.d.ts +1 -1
- package/dist/matrix/identity.d.ts.map +1 -1
- package/dist/matrix/ifft.d.ts +2 -1
- package/dist/matrix/ifft.d.ts.map +1 -1
- package/dist/matrix/inv.d.ts +3 -2
- package/dist/matrix/inv.d.ts.map +1 -1
- package/dist/matrix/kron.d.ts +2 -1
- package/dist/matrix/kron.d.ts.map +1 -1
- package/dist/matrix/map.d.ts +1 -1
- package/dist/matrix/map.d.ts.map +1 -1
- package/dist/matrix/matrixFromColumns.d.ts +2 -1
- package/dist/matrix/matrixFromColumns.d.ts.map +1 -1
- package/dist/matrix/matrixFromRows.d.ts +2 -1
- package/dist/matrix/matrixFromRows.d.ts.map +1 -1
- package/dist/matrix/native-accel.d.ts.map +1 -1
- package/dist/matrix/ones.d.ts +1 -1
- package/dist/matrix/ones.d.ts.map +1 -1
- package/dist/matrix/partitionSelect.d.ts +2 -1
- package/dist/matrix/partitionSelect.d.ts.map +1 -1
- package/dist/matrix/pinv.d.ts +1 -1
- package/dist/matrix/pinv.d.ts.map +1 -1
- package/dist/matrix/range.d.ts +1 -1
- package/dist/matrix/range.d.ts.map +1 -1
- package/dist/matrix/reshape.d.ts +1 -1
- package/dist/matrix/reshape.d.ts.map +1 -1
- package/dist/matrix/resize.d.ts +1 -1
- package/dist/matrix/resize.d.ts.map +1 -1
- package/dist/matrix/row.d.ts +2 -1
- package/dist/matrix/row.d.ts.map +1 -1
- package/dist/matrix/size.d.ts +1 -1
- package/dist/matrix/size.d.ts.map +1 -1
- package/dist/matrix/sqrtm.d.ts +3 -2
- package/dist/matrix/sqrtm.d.ts.map +1 -1
- package/dist/matrix/squeeze.d.ts +1 -1
- package/dist/matrix/squeeze.d.ts.map +1 -1
- package/dist/matrix/subset.d.ts +1 -1
- package/dist/matrix/subset.d.ts.map +1 -1
- package/dist/matrix/trace.d.ts +1 -1
- package/dist/matrix/trace.d.ts.map +1 -1
- package/dist/matrix/transpose.d.ts +1 -1
- package/dist/matrix/transpose.d.ts.map +1 -1
- package/dist/matrix/utils/zerosAndOnes.d.ts +1 -1
- package/dist/matrix/utils/zerosAndOnes.d.ts.map +1 -1
- package/dist/matrix/zeros.d.ts +1 -1
- package/dist/matrix/zeros.d.ts.map +1 -1
- package/dist/numeric/solveODE.d.ts +2 -2
- package/dist/numeric/solveODE.d.ts.map +1 -1
- package/dist/probability/bernoulli.d.ts +1 -1
- package/dist/probability/bernoulli.d.ts.map +1 -1
- package/dist/probability/combinations.d.ts +1 -1
- package/dist/probability/combinations.d.ts.map +1 -1
- package/dist/probability/combinationsWithRep.d.ts +1 -1
- package/dist/probability/combinationsWithRep.d.ts.map +1 -1
- package/dist/probability/factorial.d.ts +1 -1
- package/dist/probability/factorial.d.ts.map +1 -1
- package/dist/probability/gamma.d.ts +1 -1
- package/dist/probability/gamma.d.ts.map +1 -1
- package/dist/probability/kldivergence.d.ts +1 -1
- package/dist/probability/kldivergence.d.ts.map +1 -1
- package/dist/probability/lgamma.d.ts +1 -1
- package/dist/probability/lgamma.d.ts.map +1 -1
- package/dist/probability/multinomial.d.ts +1 -1
- package/dist/probability/multinomial.d.ts.map +1 -1
- package/dist/probability/permutations.d.ts +1 -1
- package/dist/probability/permutations.d.ts.map +1 -1
- package/dist/probability/pickRandom.d.ts +1 -1
- package/dist/probability/pickRandom.d.ts.map +1 -1
- package/dist/probability/random.d.ts +2 -2
- package/dist/probability/random.d.ts.map +1 -1
- package/dist/probability/randomInt.d.ts +1 -1
- package/dist/probability/randomInt.d.ts.map +1 -1
- package/dist/relational/compare.d.ts +2 -2
- package/dist/relational/compare.d.ts.map +1 -1
- package/dist/relational/compareNatural.d.ts +1 -1
- package/dist/relational/compareNatural.d.ts.map +1 -1
- package/dist/relational/deepEqual.d.ts +1 -1
- package/dist/relational/deepEqual.d.ts.map +1 -1
- package/dist/relational/equal.d.ts +2 -2
- package/dist/relational/equal.d.ts.map +1 -1
- package/dist/relational/equalScalar.d.ts +1 -1
- package/dist/relational/equalScalar.d.ts.map +1 -1
- package/dist/relational/equalText.d.ts +1 -1
- package/dist/relational/equalText.d.ts.map +1 -1
- package/dist/relational/larger.d.ts +2 -2
- package/dist/relational/larger.d.ts.map +1 -1
- package/dist/relational/largerEq.d.ts +2 -2
- package/dist/relational/largerEq.d.ts.map +1 -1
- package/dist/relational/smaller.d.ts +2 -2
- package/dist/relational/smaller.d.ts.map +1 -1
- package/dist/relational/smallerEq.d.ts +2 -2
- package/dist/relational/smallerEq.d.ts.map +1 -1
- package/dist/relational/unequal.d.ts +2 -2
- package/dist/relational/unequal.d.ts.map +1 -1
- package/dist/set/setCartesian.d.ts +1 -1
- package/dist/set/setCartesian.d.ts.map +1 -1
- package/dist/set/setDifference.d.ts +1 -1
- package/dist/set/setDifference.d.ts.map +1 -1
- package/dist/set/setIntersect.d.ts +1 -1
- package/dist/set/setIntersect.d.ts.map +1 -1
- package/dist/set/setSymDifference.d.ts +1 -1
- package/dist/set/setSymDifference.d.ts.map +1 -1
- package/dist/set/setUnion.d.ts +1 -1
- package/dist/set/setUnion.d.ts.map +1 -1
- package/dist/signal/freqz.d.ts +2 -1
- package/dist/signal/freqz.d.ts.map +1 -1
- package/dist/signal/zpk2tf.d.ts +2 -1
- package/dist/signal/zpk2tf.d.ts.map +1 -1
- package/dist/special/erf.d.ts +1 -1
- package/dist/special/erf.d.ts.map +1 -1
- package/dist/special/zeta.d.ts +1 -1
- package/dist/special/zeta.d.ts.map +1 -1
- package/dist/statistics/corr.d.ts +1 -1
- package/dist/statistics/corr.d.ts.map +1 -1
- package/dist/statistics/cumsum.d.ts +1 -1
- package/dist/statistics/cumsum.d.ts.map +1 -1
- package/dist/statistics/mad.d.ts +1 -1
- package/dist/statistics/mad.d.ts.map +1 -1
- package/dist/statistics/max.d.ts +1 -1
- package/dist/statistics/max.d.ts.map +1 -1
- package/dist/statistics/mean.d.ts +1 -1
- package/dist/statistics/mean.d.ts.map +1 -1
- package/dist/statistics/median.d.ts +1 -1
- package/dist/statistics/median.d.ts.map +1 -1
- package/dist/statistics/min.d.ts +1 -1
- package/dist/statistics/min.d.ts.map +1 -1
- package/dist/statistics/mode.d.ts +1 -1
- package/dist/statistics/mode.d.ts.map +1 -1
- package/dist/statistics/prod.d.ts +1 -1
- package/dist/statistics/prod.d.ts.map +1 -1
- package/dist/statistics/quantileSeq.d.ts +1 -1
- package/dist/statistics/quantileSeq.d.ts.map +1 -1
- package/dist/statistics/std.d.ts +1 -1
- package/dist/statistics/std.d.ts.map +1 -1
- package/dist/statistics/sum.d.ts +1 -1
- package/dist/statistics/sum.d.ts.map +1 -1
- package/dist/statistics/variance.d.ts +1 -1
- package/dist/statistics/variance.d.ts.map +1 -1
- package/dist/string/bin.d.ts +1 -1
- package/dist/string/bin.d.ts.map +1 -1
- package/dist/string/format.d.ts +1 -1
- package/dist/string/format.d.ts.map +1 -1
- package/dist/string/hex.d.ts +1 -1
- package/dist/string/hex.d.ts.map +1 -1
- package/dist/string/oct.d.ts +1 -1
- package/dist/string/oct.d.ts.map +1 -1
- package/dist/string/print.d.ts +1 -1
- package/dist/string/print.d.ts.map +1 -1
- package/dist/trigonometry/acos.d.ts +1 -1
- package/dist/trigonometry/acos.d.ts.map +1 -1
- package/dist/trigonometry/asin.d.ts +1 -1
- package/dist/trigonometry/asin.d.ts.map +1 -1
- package/dist/trigonometry/atan.d.ts +1 -1
- package/dist/trigonometry/atan.d.ts.map +1 -1
- package/dist/trigonometry/atan2.d.ts +1 -1
- package/dist/trigonometry/atan2.d.ts.map +1 -1
- package/dist/trigonometry/cos.d.ts +1 -1
- package/dist/trigonometry/cos.d.ts.map +1 -1
- package/dist/trigonometry/sin.d.ts +1 -1
- package/dist/trigonometry/sin.d.ts.map +1 -1
- package/dist/trigonometry/tan.d.ts +1 -1
- package/dist/trigonometry/tan.d.ts.map +1 -1
- package/dist/type/bignumber/BigNumber.d.ts +1 -1
- package/dist/type/bignumber/BigNumber.d.ts.map +1 -1
- package/dist/type/matrix/function/index.d.ts +1 -1
- package/dist/type/matrix/function/index.d.ts.map +1 -1
- package/dist/type/matrix/utils/matAlgo09xS0Sf.d.ts.map +1 -1
- package/dist/type/matrix/utils/matAlgo11xS0s.d.ts.map +1 -1
- package/dist/type/matrix/utils/matrixAlgorithmSuite.d.ts.map +1 -1
- package/dist/type/unit/function/createUnit.d.ts +1 -1
- package/dist/type/unit/function/createUnit.d.ts.map +1 -1
- package/dist/type/unit/function/splitUnit.d.ts +1 -1
- package/dist/type/unit/function/splitUnit.d.ts.map +1 -1
- package/dist/type/unit/function/unit.d.ts +1 -1
- package/dist/type/unit/function/unit.d.ts.map +1 -1
- package/dist/type/unit/physicalConstants.d.ts +5 -8
- package/dist/type/unit/physicalConstants.d.ts.map +1 -1
- package/dist/typed/algebra.d.ts +14 -5
- package/dist/typed/algebra.d.ts.map +1 -1
- package/dist/typed/arithmetic.d.ts +91 -91
- package/dist/typed/arithmetic.d.ts.map +1 -1
- package/dist/typed/bitwise.d.ts +14 -14
- package/dist/typed/bitwise.d.ts.map +1 -1
- package/dist/typed/combinatorics.d.ts +21 -21
- package/dist/typed/combinatorics.d.ts.map +1 -1
- package/dist/typed/complex.d.ts +8 -8
- package/dist/typed/complex.d.ts.map +1 -1
- package/dist/typed/distributions.d.ts +28 -28
- package/dist/typed/distributions.d.ts.map +1 -1
- package/dist/typed/geometry.d.ts +2 -6
- package/dist/typed/geometry.d.ts.map +1 -1
- package/dist/typed/graph.d.ts.map +1 -1
- package/dist/typed/hypothesis.d.ts +13 -0
- package/dist/typed/hypothesis.d.ts.map +1 -1
- package/dist/typed/logical.d.ts +10 -10
- package/dist/typed/logical.d.ts.map +1 -1
- package/dist/typed/matrix-ops.d.ts +9 -9
- package/dist/typed/matrix-ops.d.ts.map +1 -1
- package/dist/typed/numeric.d.ts +1 -1
- package/dist/typed/numeric.d.ts.map +1 -1
- package/dist/typed/probability.d.ts +16 -16
- package/dist/typed/probability.d.ts.map +1 -1
- package/dist/typed/relational.d.ts +14 -14
- package/dist/typed/relational.d.ts.map +1 -1
- package/dist/typed/set.d.ts +20 -20
- package/dist/typed/set.d.ts.map +1 -1
- package/dist/typed/signal.d.ts +15 -15
- package/dist/typed/signal.d.ts.map +1 -1
- package/dist/typed/special.d.ts +76 -76
- package/dist/typed/special.d.ts.map +1 -1
- package/dist/typed/statistics.d.ts +34 -34
- package/dist/typed/statistics.d.ts.map +1 -1
- package/dist/typed/string.d.ts +10 -10
- package/dist/typed/string.d.ts.map +1 -1
- package/dist/typed/trigonometry.d.ts +38 -38
- package/dist/typed/trigonometry.d.ts.map +1 -1
- package/dist/typed/unit.d.ts +4 -4
- package/dist/typed/unit.d.ts.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/unit/to.d.ts +1 -1
- package/dist/unit/to.d.ts.map +1 -1
- package/dist/unit/toBest.d.ts +1 -1
- package/dist/unit/toBest.d.ts.map +1 -1
- package/dist/utils/bignumber/bitwise.d.ts +1 -0
- package/dist/utils/bignumber/bitwise.d.ts.map +1 -1
- package/dist/utils/clone.d.ts +1 -1
- package/dist/utils/clone.d.ts.map +1 -1
- package/dist/utils/hasNumericValue.d.ts +1 -1
- package/dist/utils/hasNumericValue.d.ts.map +1 -1
- package/dist/utils/isInteger.d.ts +1 -1
- package/dist/utils/isInteger.d.ts.map +1 -1
- package/dist/utils/isNaN.d.ts +1 -1
- package/dist/utils/isNaN.d.ts.map +1 -1
- package/dist/utils/isNegative.d.ts +1 -1
- package/dist/utils/isNegative.d.ts.map +1 -1
- package/dist/utils/isPositive.d.ts +1 -1
- package/dist/utils/isPositive.d.ts.map +1 -1
- package/dist/utils/isPrime.d.ts +1 -1
- package/dist/utils/isPrime.d.ts.map +1 -1
- package/dist/utils/isZero.d.ts +1 -1
- package/dist/utils/isZero.d.ts.map +1 -1
- package/dist/utils/typeOf.d.ts +1 -1
- package/dist/utils/typeOf.d.ts.map +1 -1
- package/dist/wasm/WasmLoader.d.ts +28 -210
- package/dist/wasm/WasmLoader.d.ts.map +1 -1
- package/dist/wasm/bitwise/wasm-bridge.d.ts.map +1 -1
- package/dist/wasm/bridges/common.d.ts +2 -0
- package/dist/wasm/bridges/common.d.ts.map +1 -1
- package/dist/wasm/elementwise/wasm-bridge.d.ts.map +1 -1
- package/dist/wasm/interpolation/wasm-bridge.d.ts.map +1 -1
- package/dist/wasm/mathts-as.wasm +0 -0
- package/dist/wasm/policy.d.ts +37 -0
- package/dist/wasm/policy.d.ts.map +1 -0
- package/dist/wasm/poly/wasm-bridge.d.ts.map +1 -1
- package/dist/wasm/signal/wasm-bridge.d.ts.map +1 -1
- package/dist/wasm/sort/wasm-bridge.d.ts.map +1 -1
- package/dist/wasm/special/wasm-bridge.d.ts.map +1 -1
- package/dist/wasm/wasm-manifest.json +1 -1
- package/dist/{wasm-bridge-C44GQ3DS.js → wasm-bridge-74YOKWIS.js} +1 -1
- package/package.json +76 -76
- package/types/assemblyscript.d.ts +101 -101
- package/types/index.d.ts +7801 -7801
- package/types/modules.d.ts +19 -19
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
|
-
|
|
15
|
+
wasmPolicyAllows,
|
|
14
16
|
withAsF64,
|
|
15
17
|
withAsI32
|
|
16
|
-
} from "./chunk-
|
|
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
|
-
|
|
15967
|
-
|
|
15968
|
-
|
|
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-
|
|
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]];
|
|
@@ -22541,12 +21900,10 @@ var createConj = /* @__PURE__ */ factory(
|
|
|
22541
21900
|
return typed3(name17, {
|
|
22542
21901
|
"number | BigNumber | Fraction": (x) => x,
|
|
22543
21902
|
Complex: (x) => x.conjugate(),
|
|
22544
|
-
Unit: typed3.referToSelf(
|
|
22545
|
-
|
|
22546
|
-
|
|
22547
|
-
|
|
22548
|
-
}
|
|
22549
|
-
),
|
|
21903
|
+
Unit: typed3.referToSelf((self) => (x) => {
|
|
21904
|
+
const ctor = x.constructor;
|
|
21905
|
+
return new ctor(self(x.toNumeric()), x.formatUnits());
|
|
21906
|
+
}),
|
|
22550
21907
|
"Array | Matrix": typed3.referToSelf(
|
|
22551
21908
|
(self) => (x) => deepMap(x, self)
|
|
22552
21909
|
)
|
|
@@ -23166,22 +22523,6 @@ var createLgamma = /* @__PURE__ */ factory(
|
|
|
23166
22523
|
];
|
|
23167
22524
|
return typed3(name30, {
|
|
23168
22525
|
Array: function(arr10) {
|
|
23169
|
-
const wasm = wasmLoader.getModule();
|
|
23170
|
-
if (wasm && arr10.length >= 100 && arr10.every((x) => typeof x === "number")) {
|
|
23171
|
-
try {
|
|
23172
|
-
const input = new Float64Array(arr10);
|
|
23173
|
-
const inputAlloc = wasmLoader.allocateFloat64Array(input);
|
|
23174
|
-
const resultAlloc = wasmLoader.allocateFloat64ArrayEmpty(arr10.length);
|
|
23175
|
-
try {
|
|
23176
|
-
wasm.lgammaArray(inputAlloc.ptr, arr10.length, resultAlloc.ptr);
|
|
23177
|
-
return Array.from(resultAlloc.array);
|
|
23178
|
-
} finally {
|
|
23179
|
-
wasmLoader.free(inputAlloc.ptr);
|
|
23180
|
-
wasmLoader.free(resultAlloc.ptr);
|
|
23181
|
-
}
|
|
23182
|
-
} catch {
|
|
23183
|
-
}
|
|
23184
|
-
}
|
|
23185
22526
|
return arr10.map((x) => lgammaNumber(x));
|
|
23186
22527
|
},
|
|
23187
22528
|
number: lgammaNumber,
|
|
@@ -23518,27 +22859,7 @@ var createErf = /* @__PURE__ */ factory(
|
|
|
23518
22859
|
return typed3("name", {
|
|
23519
22860
|
number: erfNumber,
|
|
23520
22861
|
"Array | Matrix": typed3.referToSelf(
|
|
23521
|
-
(self) => (n) =>
|
|
23522
|
-
if (Array.isArray(n) && n.length >= 100 && n.every((x) => typeof x === "number")) {
|
|
23523
|
-
const wasm = wasmLoader.getModule();
|
|
23524
|
-
if (wasm) {
|
|
23525
|
-
try {
|
|
23526
|
-
const input = new Float64Array(n);
|
|
23527
|
-
const inputAlloc = wasmLoader.allocateFloat64Array(input);
|
|
23528
|
-
const resultAlloc = wasmLoader.allocateFloat64ArrayEmpty(n.length);
|
|
23529
|
-
try {
|
|
23530
|
-
wasm.erfArray(inputAlloc.ptr, n.length, resultAlloc.ptr);
|
|
23531
|
-
return Array.from(resultAlloc.array);
|
|
23532
|
-
} finally {
|
|
23533
|
-
wasmLoader.free(inputAlloc.ptr);
|
|
23534
|
-
wasmLoader.free(resultAlloc.ptr);
|
|
23535
|
-
}
|
|
23536
|
-
} catch {
|
|
23537
|
-
}
|
|
23538
|
-
}
|
|
23539
|
-
}
|
|
23540
|
-
return deepMap(n, self);
|
|
23541
|
-
}
|
|
22862
|
+
(self) => (n) => deepMap(n, self)
|
|
23542
22863
|
)
|
|
23543
22864
|
// TODO: For complex numbers, use the approximation for the Faddeeva function
|
|
23544
22865
|
// from "More Efficient Computation of the Complex Error Function" (AMS)
|
|
@@ -24810,15 +24131,6 @@ function improveErrorMessage(err, fnName, value) {
|
|
|
24810
24131
|
}
|
|
24811
24132
|
|
|
24812
24133
|
// src/statistics/prod.ts
|
|
24813
|
-
var WASM_PROD_THRESHOLD = 100;
|
|
24814
|
-
function isFlatNumberArray(arr10) {
|
|
24815
|
-
for (let i = 0; i < arr10.length; i++) {
|
|
24816
|
-
if (typeof arr10[i] !== "number") {
|
|
24817
|
-
return false;
|
|
24818
|
-
}
|
|
24819
|
-
}
|
|
24820
|
-
return true;
|
|
24821
|
-
}
|
|
24822
24134
|
var name76 = "prod";
|
|
24823
24135
|
var dependencies76 = ["typed", "config", "multiplyScalar", "numeric", "parseNumberWithConfig"];
|
|
24824
24136
|
var createProd = /* @__PURE__ */ factory(
|
|
@@ -24846,22 +24158,6 @@ var createProd = /* @__PURE__ */ factory(
|
|
|
24846
24158
|
}
|
|
24847
24159
|
});
|
|
24848
24160
|
function _prod(array) {
|
|
24849
|
-
if (Array.isArray(array) && array.length >= WASM_PROD_THRESHOLD) {
|
|
24850
|
-
if (isFlatNumberArray(array)) {
|
|
24851
|
-
const wasm = wasmLoader.getModule();
|
|
24852
|
-
if (wasm) {
|
|
24853
|
-
try {
|
|
24854
|
-
const alloc = wasmLoader.allocateFloat64Array(array);
|
|
24855
|
-
try {
|
|
24856
|
-
return wasm.statsProd(alloc.ptr, array.length);
|
|
24857
|
-
} finally {
|
|
24858
|
-
wasmLoader.free(alloc.ptr);
|
|
24859
|
-
}
|
|
24860
|
-
} catch {
|
|
24861
|
-
}
|
|
24862
|
-
}
|
|
24863
|
-
}
|
|
24864
|
-
}
|
|
24865
24161
|
let prod2;
|
|
24866
24162
|
deepForEach(array, function(value) {
|
|
24867
24163
|
try {
|
|
@@ -25047,27 +24343,6 @@ var createParseNumberWithConfig = /* @__PURE__ */ factory(
|
|
|
25047
24343
|
);
|
|
25048
24344
|
|
|
25049
24345
|
// src/matrix/transpose.ts
|
|
25050
|
-
var WASM_TRANSPOSE_THRESHOLD = 100;
|
|
25051
|
-
function isPlainNumberMatrix(matrix2) {
|
|
25052
|
-
for (let i = 0; i < matrix2.length; i++) {
|
|
25053
|
-
const row2 = matrix2[i];
|
|
25054
|
-
for (let j = 0; j < row2.length; j++) {
|
|
25055
|
-
if (typeof row2[j] !== "number") {
|
|
25056
|
-
return false;
|
|
25057
|
-
}
|
|
25058
|
-
}
|
|
25059
|
-
}
|
|
25060
|
-
return true;
|
|
25061
|
-
}
|
|
25062
|
-
function flattenToFloat64(matrix2, rows, cols) {
|
|
25063
|
-
const result = new Float64Array(rows * cols);
|
|
25064
|
-
for (let i = 0; i < rows; i++) {
|
|
25065
|
-
for (let j = 0; j < cols; j++) {
|
|
25066
|
-
result[i * cols + j] = matrix2[i][j];
|
|
25067
|
-
}
|
|
25068
|
-
}
|
|
25069
|
-
return result;
|
|
25070
|
-
}
|
|
25071
24346
|
var name84 = "transpose";
|
|
25072
24347
|
var dependencies84 = ["typed", "matrix"];
|
|
25073
24348
|
var createTranspose = /* @__PURE__ */ factory(
|
|
@@ -25115,34 +24390,6 @@ var createTranspose = /* @__PURE__ */ factory(
|
|
|
25115
24390
|
}
|
|
25116
24391
|
function _denseTranspose(m, rows, columns) {
|
|
25117
24392
|
const data = m._data;
|
|
25118
|
-
const wasm = wasmLoader.getModule();
|
|
25119
|
-
if (wasm && rows * columns >= WASM_TRANSPOSE_THRESHOLD && isPlainNumberMatrix(data)) {
|
|
25120
|
-
try {
|
|
25121
|
-
const flat = flattenToFloat64(data, rows, columns);
|
|
25122
|
-
const input = wasmLoader.allocateFloat64Array(flat);
|
|
25123
|
-
const output = wasmLoader.allocateFloat64ArrayEmpty(rows * columns);
|
|
25124
|
-
try {
|
|
25125
|
-
wasm.transpose(input.ptr, rows, columns, output.ptr);
|
|
25126
|
-
const transposed2 = [];
|
|
25127
|
-
for (let j = 0; j < columns; j++) {
|
|
25128
|
-
const row2 = [];
|
|
25129
|
-
for (let i = 0; i < rows; i++) {
|
|
25130
|
-
row2[i] = output.array[j * rows + i];
|
|
25131
|
-
}
|
|
25132
|
-
transposed2[j] = row2;
|
|
25133
|
-
}
|
|
25134
|
-
return m.createDenseMatrix({
|
|
25135
|
-
data: transposed2,
|
|
25136
|
-
size: [columns, rows],
|
|
25137
|
-
datatype: m._datatype
|
|
25138
|
-
});
|
|
25139
|
-
} finally {
|
|
25140
|
-
wasmLoader.free(input.ptr);
|
|
25141
|
-
wasmLoader.free(output.ptr);
|
|
25142
|
-
}
|
|
25143
|
-
} catch {
|
|
25144
|
-
}
|
|
25145
|
-
}
|
|
25146
24393
|
const transposed = [];
|
|
25147
24394
|
let transposedRow;
|
|
25148
24395
|
for (let j = 0; j < columns; j++) {
|
|
@@ -25366,24 +24613,16 @@ function createZerosAndOnes(name254, defaultValue, { typed: typed3, config: conf
|
|
|
25366
24613
|
// src/matrix/zeros.ts
|
|
25367
24614
|
var name87 = "zeros";
|
|
25368
24615
|
var dependencies87 = ["typed", "config", "matrix", "BigNumber"];
|
|
25369
|
-
var createZeros = /* @__PURE__ */ factory(
|
|
25370
|
-
name87,
|
|
25371
|
-
|
|
25372
|
-
(deps) => {
|
|
25373
|
-
return createZerosAndOnes(name87, 0, deps);
|
|
25374
|
-
}
|
|
25375
|
-
);
|
|
24616
|
+
var createZeros = /* @__PURE__ */ factory(name87, dependencies87, (deps) => {
|
|
24617
|
+
return createZerosAndOnes(name87, 0, deps);
|
|
24618
|
+
});
|
|
25376
24619
|
|
|
25377
24620
|
// src/matrix/ones.ts
|
|
25378
24621
|
var name88 = "ones";
|
|
25379
24622
|
var dependencies88 = ["typed", "config", "matrix", "BigNumber"];
|
|
25380
|
-
var createOnes = /* @__PURE__ */ factory(
|
|
25381
|
-
name88,
|
|
25382
|
-
|
|
25383
|
-
(deps) => {
|
|
25384
|
-
return createZerosAndOnes(name88, 1, deps);
|
|
25385
|
-
}
|
|
25386
|
-
);
|
|
24623
|
+
var createOnes = /* @__PURE__ */ factory(name88, dependencies88, (deps) => {
|
|
24624
|
+
return createZerosAndOnes(name88, 1, deps);
|
|
24625
|
+
});
|
|
25387
24626
|
|
|
25388
24627
|
// src/matrix/diag.ts
|
|
25389
24628
|
var name89 = "diag";
|
|
@@ -25475,38 +24714,6 @@ var createDiag = /* @__PURE__ */ factory(
|
|
|
25475
24714
|
);
|
|
25476
24715
|
|
|
25477
24716
|
// src/matrix/kron.ts
|
|
25478
|
-
var WASM_KRON_THRESHOLD = 64;
|
|
25479
|
-
function isPlainNumber2D(arr10) {
|
|
25480
|
-
for (let i = 0; i < arr10.length; i++) {
|
|
25481
|
-
const row2 = arr10[i];
|
|
25482
|
-
for (let j = 0; j < row2.length; j++) {
|
|
25483
|
-
if (typeof row2[j] !== "number") {
|
|
25484
|
-
return false;
|
|
25485
|
-
}
|
|
25486
|
-
}
|
|
25487
|
-
}
|
|
25488
|
-
return true;
|
|
25489
|
-
}
|
|
25490
|
-
function flatten2D(arr10, rows, cols) {
|
|
25491
|
-
const result = new Float64Array(rows * cols);
|
|
25492
|
-
for (let i = 0; i < rows; i++) {
|
|
25493
|
-
for (let j = 0; j < cols; j++) {
|
|
25494
|
-
result[i * cols + j] = arr10[i][j];
|
|
25495
|
-
}
|
|
25496
|
-
}
|
|
25497
|
-
return result;
|
|
25498
|
-
}
|
|
25499
|
-
function unflatten2D(flat, rows, cols) {
|
|
25500
|
-
const result = [];
|
|
25501
|
-
for (let i = 0; i < rows; i++) {
|
|
25502
|
-
const row2 = [];
|
|
25503
|
-
for (let j = 0; j < cols; j++) {
|
|
25504
|
-
row2.push(flat[i * cols + j]);
|
|
25505
|
-
}
|
|
25506
|
-
result.push(row2);
|
|
25507
|
-
}
|
|
25508
|
-
return result;
|
|
25509
|
-
}
|
|
25510
24717
|
var name90 = "kron";
|
|
25511
24718
|
var dependencies90 = ["typed", "matrix", "multiplyScalar"];
|
|
25512
24719
|
var createKron = /* @__PURE__ */ factory(
|
|
@@ -25537,37 +24744,6 @@ var createKron = /* @__PURE__ */ factory(
|
|
|
25537
24744
|
while (bdim++ < d) b = [b];
|
|
25538
24745
|
}
|
|
25539
24746
|
if (d === 1) return _kron1d(a, b);
|
|
25540
|
-
if (d === 2) {
|
|
25541
|
-
const aSize = arraySize(a);
|
|
25542
|
-
const bSize = arraySize(b);
|
|
25543
|
-
const aRows = aSize[0];
|
|
25544
|
-
const aCols = aSize[1];
|
|
25545
|
-
const bRows = bSize[0];
|
|
25546
|
-
const bCols = bSize[1];
|
|
25547
|
-
const totalElements = aRows * aCols * bRows * bCols;
|
|
25548
|
-
const wasm = wasmLoader.getModule();
|
|
25549
|
-
if (wasm && totalElements >= WASM_KRON_THRESHOLD && isPlainNumber2D(a) && isPlainNumber2D(b)) {
|
|
25550
|
-
try {
|
|
25551
|
-
const aFlat = flatten2D(a, aRows, aCols);
|
|
25552
|
-
const bFlat = flatten2D(b, bRows, bCols);
|
|
25553
|
-
const aAlloc = wasmLoader.allocateFloat64Array(aFlat);
|
|
25554
|
-
const bAlloc = wasmLoader.allocateFloat64Array(bFlat);
|
|
25555
|
-
const resultRows = aRows * bRows;
|
|
25556
|
-
const resultCols = aCols * bCols;
|
|
25557
|
-
const resultAlloc = wasmLoader.allocateFloat64ArrayEmpty(resultRows * resultCols);
|
|
25558
|
-
try {
|
|
25559
|
-
wasm.laKron(aAlloc.ptr, aRows, aCols, bAlloc.ptr, bRows, bCols);
|
|
25560
|
-
const resultFlat = new Float64Array(resultAlloc.array);
|
|
25561
|
-
return unflatten2D(resultFlat, resultRows, resultCols);
|
|
25562
|
-
} finally {
|
|
25563
|
-
wasmLoader.free(aAlloc.ptr);
|
|
25564
|
-
wasmLoader.free(bAlloc.ptr);
|
|
25565
|
-
wasmLoader.free(resultAlloc.ptr);
|
|
25566
|
-
}
|
|
25567
|
-
} catch {
|
|
25568
|
-
}
|
|
25569
|
-
}
|
|
25570
|
-
}
|
|
25571
24747
|
return a.flatMap(
|
|
25572
24748
|
(aSlice) => b.map((bSlice) => _kron(aSlice, bSlice, d - 1))
|
|
25573
24749
|
);
|
|
@@ -25972,8 +25148,7 @@ var createTrace = /* @__PURE__ */ factory(
|
|
|
25972
25148
|
);
|
|
25973
25149
|
|
|
25974
25150
|
// src/matrix/det.ts
|
|
25975
|
-
|
|
25976
|
-
function isPlainNumberMatrix2(matrix2) {
|
|
25151
|
+
function isPlainNumberMatrix(matrix2) {
|
|
25977
25152
|
for (let i = 0; i < matrix2.length; i++) {
|
|
25978
25153
|
const row2 = matrix2[i];
|
|
25979
25154
|
for (let j = 0; j < row2.length; j++) {
|
|
@@ -25984,15 +25159,6 @@ function isPlainNumberMatrix2(matrix2) {
|
|
|
25984
25159
|
}
|
|
25985
25160
|
return true;
|
|
25986
25161
|
}
|
|
25987
|
-
function flattenToFloat642(matrix2, rows, cols) {
|
|
25988
|
-
const result = new Float64Array(rows * cols);
|
|
25989
|
-
for (let i = 0; i < rows; i++) {
|
|
25990
|
-
for (let j = 0; j < cols; j++) {
|
|
25991
|
-
result[i * cols + j] = matrix2[i][j];
|
|
25992
|
-
}
|
|
25993
|
-
}
|
|
25994
|
-
return result;
|
|
25995
|
-
}
|
|
25996
25162
|
var name96 = "det";
|
|
25997
25163
|
var dependencies96 = [
|
|
25998
25164
|
"typed",
|
|
@@ -26055,22 +25221,6 @@ var createDet = /* @__PURE__ */ factory(
|
|
|
26055
25221
|
}
|
|
26056
25222
|
});
|
|
26057
25223
|
function _det(matrix3, rows, _cols) {
|
|
26058
|
-
const wasm = wasmLoader.getModule();
|
|
26059
|
-
if (wasm && rows * rows >= WASM_DET_THRESHOLD && isPlainNumberMatrix2(matrix3)) {
|
|
26060
|
-
try {
|
|
26061
|
-
const flat = flattenToFloat642(matrix3, rows, rows);
|
|
26062
|
-
const a = wasmLoader.allocateFloat64Array(flat);
|
|
26063
|
-
const work = wasmLoader.allocateFloat64ArrayEmpty(rows * rows);
|
|
26064
|
-
try {
|
|
26065
|
-
const result = wasm.laDet(a.ptr, rows, work.ptr);
|
|
26066
|
-
return result;
|
|
26067
|
-
} finally {
|
|
26068
|
-
wasmLoader.free(a.ptr);
|
|
26069
|
-
wasmLoader.free(work.ptr);
|
|
26070
|
-
}
|
|
26071
|
-
} catch {
|
|
26072
|
-
}
|
|
26073
|
-
}
|
|
26074
25224
|
if (rows === 1) {
|
|
26075
25225
|
return clone(matrix3[0][0]);
|
|
26076
25226
|
} else if (rows === 2) {
|
|
@@ -26078,12 +25228,12 @@ var createDet = /* @__PURE__ */ factory(
|
|
|
26078
25228
|
multiply2(matrix3[0][0], matrix3[1][1]),
|
|
26079
25229
|
multiply2(matrix3[1][0], matrix3[0][1])
|
|
26080
25230
|
);
|
|
26081
|
-
} else if (rows === 3 &&
|
|
25231
|
+
} else if (rows === 3 && isPlainNumberMatrix(matrix3)) {
|
|
26082
25232
|
const a = matrix3[0][0], b = matrix3[0][1], c = matrix3[0][2];
|
|
26083
25233
|
const d = matrix3[1][0], e = matrix3[1][1], f = matrix3[1][2];
|
|
26084
25234
|
const g = matrix3[2][0], h = matrix3[2][1], i = matrix3[2][2];
|
|
26085
25235
|
return a * (e * i - f * h) - b * (d * i - f * g) + c * (d * h - e * g);
|
|
26086
|
-
} else if (rows === 4 &&
|
|
25236
|
+
} else if (rows === 4 && isPlainNumberMatrix(matrix3)) {
|
|
26087
25237
|
const a00 = matrix3[0][0], a01 = matrix3[0][1];
|
|
26088
25238
|
const a02 = matrix3[0][2], a03 = matrix3[0][3];
|
|
26089
25239
|
const a10 = matrix3[1][0], a11 = matrix3[1][1];
|
|
@@ -26316,42 +25466,12 @@ function csTdfs(j, k, w, head, next, post, stack) {
|
|
|
26316
25466
|
}
|
|
26317
25467
|
|
|
26318
25468
|
// src/algebra/sparse/csAmd.ts
|
|
26319
|
-
var WASM_AMD_THRESHOLD = 100;
|
|
26320
25469
|
var name98 = "csAmd";
|
|
26321
25470
|
var dependencies98 = ["add", "multiply", "transpose"];
|
|
26322
25471
|
var createCsAmd = /* @__PURE__ */ factory(
|
|
26323
25472
|
name98,
|
|
26324
25473
|
dependencies98,
|
|
26325
25474
|
({ add: add5, multiply: multiply2, transpose: transpose5 }) => {
|
|
26326
|
-
function _tryWasmAmd(a, n) {
|
|
26327
|
-
const wasm = wasmLoader.getModule();
|
|
26328
|
-
if (!wasm || !a._ptr || !a._index) return null;
|
|
26329
|
-
const nnz = a._ptr[n];
|
|
26330
|
-
if (nnz < WASM_AMD_THRESHOLD) return null;
|
|
26331
|
-
try {
|
|
26332
|
-
const colPtr = new Int32Array(a._ptr);
|
|
26333
|
-
const rowIdx = new Int32Array(a._index);
|
|
26334
|
-
const colPtrAlloc = wasmLoader.allocateInt32Array(colPtr);
|
|
26335
|
-
const rowIdxAlloc = wasmLoader.allocateInt32Array(rowIdx);
|
|
26336
|
-
const permAlloc = wasmLoader.allocateInt32ArrayEmpty(n);
|
|
26337
|
-
const workAlloc = wasmLoader.allocateInt32ArrayEmpty(8 * (n + 1));
|
|
26338
|
-
try {
|
|
26339
|
-
wasm.amd(colPtrAlloc.ptr, rowIdxAlloc.ptr, n, permAlloc.ptr, workAlloc.ptr);
|
|
26340
|
-
const perm = new Array(n);
|
|
26341
|
-
for (let i = 0; i < n; i++) {
|
|
26342
|
-
perm[i] = permAlloc.array[i];
|
|
26343
|
-
}
|
|
26344
|
-
return perm;
|
|
26345
|
-
} finally {
|
|
26346
|
-
wasmLoader.free(colPtrAlloc.ptr);
|
|
26347
|
-
wasmLoader.free(rowIdxAlloc.ptr);
|
|
26348
|
-
wasmLoader.free(permAlloc.ptr);
|
|
26349
|
-
wasmLoader.free(workAlloc.ptr);
|
|
26350
|
-
}
|
|
26351
|
-
} catch {
|
|
26352
|
-
}
|
|
26353
|
-
return null;
|
|
26354
|
-
}
|
|
26355
25475
|
return function csAmd2(order, a) {
|
|
26356
25476
|
if (!a || order <= 0 || order > 3) {
|
|
26357
25477
|
return null;
|
|
@@ -26359,8 +25479,6 @@ var createCsAmd = /* @__PURE__ */ factory(
|
|
|
26359
25479
|
const asize = a._size;
|
|
26360
25480
|
const m = asize[0];
|
|
26361
25481
|
const n = asize[1];
|
|
26362
|
-
const wasmResult = _tryWasmAmd(a, n);
|
|
26363
|
-
if (wasmResult !== null) return wasmResult;
|
|
26364
25482
|
let lemax = 0;
|
|
26365
25483
|
let dense = Math.max(16, 10 * Math.sqrt(n));
|
|
26366
25484
|
dense = Math.min(n - 2, dense);
|
|
@@ -26730,50 +25848,12 @@ function csLeaf(i, j, w, first, maxfirst, prevleaf, ancestor) {
|
|
|
26730
25848
|
}
|
|
26731
25849
|
|
|
26732
25850
|
// src/algebra/sparse/csCounts.ts
|
|
26733
|
-
var WASM_COUNTS_THRESHOLD = 50;
|
|
26734
25851
|
var name99 = "csCounts";
|
|
26735
25852
|
var dependencies99 = ["transpose"];
|
|
26736
25853
|
var createCsCounts = /* @__PURE__ */ factory(
|
|
26737
25854
|
name99,
|
|
26738
25855
|
dependencies99,
|
|
26739
25856
|
({ transpose: transpose5 }) => {
|
|
26740
|
-
function _tryWasmCounts(a, parent, post, n) {
|
|
26741
|
-
const wasm = wasmLoader.getModule();
|
|
26742
|
-
if (!wasm || n < WASM_COUNTS_THRESHOLD || !a._index || !a._ptr) return null;
|
|
26743
|
-
try {
|
|
26744
|
-
const indexAlloc = wasmLoader.allocateInt32Array(new Int32Array(a._index));
|
|
26745
|
-
const ptrAlloc = wasmLoader.allocateInt32Array(new Int32Array(a._ptr));
|
|
26746
|
-
const parentAlloc = wasmLoader.allocateInt32Array(new Int32Array(parent));
|
|
26747
|
-
const postAlloc = wasmLoader.allocateInt32Array(new Int32Array(post));
|
|
26748
|
-
const colCountAlloc = wasmLoader.allocateInt32ArrayEmpty(n);
|
|
26749
|
-
const workAlloc = wasmLoader.allocateInt32ArrayEmpty(3 * n);
|
|
26750
|
-
try {
|
|
26751
|
-
wasm.symbolicCholesky(
|
|
26752
|
-
indexAlloc.ptr,
|
|
26753
|
-
ptrAlloc.ptr,
|
|
26754
|
-
n,
|
|
26755
|
-
parentAlloc.ptr,
|
|
26756
|
-
postAlloc.ptr,
|
|
26757
|
-
colCountAlloc.ptr,
|
|
26758
|
-
workAlloc.ptr
|
|
26759
|
-
);
|
|
26760
|
-
const colcount = new Array(n);
|
|
26761
|
-
for (let i = 0; i < n; i++) {
|
|
26762
|
-
colcount[i] = colCountAlloc.array[i];
|
|
26763
|
-
}
|
|
26764
|
-
return colcount;
|
|
26765
|
-
} finally {
|
|
26766
|
-
wasmLoader.free(indexAlloc.ptr);
|
|
26767
|
-
wasmLoader.free(ptrAlloc.ptr);
|
|
26768
|
-
wasmLoader.free(parentAlloc.ptr);
|
|
26769
|
-
wasmLoader.free(postAlloc.ptr);
|
|
26770
|
-
wasmLoader.free(colCountAlloc.ptr);
|
|
26771
|
-
wasmLoader.free(workAlloc.ptr);
|
|
26772
|
-
}
|
|
26773
|
-
} catch {
|
|
26774
|
-
}
|
|
26775
|
-
return null;
|
|
26776
|
-
}
|
|
26777
25857
|
return function csCounts2(a, parent, post, ata) {
|
|
26778
25858
|
if (!a || !parent || !post) {
|
|
26779
25859
|
return null;
|
|
@@ -26781,10 +25861,6 @@ var createCsCounts = /* @__PURE__ */ factory(
|
|
|
26781
25861
|
const asize = a._size;
|
|
26782
25862
|
const m = asize[0];
|
|
26783
25863
|
const n = asize[1];
|
|
26784
|
-
if (!ata) {
|
|
26785
|
-
const wasmResult = _tryWasmCounts(a, parent, post, n);
|
|
26786
|
-
if (wasmResult !== null) return wasmResult;
|
|
26787
|
-
}
|
|
26788
25864
|
let i, j, k, J, p, p0, p1;
|
|
26789
25865
|
const s = 4 * n + (ata ? n + m + 1 : 0);
|
|
26790
25866
|
const w = [];
|
|
@@ -27249,42 +26325,6 @@ function createSolveValidation({ DenseMatrix: DenseMatrix7 }) {
|
|
|
27249
26325
|
}
|
|
27250
26326
|
|
|
27251
26327
|
// src/algebra/solver/lsolve.ts
|
|
27252
|
-
var WASM_LSOLVE_THRESHOLD = 16;
|
|
27253
|
-
function isPlainNumberMatrix3(matrix2) {
|
|
27254
|
-
for (let i = 0; i < matrix2.length; i++) {
|
|
27255
|
-
const row2 = matrix2[i];
|
|
27256
|
-
for (let j = 0; j < row2.length; j++) {
|
|
27257
|
-
if (typeof row2[j] !== "number") {
|
|
27258
|
-
return false;
|
|
27259
|
-
}
|
|
27260
|
-
}
|
|
27261
|
-
}
|
|
27262
|
-
return true;
|
|
27263
|
-
}
|
|
27264
|
-
function isPlainNumberVector(vec) {
|
|
27265
|
-
for (let i = 0; i < vec.length; i++) {
|
|
27266
|
-
if (typeof vec[i][0] !== "number") {
|
|
27267
|
-
return false;
|
|
27268
|
-
}
|
|
27269
|
-
}
|
|
27270
|
-
return true;
|
|
27271
|
-
}
|
|
27272
|
-
function flattenToFloat643(matrix2, rows, cols) {
|
|
27273
|
-
const result = new Float64Array(rows * cols);
|
|
27274
|
-
for (let i = 0; i < rows; i++) {
|
|
27275
|
-
for (let j = 0; j < cols; j++) {
|
|
27276
|
-
result[i * cols + j] = matrix2[i][j];
|
|
27277
|
-
}
|
|
27278
|
-
}
|
|
27279
|
-
return result;
|
|
27280
|
-
}
|
|
27281
|
-
function vectorToFloat64(vec) {
|
|
27282
|
-
const result = new Float64Array(vec.length);
|
|
27283
|
-
for (let i = 0; i < vec.length; i++) {
|
|
27284
|
-
result[i] = vec[i][0];
|
|
27285
|
-
}
|
|
27286
|
-
return result;
|
|
27287
|
-
}
|
|
27288
26328
|
var name102 = "lsolve";
|
|
27289
26329
|
var dependencies102 = [
|
|
27290
26330
|
"typed",
|
|
@@ -27329,38 +26369,6 @@ var createLsolve = /* @__PURE__ */ factory(
|
|
|
27329
26369
|
const rows = m._size[0];
|
|
27330
26370
|
const columns = m._size[1];
|
|
27331
26371
|
const mdata = m._data;
|
|
27332
|
-
const wasm = wasmLoader.getModule();
|
|
27333
|
-
if (wasm && rows === columns && rows * rows >= WASM_LSOLVE_THRESHOLD && isPlainNumberMatrix3(mdata) && isPlainNumberVector(bdata)) {
|
|
27334
|
-
try {
|
|
27335
|
-
const lFlat = flattenToFloat643(mdata, rows, columns);
|
|
27336
|
-
const bFlat = vectorToFloat64(bdata);
|
|
27337
|
-
const lAlloc = wasmLoader.allocateFloat64Array(lFlat);
|
|
27338
|
-
const bAlloc = wasmLoader.allocateFloat64Array(bFlat);
|
|
27339
|
-
const resultAlloc = wasmLoader.allocateFloat64ArrayEmpty(rows);
|
|
27340
|
-
try {
|
|
27341
|
-
const success = wasm.laLsolve(lAlloc.ptr, bAlloc.ptr, rows, resultAlloc.ptr);
|
|
27342
|
-
if (success === 0) {
|
|
27343
|
-
throw new Error("Linear system cannot be solved since matrix is singular");
|
|
27344
|
-
}
|
|
27345
|
-
const x2 = [];
|
|
27346
|
-
for (let i = 0; i < rows; i++) {
|
|
27347
|
-
x2[i] = [resultAlloc.array[i]];
|
|
27348
|
-
}
|
|
27349
|
-
return new DenseMatrix7({
|
|
27350
|
-
data: x2,
|
|
27351
|
-
size: [rows, 1]
|
|
27352
|
-
});
|
|
27353
|
-
} finally {
|
|
27354
|
-
wasmLoader.free(lAlloc.ptr);
|
|
27355
|
-
wasmLoader.free(bAlloc.ptr);
|
|
27356
|
-
wasmLoader.free(resultAlloc.ptr);
|
|
27357
|
-
}
|
|
27358
|
-
} catch (e) {
|
|
27359
|
-
if (e instanceof Error && e.message.includes("singular")) {
|
|
27360
|
-
throw e;
|
|
27361
|
-
}
|
|
27362
|
-
}
|
|
27363
|
-
}
|
|
27364
26372
|
const x = [];
|
|
27365
26373
|
for (let j = 0; j < columns; j++) {
|
|
27366
26374
|
const bj = bdata[j][0] || 0;
|
|
@@ -27574,42 +26582,6 @@ var createLsolveAll = /* @__PURE__ */ factory(
|
|
|
27574
26582
|
);
|
|
27575
26583
|
|
|
27576
26584
|
// src/algebra/solver/usolve.ts
|
|
27577
|
-
var WASM_USOLVE_THRESHOLD = 16;
|
|
27578
|
-
function isPlainNumberMatrix4(matrix2) {
|
|
27579
|
-
for (let i = 0; i < matrix2.length; i++) {
|
|
27580
|
-
const row2 = matrix2[i];
|
|
27581
|
-
for (let j = 0; j < row2.length; j++) {
|
|
27582
|
-
if (typeof row2[j] !== "number") {
|
|
27583
|
-
return false;
|
|
27584
|
-
}
|
|
27585
|
-
}
|
|
27586
|
-
}
|
|
27587
|
-
return true;
|
|
27588
|
-
}
|
|
27589
|
-
function isPlainNumberVector2(vec) {
|
|
27590
|
-
for (let i = 0; i < vec.length; i++) {
|
|
27591
|
-
if (typeof vec[i][0] !== "number") {
|
|
27592
|
-
return false;
|
|
27593
|
-
}
|
|
27594
|
-
}
|
|
27595
|
-
return true;
|
|
27596
|
-
}
|
|
27597
|
-
function flattenToFloat644(matrix2, rows, cols) {
|
|
27598
|
-
const result = new Float64Array(rows * cols);
|
|
27599
|
-
for (let i = 0; i < rows; i++) {
|
|
27600
|
-
for (let j = 0; j < cols; j++) {
|
|
27601
|
-
result[i * cols + j] = matrix2[i][j];
|
|
27602
|
-
}
|
|
27603
|
-
}
|
|
27604
|
-
return result;
|
|
27605
|
-
}
|
|
27606
|
-
function vectorToFloat642(vec) {
|
|
27607
|
-
const result = new Float64Array(vec.length);
|
|
27608
|
-
for (let i = 0; i < vec.length; i++) {
|
|
27609
|
-
result[i] = vec[i][0];
|
|
27610
|
-
}
|
|
27611
|
-
return result;
|
|
27612
|
-
}
|
|
27613
26585
|
var name104 = "usolve";
|
|
27614
26586
|
var dependencies104 = [
|
|
27615
26587
|
"typed",
|
|
@@ -27654,38 +26626,6 @@ var createUsolve = /* @__PURE__ */ factory(
|
|
|
27654
26626
|
const rows = m._size[0];
|
|
27655
26627
|
const columns = m._size[1];
|
|
27656
26628
|
const mdata = m._data;
|
|
27657
|
-
const wasm = wasmLoader.getModule();
|
|
27658
|
-
if (wasm && rows === columns && rows * rows >= WASM_USOLVE_THRESHOLD && isPlainNumberMatrix4(mdata) && isPlainNumberVector2(bdata)) {
|
|
27659
|
-
try {
|
|
27660
|
-
const uFlat = flattenToFloat644(mdata, rows, columns);
|
|
27661
|
-
const bFlat = vectorToFloat642(bdata);
|
|
27662
|
-
const uAlloc = wasmLoader.allocateFloat64Array(uFlat);
|
|
27663
|
-
const bAlloc = wasmLoader.allocateFloat64Array(bFlat);
|
|
27664
|
-
const resultAlloc = wasmLoader.allocateFloat64ArrayEmpty(rows);
|
|
27665
|
-
try {
|
|
27666
|
-
const success = wasm.laUsolve(uAlloc.ptr, bAlloc.ptr, rows, resultAlloc.ptr);
|
|
27667
|
-
if (success === 0) {
|
|
27668
|
-
throw new Error("Linear system cannot be solved since matrix is singular");
|
|
27669
|
-
}
|
|
27670
|
-
const x2 = [];
|
|
27671
|
-
for (let i = 0; i < rows; i++) {
|
|
27672
|
-
x2[i] = [resultAlloc.array[i]];
|
|
27673
|
-
}
|
|
27674
|
-
return new DenseMatrix7({
|
|
27675
|
-
data: x2,
|
|
27676
|
-
size: [rows, 1]
|
|
27677
|
-
});
|
|
27678
|
-
} finally {
|
|
27679
|
-
wasmLoader.free(uAlloc.ptr);
|
|
27680
|
-
wasmLoader.free(bAlloc.ptr);
|
|
27681
|
-
wasmLoader.free(resultAlloc.ptr);
|
|
27682
|
-
}
|
|
27683
|
-
} catch (e) {
|
|
27684
|
-
if (e instanceof Error && e.message.includes("singular")) {
|
|
27685
|
-
throw e;
|
|
27686
|
-
}
|
|
27687
|
-
}
|
|
27688
|
-
}
|
|
27689
26629
|
const x = [];
|
|
27690
26630
|
for (let j = columns - 1; j >= 0; j--) {
|
|
27691
26631
|
const bj = bdata[j][0] || 0;
|
|
@@ -28084,7 +27024,10 @@ var createMatAlgo11xS0s = /* @__PURE__ */ factory(
|
|
|
28084
27024
|
eq = _eqCache;
|
|
28085
27025
|
cf = _cfCache;
|
|
28086
27026
|
} else {
|
|
28087
|
-
eq = typed3.find(equalScalar3, [
|
|
27027
|
+
eq = typed3.find(equalScalar3, [
|
|
27028
|
+
dt,
|
|
27029
|
+
dt
|
|
27030
|
+
]) || equalScalar3;
|
|
28088
27031
|
cf = typed3.find(callback, [dt, dt]) || callback;
|
|
28089
27032
|
_dtCache = dt;
|
|
28090
27033
|
_cbCache = callback;
|
|
@@ -28343,17 +27286,32 @@ var createRound = /* @__PURE__ */ factory(
|
|
|
28343
27286
|
),
|
|
28344
27287
|
"SparseMatrix, number | BigNumber": typed3.referToSelf(
|
|
28345
27288
|
(self) => (x, n) => {
|
|
28346
|
-
return matAlgo11xS0s(
|
|
27289
|
+
return matAlgo11xS0s(
|
|
27290
|
+
x,
|
|
27291
|
+
n,
|
|
27292
|
+
self,
|
|
27293
|
+
false
|
|
27294
|
+
);
|
|
28347
27295
|
}
|
|
28348
27296
|
),
|
|
28349
27297
|
"DenseMatrix, number | BigNumber": typed3.referToSelf(
|
|
28350
27298
|
(self) => (x, n) => {
|
|
28351
|
-
return matAlgo14xDs(
|
|
27299
|
+
return matAlgo14xDs(
|
|
27300
|
+
x,
|
|
27301
|
+
n,
|
|
27302
|
+
self,
|
|
27303
|
+
false
|
|
27304
|
+
);
|
|
28352
27305
|
}
|
|
28353
27306
|
),
|
|
28354
27307
|
"Array, number | BigNumber": typed3.referToSelf(
|
|
28355
27308
|
(self) => (x, n) => {
|
|
28356
|
-
return matAlgo14xDs(
|
|
27309
|
+
return matAlgo14xDs(
|
|
27310
|
+
matrix2(x),
|
|
27311
|
+
n,
|
|
27312
|
+
self,
|
|
27313
|
+
false
|
|
27314
|
+
).valueOf();
|
|
28357
27315
|
}
|
|
28358
27316
|
),
|
|
28359
27317
|
"number | Complex | BigNumber | Fraction, SparseMatrix": typed3.referToSelf(
|
|
@@ -28361,7 +27319,12 @@ var createRound = /* @__PURE__ */ factory(
|
|
|
28361
27319
|
if (equalScalar3(x, 0)) {
|
|
28362
27320
|
return zeros4(n.size(), n.storage());
|
|
28363
27321
|
}
|
|
28364
|
-
return matAlgo12xSfs(
|
|
27322
|
+
return matAlgo12xSfs(
|
|
27323
|
+
n,
|
|
27324
|
+
x,
|
|
27325
|
+
self,
|
|
27326
|
+
true
|
|
27327
|
+
);
|
|
28365
27328
|
}
|
|
28366
27329
|
),
|
|
28367
27330
|
"number | Complex | BigNumber | Fraction, DenseMatrix": typed3.referToSelf(
|
|
@@ -28369,12 +27332,22 @@ var createRound = /* @__PURE__ */ factory(
|
|
|
28369
27332
|
if (equalScalar3(x, 0)) {
|
|
28370
27333
|
return zeros4(n.size(), n.storage());
|
|
28371
27334
|
}
|
|
28372
|
-
return matAlgo14xDs(
|
|
27335
|
+
return matAlgo14xDs(
|
|
27336
|
+
n,
|
|
27337
|
+
x,
|
|
27338
|
+
self,
|
|
27339
|
+
true
|
|
27340
|
+
);
|
|
28373
27341
|
}
|
|
28374
27342
|
),
|
|
28375
27343
|
"number | Complex | BigNumber | Fraction, Array": typed3.referToSelf(
|
|
28376
27344
|
(self) => (x, n) => {
|
|
28377
|
-
return matAlgo14xDs(
|
|
27345
|
+
return matAlgo14xDs(
|
|
27346
|
+
matrix2(n),
|
|
27347
|
+
x,
|
|
27348
|
+
self,
|
|
27349
|
+
true
|
|
27350
|
+
).valueOf();
|
|
28378
27351
|
}
|
|
28379
27352
|
)
|
|
28380
27353
|
});
|
|
@@ -28622,27 +27595,6 @@ var createConcat = /* @__PURE__ */ factory(
|
|
|
28622
27595
|
);
|
|
28623
27596
|
|
|
28624
27597
|
// src/matrix/inv.ts
|
|
28625
|
-
var WASM_INV_THRESHOLD = 16;
|
|
28626
|
-
function isPlainNumberMatrix5(matrix2) {
|
|
28627
|
-
for (let i = 0; i < matrix2.length; i++) {
|
|
28628
|
-
const row2 = matrix2[i];
|
|
28629
|
-
for (let j = 0; j < row2.length; j++) {
|
|
28630
|
-
if (typeof row2[j] !== "number") {
|
|
28631
|
-
return false;
|
|
28632
|
-
}
|
|
28633
|
-
}
|
|
28634
|
-
}
|
|
28635
|
-
return true;
|
|
28636
|
-
}
|
|
28637
|
-
function flattenToFloat645(matrix2, rows, cols) {
|
|
28638
|
-
const result = new Float64Array(rows * cols);
|
|
28639
|
-
for (let i = 0; i < rows; i++) {
|
|
28640
|
-
for (let j = 0; j < cols; j++) {
|
|
28641
|
-
result[i * cols + j] = matrix2[i][j];
|
|
28642
|
-
}
|
|
28643
|
-
}
|
|
28644
|
-
return result;
|
|
28645
|
-
}
|
|
28646
27598
|
var name116 = "inv";
|
|
28647
27599
|
var dependencies116 = [
|
|
28648
27600
|
"typed",
|
|
@@ -28711,38 +27663,6 @@ var createInv = /* @__PURE__ */ factory(
|
|
|
28711
27663
|
});
|
|
28712
27664
|
function _inv4(mat, rows, cols) {
|
|
28713
27665
|
let r, s, f, value, temp;
|
|
28714
|
-
const wasm = wasmLoader.getModule();
|
|
28715
|
-
if (wasm && rows >= 3 && rows * rows >= WASM_INV_THRESHOLD && isPlainNumberMatrix5(mat)) {
|
|
28716
|
-
try {
|
|
28717
|
-
const flat = flattenToFloat645(mat, rows, rows);
|
|
28718
|
-
const input = wasmLoader.allocateFloat64Array(flat);
|
|
28719
|
-
const result = wasmLoader.allocateFloat64ArrayEmpty(rows * rows);
|
|
28720
|
-
const work = wasmLoader.allocateFloat64ArrayEmpty(rows * 2 * rows);
|
|
28721
|
-
try {
|
|
28722
|
-
const success = wasm.laInv(input.ptr, rows, result.ptr, work.ptr);
|
|
28723
|
-
if (success === 0) {
|
|
28724
|
-
throw Error("Cannot calculate inverse, determinant is zero");
|
|
28725
|
-
}
|
|
28726
|
-
const invMatrix = [];
|
|
28727
|
-
for (let i = 0; i < rows; i++) {
|
|
28728
|
-
const row2 = [];
|
|
28729
|
-
for (let j = 0; j < rows; j++) {
|
|
28730
|
-
row2[j] = result.array[i * rows + j];
|
|
28731
|
-
}
|
|
28732
|
-
invMatrix[i] = row2;
|
|
28733
|
-
}
|
|
28734
|
-
return invMatrix;
|
|
28735
|
-
} finally {
|
|
28736
|
-
wasmLoader.free(input.ptr);
|
|
28737
|
-
wasmLoader.free(result.ptr);
|
|
28738
|
-
wasmLoader.free(work.ptr);
|
|
28739
|
-
}
|
|
28740
|
-
} catch (e) {
|
|
28741
|
-
if (e instanceof Error && e.message.includes("determinant is zero")) {
|
|
28742
|
-
throw e;
|
|
28743
|
-
}
|
|
28744
|
-
}
|
|
28745
|
-
}
|
|
28746
27666
|
if (rows === 1) {
|
|
28747
27667
|
value = mat[0][0];
|
|
28748
27668
|
if (value === 0) {
|
|
@@ -29070,7 +27990,12 @@ var createSubset = /* @__PURE__ */ factory(
|
|
|
29070
27990
|
},
|
|
29071
27991
|
"Array, Index, any, any": referTo("Matrix, Index, any, any", function(subsetRef) {
|
|
29072
27992
|
return function(value, index, replacement, defaultValue) {
|
|
29073
|
-
const subsetResult = subsetRef(
|
|
27993
|
+
const subsetResult = subsetRef(
|
|
27994
|
+
matrix2(value),
|
|
27995
|
+
index,
|
|
27996
|
+
replacement,
|
|
27997
|
+
defaultValue
|
|
27998
|
+
);
|
|
29074
27999
|
return subsetResult.isMatrix ? subsetResult.valueOf() : subsetResult;
|
|
29075
28000
|
};
|
|
29076
28001
|
}),
|
|
@@ -29589,12 +28514,18 @@ var createMatrixAlgorithmSuite = /* @__PURE__ */ factory(
|
|
|
29589
28514
|
),
|
|
29590
28515
|
"Array, DenseMatrix": typed3.referToSelf(
|
|
29591
28516
|
(self) => (x, y) => {
|
|
29592
|
-
return matAlgo13xDD(
|
|
28517
|
+
return matAlgo13xDD(
|
|
28518
|
+
...bcast(matrix2(x), y),
|
|
28519
|
+
self
|
|
28520
|
+
);
|
|
29593
28521
|
}
|
|
29594
28522
|
),
|
|
29595
28523
|
"DenseMatrix, Array": typed3.referToSelf(
|
|
29596
28524
|
(self) => (x, y) => {
|
|
29597
|
-
return matAlgo13xDD(
|
|
28525
|
+
return matAlgo13xDD(
|
|
28526
|
+
...bcast(x, matrix2(y)),
|
|
28527
|
+
self
|
|
28528
|
+
);
|
|
29598
28529
|
}
|
|
29599
28530
|
)
|
|
29600
28531
|
};
|
|
@@ -29636,8 +28567,18 @@ var createMatrixAlgorithmSuite = /* @__PURE__ */ factory(
|
|
|
29636
28567
|
if (elop) {
|
|
29637
28568
|
matrixSignatures["DenseMatrix," + scalar] = (x, y) => matAlgo14xDs(x, y, elop, false);
|
|
29638
28569
|
matrixSignatures[scalar + ", DenseMatrix"] = (x, y) => matAlgo14xDs(y, x, elop, true);
|
|
29639
|
-
matrixSignatures["Array," + scalar] = (x, y) => matAlgo14xDs(
|
|
29640
|
-
|
|
28570
|
+
matrixSignatures["Array," + scalar] = (x, y) => matAlgo14xDs(
|
|
28571
|
+
matrix2(x),
|
|
28572
|
+
y,
|
|
28573
|
+
elop,
|
|
28574
|
+
false
|
|
28575
|
+
).valueOf();
|
|
28576
|
+
matrixSignatures[scalar + ", Array"] = (x, y) => matAlgo14xDs(
|
|
28577
|
+
matrix2(y),
|
|
28578
|
+
x,
|
|
28579
|
+
elop,
|
|
28580
|
+
true
|
|
28581
|
+
).valueOf();
|
|
29641
28582
|
} else {
|
|
29642
28583
|
matrixSignatures["DenseMatrix," + scalar] = typed3.referToSelf(
|
|
29643
28584
|
(self) => (x, y) => {
|
|
@@ -29782,6 +28723,8 @@ var dependencies127 = ["typed", "add", "multiply", "Complex", "number"];
|
|
|
29782
28723
|
var createZpk2tf = /* @__PURE__ */ factory(
|
|
29783
28724
|
name127,
|
|
29784
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.
|
|
29785
28728
|
({ typed: typed3, add: add5, multiply: multiply2, Complex: Complex13, number: number2 }) => {
|
|
29786
28729
|
return typed3(name127, {
|
|
29787
28730
|
"Array,Array,number": function(z, p, k) {
|
|
@@ -29841,7 +28784,7 @@ import { _switch as _switch2 } from "@danielsimonjr/mathts-core/internal";
|
|
|
29841
28784
|
|
|
29842
28785
|
// src/statistics/cumsum.ts
|
|
29843
28786
|
import { neumaierCumsum as neumaierCumsum2 } from "@danielsimonjr/mathts-core";
|
|
29844
|
-
function
|
|
28787
|
+
function isFlatNumberArray(arr10) {
|
|
29845
28788
|
for (let i = 0; i < arr10.length; i++) {
|
|
29846
28789
|
if (typeof arr10[i] !== "number") {
|
|
29847
28790
|
return false;
|
|
@@ -29888,7 +28831,7 @@ var createCumSum = /* @__PURE__ */ factory(
|
|
|
29888
28831
|
if (array.length === 0) {
|
|
29889
28832
|
return [];
|
|
29890
28833
|
}
|
|
29891
|
-
if (
|
|
28834
|
+
if (isFlatNumberArray(array)) {
|
|
29892
28835
|
const result = new Array(array.length);
|
|
29893
28836
|
neumaierCumsum2(array, result);
|
|
29894
28837
|
return result;
|
|
@@ -29940,7 +28883,7 @@ var createCumSum = /* @__PURE__ */ factory(
|
|
|
29940
28883
|
|
|
29941
28884
|
// src/statistics/sum.ts
|
|
29942
28885
|
import { pairwiseSum as pairwiseSum2 } from "@danielsimonjr/mathts-core";
|
|
29943
|
-
function
|
|
28886
|
+
function isFlatNumberArray2(arr10) {
|
|
29944
28887
|
for (let i = 0; i < arr10.length; i++) {
|
|
29945
28888
|
if (typeof arr10[i] !== "number") {
|
|
29946
28889
|
return false;
|
|
@@ -29972,7 +28915,7 @@ var createSum = /* @__PURE__ */ factory(
|
|
|
29972
28915
|
}
|
|
29973
28916
|
});
|
|
29974
28917
|
function _sum(array) {
|
|
29975
|
-
if (Array.isArray(array) &&
|
|
28918
|
+
if (Array.isArray(array) && isFlatNumberArray2(array)) {
|
|
29976
28919
|
return pairwiseSum2(array);
|
|
29977
28920
|
}
|
|
29978
28921
|
let sum3;
|
|
@@ -30147,7 +29090,10 @@ var createMatAlgo09xS0Sf = /* @__PURE__ */ factory(
|
|
|
30147
29090
|
let cf = callback;
|
|
30148
29091
|
if (typeof adt === "string" && adt === bdt && adt !== "mixed") {
|
|
30149
29092
|
dt = adt;
|
|
30150
|
-
eq = typed3.find(equalScalar3, [
|
|
29093
|
+
eq = typed3.find(equalScalar3, [
|
|
29094
|
+
dt,
|
|
29095
|
+
dt
|
|
29096
|
+
]);
|
|
30151
29097
|
zero = typed3.convert(0, dt);
|
|
30152
29098
|
cf = typed3.find(callback, [dt, dt]);
|
|
30153
29099
|
}
|
|
@@ -30227,7 +29173,7 @@ var createDotMultiply = /* @__PURE__ */ factory(
|
|
|
30227
29173
|
);
|
|
30228
29174
|
|
|
30229
29175
|
// src/arithmetic/floor.ts
|
|
30230
|
-
import Decimal from "decimal.js";
|
|
29176
|
+
import { Decimal } from "decimal.js";
|
|
30231
29177
|
var name134 = "floor";
|
|
30232
29178
|
var dependencies134 = ["typed", "config", "round", "matrix", "equalScalar", "zeros", "DenseMatrix"];
|
|
30233
29179
|
var bigTen = new Decimal(10);
|
|
@@ -30335,26 +29281,51 @@ var createFloor = /* @__PURE__ */ factory(
|
|
|
30335
29281
|
),
|
|
30336
29282
|
"SparseMatrix, number | BigNumber": typed3.referToSelf(
|
|
30337
29283
|
(self) => (x, y) => {
|
|
30338
|
-
return matAlgo11xS0s(
|
|
29284
|
+
return matAlgo11xS0s(
|
|
29285
|
+
x,
|
|
29286
|
+
y,
|
|
29287
|
+
self,
|
|
29288
|
+
false
|
|
29289
|
+
);
|
|
30339
29290
|
}
|
|
30340
29291
|
),
|
|
30341
29292
|
"DenseMatrix, number | BigNumber": typed3.referToSelf(
|
|
30342
29293
|
(self) => (x, y) => {
|
|
30343
|
-
return matAlgo14xDs(
|
|
29294
|
+
return matAlgo14xDs(
|
|
29295
|
+
x,
|
|
29296
|
+
y,
|
|
29297
|
+
self,
|
|
29298
|
+
false
|
|
29299
|
+
);
|
|
30344
29300
|
}
|
|
30345
29301
|
),
|
|
30346
29302
|
"number | Complex | Fraction | BigNumber, Array": typed3.referToSelf(
|
|
30347
29303
|
(self) => (x, y) => {
|
|
30348
|
-
return matAlgo14xDs(
|
|
29304
|
+
return matAlgo14xDs(
|
|
29305
|
+
matrix2(y),
|
|
29306
|
+
x,
|
|
29307
|
+
self,
|
|
29308
|
+
true
|
|
29309
|
+
).valueOf();
|
|
30349
29310
|
}
|
|
30350
29311
|
),
|
|
30351
29312
|
"number | Complex | Fraction | BigNumber, Matrix": typed3.referToSelf(
|
|
30352
29313
|
(self) => (x, y) => {
|
|
30353
29314
|
if (equalScalar3(x, 0)) return zeros4(y.size(), y.storage());
|
|
30354
29315
|
if (y.storage() === "dense") {
|
|
30355
|
-
return matAlgo14xDs(
|
|
29316
|
+
return matAlgo14xDs(
|
|
29317
|
+
y,
|
|
29318
|
+
x,
|
|
29319
|
+
self,
|
|
29320
|
+
true
|
|
29321
|
+
);
|
|
30356
29322
|
}
|
|
30357
|
-
return matAlgo12xSfs(
|
|
29323
|
+
return matAlgo12xSfs(
|
|
29324
|
+
y,
|
|
29325
|
+
x,
|
|
29326
|
+
self,
|
|
29327
|
+
true
|
|
29328
|
+
);
|
|
30358
29329
|
}
|
|
30359
29330
|
)
|
|
30360
29331
|
});
|
|
@@ -30752,7 +29723,6 @@ var createMatAlgo10xSids = /* @__PURE__ */ factory(
|
|
|
30752
29723
|
);
|
|
30753
29724
|
|
|
30754
29725
|
// src/arithmetic/gcd.ts
|
|
30755
|
-
var WASM_GCD_ARRAY_THRESHOLD = 50;
|
|
30756
29726
|
var name140 = "gcd";
|
|
30757
29727
|
var dependencies140 = [
|
|
30758
29728
|
"typed",
|
|
@@ -30826,14 +29796,9 @@ var createGcd = /* @__PURE__ */ factory(
|
|
|
30826
29796
|
),
|
|
30827
29797
|
Array: typed3.referToSelf((self) => (array) => {
|
|
30828
29798
|
if (array.length === 1 && Array.isArray(array[0]) && is1d(array[0])) {
|
|
30829
|
-
|
|
30830
|
-
const wasmResult = _tryWasmGcdArray(flat);
|
|
30831
|
-
if (wasmResult !== null) return wasmResult;
|
|
30832
|
-
return self(...flat);
|
|
29799
|
+
return self(...array[0]);
|
|
30833
29800
|
}
|
|
30834
29801
|
if (is1d(array)) {
|
|
30835
|
-
const wasmResult = _tryWasmGcdArray(array);
|
|
30836
|
-
if (wasmResult !== null) return wasmResult;
|
|
30837
29802
|
return self(...array);
|
|
30838
29803
|
}
|
|
30839
29804
|
throw new Error("gcd() supports only 1d matrices!");
|
|
@@ -30843,27 +29808,6 @@ var createGcd = /* @__PURE__ */ factory(
|
|
|
30843
29808
|
})
|
|
30844
29809
|
}
|
|
30845
29810
|
);
|
|
30846
|
-
function _tryWasmGcdArray(array) {
|
|
30847
|
-
if (array.length < WASM_GCD_ARRAY_THRESHOLD) return null;
|
|
30848
|
-
const wasm = wasmLoader.getModule();
|
|
30849
|
-
if (!wasm) return null;
|
|
30850
|
-
const n = array.length;
|
|
30851
|
-
const data = new Float64Array(n);
|
|
30852
|
-
for (let i = 0; i < n; i++) {
|
|
30853
|
-
if (typeof array[i] !== "number" || !isInteger(array[i])) {
|
|
30854
|
-
return null;
|
|
30855
|
-
}
|
|
30856
|
-
data[i] = array[i];
|
|
30857
|
-
}
|
|
30858
|
-
const alloc = wasmLoader.allocateFloat64Array(data);
|
|
30859
|
-
try {
|
|
30860
|
-
return wasm.gcdArray(alloc.ptr, n);
|
|
30861
|
-
} catch {
|
|
30862
|
-
return null;
|
|
30863
|
-
} finally {
|
|
30864
|
-
wasmLoader.free(alloc.ptr);
|
|
30865
|
-
}
|
|
30866
|
-
}
|
|
30867
29811
|
function _gcdNumber(a, b) {
|
|
30868
29812
|
if (!isInteger(a) || !isInteger(b)) {
|
|
30869
29813
|
throw new Error("Parameters in function gcd must be integer numbers");
|
|
@@ -31329,7 +30273,7 @@ var createPow = /* @__PURE__ */ factory(
|
|
|
31329
30273
|
);
|
|
31330
30274
|
|
|
31331
30275
|
// src/arithmetic/ceil.ts
|
|
31332
|
-
import Decimal2 from "decimal.js";
|
|
30276
|
+
import { Decimal as Decimal2 } from "decimal.js";
|
|
31333
30277
|
var name146 = "ceil";
|
|
31334
30278
|
var dependencies146 = ["typed", "config", "round", "matrix", "equalScalar", "zeros", "DenseMatrix"];
|
|
31335
30279
|
var bigTen2 = new Decimal2(10);
|
|
@@ -31437,26 +30381,51 @@ var createCeil = /* @__PURE__ */ factory(
|
|
|
31437
30381
|
),
|
|
31438
30382
|
"SparseMatrix, number | BigNumber": typed3.referToSelf(
|
|
31439
30383
|
(self) => (x, y) => {
|
|
31440
|
-
return matAlgo11xS0s(
|
|
30384
|
+
return matAlgo11xS0s(
|
|
30385
|
+
x,
|
|
30386
|
+
y,
|
|
30387
|
+
self,
|
|
30388
|
+
false
|
|
30389
|
+
);
|
|
31441
30390
|
}
|
|
31442
30391
|
),
|
|
31443
30392
|
"DenseMatrix, number | BigNumber": typed3.referToSelf(
|
|
31444
30393
|
(self) => (x, y) => {
|
|
31445
|
-
return matAlgo14xDs(
|
|
30394
|
+
return matAlgo14xDs(
|
|
30395
|
+
x,
|
|
30396
|
+
y,
|
|
30397
|
+
self,
|
|
30398
|
+
false
|
|
30399
|
+
);
|
|
31446
30400
|
}
|
|
31447
30401
|
),
|
|
31448
30402
|
"number | Complex | Fraction | BigNumber, Array": typed3.referToSelf(
|
|
31449
30403
|
(self) => (x, y) => {
|
|
31450
|
-
return matAlgo14xDs(
|
|
30404
|
+
return matAlgo14xDs(
|
|
30405
|
+
matrix2(y),
|
|
30406
|
+
x,
|
|
30407
|
+
self,
|
|
30408
|
+
true
|
|
30409
|
+
).valueOf();
|
|
31451
30410
|
}
|
|
31452
30411
|
),
|
|
31453
30412
|
"number | Complex | Fraction | BigNumber, Matrix": typed3.referToSelf(
|
|
31454
30413
|
(self) => (x, y) => {
|
|
31455
30414
|
if (equalScalar3(x, 0)) return zeros4(y.size(), y.storage());
|
|
31456
30415
|
if (y.storage() === "dense") {
|
|
31457
|
-
return matAlgo14xDs(
|
|
30416
|
+
return matAlgo14xDs(
|
|
30417
|
+
y,
|
|
30418
|
+
x,
|
|
30419
|
+
self,
|
|
30420
|
+
true
|
|
30421
|
+
);
|
|
31458
30422
|
}
|
|
31459
|
-
return matAlgo12xSfs(
|
|
30423
|
+
return matAlgo12xSfs(
|
|
30424
|
+
y,
|
|
30425
|
+
x,
|
|
30426
|
+
self,
|
|
30427
|
+
true
|
|
30428
|
+
);
|
|
31460
30429
|
}
|
|
31461
30430
|
)
|
|
31462
30431
|
});
|
|
@@ -31702,7 +30671,12 @@ var createLeftShift = /* @__PURE__ */ factory(
|
|
|
31702
30671
|
if (equalScalar3(y, 0)) {
|
|
31703
30672
|
return x.clone();
|
|
31704
30673
|
}
|
|
31705
|
-
return matAlgo11xS0s(
|
|
30674
|
+
return matAlgo11xS0s(
|
|
30675
|
+
x,
|
|
30676
|
+
y,
|
|
30677
|
+
self,
|
|
30678
|
+
false
|
|
30679
|
+
);
|
|
31706
30680
|
}
|
|
31707
30681
|
),
|
|
31708
30682
|
"DenseMatrix, number | BigNumber": typed3.referToSelf(
|
|
@@ -31710,7 +30684,12 @@ var createLeftShift = /* @__PURE__ */ factory(
|
|
|
31710
30684
|
if (equalScalar3(y, 0)) {
|
|
31711
30685
|
return x.clone();
|
|
31712
30686
|
}
|
|
31713
|
-
return matAlgo14xDs(
|
|
30687
|
+
return matAlgo14xDs(
|
|
30688
|
+
x,
|
|
30689
|
+
y,
|
|
30690
|
+
self,
|
|
30691
|
+
false
|
|
30692
|
+
);
|
|
31714
30693
|
}
|
|
31715
30694
|
),
|
|
31716
30695
|
"number | BigNumber, SparseMatrix": typed3.referToSelf(
|
|
@@ -31718,7 +30697,12 @@ var createLeftShift = /* @__PURE__ */ factory(
|
|
|
31718
30697
|
if (equalScalar3(x, 0)) {
|
|
31719
30698
|
return zeros4(y.size(), y.storage());
|
|
31720
30699
|
}
|
|
31721
|
-
return matAlgo10xSids(
|
|
30700
|
+
return matAlgo10xSids(
|
|
30701
|
+
y,
|
|
30702
|
+
x,
|
|
30703
|
+
self,
|
|
30704
|
+
true
|
|
30705
|
+
);
|
|
31722
30706
|
}
|
|
31723
30707
|
),
|
|
31724
30708
|
"number | BigNumber, DenseMatrix": typed3.referToSelf(
|
|
@@ -31726,7 +30710,12 @@ var createLeftShift = /* @__PURE__ */ factory(
|
|
|
31726
30710
|
if (equalScalar3(x, 0)) {
|
|
31727
30711
|
return zeros4(y.size(), y.storage());
|
|
31728
30712
|
}
|
|
31729
|
-
return matAlgo14xDs(
|
|
30713
|
+
return matAlgo14xDs(
|
|
30714
|
+
y,
|
|
30715
|
+
x,
|
|
30716
|
+
self,
|
|
30717
|
+
true
|
|
30718
|
+
);
|
|
31730
30719
|
}
|
|
31731
30720
|
)
|
|
31732
30721
|
},
|
|
@@ -31773,7 +30762,12 @@ var createRightArithShift = /* @__PURE__ */ factory(
|
|
|
31773
30762
|
if (equalScalar3(y, 0)) {
|
|
31774
30763
|
return x.clone();
|
|
31775
30764
|
}
|
|
31776
|
-
return matAlgo11xS0s(
|
|
30765
|
+
return matAlgo11xS0s(
|
|
30766
|
+
x,
|
|
30767
|
+
y,
|
|
30768
|
+
self,
|
|
30769
|
+
false
|
|
30770
|
+
);
|
|
31777
30771
|
}
|
|
31778
30772
|
),
|
|
31779
30773
|
"DenseMatrix, number | BigNumber": typed3.referToSelf(
|
|
@@ -31781,7 +30775,12 @@ var createRightArithShift = /* @__PURE__ */ factory(
|
|
|
31781
30775
|
if (equalScalar3(y, 0)) {
|
|
31782
30776
|
return x.clone();
|
|
31783
30777
|
}
|
|
31784
|
-
return matAlgo14xDs(
|
|
30778
|
+
return matAlgo14xDs(
|
|
30779
|
+
x,
|
|
30780
|
+
y,
|
|
30781
|
+
self,
|
|
30782
|
+
false
|
|
30783
|
+
);
|
|
31785
30784
|
}
|
|
31786
30785
|
),
|
|
31787
30786
|
"number | BigNumber, SparseMatrix": typed3.referToSelf(
|
|
@@ -31789,7 +30788,12 @@ var createRightArithShift = /* @__PURE__ */ factory(
|
|
|
31789
30788
|
if (equalScalar3(x, 0)) {
|
|
31790
30789
|
return zeros4(y.size(), y.storage());
|
|
31791
30790
|
}
|
|
31792
|
-
return matAlgo10xSids(
|
|
30791
|
+
return matAlgo10xSids(
|
|
30792
|
+
y,
|
|
30793
|
+
x,
|
|
30794
|
+
self,
|
|
30795
|
+
true
|
|
30796
|
+
);
|
|
31793
30797
|
}
|
|
31794
30798
|
),
|
|
31795
30799
|
"number | BigNumber, DenseMatrix": typed3.referToSelf(
|
|
@@ -31797,7 +30801,12 @@ var createRightArithShift = /* @__PURE__ */ factory(
|
|
|
31797
30801
|
if (equalScalar3(x, 0)) {
|
|
31798
30802
|
return zeros4(y.size(), y.storage());
|
|
31799
30803
|
}
|
|
31800
|
-
return matAlgo14xDs(
|
|
30804
|
+
return matAlgo14xDs(
|
|
30805
|
+
y,
|
|
30806
|
+
x,
|
|
30807
|
+
self,
|
|
30808
|
+
true
|
|
30809
|
+
);
|
|
31801
30810
|
}
|
|
31802
30811
|
)
|
|
31803
30812
|
},
|
|
@@ -31843,7 +30852,12 @@ var createRightLogShift = /* @__PURE__ */ factory(
|
|
|
31843
30852
|
if (equalScalar3(y, 0)) {
|
|
31844
30853
|
return x.clone();
|
|
31845
30854
|
}
|
|
31846
|
-
return matAlgo11xS0s(
|
|
30855
|
+
return matAlgo11xS0s(
|
|
30856
|
+
x,
|
|
30857
|
+
y,
|
|
30858
|
+
self,
|
|
30859
|
+
false
|
|
30860
|
+
);
|
|
31847
30861
|
}
|
|
31848
30862
|
),
|
|
31849
30863
|
"DenseMatrix, number | BigNumber": typed3.referToSelf(
|
|
@@ -31851,7 +30865,12 @@ var createRightLogShift = /* @__PURE__ */ factory(
|
|
|
31851
30865
|
if (equalScalar3(y, 0)) {
|
|
31852
30866
|
return x.clone();
|
|
31853
30867
|
}
|
|
31854
|
-
return matAlgo14xDs(
|
|
30868
|
+
return matAlgo14xDs(
|
|
30869
|
+
x,
|
|
30870
|
+
y,
|
|
30871
|
+
self,
|
|
30872
|
+
false
|
|
30873
|
+
);
|
|
31855
30874
|
}
|
|
31856
30875
|
),
|
|
31857
30876
|
"number | BigNumber, SparseMatrix": typed3.referToSelf(
|
|
@@ -31859,7 +30878,12 @@ var createRightLogShift = /* @__PURE__ */ factory(
|
|
|
31859
30878
|
if (equalScalar3(x, 0)) {
|
|
31860
30879
|
return zeros4(y.size(), y.storage());
|
|
31861
30880
|
}
|
|
31862
|
-
return matAlgo10xSids(
|
|
30881
|
+
return matAlgo10xSids(
|
|
30882
|
+
y,
|
|
30883
|
+
x,
|
|
30884
|
+
self,
|
|
30885
|
+
true
|
|
30886
|
+
);
|
|
31863
30887
|
}
|
|
31864
30888
|
),
|
|
31865
30889
|
"number | BigNumber, DenseMatrix": typed3.referToSelf(
|
|
@@ -31867,7 +30891,12 @@ var createRightLogShift = /* @__PURE__ */ factory(
|
|
|
31867
30891
|
if (equalScalar3(x, 0)) {
|
|
31868
30892
|
return zeros4(y.size(), y.storage());
|
|
31869
30893
|
}
|
|
31870
|
-
return matAlgo14xDs(
|
|
30894
|
+
return matAlgo14xDs(
|
|
30895
|
+
y,
|
|
30896
|
+
x,
|
|
30897
|
+
self,
|
|
30898
|
+
true
|
|
30899
|
+
);
|
|
31871
30900
|
}
|
|
31872
30901
|
)
|
|
31873
30902
|
},
|
|
@@ -32626,16 +31655,31 @@ var createFix = /* @__PURE__ */ factory(
|
|
|
32626
31655
|
),
|
|
32627
31656
|
"number | Complex | Fraction | BigNumber, Array": typed3.referToSelf(
|
|
32628
31657
|
(self) => (x, y) => {
|
|
32629
|
-
return matAlgo14xDs(
|
|
31658
|
+
return matAlgo14xDs(
|
|
31659
|
+
matrix2(y),
|
|
31660
|
+
x,
|
|
31661
|
+
self,
|
|
31662
|
+
true
|
|
31663
|
+
).valueOf();
|
|
32630
31664
|
}
|
|
32631
31665
|
),
|
|
32632
31666
|
"number | Complex | Fraction | BigNumber, Matrix": typed3.referToSelf(
|
|
32633
31667
|
(self) => (x, y) => {
|
|
32634
31668
|
if (equalScalar3(x, 0)) return zeros4(y.size(), y.storage());
|
|
32635
31669
|
if (y.storage() === "dense") {
|
|
32636
|
-
return matAlgo14xDs(
|
|
31670
|
+
return matAlgo14xDs(
|
|
31671
|
+
y,
|
|
31672
|
+
x,
|
|
31673
|
+
self,
|
|
31674
|
+
true
|
|
31675
|
+
);
|
|
32637
31676
|
}
|
|
32638
|
-
return matAlgo12xSfs(
|
|
31677
|
+
return matAlgo12xSfs(
|
|
31678
|
+
y,
|
|
31679
|
+
x,
|
|
31680
|
+
self,
|
|
31681
|
+
true
|
|
31682
|
+
);
|
|
32639
31683
|
}
|
|
32640
31684
|
)
|
|
32641
31685
|
});
|
|
@@ -32713,7 +31757,12 @@ var createAnd = /* @__PURE__ */ factory(
|
|
|
32713
31757
|
if (not3(y)) {
|
|
32714
31758
|
return zeros4(x.size(), x.storage());
|
|
32715
31759
|
}
|
|
32716
|
-
return matAlgo11xS0s(
|
|
31760
|
+
return matAlgo11xS0s(
|
|
31761
|
+
x,
|
|
31762
|
+
y,
|
|
31763
|
+
self,
|
|
31764
|
+
false
|
|
31765
|
+
);
|
|
32717
31766
|
}
|
|
32718
31767
|
),
|
|
32719
31768
|
"DenseMatrix, any": typed3.referToSelf(
|
|
@@ -32721,7 +31770,12 @@ var createAnd = /* @__PURE__ */ factory(
|
|
|
32721
31770
|
if (not3(y)) {
|
|
32722
31771
|
return zeros4(x.size(), x.storage());
|
|
32723
31772
|
}
|
|
32724
|
-
return matAlgo14xDs(
|
|
31773
|
+
return matAlgo14xDs(
|
|
31774
|
+
x,
|
|
31775
|
+
y,
|
|
31776
|
+
self,
|
|
31777
|
+
false
|
|
31778
|
+
);
|
|
32725
31779
|
}
|
|
32726
31780
|
),
|
|
32727
31781
|
"any, SparseMatrix": typed3.referToSelf(
|
|
@@ -32729,7 +31783,12 @@ var createAnd = /* @__PURE__ */ factory(
|
|
|
32729
31783
|
if (not3(x)) {
|
|
32730
31784
|
return zeros4(y.size(), y.storage());
|
|
32731
31785
|
}
|
|
32732
|
-
return matAlgo11xS0s(
|
|
31786
|
+
return matAlgo11xS0s(
|
|
31787
|
+
y,
|
|
31788
|
+
x,
|
|
31789
|
+
self,
|
|
31790
|
+
true
|
|
31791
|
+
);
|
|
32733
31792
|
}
|
|
32734
31793
|
),
|
|
32735
31794
|
"any, DenseMatrix": typed3.referToSelf(
|
|
@@ -32737,7 +31796,12 @@ var createAnd = /* @__PURE__ */ factory(
|
|
|
32737
31796
|
if (not3(x)) {
|
|
32738
31797
|
return zeros4(y.size(), y.storage());
|
|
32739
31798
|
}
|
|
32740
|
-
return matAlgo14xDs(
|
|
31799
|
+
return matAlgo14xDs(
|
|
31800
|
+
y,
|
|
31801
|
+
x,
|
|
31802
|
+
self,
|
|
31803
|
+
true
|
|
31804
|
+
);
|
|
32741
31805
|
}
|
|
32742
31806
|
),
|
|
32743
31807
|
"Array, any": typed3.referToSelf(
|
|
@@ -32796,15 +31860,6 @@ var createComposition = /* @__PURE__ */ factory(
|
|
|
32796
31860
|
);
|
|
32797
31861
|
|
|
32798
31862
|
// src/matrix/partitionSelect.ts
|
|
32799
|
-
var WASM_PARTITION_SELECT_THRESHOLD = 100;
|
|
32800
|
-
function isFlatNumberArray4(arr10) {
|
|
32801
|
-
for (let i = 0; i < arr10.length; i++) {
|
|
32802
|
-
if (typeof arr10[i] !== "number") {
|
|
32803
|
-
return false;
|
|
32804
|
-
}
|
|
32805
|
-
}
|
|
32806
|
-
return true;
|
|
32807
|
-
}
|
|
32808
31863
|
var name171 = "partitionSelect";
|
|
32809
31864
|
var dependencies171 = ["typed", "isNumeric", "isNaN", "compare"];
|
|
32810
31865
|
var createPartitionSelect = /* @__PURE__ */ factory(
|
|
@@ -32850,29 +31905,6 @@ var createPartitionSelect = /* @__PURE__ */ factory(
|
|
|
32850
31905
|
return arr10[i];
|
|
32851
31906
|
}
|
|
32852
31907
|
}
|
|
32853
|
-
const wasm = wasmLoader.getModule();
|
|
32854
|
-
if (wasm && arr10.length >= WASM_PARTITION_SELECT_THRESHOLD && isFlatNumberArray4(arr10)) {
|
|
32855
|
-
const isAsc = compare3 === asc;
|
|
32856
|
-
const isDesc = compare3 === desc;
|
|
32857
|
-
if (isAsc || isDesc) {
|
|
32858
|
-
try {
|
|
32859
|
-
const effectiveK = isDesc ? arr10.length - 1 - k : k;
|
|
32860
|
-
const data = wasmLoader.allocateFloat64Array(arr10);
|
|
32861
|
-
const work = wasmLoader.allocateFloat64ArrayEmpty(arr10.length);
|
|
32862
|
-
try {
|
|
32863
|
-
const result = wasm.partitionSelect(data.ptr, arr10.length, effectiveK, work.ptr);
|
|
32864
|
-
for (let i = 0; i < arr10.length; i++) {
|
|
32865
|
-
arr10[i] = work.array[i];
|
|
32866
|
-
}
|
|
32867
|
-
return result;
|
|
32868
|
-
} finally {
|
|
32869
|
-
wasmLoader.free(data.ptr);
|
|
32870
|
-
wasmLoader.free(work.ptr);
|
|
32871
|
-
}
|
|
32872
|
-
} catch {
|
|
32873
|
-
}
|
|
32874
|
-
}
|
|
32875
|
-
}
|
|
32876
31908
|
let from = 0;
|
|
32877
31909
|
let to3 = arr10.length - 1;
|
|
32878
31910
|
while (from < to3) {
|
|
@@ -33041,27 +32073,6 @@ var createPinv = /* @__PURE__ */ factory(
|
|
|
33041
32073
|
);
|
|
33042
32074
|
|
|
33043
32075
|
// src/algebra/decomposition/qr.ts
|
|
33044
|
-
var WASM_QR_THRESHOLD = 16;
|
|
33045
|
-
function isPlainNumberMatrix6(matrix2) {
|
|
33046
|
-
for (let i = 0; i < matrix2.length; i++) {
|
|
33047
|
-
const row2 = matrix2[i];
|
|
33048
|
-
for (let j = 0; j < row2.length; j++) {
|
|
33049
|
-
if (typeof row2[j] !== "number") {
|
|
33050
|
-
return false;
|
|
33051
|
-
}
|
|
33052
|
-
}
|
|
33053
|
-
}
|
|
33054
|
-
return true;
|
|
33055
|
-
}
|
|
33056
|
-
function flattenToFloat646(matrix2, rows, cols) {
|
|
33057
|
-
const result = new Float64Array(rows * cols);
|
|
33058
|
-
for (let i = 0; i < rows; i++) {
|
|
33059
|
-
for (let j = 0; j < cols; j++) {
|
|
33060
|
-
result[i * cols + j] = matrix2[i][j];
|
|
33061
|
-
}
|
|
33062
|
-
}
|
|
33063
|
-
return result;
|
|
33064
|
-
}
|
|
33065
32076
|
var name173 = "qr";
|
|
33066
32077
|
var dependencies173 = [
|
|
33067
32078
|
"typed",
|
|
@@ -33121,44 +32132,6 @@ var createQr = /* @__PURE__ */ factory(
|
|
|
33121
32132
|
function _denseQRimpl(m) {
|
|
33122
32133
|
const rows = m._size[0];
|
|
33123
32134
|
const cols = m._size[1];
|
|
33124
|
-
const wasm = wasmLoader.getModule();
|
|
33125
|
-
if (wasm && rows * cols >= WASM_QR_THRESHOLD && isPlainNumberMatrix6(m._data)) {
|
|
33126
|
-
try {
|
|
33127
|
-
const flat = flattenToFloat646(m._data, rows, cols);
|
|
33128
|
-
const aAlloc = wasmLoader.allocateFloat64Array(flat);
|
|
33129
|
-
const qAlloc = wasmLoader.allocateFloat64ArrayEmpty(rows * rows);
|
|
33130
|
-
try {
|
|
33131
|
-
wasm.qrDecomposition(aAlloc.ptr, rows, cols, qAlloc.ptr);
|
|
33132
|
-
const Rdata2 = [];
|
|
33133
|
-
for (let i2 = 0; i2 < rows; i2++) {
|
|
33134
|
-
Rdata2[i2] = [];
|
|
33135
|
-
for (let j2 = 0; j2 < cols; j2++) {
|
|
33136
|
-
Rdata2[i2][j2] = aAlloc.array[i2 * cols + j2];
|
|
33137
|
-
}
|
|
33138
|
-
}
|
|
33139
|
-
const Qdata2 = [];
|
|
33140
|
-
for (let i2 = 0; i2 < rows; i2++) {
|
|
33141
|
-
Qdata2[i2] = [];
|
|
33142
|
-
for (let j2 = 0; j2 < rows; j2++) {
|
|
33143
|
-
Qdata2[i2][j2] = qAlloc.array[i2 * rows + j2];
|
|
33144
|
-
}
|
|
33145
|
-
}
|
|
33146
|
-
const Q3 = matrix2(Qdata2);
|
|
33147
|
-
const R2 = matrix2(Rdata2);
|
|
33148
|
-
return {
|
|
33149
|
-
Q: Q3,
|
|
33150
|
-
R: R2,
|
|
33151
|
-
toString: function() {
|
|
33152
|
-
return "Q: " + this.Q.toString() + "\nR: " + this.R.toString();
|
|
33153
|
-
}
|
|
33154
|
-
};
|
|
33155
|
-
} finally {
|
|
33156
|
-
wasmLoader.free(aAlloc.ptr);
|
|
33157
|
-
wasmLoader.free(qAlloc.ptr);
|
|
33158
|
-
}
|
|
33159
|
-
} catch {
|
|
33160
|
-
}
|
|
33161
|
-
}
|
|
33162
32135
|
const Q2 = identity2([rows], "dense");
|
|
33163
32136
|
const Qdata = Q2._data;
|
|
33164
32137
|
const R = m.clone();
|
|
@@ -33651,15 +32624,6 @@ var createEqualText = /* @__PURE__ */ factory(
|
|
|
33651
32624
|
);
|
|
33652
32625
|
|
|
33653
32626
|
// src/statistics/max.ts
|
|
33654
|
-
var WASM_MAX_THRESHOLD = 100;
|
|
33655
|
-
function isFlatNumberArray5(arr10) {
|
|
33656
|
-
for (let i = 0; i < arr10.length; i++) {
|
|
33657
|
-
if (typeof arr10[i] !== "number") {
|
|
33658
|
-
return false;
|
|
33659
|
-
}
|
|
33660
|
-
}
|
|
33661
|
-
return true;
|
|
33662
|
-
}
|
|
33663
32627
|
var name178 = "max";
|
|
33664
32628
|
var dependencies178 = ["typed", "config", "numeric", "larger", "isNaN"];
|
|
33665
32629
|
var createMax = /* @__PURE__ */ factory(
|
|
@@ -33690,22 +32654,6 @@ var createMax = /* @__PURE__ */ factory(
|
|
|
33690
32654
|
}
|
|
33691
32655
|
}
|
|
33692
32656
|
function _max(array) {
|
|
33693
|
-
if (Array.isArray(array) && array.length >= WASM_MAX_THRESHOLD) {
|
|
33694
|
-
if (isFlatNumberArray5(array)) {
|
|
33695
|
-
const wasm = wasmLoader.getModule();
|
|
33696
|
-
if (wasm) {
|
|
33697
|
-
try {
|
|
33698
|
-
const alloc = wasmLoader.allocateFloat64Array(array);
|
|
33699
|
-
try {
|
|
33700
|
-
return wasm.statsMax(alloc.ptr, array.length);
|
|
33701
|
-
} finally {
|
|
33702
|
-
wasmLoader.free(alloc.ptr);
|
|
33703
|
-
}
|
|
33704
|
-
} catch {
|
|
33705
|
-
}
|
|
33706
|
-
}
|
|
33707
|
-
}
|
|
33708
|
-
}
|
|
33709
32657
|
let res;
|
|
33710
32658
|
deepForEach(array, function(value) {
|
|
33711
32659
|
try {
|
|
@@ -33730,15 +32678,6 @@ var createMax = /* @__PURE__ */ factory(
|
|
|
33730
32678
|
);
|
|
33731
32679
|
|
|
33732
32680
|
// src/statistics/min.ts
|
|
33733
|
-
var WASM_MIN_THRESHOLD = 100;
|
|
33734
|
-
function isFlatNumberArray6(arr10) {
|
|
33735
|
-
for (let i = 0; i < arr10.length; i++) {
|
|
33736
|
-
if (typeof arr10[i] !== "number") {
|
|
33737
|
-
return false;
|
|
33738
|
-
}
|
|
33739
|
-
}
|
|
33740
|
-
return true;
|
|
33741
|
-
}
|
|
33742
32681
|
var name179 = "min";
|
|
33743
32682
|
var dependencies179 = ["typed", "config", "numeric", "smaller", "isNaN"];
|
|
33744
32683
|
var createMin = /* @__PURE__ */ factory(
|
|
@@ -33769,22 +32708,6 @@ var createMin = /* @__PURE__ */ factory(
|
|
|
33769
32708
|
}
|
|
33770
32709
|
}
|
|
33771
32710
|
function _min(array) {
|
|
33772
|
-
if (Array.isArray(array) && array.length >= WASM_MIN_THRESHOLD) {
|
|
33773
|
-
if (isFlatNumberArray6(array)) {
|
|
33774
|
-
const wasm = wasmLoader.getModule();
|
|
33775
|
-
if (wasm) {
|
|
33776
|
-
try {
|
|
33777
|
-
const alloc = wasmLoader.allocateFloat64Array(array);
|
|
33778
|
-
try {
|
|
33779
|
-
return wasm.statsMin(alloc.ptr, array.length);
|
|
33780
|
-
} finally {
|
|
33781
|
-
wasmLoader.free(alloc.ptr);
|
|
33782
|
-
}
|
|
33783
|
-
} catch {
|
|
33784
|
-
}
|
|
33785
|
-
}
|
|
33786
|
-
}
|
|
33787
|
-
}
|
|
33788
32711
|
let min2;
|
|
33789
32712
|
deepForEach(array, function(value) {
|
|
33790
32713
|
try {
|
|
@@ -33835,36 +32758,71 @@ var createNullish = /* @__PURE__ */ factory(
|
|
|
33835
32758
|
},
|
|
33836
32759
|
// DenseMatrix-first handlers (no broadcasting between collections)
|
|
33837
32760
|
"DenseMatrix, DenseMatrix": typed3.referToSelf(
|
|
33838
|
-
(self) => (x, y) => matAlgo13xDD(
|
|
32761
|
+
(self) => (x, y) => matAlgo13xDD(
|
|
32762
|
+
x,
|
|
32763
|
+
y,
|
|
32764
|
+
self
|
|
32765
|
+
)
|
|
33839
32766
|
),
|
|
33840
32767
|
"DenseMatrix, SparseMatrix": typed3.referToSelf(
|
|
33841
|
-
(self) => (x, y) => matAlgo03xDSf(
|
|
32768
|
+
(self) => (x, y) => matAlgo03xDSf(
|
|
32769
|
+
x,
|
|
32770
|
+
y,
|
|
32771
|
+
self,
|
|
32772
|
+
false
|
|
32773
|
+
)
|
|
33842
32774
|
),
|
|
33843
32775
|
"DenseMatrix, Array": typed3.referToSelf(
|
|
33844
|
-
(self) => (x, y) => matAlgo13xDD(
|
|
32776
|
+
(self) => (x, y) => matAlgo13xDD(
|
|
32777
|
+
x,
|
|
32778
|
+
toMatrix(y),
|
|
32779
|
+
self
|
|
32780
|
+
)
|
|
33845
32781
|
),
|
|
33846
32782
|
"DenseMatrix, any": typed3.referToSelf(
|
|
33847
|
-
(self) => (x, y) => matAlgo14xDs(
|
|
32783
|
+
(self) => (x, y) => matAlgo14xDs(
|
|
32784
|
+
x,
|
|
32785
|
+
y,
|
|
32786
|
+
self,
|
|
32787
|
+
false
|
|
32788
|
+
)
|
|
33848
32789
|
),
|
|
33849
32790
|
// Array-first handlers (bridge via matrix() where needed)
|
|
33850
32791
|
"Array, Array": typed3.referToSelf(
|
|
33851
|
-
(self) => (x, y) => matAlgo13xDD(
|
|
32792
|
+
(self) => (x, y) => matAlgo13xDD(
|
|
32793
|
+
toMatrix(x),
|
|
32794
|
+
toMatrix(y),
|
|
32795
|
+
self
|
|
32796
|
+
).valueOf()
|
|
33852
32797
|
),
|
|
33853
32798
|
"Array, DenseMatrix": typed3.referToSelf(
|
|
33854
|
-
(self) => (x, y) => matAlgo13xDD(
|
|
32799
|
+
(self) => (x, y) => matAlgo13xDD(
|
|
32800
|
+
toMatrix(x),
|
|
32801
|
+
y,
|
|
32802
|
+
self
|
|
32803
|
+
)
|
|
33855
32804
|
),
|
|
33856
32805
|
"Array, SparseMatrix": typed3.referToSelf(
|
|
33857
|
-
(self) => (x, y) => matAlgo03xDSf(
|
|
32806
|
+
(self) => (x, y) => matAlgo03xDSf(
|
|
32807
|
+
toMatrix(x),
|
|
32808
|
+
y,
|
|
32809
|
+
self,
|
|
32810
|
+
false
|
|
32811
|
+
)
|
|
33858
32812
|
),
|
|
33859
32813
|
"Array, any": typed3.referToSelf(
|
|
33860
|
-
(self) => (x, y) => matAlgo14xDs(
|
|
32814
|
+
(self) => (x, y) => matAlgo14xDs(
|
|
32815
|
+
toMatrix(x),
|
|
32816
|
+
y,
|
|
32817
|
+
self,
|
|
32818
|
+
false
|
|
32819
|
+
).valueOf()
|
|
33861
32820
|
)
|
|
33862
32821
|
});
|
|
33863
32822
|
}
|
|
33864
32823
|
);
|
|
33865
32824
|
|
|
33866
32825
|
// src/arithmetic/hypot.ts
|
|
33867
|
-
var WASM_HYPOT_THRESHOLD = 50;
|
|
33868
32826
|
var name181 = "hypot";
|
|
33869
32827
|
var dependencies181 = [
|
|
33870
32828
|
"typed",
|
|
@@ -33894,28 +32852,7 @@ var createHypot = /* @__PURE__ */ factory(
|
|
|
33894
32852
|
Array: _hypot,
|
|
33895
32853
|
Matrix: (M) => _hypot(flatten2(M.toArray(), true))
|
|
33896
32854
|
});
|
|
33897
|
-
function _tryWasmHypot(args) {
|
|
33898
|
-
if (args.length < WASM_HYPOT_THRESHOLD) return null;
|
|
33899
|
-
const wasm = wasmLoader.getModule();
|
|
33900
|
-
if (!wasm) return null;
|
|
33901
|
-
const n = args.length;
|
|
33902
|
-
const data = new Float64Array(n);
|
|
33903
|
-
for (let i = 0; i < n; i++) {
|
|
33904
|
-
if (typeof args[i] !== "number") return null;
|
|
33905
|
-
data[i] = args[i];
|
|
33906
|
-
}
|
|
33907
|
-
const alloc = wasmLoader.allocateFloat64Array(data);
|
|
33908
|
-
try {
|
|
33909
|
-
return wasm.hypotArray(alloc.ptr, n);
|
|
33910
|
-
} catch {
|
|
33911
|
-
return null;
|
|
33912
|
-
} finally {
|
|
33913
|
-
wasmLoader.free(alloc.ptr);
|
|
33914
|
-
}
|
|
33915
|
-
}
|
|
33916
32855
|
function _hypot(args) {
|
|
33917
|
-
const wasmResult = _tryWasmHypot(args);
|
|
33918
|
-
if (wasmResult !== null) return wasmResult;
|
|
33919
32856
|
let result = 0;
|
|
33920
32857
|
let largest = 0;
|
|
33921
32858
|
for (let i = 0; i < args.length; i++) {
|
|
@@ -34244,8 +33181,6 @@ var createDistance = /* @__PURE__ */ factory(
|
|
|
34244
33181
|
return sqrt2(result);
|
|
34245
33182
|
}
|
|
34246
33183
|
function _distancePairwise(a) {
|
|
34247
|
-
const wasmResult = _tryWasmPairwise(a);
|
|
34248
|
-
if (wasmResult !== null) return wasmResult;
|
|
34249
33184
|
const result = [];
|
|
34250
33185
|
let pointA = [];
|
|
34251
33186
|
let pointB = [];
|
|
@@ -34263,37 +33198,6 @@ var createDistance = /* @__PURE__ */ factory(
|
|
|
34263
33198
|
}
|
|
34264
33199
|
return result;
|
|
34265
33200
|
}
|
|
34266
|
-
function _tryWasmPairwise(a) {
|
|
34267
|
-
const wasm = wasmLoader.getModule();
|
|
34268
|
-
if (!wasm) return null;
|
|
34269
|
-
const numPoints = a.length;
|
|
34270
|
-
const dims = a[0].length;
|
|
34271
|
-
for (let i = 0; i < numPoints; i++) {
|
|
34272
|
-
for (let d = 0; d < dims; d++) {
|
|
34273
|
-
if (typeof a[i][d] !== "number") return null;
|
|
34274
|
-
}
|
|
34275
|
-
}
|
|
34276
|
-
const p1Alloc = wasmLoader.allocateFloat64ArrayEmpty(dims);
|
|
34277
|
-
const p2Alloc = wasmLoader.allocateFloat64ArrayEmpty(dims);
|
|
34278
|
-
try {
|
|
34279
|
-
const result = [];
|
|
34280
|
-
for (let i = 0; i < numPoints - 1; i++) {
|
|
34281
|
-
for (let d = 0; d < dims; d++) {
|
|
34282
|
-
p1Alloc.array[d] = a[i][d];
|
|
34283
|
-
}
|
|
34284
|
-
for (let j = i + 1; j < numPoints; j++) {
|
|
34285
|
-
for (let d = 0; d < dims; d++) {
|
|
34286
|
-
p2Alloc.array[d] = a[j][d];
|
|
34287
|
-
}
|
|
34288
|
-
result.push(wasm.distanceND(p1Alloc.ptr, p2Alloc.ptr, dims));
|
|
34289
|
-
}
|
|
34290
|
-
}
|
|
34291
|
-
return result;
|
|
34292
|
-
} finally {
|
|
34293
|
-
wasmLoader.free(p1Alloc.ptr);
|
|
34294
|
-
wasmLoader.free(p2Alloc.ptr);
|
|
34295
|
-
}
|
|
34296
|
-
}
|
|
34297
33201
|
}
|
|
34298
33202
|
);
|
|
34299
33203
|
|
|
@@ -34955,7 +33859,12 @@ var createUtil = /* @__PURE__ */ factory(
|
|
|
34955
33859
|
if (isOperatorNode(node)) {
|
|
34956
33860
|
return function(args) {
|
|
34957
33861
|
try {
|
|
34958
|
-
return new OperatorNode(
|
|
33862
|
+
return new OperatorNode(
|
|
33863
|
+
node.op,
|
|
33864
|
+
node.fn,
|
|
33865
|
+
args,
|
|
33866
|
+
node.implicit
|
|
33867
|
+
);
|
|
34959
33868
|
} catch (err) {
|
|
34960
33869
|
console.error(err);
|
|
34961
33870
|
return [];
|
|
@@ -35172,7 +34081,10 @@ var createSimplifyConstant = /* @__PURE__ */ factory(
|
|
|
35172
34081
|
const remainingDims = Array.from(index.dimensions);
|
|
35173
34082
|
while (remainingDims.length > 0) {
|
|
35174
34083
|
if (isConstantNode(remainingDims[0]) && typeof remainingDims[0].value !== "string") {
|
|
35175
|
-
const first = _toNumber(
|
|
34084
|
+
const first = _toNumber(
|
|
34085
|
+
remainingDims.shift().value,
|
|
34086
|
+
options
|
|
34087
|
+
);
|
|
35176
34088
|
if (isArrayNode(obj)) {
|
|
35177
34089
|
obj = obj.items[first - 1];
|
|
35178
34090
|
} else {
|
|
@@ -35182,7 +34094,10 @@ var createSimplifyConstant = /* @__PURE__ */ factory(
|
|
|
35182
34094
|
}
|
|
35183
34095
|
}
|
|
35184
34096
|
} else if (remainingDims.length > 1 && isConstantNode(remainingDims[1]) && typeof remainingDims[1].value !== "string") {
|
|
35185
|
-
const second = _toNumber(
|
|
34097
|
+
const second = _toNumber(
|
|
34098
|
+
remainingDims[1].value,
|
|
34099
|
+
options
|
|
34100
|
+
);
|
|
35186
34101
|
const tryItems = [];
|
|
35187
34102
|
const fromItems = isArrayNode(obj) ? obj.items : obj.valueOf();
|
|
35188
34103
|
for (const item of fromItems) {
|
|
@@ -35295,7 +34210,10 @@ var createSimplifyConstant = /* @__PURE__ */ factory(
|
|
|
35295
34210
|
}
|
|
35296
34211
|
return matrix2(sz);
|
|
35297
34212
|
}
|
|
35298
|
-
return new FunctionNode(
|
|
34213
|
+
return new FunctionNode(
|
|
34214
|
+
node.name,
|
|
34215
|
+
args.map(_ensureNode)
|
|
34216
|
+
);
|
|
35299
34217
|
}
|
|
35300
34218
|
return _foldOperatorNode(node, options);
|
|
35301
34219
|
}
|
|
@@ -35320,13 +34238,18 @@ var createSimplifyConstant = /* @__PURE__ */ factory(
|
|
|
35320
34238
|
}
|
|
35321
34239
|
case "IndexNode": {
|
|
35322
34240
|
return new IndexNode(
|
|
35323
|
-
node.dimensions.map(
|
|
34241
|
+
node.dimensions.map(
|
|
34242
|
+
(n) => simplifyConstant2(n, options)
|
|
34243
|
+
)
|
|
35324
34244
|
);
|
|
35325
34245
|
}
|
|
35326
34246
|
case "ObjectNode": {
|
|
35327
34247
|
const foldProps = {};
|
|
35328
34248
|
for (const prop in node.properties) {
|
|
35329
|
-
foldProps[prop] = simplifyConstant2(
|
|
34249
|
+
foldProps[prop] = simplifyConstant2(
|
|
34250
|
+
node.properties[prop],
|
|
34251
|
+
options
|
|
34252
|
+
);
|
|
35330
34253
|
}
|
|
35331
34254
|
return new ObjectNode(foldProps);
|
|
35332
34255
|
}
|
|
@@ -35385,7 +34308,9 @@ var createSimplifyConstant = /* @__PURE__ */ factory(
|
|
|
35385
34308
|
res = foldOp(fn, args, makeNode, options);
|
|
35386
34309
|
}
|
|
35387
34310
|
} else {
|
|
35388
|
-
args = node.args.map(
|
|
34311
|
+
args = node.args.map(
|
|
34312
|
+
(arg3) => foldFraction(arg3, options)
|
|
34313
|
+
);
|
|
35389
34314
|
res = foldOp(fn, args, makeNode, options);
|
|
35390
34315
|
}
|
|
35391
34316
|
return res;
|
|
@@ -35801,15 +34726,7 @@ var dependencies199 = [
|
|
|
35801
34726
|
var createDivide = /* @__PURE__ */ factory(
|
|
35802
34727
|
name199,
|
|
35803
34728
|
dependencies199,
|
|
35804
|
-
({
|
|
35805
|
-
typed: typed3,
|
|
35806
|
-
matrix: matrix2,
|
|
35807
|
-
multiply: multiply2,
|
|
35808
|
-
equalScalar: equalScalar3,
|
|
35809
|
-
divideScalar: divideScalar2,
|
|
35810
|
-
pinv: pinv2,
|
|
35811
|
-
nodeOperations: nodeOperations2
|
|
35812
|
-
}) => {
|
|
34729
|
+
({ typed: typed3, matrix: matrix2, multiply: multiply2, equalScalar: equalScalar3, divideScalar: divideScalar2, pinv: pinv2, nodeOperations: nodeOperations2 }) => {
|
|
35813
34730
|
const matAlgo11xS0s = createMatAlgo11xS0s({ typed: typed3, equalScalar: equalScalar3 });
|
|
35814
34731
|
const matAlgo14xDs = createMatAlgo14xDs({ typed: typed3 });
|
|
35815
34732
|
return typed3(
|
|
@@ -36917,11 +35834,14 @@ var createDiff = /* @__PURE__ */ factory(
|
|
|
36917
35834
|
return _recursive(arr10, dim);
|
|
36918
35835
|
}
|
|
36919
35836
|
},
|
|
36920
|
-
|
|
36921
|
-
|
|
36922
|
-
|
|
36923
|
-
|
|
36924
|
-
"Matrix, BigNumber": typed3.referTo(
|
|
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
|
+
)
|
|
36925
35845
|
});
|
|
36926
35846
|
function _recursive(arr10, dim) {
|
|
36927
35847
|
if (isMatrix(arr10)) {
|
|
@@ -36978,7 +35898,6 @@ var createDiff = /* @__PURE__ */ factory(
|
|
|
36978
35898
|
);
|
|
36979
35899
|
|
|
36980
35900
|
// src/matrix/sqrtm.ts
|
|
36981
|
-
var WASM_SQRTM_THRESHOLD = 16;
|
|
36982
35901
|
var name211 = "sqrtm";
|
|
36983
35902
|
var dependencies211 = [
|
|
36984
35903
|
"typed",
|
|
@@ -36999,62 +35918,6 @@ var createSqrtm = /* @__PURE__ */ factory(
|
|
|
36999
35918
|
({ typed: typed3, abs: abs2, add: add5, multiply: multiply2, map: map3, sqrt: sqrt2, subtract: subtract3, inv: inv3, size: size2, max: max2, identity: identity2 }) => {
|
|
37000
35919
|
const _maxIterations = 1e3;
|
|
37001
35920
|
const _tolerance = 1e-6;
|
|
37002
|
-
function _tryWasmSqrtm(A, n) {
|
|
37003
|
-
const wasm = wasmLoader.getModule();
|
|
37004
|
-
if (!wasm || n * n < WASM_SQRTM_THRESHOLD) return null;
|
|
37005
|
-
const data = isMatrix(A) ? A._data : A;
|
|
37006
|
-
if (!data || !Array.isArray(data)) return null;
|
|
37007
|
-
try {
|
|
37008
|
-
const flat = new Float64Array(n * n);
|
|
37009
|
-
for (let i = 0; i < n; i++) {
|
|
37010
|
-
const row2 = data[i];
|
|
37011
|
-
if (!Array.isArray(row2)) return null;
|
|
37012
|
-
for (let j = 0; j < n; j++) {
|
|
37013
|
-
const val = row2[j];
|
|
37014
|
-
if (typeof val !== "number") return null;
|
|
37015
|
-
flat[i * n + j] = val;
|
|
37016
|
-
}
|
|
37017
|
-
}
|
|
37018
|
-
const matrixAlloc = wasmLoader.allocateFloat64Array(flat);
|
|
37019
|
-
const resultAlloc = wasmLoader.allocateFloat64ArrayEmpty(n * n);
|
|
37020
|
-
const workAlloc = wasmLoader.allocateFloat64ArrayEmpty(5 * n * n);
|
|
37021
|
-
try {
|
|
37022
|
-
const status = wasm.sqrtm(
|
|
37023
|
-
matrixAlloc.ptr,
|
|
37024
|
-
n,
|
|
37025
|
-
resultAlloc.ptr,
|
|
37026
|
-
_tolerance,
|
|
37027
|
-
_maxIterations,
|
|
37028
|
-
workAlloc.ptr
|
|
37029
|
-
);
|
|
37030
|
-
if (status > 0) {
|
|
37031
|
-
const result = [];
|
|
37032
|
-
for (let i = 0; i < n; i++) {
|
|
37033
|
-
const row2 = [];
|
|
37034
|
-
for (let j = 0; j < n; j++) {
|
|
37035
|
-
row2[j] = resultAlloc.array[i * n + j];
|
|
37036
|
-
}
|
|
37037
|
-
result[i] = row2;
|
|
37038
|
-
}
|
|
37039
|
-
if (isMatrix(A)) {
|
|
37040
|
-
const matA = A;
|
|
37041
|
-
return matA.createDenseMatrix({
|
|
37042
|
-
data: result,
|
|
37043
|
-
size: [n, n],
|
|
37044
|
-
datatype: matA._datatype
|
|
37045
|
-
});
|
|
37046
|
-
}
|
|
37047
|
-
return result;
|
|
37048
|
-
}
|
|
37049
|
-
} finally {
|
|
37050
|
-
wasmLoader.free(matrixAlloc.ptr);
|
|
37051
|
-
wasmLoader.free(resultAlloc.ptr);
|
|
37052
|
-
wasmLoader.free(workAlloc.ptr);
|
|
37053
|
-
}
|
|
37054
|
-
} catch {
|
|
37055
|
-
}
|
|
37056
|
-
return null;
|
|
37057
|
-
}
|
|
37058
35921
|
function _denmanBeavers(A) {
|
|
37059
35922
|
let error;
|
|
37060
35923
|
let iterations = 0;
|
|
@@ -37087,8 +35950,6 @@ var createSqrtm = /* @__PURE__ */ factory(
|
|
|
37087
35950
|
const rows = sizeArray[0];
|
|
37088
35951
|
const cols = sizeArray[1];
|
|
37089
35952
|
if (rows === cols) {
|
|
37090
|
-
const wasmResult = _tryWasmSqrtm(A, rows);
|
|
37091
|
-
if (wasmResult !== null) return wasmResult;
|
|
37092
35953
|
return _denmanBeavers(A);
|
|
37093
35954
|
} else {
|
|
37094
35955
|
throw new RangeError(
|
|
@@ -37107,27 +35968,6 @@ var createSqrtm = /* @__PURE__ */ factory(
|
|
|
37107
35968
|
);
|
|
37108
35969
|
|
|
37109
35970
|
// src/algebra/decomposition/lup.ts
|
|
37110
|
-
var WASM_LUP_THRESHOLD = 16;
|
|
37111
|
-
function isPlainNumberMatrix7(matrix2) {
|
|
37112
|
-
for (let i = 0; i < matrix2.length; i++) {
|
|
37113
|
-
const row2 = matrix2[i];
|
|
37114
|
-
for (let j = 0; j < row2.length; j++) {
|
|
37115
|
-
if (typeof row2[j] !== "number") {
|
|
37116
|
-
return false;
|
|
37117
|
-
}
|
|
37118
|
-
}
|
|
37119
|
-
}
|
|
37120
|
-
return true;
|
|
37121
|
-
}
|
|
37122
|
-
function flattenToFloat647(matrix2, rows, cols) {
|
|
37123
|
-
const result = new Float64Array(rows * cols);
|
|
37124
|
-
for (let i = 0; i < rows; i++) {
|
|
37125
|
-
for (let j = 0; j < cols; j++) {
|
|
37126
|
-
result[i * cols + j] = matrix2[i][j];
|
|
37127
|
-
}
|
|
37128
|
-
}
|
|
37129
|
-
return result;
|
|
37130
|
-
}
|
|
37131
35971
|
var name212 = "lup";
|
|
37132
35972
|
var dependencies212 = [
|
|
37133
35973
|
"typed",
|
|
@@ -37183,66 +36023,6 @@ var createLup = /* @__PURE__ */ factory(
|
|
|
37183
36023
|
const rows = m._size[0];
|
|
37184
36024
|
const columns = m._size[1];
|
|
37185
36025
|
let n = Math.min(rows, columns);
|
|
37186
|
-
const wasm = wasmLoader.getModule();
|
|
37187
|
-
if (wasm && rows === columns && rows * rows >= WASM_LUP_THRESHOLD && isPlainNumberMatrix7(m._data)) {
|
|
37188
|
-
try {
|
|
37189
|
-
const flat = flattenToFloat647(m._data, rows, columns);
|
|
37190
|
-
const aAlloc = wasmLoader.allocateFloat64Array(flat);
|
|
37191
|
-
const permAlloc = wasmLoader.allocateInt32ArrayEmpty(rows);
|
|
37192
|
-
try {
|
|
37193
|
-
const result = wasm.luDecomposition(aAlloc.ptr, rows, permAlloc.ptr);
|
|
37194
|
-
if (result !== 0) {
|
|
37195
|
-
throw new Error("Matrix is singular and cannot be decomposed");
|
|
37196
|
-
}
|
|
37197
|
-
const ldata2 = [];
|
|
37198
|
-
const udata2 = [];
|
|
37199
|
-
for (let i2 = 0; i2 < rows; i2++) {
|
|
37200
|
-
ldata2[i2] = [];
|
|
37201
|
-
udata2[i2] = [];
|
|
37202
|
-
for (let j2 = 0; j2 < columns; j2++) {
|
|
37203
|
-
const val = aAlloc.array[i2 * columns + j2];
|
|
37204
|
-
if (i2 > j2) {
|
|
37205
|
-
ldata2[i2][j2] = val;
|
|
37206
|
-
udata2[i2][j2] = 0;
|
|
37207
|
-
} else if (i2 === j2) {
|
|
37208
|
-
ldata2[i2][j2] = 1;
|
|
37209
|
-
udata2[i2][j2] = val;
|
|
37210
|
-
} else {
|
|
37211
|
-
ldata2[i2][j2] = 0;
|
|
37212
|
-
udata2[i2][j2] = val;
|
|
37213
|
-
}
|
|
37214
|
-
}
|
|
37215
|
-
}
|
|
37216
|
-
const p2 = [];
|
|
37217
|
-
for (let i2 = 0; i2 < rows; i2++) {
|
|
37218
|
-
p2[i2] = permAlloc.array[i2];
|
|
37219
|
-
}
|
|
37220
|
-
const l2 = new DenseMatrix7({
|
|
37221
|
-
data: ldata2,
|
|
37222
|
-
size: [rows, n]
|
|
37223
|
-
});
|
|
37224
|
-
const u2 = new DenseMatrix7({
|
|
37225
|
-
data: udata2,
|
|
37226
|
-
size: [n, columns]
|
|
37227
|
-
});
|
|
37228
|
-
return {
|
|
37229
|
-
L: l2,
|
|
37230
|
-
U: u2,
|
|
37231
|
-
p: p2,
|
|
37232
|
-
toString: function() {
|
|
37233
|
-
return "L: " + this.L.toString() + "\nU: " + this.U.toString() + "\nP: " + this.p;
|
|
37234
|
-
}
|
|
37235
|
-
};
|
|
37236
|
-
} finally {
|
|
37237
|
-
wasmLoader.free(aAlloc.ptr);
|
|
37238
|
-
wasmLoader.free(permAlloc.ptr);
|
|
37239
|
-
}
|
|
37240
|
-
} catch (e) {
|
|
37241
|
-
if (e instanceof Error && e.message.includes("singular")) {
|
|
37242
|
-
throw e;
|
|
37243
|
-
}
|
|
37244
|
-
}
|
|
37245
|
-
}
|
|
37246
36026
|
const data = clone(m._data);
|
|
37247
36027
|
const ldata = [];
|
|
37248
36028
|
const lsize = [rows, n];
|
|
@@ -38126,8 +36906,6 @@ var createIntersect = /* @__PURE__ */ factory(
|
|
|
38126
36906
|
return x.length === 4 && isNumeric2(x[0]) && isNumeric2(x[1]) && isNumeric2(x[2]) && isNumeric2(x[3]);
|
|
38127
36907
|
}
|
|
38128
36908
|
function _intersect2d(p1a, p1b, p2a, p2b) {
|
|
38129
|
-
const wasmResult = _tryWasmIntersect2d(p1a, p1b, p2a, p2b);
|
|
38130
|
-
if (wasmResult !== void 0) return wasmResult;
|
|
38131
36909
|
const o1 = p1a;
|
|
38132
36910
|
const o2 = p2a;
|
|
38133
36911
|
const d1 = subtract3(o1, p1b);
|
|
@@ -38153,34 +36931,6 @@ var createIntersect = /* @__PURE__ */ factory(
|
|
|
38153
36931
|
);
|
|
38154
36932
|
return add5(multiply2(d1, t), o1);
|
|
38155
36933
|
}
|
|
38156
|
-
function _tryWasmIntersect2d(p1a, p1b, p2a, p2b) {
|
|
38157
|
-
const wasm = wasmLoader.getModule();
|
|
38158
|
-
if (!wasm) return void 0;
|
|
38159
|
-
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") {
|
|
38160
|
-
return void 0;
|
|
38161
|
-
}
|
|
38162
|
-
const resultAlloc = wasmLoader.allocateFloat64ArrayEmpty(3);
|
|
38163
|
-
try {
|
|
38164
|
-
wasm.intersect2DInfiniteLines(
|
|
38165
|
-
p1a[0],
|
|
38166
|
-
p1a[1],
|
|
38167
|
-
p1b[0],
|
|
38168
|
-
p1b[1],
|
|
38169
|
-
p2a[0],
|
|
38170
|
-
p2a[1],
|
|
38171
|
-
p2b[0],
|
|
38172
|
-
p2b[1],
|
|
38173
|
-
resultAlloc.ptr
|
|
38174
|
-
);
|
|
38175
|
-
const exists = resultAlloc.array[2];
|
|
38176
|
-
if (exists === 0) {
|
|
38177
|
-
return null;
|
|
38178
|
-
}
|
|
38179
|
-
return [resultAlloc.array[0], resultAlloc.array[1]];
|
|
38180
|
-
} finally {
|
|
38181
|
-
wasmLoader.free(resultAlloc.ptr);
|
|
38182
|
-
}
|
|
38183
|
-
}
|
|
38184
36934
|
function _intersect3dHelper(a, b, c, d, e, f, g, h, i, j, k, l) {
|
|
38185
36935
|
const add1 = multiplyScalar2(
|
|
38186
36936
|
subtract3(a, b),
|
|
@@ -38262,15 +37012,6 @@ var createIntersect = /* @__PURE__ */ factory(
|
|
|
38262
37012
|
);
|
|
38263
37013
|
|
|
38264
37014
|
// src/statistics/mean.ts
|
|
38265
|
-
var WASM_MEAN_THRESHOLD = 100;
|
|
38266
|
-
function isFlatNumberArray7(arr10) {
|
|
38267
|
-
for (let i = 0; i < arr10.length; i++) {
|
|
38268
|
-
if (typeof arr10[i] !== "number") {
|
|
38269
|
-
return false;
|
|
38270
|
-
}
|
|
38271
|
-
}
|
|
38272
|
-
return true;
|
|
38273
|
-
}
|
|
38274
37015
|
var name219 = "mean";
|
|
38275
37016
|
var dependencies219 = ["typed", "add", "divide"];
|
|
38276
37017
|
var createMean = /* @__PURE__ */ factory(
|
|
@@ -38301,22 +37042,6 @@ var createMean = /* @__PURE__ */ factory(
|
|
|
38301
37042
|
}
|
|
38302
37043
|
}
|
|
38303
37044
|
function _mean2(array) {
|
|
38304
|
-
if (Array.isArray(array) && array.length >= WASM_MEAN_THRESHOLD) {
|
|
38305
|
-
if (isFlatNumberArray7(array)) {
|
|
38306
|
-
const wasm = wasmLoader.getModule();
|
|
38307
|
-
if (wasm) {
|
|
38308
|
-
try {
|
|
38309
|
-
const alloc = wasmLoader.allocateFloat64Array(array);
|
|
38310
|
-
try {
|
|
38311
|
-
return wasm.statsMean(alloc.ptr, array.length);
|
|
38312
|
-
} finally {
|
|
38313
|
-
wasmLoader.free(alloc.ptr);
|
|
38314
|
-
}
|
|
38315
|
-
} catch {
|
|
38316
|
-
}
|
|
38317
|
-
}
|
|
38318
|
-
}
|
|
38319
|
-
}
|
|
38320
37045
|
let sum3;
|
|
38321
37046
|
let num2 = 0;
|
|
38322
37047
|
deepForEach(array, function(value) {
|
|
@@ -38401,7 +37126,7 @@ var createMedian = /* @__PURE__ */ factory(
|
|
|
38401
37126
|
|
|
38402
37127
|
// src/statistics/variance.ts
|
|
38403
37128
|
import { sumSquaredDeviations as sumSquaredDeviations2 } from "@danielsimonjr/mathts-core";
|
|
38404
|
-
function
|
|
37129
|
+
function isFlatNumberArray3(arr10) {
|
|
38405
37130
|
for (let i = 0; i < arr10.length; i++) {
|
|
38406
37131
|
if (typeof arr10[i] !== "number") {
|
|
38407
37132
|
return false;
|
|
@@ -38446,7 +37171,7 @@ var createVariance = /* @__PURE__ */ factory(
|
|
|
38446
37171
|
if (array.length === 0) {
|
|
38447
37172
|
throw new SyntaxError("Function variance requires one or more parameters (0 provided)");
|
|
38448
37173
|
}
|
|
38449
|
-
if (Array.isArray(array) &&
|
|
37174
|
+
if (Array.isArray(array) && isFlatNumberArray3(array)) {
|
|
38450
37175
|
const nn = array.length;
|
|
38451
37176
|
const ssd = sumSquaredDeviations2(array);
|
|
38452
37177
|
switch (normalization) {
|
|
@@ -38774,12 +37499,13 @@ var createMultinomial = /* @__PURE__ */ factory(
|
|
|
38774
37499
|
);
|
|
38775
37500
|
|
|
38776
37501
|
// src/signal/freqz.ts
|
|
38777
|
-
var WASM_FREQZ_THRESHOLD = 32;
|
|
38778
37502
|
var name225 = "freqz";
|
|
38779
37503
|
var dependencies225 = ["typed", "add", "multiply", "Complex", "divide", "matrix"];
|
|
38780
37504
|
var createFreqz = /* @__PURE__ */ factory(
|
|
38781
37505
|
name225,
|
|
38782
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.
|
|
38783
37509
|
({ typed: typed3, add: add5, multiply: multiply2, Complex: Complex13, divide: divide2, matrix: matrix2 }) => {
|
|
38784
37510
|
return typed3(name225, {
|
|
38785
37511
|
"Array, Array": function(b, a) {
|
|
@@ -38827,47 +37553,7 @@ var createFreqz = /* @__PURE__ */ factory(
|
|
|
38827
37553
|
};
|
|
38828
37554
|
}
|
|
38829
37555
|
});
|
|
38830
|
-
function _tryWasmFreqz(b, a, w) {
|
|
38831
|
-
const wasm = wasmLoader.getModule();
|
|
38832
|
-
if (!wasm || w.length < WASM_FREQZ_THRESHOLD) return null;
|
|
38833
|
-
try {
|
|
38834
|
-
const bAlloc = wasmLoader.allocateFloat64Array(b);
|
|
38835
|
-
const aAlloc = wasmLoader.allocateFloat64Array(a);
|
|
38836
|
-
const wAlloc = wasmLoader.allocateFloat64Array(w);
|
|
38837
|
-
const hRealAlloc = wasmLoader.allocateFloat64ArrayEmpty(w.length);
|
|
38838
|
-
const hImagAlloc = wasmLoader.allocateFloat64ArrayEmpty(w.length);
|
|
38839
|
-
try {
|
|
38840
|
-
wasm.freqz(
|
|
38841
|
-
bAlloc.ptr,
|
|
38842
|
-
b.length,
|
|
38843
|
-
aAlloc.ptr,
|
|
38844
|
-
a.length,
|
|
38845
|
-
wAlloc.ptr,
|
|
38846
|
-
w.length,
|
|
38847
|
-
hRealAlloc.ptr,
|
|
38848
|
-
hImagAlloc.ptr
|
|
38849
|
-
);
|
|
38850
|
-
const h = [];
|
|
38851
|
-
for (let i = 0; i < w.length; i++) {
|
|
38852
|
-
h.push(Complex13(hRealAlloc.array[i], hImagAlloc.array[i]));
|
|
38853
|
-
}
|
|
38854
|
-
return { h, w };
|
|
38855
|
-
} finally {
|
|
38856
|
-
wasmLoader.free(bAlloc.ptr);
|
|
38857
|
-
wasmLoader.free(aAlloc.ptr);
|
|
38858
|
-
wasmLoader.free(wAlloc.ptr);
|
|
38859
|
-
wasmLoader.free(hRealAlloc.ptr);
|
|
38860
|
-
wasmLoader.free(hImagAlloc.ptr);
|
|
38861
|
-
}
|
|
38862
|
-
} catch {
|
|
38863
|
-
}
|
|
38864
|
-
return null;
|
|
38865
|
-
}
|
|
38866
37556
|
function _freqz(b, a, w) {
|
|
38867
|
-
const wasmResult = _tryWasmFreqz(b, a, w);
|
|
38868
|
-
if (wasmResult !== null) {
|
|
38869
|
-
return wasmResult;
|
|
38870
|
-
}
|
|
38871
37557
|
const num2 = [];
|
|
38872
37558
|
const den = [];
|
|
38873
37559
|
for (let i = 0; i < w.length; i++) {
|
|
@@ -39979,16 +38665,6 @@ var createIndex = /* @__PURE__ */ factory(
|
|
|
39979
38665
|
);
|
|
39980
38666
|
|
|
39981
38667
|
// src/matrix/eigs/complexEigs.ts
|
|
39982
|
-
var WASM_EIGS_THRESHOLD = 16;
|
|
39983
|
-
function flattenToFloat648(matrix2, rows, cols) {
|
|
39984
|
-
const result = new Float64Array(rows * cols);
|
|
39985
|
-
for (let i = 0; i < rows; i++) {
|
|
39986
|
-
for (let j = 0; j < cols; j++) {
|
|
39987
|
-
result[i * cols + j] = matrix2[i][j];
|
|
39988
|
-
}
|
|
39989
|
-
}
|
|
39990
|
-
return result;
|
|
39991
|
-
}
|
|
39992
38668
|
function createComplexEigs({
|
|
39993
38669
|
addScalar: addScalar2,
|
|
39994
38670
|
subtract: subtract3,
|
|
@@ -40014,54 +38690,6 @@ function createComplexEigs({
|
|
|
40014
38690
|
dot: dot9
|
|
40015
38691
|
}) {
|
|
40016
38692
|
function complexEigs(arr10, N2, prec, type, findVectors = true) {
|
|
40017
|
-
if (!findVectors && type === "number" && N2 * N2 >= WASM_EIGS_THRESHOLD) {
|
|
40018
|
-
const wasm = wasmLoader.getModule();
|
|
40019
|
-
if (wasm) {
|
|
40020
|
-
try {
|
|
40021
|
-
const flat = flattenToFloat648(arr10, N2, N2);
|
|
40022
|
-
const matrixAlloc = wasmLoader.allocateFloat64Array(flat);
|
|
40023
|
-
const eigenvaluesRealAlloc = wasmLoader.allocateFloat64ArrayEmpty(N2);
|
|
40024
|
-
const eigenvaluesImagAlloc = wasmLoader.allocateFloat64ArrayEmpty(N2);
|
|
40025
|
-
const workAlloc = wasmLoader.allocateFloat64ArrayEmpty(N2 * N2);
|
|
40026
|
-
try {
|
|
40027
|
-
const iterations = wasm.qrAlgorithm(
|
|
40028
|
-
matrixAlloc.ptr,
|
|
40029
|
-
N2,
|
|
40030
|
-
eigenvaluesRealAlloc.ptr,
|
|
40031
|
-
eigenvaluesImagAlloc.ptr,
|
|
40032
|
-
workAlloc.ptr,
|
|
40033
|
-
1e3,
|
|
40034
|
-
// maxIterations
|
|
40035
|
-
typeof prec === "number" ? prec : 1e-12
|
|
40036
|
-
);
|
|
40037
|
-
if (iterations >= 0) {
|
|
40038
|
-
const values2 = [];
|
|
40039
|
-
for (let i = 0; i < N2; i++) {
|
|
40040
|
-
const re3 = eigenvaluesRealAlloc.array[i];
|
|
40041
|
-
const im3 = eigenvaluesImagAlloc.array[i];
|
|
40042
|
-
if (Math.abs(im3) < 1e-14) {
|
|
40043
|
-
values2.push(re3);
|
|
40044
|
-
} else {
|
|
40045
|
-
values2.push(complex3(re3, im3));
|
|
40046
|
-
}
|
|
40047
|
-
}
|
|
40048
|
-
values2.sort((a, b) => {
|
|
40049
|
-
const absA = typeof a === "number" ? Math.abs(a) : Math.sqrt(a.re ** 2 + a.im ** 2);
|
|
40050
|
-
const absB = typeof b === "number" ? Math.abs(b) : Math.sqrt(b.re ** 2 + b.im ** 2);
|
|
40051
|
-
return absA - absB;
|
|
40052
|
-
});
|
|
40053
|
-
return { values: values2 };
|
|
40054
|
-
}
|
|
40055
|
-
} finally {
|
|
40056
|
-
wasmLoader.free(matrixAlloc.ptr);
|
|
40057
|
-
wasmLoader.free(eigenvaluesRealAlloc.ptr);
|
|
40058
|
-
wasmLoader.free(eigenvaluesImagAlloc.ptr);
|
|
40059
|
-
wasmLoader.free(workAlloc.ptr);
|
|
40060
|
-
}
|
|
40061
|
-
} catch {
|
|
40062
|
-
}
|
|
40063
|
-
}
|
|
40064
|
-
}
|
|
40065
38693
|
const R = balance(arr10, N2, prec, type, findVectors);
|
|
40066
38694
|
reduceToHessenberg(arr10, N2, prec, type, findVectors, R);
|
|
40067
38695
|
const { values, C } = iterateUntilTriangular(arr10, N2, prec, type, findVectors);
|
|
@@ -40472,16 +39100,6 @@ function createComplexEigs({
|
|
|
40472
39100
|
}
|
|
40473
39101
|
|
|
40474
39102
|
// src/matrix/eigs/realSymmetric.ts
|
|
40475
|
-
var WASM_EIGS_THRESHOLD2 = 16;
|
|
40476
|
-
function flattenToFloat649(matrix2, rows, cols) {
|
|
40477
|
-
const result = new Float64Array(rows * cols);
|
|
40478
|
-
for (let i = 0; i < rows; i++) {
|
|
40479
|
-
for (let j = 0; j < cols; j++) {
|
|
40480
|
-
result[i * cols + j] = matrix2[i][j];
|
|
40481
|
-
}
|
|
40482
|
-
}
|
|
40483
|
-
return result;
|
|
40484
|
-
}
|
|
40485
39103
|
function createRealSymmetric({
|
|
40486
39104
|
config: config2,
|
|
40487
39105
|
addScalar: addScalar2,
|
|
@@ -40519,62 +39137,6 @@ function createRealSymmetric({
|
|
|
40519
39137
|
}
|
|
40520
39138
|
function diag2(x, precision, computeVectors) {
|
|
40521
39139
|
const N2 = x.length;
|
|
40522
|
-
const wasm = wasmLoader.getModule();
|
|
40523
|
-
if (wasm && N2 * N2 >= WASM_EIGS_THRESHOLD2) {
|
|
40524
|
-
try {
|
|
40525
|
-
const flat = flattenToFloat649(x, N2, N2);
|
|
40526
|
-
const matrixAlloc = wasmLoader.allocateFloat64Array(flat);
|
|
40527
|
-
const eigenvaluesAlloc = wasmLoader.allocateFloat64ArrayEmpty(N2);
|
|
40528
|
-
const eigenvectorsAlloc = computeVectors ? wasmLoader.allocateFloat64ArrayEmpty(N2 * N2) : { ptr: 0, array: new Float64Array(0) };
|
|
40529
|
-
const workAlloc = wasmLoader.allocateFloat64ArrayEmpty(N2 * N2);
|
|
40530
|
-
try {
|
|
40531
|
-
const iterations = wasm.eigsSymmetric(
|
|
40532
|
-
matrixAlloc.ptr,
|
|
40533
|
-
N2,
|
|
40534
|
-
eigenvaluesAlloc.ptr,
|
|
40535
|
-
eigenvectorsAlloc.ptr,
|
|
40536
|
-
workAlloc.ptr,
|
|
40537
|
-
1e3,
|
|
40538
|
-
// maxIterations
|
|
40539
|
-
precision
|
|
40540
|
-
);
|
|
40541
|
-
if (iterations >= 0) {
|
|
40542
|
-
const values = Array(N2);
|
|
40543
|
-
for (let i = 0; i < N2; i++) {
|
|
40544
|
-
values[i] = eigenvaluesAlloc.array[i];
|
|
40545
|
-
}
|
|
40546
|
-
if (!computeVectors) {
|
|
40547
|
-
const sortedValues = values.map((v, i) => ({ v, i })).sort((a, b) => Math.abs(a.v) - Math.abs(b.v)).map((x2) => x2.v);
|
|
40548
|
-
return { values: sortedValues };
|
|
40549
|
-
}
|
|
40550
|
-
const eigenvectors = [];
|
|
40551
|
-
const sortedIndices = values.map((v, i) => ({ v, i })).sort((a, b) => Math.abs(a.v) - Math.abs(b.v)).map((x2) => x2.i);
|
|
40552
|
-
for (const origIdx of sortedIndices) {
|
|
40553
|
-
const vector = Array(N2);
|
|
40554
|
-
for (let i = 0; i < N2; i++) {
|
|
40555
|
-
vector[i] = eigenvectorsAlloc.array[i * N2 + origIdx];
|
|
40556
|
-
}
|
|
40557
|
-
eigenvectors.push({
|
|
40558
|
-
value: values[origIdx],
|
|
40559
|
-
vector
|
|
40560
|
-
});
|
|
40561
|
-
}
|
|
40562
|
-
return {
|
|
40563
|
-
values: sortedIndices.map((i) => values[i]),
|
|
40564
|
-
eigenvectors
|
|
40565
|
-
};
|
|
40566
|
-
}
|
|
40567
|
-
} finally {
|
|
40568
|
-
wasmLoader.free(matrixAlloc.ptr);
|
|
40569
|
-
wasmLoader.free(eigenvaluesAlloc.ptr);
|
|
40570
|
-
if (computeVectors) {
|
|
40571
|
-
wasmLoader.free(eigenvectorsAlloc.ptr);
|
|
40572
|
-
}
|
|
40573
|
-
wasmLoader.free(workAlloc.ptr);
|
|
40574
|
-
}
|
|
40575
|
-
} catch {
|
|
40576
|
-
}
|
|
40577
|
-
}
|
|
40578
39140
|
const e0 = Math.abs(precision / N2);
|
|
40579
39141
|
let psi;
|
|
40580
39142
|
let Sij;
|
|
@@ -41097,42 +39659,6 @@ function csIpvec(p, b) {
|
|
|
41097
39659
|
}
|
|
41098
39660
|
|
|
41099
39661
|
// src/algebra/solver/lusolve.ts
|
|
41100
|
-
var WASM_LUSOLVE_THRESHOLD = 16;
|
|
41101
|
-
function isPlainNumberMatrix8(matrix2) {
|
|
41102
|
-
for (let i = 0; i < matrix2.length; i++) {
|
|
41103
|
-
const row2 = matrix2[i];
|
|
41104
|
-
for (let j = 0; j < row2.length; j++) {
|
|
41105
|
-
if (typeof row2[j] !== "number") {
|
|
41106
|
-
return false;
|
|
41107
|
-
}
|
|
41108
|
-
}
|
|
41109
|
-
}
|
|
41110
|
-
return true;
|
|
41111
|
-
}
|
|
41112
|
-
function isPlainNumberVector3(vec) {
|
|
41113
|
-
for (let i = 0; i < vec.length; i++) {
|
|
41114
|
-
if (typeof vec[i][0] !== "number") {
|
|
41115
|
-
return false;
|
|
41116
|
-
}
|
|
41117
|
-
}
|
|
41118
|
-
return true;
|
|
41119
|
-
}
|
|
41120
|
-
function flattenToFloat6410(matrix2, rows, cols) {
|
|
41121
|
-
const result = new Float64Array(rows * cols);
|
|
41122
|
-
for (let i = 0; i < rows; i++) {
|
|
41123
|
-
for (let j = 0; j < cols; j++) {
|
|
41124
|
-
result[i * cols + j] = matrix2[i][j];
|
|
41125
|
-
}
|
|
41126
|
-
}
|
|
41127
|
-
return result;
|
|
41128
|
-
}
|
|
41129
|
-
function vectorToFloat643(vec) {
|
|
41130
|
-
const result = new Float64Array(vec.length);
|
|
41131
|
-
for (let i = 0; i < vec.length; i++) {
|
|
41132
|
-
result[i] = vec[i][0];
|
|
41133
|
-
}
|
|
41134
|
-
return result;
|
|
41135
|
-
}
|
|
41136
39662
|
var name238 = "lusolve";
|
|
41137
39663
|
var dependencies238 = ["typed", "matrix", "lup", "slu", "usolve", "lsolve", "DenseMatrix"];
|
|
41138
39664
|
var createLusolve = /* @__PURE__ */ factory(
|
|
@@ -41144,102 +39670,12 @@ var createLusolve = /* @__PURE__ */ factory(
|
|
|
41144
39670
|
});
|
|
41145
39671
|
return typed3(name238, {
|
|
41146
39672
|
"Array, Array | Matrix": function(a, b) {
|
|
41147
|
-
const rows = a.length;
|
|
41148
|
-
const columns = a[0]?.length || 0;
|
|
41149
|
-
const wasm = wasmLoader.getModule();
|
|
41150
|
-
if (wasm && rows === columns && rows * rows >= WASM_LUSOLVE_THRESHOLD && isPlainNumberMatrix8(a)) {
|
|
41151
|
-
const aMatrix2 = matrix2(a);
|
|
41152
|
-
const bMatrix = solveValidation(aMatrix2, b, true);
|
|
41153
|
-
const bdata = bMatrix._data;
|
|
41154
|
-
if (isPlainNumberVector3(bdata) && bdata.length === rows) {
|
|
41155
|
-
try {
|
|
41156
|
-
const aFlat = flattenToFloat6410(a, rows, columns);
|
|
41157
|
-
const bFlat = vectorToFloat643(bdata);
|
|
41158
|
-
const aAlloc = wasmLoader.allocateFloat64Array(aFlat);
|
|
41159
|
-
const bAlloc = wasmLoader.allocateFloat64Array(bFlat);
|
|
41160
|
-
const resultAlloc = wasmLoader.allocateFloat64ArrayEmpty(rows);
|
|
41161
|
-
const workAlloc = wasmLoader.allocateFloat64ArrayEmpty(rows * rows);
|
|
41162
|
-
try {
|
|
41163
|
-
const success = wasm.laSolve(
|
|
41164
|
-
aAlloc.ptr,
|
|
41165
|
-
bAlloc.ptr,
|
|
41166
|
-
rows,
|
|
41167
|
-
resultAlloc.ptr,
|
|
41168
|
-
workAlloc.ptr
|
|
41169
|
-
);
|
|
41170
|
-
if (success === 0) {
|
|
41171
|
-
throw new Error("Linear system cannot be solved since matrix is singular");
|
|
41172
|
-
}
|
|
41173
|
-
const x2 = [];
|
|
41174
|
-
for (let i = 0; i < rows; i++) {
|
|
41175
|
-
x2[i] = [resultAlloc.array[i]];
|
|
41176
|
-
}
|
|
41177
|
-
return x2;
|
|
41178
|
-
} finally {
|
|
41179
|
-
wasmLoader.free(aAlloc.ptr);
|
|
41180
|
-
wasmLoader.free(bAlloc.ptr);
|
|
41181
|
-
wasmLoader.free(resultAlloc.ptr);
|
|
41182
|
-
wasmLoader.free(workAlloc.ptr);
|
|
41183
|
-
}
|
|
41184
|
-
} catch (e) {
|
|
41185
|
-
if (e instanceof Error && e.message.includes("singular")) {
|
|
41186
|
-
throw e;
|
|
41187
|
-
}
|
|
41188
|
-
}
|
|
41189
|
-
}
|
|
41190
|
-
}
|
|
41191
39673
|
const aMatrix = matrix2(a);
|
|
41192
39674
|
const d = lup2(aMatrix);
|
|
41193
39675
|
const x = _lusolve(d.L, d.U, d.p, null, b);
|
|
41194
39676
|
return x.valueOf();
|
|
41195
39677
|
},
|
|
41196
39678
|
"DenseMatrix, Array | Matrix": function(a, b) {
|
|
41197
|
-
const rows = a._size[0];
|
|
41198
|
-
const columns = a._size[1];
|
|
41199
|
-
const wasm = wasmLoader.getModule();
|
|
41200
|
-
if (wasm && rows === columns && rows * rows >= WASM_LUSOLVE_THRESHOLD && isPlainNumberMatrix8(a._data)) {
|
|
41201
|
-
const bMatrix = solveValidation(a, b, true);
|
|
41202
|
-
const bdata = bMatrix._data;
|
|
41203
|
-
if (isPlainNumberVector3(bdata) && bdata.length === rows) {
|
|
41204
|
-
try {
|
|
41205
|
-
const aFlat = flattenToFloat6410(a._data, rows, columns);
|
|
41206
|
-
const bFlat = vectorToFloat643(bdata);
|
|
41207
|
-
const aAlloc = wasmLoader.allocateFloat64Array(aFlat);
|
|
41208
|
-
const bAlloc = wasmLoader.allocateFloat64Array(bFlat);
|
|
41209
|
-
const resultAlloc = wasmLoader.allocateFloat64ArrayEmpty(rows);
|
|
41210
|
-
const workAlloc = wasmLoader.allocateFloat64ArrayEmpty(rows * rows);
|
|
41211
|
-
try {
|
|
41212
|
-
const success = wasm.laSolve(
|
|
41213
|
-
aAlloc.ptr,
|
|
41214
|
-
bAlloc.ptr,
|
|
41215
|
-
rows,
|
|
41216
|
-
resultAlloc.ptr,
|
|
41217
|
-
workAlloc.ptr
|
|
41218
|
-
);
|
|
41219
|
-
if (success === 0) {
|
|
41220
|
-
throw new Error("Linear system cannot be solved since matrix is singular");
|
|
41221
|
-
}
|
|
41222
|
-
const x = [];
|
|
41223
|
-
for (let i = 0; i < rows; i++) {
|
|
41224
|
-
x[i] = [resultAlloc.array[i]];
|
|
41225
|
-
}
|
|
41226
|
-
return new DenseMatrix7({
|
|
41227
|
-
data: x,
|
|
41228
|
-
size: [rows, 1]
|
|
41229
|
-
});
|
|
41230
|
-
} finally {
|
|
41231
|
-
wasmLoader.free(aAlloc.ptr);
|
|
41232
|
-
wasmLoader.free(bAlloc.ptr);
|
|
41233
|
-
wasmLoader.free(resultAlloc.ptr);
|
|
41234
|
-
wasmLoader.free(workAlloc.ptr);
|
|
41235
|
-
}
|
|
41236
|
-
} catch (e) {
|
|
41237
|
-
if (e instanceof Error && e.message.includes("singular")) {
|
|
41238
|
-
throw e;
|
|
41239
|
-
}
|
|
41240
|
-
}
|
|
41241
|
-
}
|
|
41242
|
-
}
|
|
41243
39679
|
const d = lup2(a);
|
|
41244
39680
|
return _lusolve(d.L, d.U, d.p, null, b);
|
|
41245
39681
|
},
|
|
@@ -41362,15 +39798,6 @@ var createCorr = /* @__PURE__ */ factory(
|
|
|
41362
39798
|
);
|
|
41363
39799
|
|
|
41364
39800
|
// src/statistics/mad.ts
|
|
41365
|
-
var WASM_MAD_THRESHOLD = 500;
|
|
41366
|
-
function isPlainNumberArray2(arr10) {
|
|
41367
|
-
for (let i = 0; i < arr10.length; i++) {
|
|
41368
|
-
if (typeof arr10[i] !== "number") {
|
|
41369
|
-
return false;
|
|
41370
|
-
}
|
|
41371
|
-
}
|
|
41372
|
-
return true;
|
|
41373
|
-
}
|
|
41374
39801
|
var name240 = "mad";
|
|
41375
39802
|
var dependencies240 = ["typed", "abs", "map", "median", "subtract"];
|
|
41376
39803
|
var createMad = /* @__PURE__ */ factory(
|
|
@@ -41390,19 +39817,6 @@ var createMad = /* @__PURE__ */ factory(
|
|
|
41390
39817
|
if (flat.length === 0) {
|
|
41391
39818
|
throw new Error("Cannot calculate median absolute deviation (mad) of an empty array");
|
|
41392
39819
|
}
|
|
41393
|
-
const wasm = wasmLoader.getModule();
|
|
41394
|
-
if (wasm && flat.length >= WASM_MAD_THRESHOLD && isPlainNumberArray2(flat)) {
|
|
41395
|
-
try {
|
|
41396
|
-
const aAlloc = wasmLoader.allocateFloat64Array(flat);
|
|
41397
|
-
try {
|
|
41398
|
-
const result = wasm.statsMad(aAlloc.ptr, flat.length);
|
|
41399
|
-
return result;
|
|
41400
|
-
} finally {
|
|
41401
|
-
wasmLoader.free(aAlloc.ptr);
|
|
41402
|
-
}
|
|
41403
|
-
} catch {
|
|
41404
|
-
}
|
|
41405
|
-
}
|
|
41406
39820
|
try {
|
|
41407
39821
|
const med = median2(flat);
|
|
41408
39822
|
return median2(
|
|
@@ -42905,7 +41319,6 @@ var createDerivative = /* @__PURE__ */ factory(
|
|
|
42905
41319
|
|
|
42906
41320
|
// src/arithmetic/norm.ts
|
|
42907
41321
|
import { norm2 as norm23 } from "@danielsimonjr/mathts-core";
|
|
42908
|
-
var WASM_NORM_THRESHOLD = 100;
|
|
42909
41322
|
var name245 = "norm";
|
|
42910
41323
|
var dependencies245 = [
|
|
42911
41324
|
"typed",
|
|
@@ -42964,39 +41377,6 @@ var createNorm = /* @__PURE__ */ factory(
|
|
|
42964
41377
|
return _norm(x, p);
|
|
42965
41378
|
}
|
|
42966
41379
|
});
|
|
42967
|
-
function _tryWasmVectorNorm(x, p) {
|
|
42968
|
-
const size2 = x.size();
|
|
42969
|
-
if (size2.length !== 1 || size2[0] < WASM_NORM_THRESHOLD) return null;
|
|
42970
|
-
const wasm = wasmLoader.getModule();
|
|
42971
|
-
if (!wasm) return null;
|
|
42972
|
-
const arr10 = x.toArray();
|
|
42973
|
-
const n = arr10.length;
|
|
42974
|
-
const data = new Float64Array(n);
|
|
42975
|
-
for (let i = 0; i < n; i++) {
|
|
42976
|
-
if (typeof arr10[i] !== "number") return null;
|
|
42977
|
-
data[i] = arr10[i];
|
|
42978
|
-
}
|
|
42979
|
-
const alloc = wasmLoader.allocateFloat64Array(data);
|
|
42980
|
-
try {
|
|
42981
|
-
if (p === 1) {
|
|
42982
|
-
return wasm.norm1(alloc.ptr, n);
|
|
42983
|
-
}
|
|
42984
|
-
if (p === 2) {
|
|
42985
|
-
return wasm.norm2(alloc.ptr, n);
|
|
42986
|
-
}
|
|
42987
|
-
if (p === Number.POSITIVE_INFINITY || p === "inf") {
|
|
42988
|
-
return wasm.normInf(alloc.ptr, n);
|
|
42989
|
-
}
|
|
42990
|
-
if (typeof p === "number" && !isNaN(p) && p !== 0) {
|
|
42991
|
-
return wasm.normP(alloc.ptr, n, p);
|
|
42992
|
-
}
|
|
42993
|
-
return null;
|
|
42994
|
-
} catch {
|
|
42995
|
-
return null;
|
|
42996
|
-
} finally {
|
|
42997
|
-
wasmLoader.free(alloc.ptr);
|
|
42998
|
-
}
|
|
42999
|
-
}
|
|
43000
41380
|
function _vectorNormPlusInfinity(x) {
|
|
43001
41381
|
let pinf = 0;
|
|
43002
41382
|
x.forEach(function(value) {
|
|
@@ -43018,8 +41398,6 @@ var createNorm = /* @__PURE__ */ factory(
|
|
|
43018
41398
|
return ninf || 0;
|
|
43019
41399
|
}
|
|
43020
41400
|
function _vectorNorm(x, p) {
|
|
43021
|
-
const wasmResult = _tryWasmVectorNorm(x, p);
|
|
43022
|
-
if (wasmResult !== null) return wasmResult;
|
|
43023
41401
|
if (p === Number.POSITIVE_INFINITY || p === "inf") {
|
|
43024
41402
|
return _vectorNormPlusInfinity(x);
|
|
43025
41403
|
}
|
|
@@ -43780,7 +42158,7 @@ var createRotationMatrix = /* @__PURE__ */ factory(
|
|
|
43780
42158
|
|
|
43781
42159
|
// src/algebra/decomposition/schur.ts
|
|
43782
42160
|
import { matrixSchur, DenseMatrix as NativeDenseMatrix } from "@danielsimonjr/mathts-matrix";
|
|
43783
|
-
function
|
|
42161
|
+
function isPlainNumberMatrix2(matrix2) {
|
|
43784
42162
|
for (let i = 0; i < matrix2.length; i++) {
|
|
43785
42163
|
const row2 = matrix2[i];
|
|
43786
42164
|
for (let j = 0; j < row2.length; j++) {
|
|
@@ -43810,7 +42188,7 @@ var createSchur = /* @__PURE__ */ factory(
|
|
|
43810
42188
|
}
|
|
43811
42189
|
});
|
|
43812
42190
|
function _schur(data) {
|
|
43813
|
-
if (!
|
|
42191
|
+
if (!isPlainNumberMatrix2(data)) {
|
|
43814
42192
|
throw new TypeError("schur: only real (number) matrices are supported");
|
|
43815
42193
|
}
|
|
43816
42194
|
const n = data.length;
|
|
@@ -54079,7 +52457,10 @@ function quaternionFromAxisAngle(axis, angle) {
|
|
|
54079
52457
|
return [Math.cos(angle / 2), axis[0] / n * s, axis[1] / n * s, axis[2] / n * s];
|
|
54080
52458
|
}
|
|
54081
52459
|
function quaternionRotate(q, v) {
|
|
54082
|
-
const r = quaternionMultiply(
|
|
52460
|
+
const r = quaternionMultiply(
|
|
52461
|
+
quaternionMultiply(q, [0, v[0], v[1], v[2]]),
|
|
52462
|
+
quaternionConjugate(q)
|
|
52463
|
+
);
|
|
54083
52464
|
return [r[1], r[2], r[3]];
|
|
54084
52465
|
}
|
|
54085
52466
|
function quaternionToRotationMatrix(q) {
|
|
@@ -57417,6 +55798,7 @@ export {
|
|
|
57417
55798
|
isNumeric,
|
|
57418
55799
|
isPositive,
|
|
57419
55800
|
isPrime2 as isPrime,
|
|
55801
|
+
isWasmLoaded,
|
|
57420
55802
|
isZero3 as isZero,
|
|
57421
55803
|
istft,
|
|
57422
55804
|
jacobiCN,
|
|
@@ -57482,6 +55864,7 @@ export {
|
|
|
57482
55864
|
linregress,
|
|
57483
55865
|
linsolve,
|
|
57484
55866
|
ljungBox,
|
|
55867
|
+
loadWasm,
|
|
57485
55868
|
loess,
|
|
57486
55869
|
log,
|
|
57487
55870
|
log10,
|