Added vector srslte_vec_avg_power_sf

master
Xavier Arteaga 5 years ago committed by Xavier Arteaga
parent 8c58d1054a
commit 44a5ce172e

@ -174,6 +174,7 @@ SRSLTE_API void srslte_vec_conj_cc(const cf_t* x, cf_t* y, const uint32_t len);
/* average vector power */
SRSLTE_API float srslte_vec_avg_power_cf(const cf_t* x, const uint32_t len);
SRSLTE_API float srslte_vec_avg_power_sf(const int16_t* x, const uint32_t len);
/* Correlation between complex vectors x and y */
SRSLTE_API float srslte_vec_corr_ccc(const cf_t* x, cf_t* y, const uint32_t len);

@ -459,6 +459,28 @@ float srslte_vec_avg_power_cf(const cf_t* x, const uint32_t len)
return crealf(srslte_vec_dot_prod_conj_ccc(x, x, len)) / len;
}
float srslte_vec_avg_power_sf(const int16_t* x, const uint32_t len)
{
// Accumulator
float acc = 0.0f;
for (uint32_t i = 0; i < len; i++) {
// Read value and typecast to float
float t = (float)x[i];
// Square value
acc += t * t;
}
// Do average
if (len) {
acc /= len;
}
// Return accumulated value
return acc;
}
// Correlation assumes zero-mean x and y
float srslte_vec_corr_ccc(const cf_t* x, cf_t* y, const uint32_t len)
{

Loading…
Cancel
Save