Skip to content

Commit 52c6cd0

Browse files
committed
Update util.js
1 parent b5fe36b commit 52c6cd0

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

util.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,21 @@ export let PI2 = 2 * PI
55

66
// ── Internal helpers (used by window functions) ──
77

8+
/** Cosine-sum: w(i) = Σ (-1)^k aₖ cos(2πki/(N-1)). Used by blackman, nuttall, etc. */
89
export function cosineSum (i, N, a) {
910
let f = PI2 * i / (N - 1), v = a[0]
1011
for (let k = 1; k < a.length; k++) v += (k % 2 ? -1 : 1) * a[k] * cos(k * f)
1112
return v
1213
}
1314

15+
/** Modified Bessel function of the first kind, order 0. Used by kaiser, kaiserBesselDerived. */
1416
export function i0 (x) {
1517
let s = 1, t = 1
1618
for (let k = 1; k <= 25; k++) { t *= (x / (2 * k)) * (x / (2 * k)); s += t; if (t < 1e-15 * s) break }
1719
return s
1820
}
1921

22+
/** Gegenbauer (ultraspherical) polynomial C_n^mu(x) via recurrence. Used by ultraspherical. */
2023
export function gegen (n, mu, x) {
2124
if (n === 0) return 1
2225
if (n === 1) return 2 * mu * x
@@ -28,6 +31,7 @@ export function gegen (n, mu, x) {
2831
return c1
2932
}
3033

34+
/** Normalize array to peak absolute value of 1. Used by array-computed windows. */
3135
export function normalize (w) {
3236
let peak = 0
3337
for (let i = 0; i < w.length; i++) if (abs(w[i]) > peak) peak = abs(w[i])

0 commit comments

Comments
 (0)