28 lines
686 B
C++
28 lines
686 B
C++
#include <stdio.h>
|
|
|
|
/**
|
|
* Returns index of maximum value, for each row (scan)
|
|
*
|
|
* @param inArray array containing block of data (assumed to be 2D)
|
|
* @param n number data (scans)
|
|
* @param m number data points (samples)
|
|
* @param[out] outVector pointer to output array, calculated idx for each 0:n-1
|
|
*
|
|
**/
|
|
void maximumDetection(float* inArray, int n, int m, float* outVector) {
|
|
|
|
float maxVal;
|
|
for (int j = 0; j < n; j++) {
|
|
outVector[j] = 0;
|
|
maxVal = inArray[j*m];
|
|
for (int i = 1; i < m; i++) {
|
|
if (inArray[j * m + i] > maxVal) {
|
|
maxVal = inArray[j * m + i];
|
|
outVector[j] = i;
|
|
}
|
|
}
|
|
// printf("\n %i \n",outVector[j]);
|
|
|
|
}
|
|
|
|
} |