Motorola DSP Developer's Kit | ![]() ![]() |
[ Y, I] = mot###_sort( X )
Description
This function sorts the complex input vector X
Input/Output
Input: Complex vector X (includes the real part Xr
, and the imaginary part Xi
)
Output: Complex vector Y, and vector I (index)
Algorithm
#define IN $0 #define IN_REAL x:$0 #define IN_IMAG y:$0
Algorithm
for(i = 0; i< size; i++) { R[i] = (Xr[i]* Xr[i] + Xi[i]* Xi[i])>>1; }
Sort vector R using heap sort algorithm, and then adjust vector X according to the index of vector R.
Generate vector R (and its index vector starting from 1), and then put the results in the address:
#IN+SIZE (X and Y memory, respectively)
Sort vector R and adjust its index vector accordingly.
Adjust the complex data according to the index.
Please refer to sort-r1.asm
for the heap sort algorithm.
Vector R: R[i] = (Xr[i]*Xr[i] + Xi[i]*Xi[i])>>1
Start address of Vector R, and Vector I (index) will be calculated by the assembly code.
Vector I is located in Y memory.
Memory & Register
Status Register
The assembly function sort-c.asm
does not explicitly set any status registers/bits during the function execution.
Data Size Limit
The length of vector X can't be larger than the continuous available data memory size.
Data Range Limit
Input data vector X range [-1.0, +1.0]
Precision
In the case of DSP563, precision is 23 bits.
In the case of DSP566, precision is 15 bits.
![]() | sort-r2.asm | sqrt-sr.asm | ![]() |