Main Archive Specials Wiki | FAQ Links Submit Forum


Fast in-place Walsh-Hadamard Transform

Type : wavelet transform
References : Posted by Timo H Tossavainen

Notes :
IIRC, They're also called walsh-hadamard transforms.
Basically like Fourier, but the basis functions are squarewaves with different sequencies.
I did this for a transform data compression study a while back.
Here's some code to do a walsh hadamard transform on long ints in-place (you need to divide by n to get transform) the order is bit-reversed at output, IIRC.
The inverse transform is the same as the forward transform (expects bit-reversed input). i.e. x = 1/n * FWHT(FWHT(x)) (x is a vector)


Code :
void inline wht_bfly (long& a, long& b)
{
long tmp = a;
a += b;
b = tmp - b;
}

// just a integer log2
int inline l2 (long x)
{
int l2;
for (l2 = 0; x > 0; x >>=1)
{
++ l2;
}

return (l2);
}

////////////////////////////////////////////
// Fast in-place Walsh-Hadamard Transform //
////////////////////////////////////////////

void FWHT (std::vector& data)
{
const int log2 = l2 (data.size()) - 1;
for (int i = 0; i < log2; ++i)
{
for (int j = 0; j < (1 << log2); j += 1 << (i+1))
{
for (int k = 0; k < (1< {
wht_bfly (data [j + k], data [j + k + (1< }
}
}
}



Comments


Added on : 29/01/03 by i_arslan[ AT ]gmx[ DOT ]net
Comment :
    How can i implement this code in matlab ?



Added on : 13/04/03 by Noor98z[ AT ]hotmail[ DOT ]com
Comment :
Need an Implemtation of Walsh Transform Matlab Code              



Added on : 14/04/03 by ambadarneh[ AT ]hotmail[ DOT ]com
Comment :
   well sir nice work ,but how can i get the code in MATLAB .
could you help me please.

thank you
yours sicerly
Ala' Badarneh
Jordan University of Science & Technology
Biomedical Engineering Department          




Added on : 06/04/04 by msalharbi[ AT ]hotmail[ DOT ]com
Comment :
Noor98z@hotmail.com ....
need implementation of walsh transform Matlab code
and me need.




Added on : 18/06/04 by fahira10[ AT ]hotmail[ DOT ]com
Comment :
Dear sir,
your job is amazing!
I was just searching for a WHT program but I did not find any Matlab command for that. Is there a way to implement that code in Matlab?

Best regards




Added on : 22/11/04 by z_xf[ AT ]sdu[ DOT ]edu[ DOT ]cn
Comment :
   nice work ,but how can i get the code in MATLAB .
could you help me please.thank you!

yours sicerly  zhang          




Added on : 11/01/05 by (1< - ??????????????????????
Comment :
What is symbols "(1<" in C++; I dont know this symbols. Please help me.



Added on : 24/01/05 by beeka at beeka dot org
Comment :
You might want to look at the page source. This shows the "(1<" was trying to be "(1 << i)" (I hope the browser leaves that one alone):

for (int k = 0; k < (1 << i); ++k)
{
  wht_bfly (data [j + k], data [j + k + (1 << i)]);
}




Added on : 25/01/05 by bcreado[ AT ]hotmail[ DOT ]com
Comment :
     well sir nice work ,but how can i get the code in MATLAB .
could you help me please        




Added on : 20/02/05 by anonymous
Comment :
Hello,
I just thought I would let you know that I do not want MatLab code for this.
Thank you.




Added on : 04/01/07 by tired_of_morons[ AT ]gmail[ DOT ]com
Comment :
FOR CRYING OUT LOUD!! IMPLEMENT IT YOURSELF IN MATLAB! OR MAYBE, JUST MAYBE, IF YOU REQUEST FOR MATLAB CODE TEN TIMES MORE, YOU'LL GET IT... NOT!

"Most people are amazing. Just not in a positive sense..." - unknown




Added on : 04/01/07 by nobody[ AT ]nowhere[ DOT ]com
Comment :
What the hell is MATLAB anyway?  



Added on : 05/01/07 by scoofy[ AT ]inf[ DOT ]elte[ DOT ]hu
Comment :
MATLAB guys: Have you ever tried the google search "fast walsh hadamard matlab"? If yes, look at the first link.              



Added on : 29/08/07 by debonair_swathi[ AT ]yahoo[ DOT ]co[ DOT ]in
Comment :
       i need program in c to generate a hadamard matrix of any order      



Added on : 07/09/07 by debonair_swathi[ AT ]yahoo[ DOT ]co[ DOT ]in
Comment :
   sir i need program in c to get the walsh matrix of any order to use as a coding tecchnique in  CDMA  .can u email it to me          



Added on : 04/11/07 by anonymous
Comment :
Lend a hand and they grab your shoulder...      



Added on : 19/05/09 by bob[ AT ]yahoob[ DOT ]com
Comment :
If you can't convert a few lines of 'c' into to another language, then you must be mad, or lazy, or both.



Add your own comment
Comments are displayed in fixed width, no HTML code allowed!
Email:

Comment:

Are you human?



Site created and maintained by Bram
Graphic design by line.out | Server sponsered by fxpansion