cxvec_math: Mark input vectors as 'const' where applicable

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
This commit is contained in:
Sylvain Munaut 2012-05-23 19:27:01 +02:00
parent e03f966590
commit 0a2560db76
2 changed files with 18 additions and 16 deletions

View File

@ -71,11 +71,11 @@ osmo_normsqf(float complex c)
/* Complex vector math */ /* Complex vector math */
struct osmo_cxvec * struct osmo_cxvec *
osmo_cxvec_scale(struct osmo_cxvec *in, float complex scale, osmo_cxvec_scale(const struct osmo_cxvec *in, float complex scale,
struct osmo_cxvec *out); struct osmo_cxvec *out);
struct osmo_cxvec * struct osmo_cxvec *
osmo_cxvec_rotate(struct osmo_cxvec *in, float freq_shift, osmo_cxvec_rotate(const struct osmo_cxvec *in, float freq_shift,
struct osmo_cxvec *out); struct osmo_cxvec *out);
/*! \brief Various possible types of convolution span */ /*! \brief Various possible types of convolution span */
@ -89,15 +89,15 @@ enum osmo_cxvec_conv_type {
}; };
struct osmo_cxvec * struct osmo_cxvec *
osmo_cxvec_convolve(struct osmo_cxvec *f, struct osmo_cxvec *g, osmo_cxvec_convolve(const struct osmo_cxvec *f, const struct osmo_cxvec *g,
enum osmo_cxvec_conv_type type, struct osmo_cxvec *out); enum osmo_cxvec_conv_type type, struct osmo_cxvec *out);
struct osmo_cxvec * struct osmo_cxvec *
osmo_cxvec_correlate(struct osmo_cxvec *f, struct osmo_cxvec *g, int g_corr_step, osmo_cxvec_correlate(const struct osmo_cxvec *f, const struct osmo_cxvec *g,
struct osmo_cxvec *out); int g_corr_step, struct osmo_cxvec *out);
float complex float complex
osmo_cxvec_interpolate_point(struct osmo_cxvec *cv, float pos); osmo_cxvec_interpolate_point(const struct osmo_cxvec *cv, float pos);
/*! \brief Various possible peak finding algorithms */ /*! \brief Various possible peak finding algorithms */
enum osmo_cxvec_peak_alg { enum osmo_cxvec_peak_alg {
@ -110,12 +110,13 @@ enum osmo_cxvec_peak_alg {
}; };
float float
osmo_cxvec_peak_energy_find(struct osmo_cxvec *cv, int win_size, osmo_cxvec_peak_energy_find(const struct osmo_cxvec *cv, int win_size,
enum osmo_cxvec_peak_alg alg, enum osmo_cxvec_peak_alg alg,
float complex *peak_val_p); float complex *peak_val_p);
struct osmo_cxvec * struct osmo_cxvec *
osmo_cxvec_sig_normalize(struct osmo_cxvec *sig, int decim, float freq_shift, osmo_cxvec_sig_normalize(const struct osmo_cxvec *sig,
int decim, float freq_shift,
struct osmo_cxvec *out); struct osmo_cxvec *out);
/*! @} */ /*! @} */

View File

@ -52,7 +52,7 @@
* to contain the result (i.e. in->len) * to contain the result (i.e. in->len)
*/ */
struct osmo_cxvec * struct osmo_cxvec *
osmo_cxvec_scale(struct osmo_cxvec *in, float complex scale, osmo_cxvec_scale(const struct osmo_cxvec *in, float complex scale,
struct osmo_cxvec *out) struct osmo_cxvec *out)
{ {
int i; int i;
@ -109,7 +109,7 @@ osmo_cxvec_scale(struct osmo_cxvec *in, float complex scale,
* to contain the result (i.e. in->len) * to contain the result (i.e. in->len)
*/ */
struct osmo_cxvec * struct osmo_cxvec *
osmo_cxvec_rotate(struct osmo_cxvec *in, float rps, osmo_cxvec_rotate(const struct osmo_cxvec *in, float rps,
struct osmo_cxvec *out) struct osmo_cxvec *out)
{ {
int i; int i;
@ -150,7 +150,7 @@ osmo_cxvec_rotate(struct osmo_cxvec *in, float rps,
* (length depends on the exact convolution type) * (length depends on the exact convolution type)
*/ */
struct osmo_cxvec * struct osmo_cxvec *
osmo_cxvec_convolve(struct osmo_cxvec *f, struct osmo_cxvec *g, osmo_cxvec_convolve(const struct osmo_cxvec *f, const struct osmo_cxvec *g,
enum osmo_cxvec_conv_type type, struct osmo_cxvec *out) enum osmo_cxvec_conv_type type, struct osmo_cxvec *out)
{ {
int Lf, Lg, Lo, si, ei, i, jf, jg; int Lf, Lg, Lo, si, ei, i, jf, jg;
@ -257,8 +257,8 @@ osmo_cxvec_convolve(struct osmo_cxvec *f, struct osmo_cxvec *g,
* (i.e. g->len - f->len + 1) * (i.e. g->len - f->len + 1)
*/ */
struct osmo_cxvec * struct osmo_cxvec *
osmo_cxvec_correlate(struct osmo_cxvec *f, struct osmo_cxvec *g, int g_corr_step, osmo_cxvec_correlate(const struct osmo_cxvec *f, const struct osmo_cxvec *g,
struct osmo_cxvec *out) int g_corr_step, struct osmo_cxvec *out)
{ {
int l, m, n, mn; int l, m, n, mn;
int f_real, g_real; int f_real, g_real;
@ -321,7 +321,7 @@ osmo_cxvec_correlate(struct osmo_cxvec *f, struct osmo_cxvec *g, int g_corr_step
* pos must be >= 0 and < cv->len * pos must be >= 0 and < cv->len
*/ */
float complex float complex
osmo_cxvec_interpolate_point(struct osmo_cxvec *cv, float pos) osmo_cxvec_interpolate_point(const struct osmo_cxvec *cv, float pos)
{ {
const int N = 10; const int N = 10;
int b, e, i; int b, e, i;
@ -361,7 +361,7 @@ osmo_cxvec_interpolate_point(struct osmo_cxvec *cv, float pos)
* \returns Peak position with sub-sample accuracy * \returns Peak position with sub-sample accuracy
*/ */
float float
osmo_cxvec_peak_energy_find(struct osmo_cxvec *cv, int win_size, osmo_cxvec_peak_energy_find(const struct osmo_cxvec *cv, int win_size,
enum osmo_cxvec_peak_alg alg, enum osmo_cxvec_peak_alg alg,
float complex *peak_val_p) float complex *peak_val_p)
{ {
@ -490,7 +490,8 @@ osmo_cxvec_peak_energy_find(struct osmo_cxvec *cv, int win_size,
* the result (i.e. (sig->len + decim - 1) / decim) * the result (i.e. (sig->len + decim - 1) / decim)
*/ */
struct osmo_cxvec * struct osmo_cxvec *
osmo_cxvec_sig_normalize(struct osmo_cxvec *sig, int decim, float freq_shift, osmo_cxvec_sig_normalize(const struct osmo_cxvec *sig,
int decim, float freq_shift,
struct osmo_cxvec *out) struct osmo_cxvec *out)
{ {
float complex avg = 0.0f; float complex avg = 0.0f;