Improve code in calibration module
This commit is contained in:
parent
e37001e3c4
commit
7b1ae3bdc6
@ -92,7 +92,7 @@ static float calculate_mean(float *values, uint32_t count)
|
|||||||
} while (--loop_cnt > 0);
|
} while (--loop_cnt > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return sum/(float)count;
|
return sum / (float)count;
|
||||||
}
|
}
|
||||||
|
|
||||||
static float calculate_standard_deviation(float *values, uint32_t count, float mean)
|
static float calculate_standard_deviation(float *values, uint32_t count, float mean)
|
||||||
@ -103,35 +103,36 @@ static float calculate_standard_deviation(float *values, uint32_t count, float m
|
|||||||
float res;
|
float res;
|
||||||
|
|
||||||
switch (remainder) {
|
switch (remainder) {
|
||||||
case 0: do { sum += (*values - mean) * (*values - mean);
|
case 0: do {
|
||||||
values++;
|
sum += (*values - mean) * (*values - mean);
|
||||||
/* FALLTHRU */
|
values++;
|
||||||
case 7: sum += (*values - mean) * (*values - mean);
|
/* FALLTHRU */
|
||||||
values++;
|
case 7: sum += (*values - mean) * (*values - mean);
|
||||||
/* FALLTHRU */
|
values++;
|
||||||
case 6: sum += (*values - mean) * (*values - mean);
|
/* FALLTHRU */
|
||||||
values++;
|
case 6: sum += (*values - mean) * (*values - mean);
|
||||||
/* FALLTHRU */
|
values++;
|
||||||
case 5: sum += (*values - mean) * (*values - mean);
|
/* FALLTHRU */
|
||||||
values++;
|
case 5: sum += (*values - mean) * (*values - mean);
|
||||||
/* FALLTHRU */
|
values++;
|
||||||
case 4: sum += (*values - mean) * (*values - mean);
|
/* FALLTHRU */
|
||||||
values++;
|
case 4: sum += (*values - mean) * (*values - mean);
|
||||||
/* FALLTHRU */
|
values++;
|
||||||
case 3: sum += (*values - mean) * (*values - mean);
|
/* FALLTHRU */
|
||||||
values++;
|
case 3: sum += (*values - mean) * (*values - mean);
|
||||||
/* FALLTHRU */
|
values++;
|
||||||
case 2: sum += (*values - mean) * (*values - mean);
|
/* FALLTHRU */
|
||||||
values++;
|
case 2: sum += (*values - mean) * (*values - mean);
|
||||||
/* FALLTHRU */
|
values++;
|
||||||
case 1: sum += (*values - mean) * (*values - mean);
|
/* FALLTHRU */
|
||||||
values++;
|
case 1: sum += (*values - mean) * (*values - mean);
|
||||||
/* FALLTHRU */
|
values++;
|
||||||
|
/* FALLTHRU */
|
||||||
} while (--loop_cnt > 0);
|
} while (--loop_cnt > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
sum /= (float)count;
|
sum /= (float)count;
|
||||||
/* Compute the square roor using the FPU.
|
/* Compute the square root using the FPU.
|
||||||
* The constraint 't' tells GCC to use a floating point register
|
* The constraint 't' tells GCC to use a floating point register
|
||||||
*/
|
*/
|
||||||
__asm__ __volatile__("vsqrt.f32 %0, %1" : "=t"(res) : "t"(sum));
|
__asm__ __volatile__("vsqrt.f32 %0, %1" : "=t"(res) : "t"(sum));
|
||||||
|
Loading…
Reference in New Issue
Block a user