📄 bit_reverse_cplx.c
字号:
/*
* DATE:05/30/2006
*
* AUTHOR:CHEN PENG
*
* VERSION:ORIGINAL 05/30/2006
* MODIFIED 06/20/2006
*/
/******************************************************************************\
* FUNCTION: void bit_reverse_cplx(int x[], int num)
*
* AGRUMENTS: x[num] Input and output sequences. Size num complex
* elements
*
* num Number of complex elements in vector x. Must be
* power of 2
*
* DESCRIPTION: This routine is used to compute the bit-reverse or
* bit-normal order corresponding to input vector x,
* with size num. Each complex value is with interleaved
* 16-bit real and imaginary parts.
*
* REQUIREMENTS: 1. 4 <= num <= 65536( num a power of 2)
* 2. x data is stored in the order real[0],image[0],real[1],...
* 3. x is aligned on a 4*num byte boundary
* 4. The code is LITTLE ENDIAN
*
\******************************************************************************/
void bit_reverse_cplx(int x[], int num){
int iBefore, iBehind, tempData, temph, templ, temp, i;
int hBitRef, lBitRef, hBit, lBit;
char hPos, lPos, bitMov;
short nBits;
nBits = 0;
i = num;
/* acquire bit numbers occupied by the size of x */
while(i > 1){
i >>= 1;
nBits++;
}
hBitRef = 0x00000001 << (--nBits);
lBitRef = 0x00000001;
/*
*for each index, search for its corresponding bit-reversed index, then
*switch the indexed datas.
*/
for( iBefore = 1; iBefore < num; iBefore++ ){
hPos = nBits;
lPos = 0;
hBit = hBitRef;
lBit = lBitRef;
bitMov = nBits;
temp = 0;
/* bit-reverse */
while( hPos > lPos ){
temph = iBefore & hBit;
templ = iBefore & lBit;
temph >>= bitMov;
templ <<= bitMov;
temp += temph + templ;
hPos--;
lPos++;
bitMov -= 2;
hBit >>= 1;
lBit <<= 1;
}
if( hPos == lPos ){
temph = iBefore & hBit;
temp += temph;
}
/* data exchange */
iBehind = temp;
if( iBehind < iBefore )
continue;
tempData = x[iBefore];
x[iBefore] = x[iBehind];
x[iBehind] = tempData;
}
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -