|
|
| DSP_maxidx | |
| Index of Maximum Element of Vector | |||
DSP_maxidx | ||||
Function |
| int DSP_maxidx (const short *x, int nx) |
| |
Arguments |
| x[nx] | Pointer to input vector of size nx. Must be | |
|
| nx | Length of input data vector. Must be multiple of 16 and ≥ 48. | |
|
| return int | Index for vector element with maximum value. | |
Description |
| This routine finds the max value of a vector and returns the index of that value. | ||
|
| The input array is treated as 16 separate columns that are interleaved | ||
|
| throughout the array. If values in different columns are equal to the maximum | ||
|
| value, then the element in the leftmost column is returned. If two values within | ||
|
| a column are equal to the maximum, then the one with the lower index is | ||
|
| returned. Column takes precedence over index. | ||
Algorithm |
| This is the C equivalent of the assembly code without restrictions. Note that | ||
|
| the assembly code is hand optimized and restrictions may apply. |
int DSP_maxidx(short x[ ], int nx)
{
int max, index, i; max = −32768;
for (i = 0; i < nx; i++) if (x[i] > max) {
max = x[i]; index = i;
}
return index;
}
Special Requirements
-nx must be a multiple of 16 and greater than or equal to 48.
-The input vector x[ ] must be
C64x+ DSPLIB Reference |