Commit source
This commit is contained in:
28
TransmissionDetection/src/mathMethods.cpp
Normal file
28
TransmissionDetection/src/mathMethods.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
#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]);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user