/* This is a sample program of 1D Walsh-Hadamard transform (WHT). Compile it with "cc mywht.c -lm -o mywht". You can choose either Hadamard order or Sequency (Walsh) order by setting the switch "sequency" in the function wht(x,m,sequency,inverse). You can use the wht function in this program for your project. I wrote this wht function following closely what I showed you in class (and also the handout). Do not treat it as a black box. Read it to understand it. */ #include #include #include #include #include "array_utility.h" int howo(i,m) /* converts a sequency index i to Haramard index j */ int i,m; { int j,k; /* j=i>>1; i=i^j; /* converting binary to Gray code */ i=i^(i>>1); j=0; for (k=0; k> k)); /* bit-reversal */ return j; } void wht(x,N,sequency,inverse) float *x; int N,inverse,sequency; { int mmax,step,i,j,k,j1,m,n,nu; float w; m=log((float)N)/log(2.0); if (sequency) { for (i=0; i> k)); if (j < i) { w=x[i]; x[i]=x[j]; x[j]=w; } } } for (i=0; i