package utils
// FFT twiddle factors and bit-reversal tables, cached per size.
// fftPlan holds pre-computed data for a given FFT size.
// getFFFTPlan returns a cached FFT plan for the given size (must be power of 2).
// reverseBitsN reverses the lowest `bits` bits of v.
// PowerSpectrumFFT computes the power spectrum of a real-valued signal using radix-2 FFT.
//
// samples: real input of length N (must be power of 2, N >= 2)
// power: output buffer of length >= N/2+1; receives |X[k]|^2 for k=0..N/2
// scratch: working buffer of length >= N; contents are overwritten
//
// All buffers are caller-provided to enable zero-allocation across repeated calls.