JuliaMath / Hadamard.jl

Fast Walsh-Hadamard transforms for the Julia language

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

fwht() input dimension

W-Wuxian opened this issue · comments

From the README, we can use fwht(A) function for arbitrary A matrix with dimensions (n,m), but in fact both n and m have to be power of 2, right?

So could you add an internal function to deal with non-power of two dimensions?

The standard definition of the Walsh-Hadamard transform is only for power-of-two sizes. It can be extended to some other sizes, but the set of known sizes is somewhat limited (see also the hadamard function in this package), and the algorithms would become rapidly less efficient for larger factors. See also https://dsp.stackexchange.com/questions/7963/can-the-walsh-hadamard-transform-be-computed-for-non-power-of-2-sizes

For example, it would be possible to handle sizes of the form 2ⁿ(12)ᵐ(20)ᵏ with O[(n+m+k)log(n+m+k)] complexity, since we know Hadamard matrices of size 12 and 20, but they are dense 12x12 and 20x20 matrices so they would be handled much less efficiently than factors of 2.