**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<<i); ++k)

{

wht_bfly (data [j + k], data [j + k + (1<<i)]);

}

}

}

}

**Comments**

__from__ : i_arslan[AT]gmx[DOT]net

__comment__ : How can i implement this code in matlab ?

__from__ : Noor98z[AT]hotmail[DOT]com

__comment__ : Need an Implemtation of Walsh Transform Matlab Code

__from__ : 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

__from__ : msalharbi[AT]hotmail[DOT]com

__comment__ : Noor98z@hotmail.com ....
need implementation of walsh transform Matlab code
and me need.

__from__ : 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

__from__ : 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

__from__ : (1< - ??????????????????????

__comment__ : What is symbols "(1<" in C++; I dont know this symbols. Please help me.

__from__ : 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)]);
}

__from__ : bcreado[AT]hotmail[DOT]com

__comment__ : well sir nice work ,but how can i get the code in MATLAB .
could you help me please

__from__ : anonymous

__comment__ : Hello,
I just thought I would let you know that I do not want MatLab code for this.
Thank you.

__from__ : 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

__from__ : nobody[AT]nowhere[DOT]com

__comment__ : What the hell is MATLAB anyway?

__from__ : 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.

__from__ : debonair_swathi[AT]yahoo[DOT]co[DOT]in

__comment__ : i need program in c to generate a hadamard matrix of any order

__from__ : 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

__from__ : 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.

__from__ : anonymous

__comment__ : Lend a hand and they grab your shoulder...