www.pudn.com > WCDMA.rar > Hadamard.cpp
#include#include #include #include int *Hadamard( unsigned N ) /************************************************************************************* / int *Hadamard( unsigned N ) / / Copyright 2002 The Mobile and Portable Radio Research Group / / / Produces a 2^N by 2^N Hadamard Matrix / / Returns an integer pointer to a 2^(2N) array that contains the resultant / hadamard matrix / / Parmeters / Input / N unsigned Used to determine the size of the Hadamard matrix. The size / of the Hadamard matrix is 2^N by 2^N / /*************************************************************************************/ { unsigned Nold,Nnew,k,j,i,Npower2,Nhalf; int *Hold,*Hnew,*TempHold,*TempHnew; Hold = (int *) calloc(1,sizeof(int)); *Hold = 1; Nold = 1; k=0; Npower2 = 1; for (k=1; k<=N; k++) { Npower2 = (unsigned) pow( (double) 2.0, (double) k); Nnew = Npower2 * Npower2; Hnew = (int *) calloc(Nnew,sizeof(int)); if (Hnew == NULL) { printf("\nk = %d: Matrix Hnew not allocated--exiting\n",k); exit(NULL); } Nhalf = Npower2/2; TempHold = Hold; TempHnew = Hnew; for (i=0; i