Added vector srslte_vec_avg_power_sf

This commit is contained in:
Xavier Arteaga 2020-03-06 19:51:06 +01:00 committed by Xavier Arteaga
parent 8c58d1054a
commit 44a5ce172e
2 changed files with 23 additions and 0 deletions

View File

@ -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);

View File

@ -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)
{