From: Paul Brossier Date: Thu, 21 Apr 2016 16:21:43 +0000 (+0200) Subject: src/{fvec,cvec,fmat,lvec}.{c,h}: added const qualifiers to unmodified pointers X-Git-Tag: 0.4.4~300^2~300 X-Git-Url: https://git.aubio.org/?a=commitdiff_plain;h=1120f86f4c27475f0ae23afaa06d2a2e5996ecd8;p=aubio.git src/{fvec,cvec,fmat,lvec}.{c,h}: added const qualifiers to unmodified pointers --- diff --git a/src/cvec.c b/src/cvec.c index 6d1edb83..b8eb1614 100644 --- a/src/cvec.c +++ b/src/cvec.c @@ -21,7 +21,7 @@ #include "aubio_priv.h" #include "cvec.h" -cvec_t * new_cvec( uint_t length) { +cvec_t * new_cvec(uint_t length) { cvec_t * s; if ((sint_t)length <= 0) { return NULL; @@ -55,17 +55,17 @@ smpl_t cvec_phas_get_sample (cvec_t *s, uint_t position) { return s->phas[position]; } -smpl_t * cvec_norm_get_data (cvec_t *s) { +smpl_t * cvec_norm_get_data (const cvec_t *s) { return s->norm; } -smpl_t * cvec_phas_get_data (cvec_t *s) { +smpl_t * cvec_phas_get_data (const cvec_t *s) { return s->phas; } /* helper functions */ -void cvec_print(cvec_t *s) { +void cvec_print(const cvec_t *s) { uint_t j; AUBIO_MSG("norm: "); for (j=0; j< s->length; j++) { @@ -79,7 +79,7 @@ void cvec_print(cvec_t *s) { AUBIO_MSG("\n"); } -void cvec_copy(cvec_t *s, cvec_t *t) { +void cvec_copy(const cvec_t *s, cvec_t *t) { if (s->length != t->length) { AUBIO_ERR("trying to copy %d elements to %d elements \n", s->length, t->length); diff --git a/src/cvec.h b/src/cvec.h index c77853ff..e13ca63c 100644 --- a/src/cvec.h +++ b/src/cvec.h @@ -150,7 +150,7 @@ smpl_t cvec_phas_get_sample (cvec_t *s, uint_t position); \param s vector to read from */ -smpl_t * cvec_norm_get_data (cvec_t *s); +smpl_t * cvec_norm_get_data (const cvec_t *s); /** read phase data from a complex buffer @@ -162,14 +162,14 @@ smpl_t * cvec_norm_get_data (cvec_t *s); \param s vector to read from */ -smpl_t * cvec_phas_get_data (cvec_t *s); +smpl_t * cvec_phas_get_data (const cvec_t *s); /** print out cvec data \param s vector to print out */ -void cvec_print(cvec_t *s); +void cvec_print(const cvec_t *s); /** make a copy of a vector @@ -177,7 +177,7 @@ void cvec_print(cvec_t *s); \param t vector to copy to */ -void cvec_copy(cvec_t *s, cvec_t *t); +void cvec_copy(const cvec_t *s, cvec_t *t); /** set all norm elements to a given value diff --git a/src/fmat.c b/src/fmat.c index 0187928f..679c9585 100644 --- a/src/fmat.c +++ b/src/fmat.c @@ -53,27 +53,27 @@ void fmat_set_sample(fmat_t *s, smpl_t data, uint_t channel, uint_t position) { s->data[channel][position] = data; } -smpl_t fmat_get_sample(fmat_t *s, uint_t channel, uint_t position) { +smpl_t fmat_get_sample(const fmat_t *s, uint_t channel, uint_t position) { return s->data[channel][position]; } -void fmat_get_channel(fmat_t *s, uint_t channel, fvec_t *output) { +void fmat_get_channel(const fmat_t *s, uint_t channel, fvec_t *output) { output->data = s->data[channel]; output->length = s->length; return; } -smpl_t * fmat_get_channel_data(fmat_t *s, uint_t channel) { +smpl_t * fmat_get_channel_data(const fmat_t *s, uint_t channel) { return s->data[channel]; } -smpl_t ** fmat_get_data(fmat_t *s) { +smpl_t ** fmat_get_data(const fmat_t *s) { return s->data; } /* helper functions */ -void fmat_print(fmat_t *s) { +void fmat_print(const fmat_t *s) { uint_t i,j; for (i=0; i< s->height; i++) { for (j=0; j< s->length; j++) { @@ -116,7 +116,7 @@ void fmat_rev(fmat_t *s) { } } -void fmat_weight(fmat_t *s, fmat_t *weight) { +void fmat_weight(fmat_t *s, const fmat_t *weight) { uint_t i,j; uint_t length = MIN(s->length, weight->length); for (i=0; i< s->height; i++) { @@ -126,7 +126,7 @@ void fmat_weight(fmat_t *s, fmat_t *weight) { } } -void fmat_copy(fmat_t *s, fmat_t *t) { +void fmat_copy(const fmat_t *s, fmat_t *t) { uint_t i; #if !HAVE_MEMCPY_HACKS uint_t j; @@ -154,7 +154,7 @@ void fmat_copy(fmat_t *s, fmat_t *t) { #endif } -void fmat_vecmul(fmat_t *s, fvec_t *scale, fvec_t *output) { +void fmat_vecmul(const fmat_t *s, const fvec_t *scale, fvec_t *output) { uint_t k; #if 0 assert(s->height == output->length); diff --git a/src/fmat.h b/src/fmat.h index df2b835d..05d0975f 100644 --- a/src/fmat.h +++ b/src/fmat.h @@ -65,7 +65,7 @@ void del_fmat(fmat_t *s); \param position sample position to read from */ -smpl_t fmat_get_sample(fmat_t *s, uint_t channel, uint_t position); +smpl_t fmat_get_sample(const fmat_t *s, uint_t channel, uint_t position); /** write sample value in a buffer @@ -84,7 +84,7 @@ void fmat_set_sample(fmat_t *s, smpl_t data, uint_t channel, uint_t position); \param output ::fvec_t to output to */ -void fmat_get_channel (fmat_t *s, uint_t channel, fvec_t *output); +void fmat_get_channel (const fmat_t *s, uint_t channel, fvec_t *output); /** get vector buffer from an fmat data @@ -92,21 +92,21 @@ void fmat_get_channel (fmat_t *s, uint_t channel, fvec_t *output); \param channel channel to read from */ -smpl_t * fmat_get_channel_data (fmat_t *s, uint_t channel); +smpl_t * fmat_get_channel_data (const fmat_t *s, uint_t channel); /** read data from a buffer \param s vector to read from */ -smpl_t ** fmat_get_data(fmat_t *s); +smpl_t ** fmat_get_data(const fmat_t *s); /** print out fmat data \param s vector to print out */ -void fmat_print(fmat_t *s); +void fmat_print(const fmat_t *s); /** set all elements to a given value @@ -146,7 +146,7 @@ void fmat_rev(fmat_t *s); \param weight weighting coefficients */ -void fmat_weight(fmat_t *s, fmat_t *weight); +void fmat_weight(fmat_t *s, const fmat_t *weight); /** make a copy of a matrix @@ -154,7 +154,7 @@ void fmat_weight(fmat_t *s, fmat_t *weight); \param t vector to copy to */ -void fmat_copy(fmat_t *s, fmat_t *t); +void fmat_copy(const fmat_t *s, fmat_t *t); /* compute the product of a matrix by a vector @@ -163,7 +163,7 @@ void fmat_copy(fmat_t *s, fmat_t *t); \param output vector to store restults in */ -void fmat_vecmul(fmat_t *s, fvec_t *scale, fvec_t *output); +void fmat_vecmul(const fmat_t *s, const fvec_t *scale, fvec_t *output); #ifdef __cplusplus } diff --git a/src/fvec.c b/src/fvec.c index 1b0f750e..83c60c46 100644 --- a/src/fvec.c +++ b/src/fvec.c @@ -21,7 +21,7 @@ #include "aubio_priv.h" #include "fvec.h" -fvec_t * new_fvec( uint_t length) { +fvec_t * new_fvec(uint_t length) { fvec_t * s; if ((sint_t)length <= 0) { return NULL; @@ -41,17 +41,17 @@ void fvec_set_sample(fvec_t *s, smpl_t data, uint_t position) { s->data[position] = data; } -smpl_t fvec_get_sample(fvec_t *s, uint_t position) { +smpl_t fvec_get_sample(const fvec_t *s, uint_t position) { return s->data[position]; } -smpl_t * fvec_get_data(fvec_t *s) { +smpl_t * fvec_get_data(const fvec_t *s) { return s->data; } /* helper functions */ -void fvec_print(fvec_t *s) { +void fvec_print(const fvec_t *s) { uint_t j; for (j=0; j< s->length; j++) { AUBIO_MSG(AUBIO_SMPL_FMT " ", s->data[j]); @@ -95,7 +95,7 @@ void fvec_rev(fvec_t *s) { } } -void fvec_weight(fvec_t *s, fvec_t *weight) { +void fvec_weight(fvec_t *s, const fvec_t *weight) { #ifndef HAVE_ACCELERATE uint_t j; uint_t length = MIN(s->length, weight->length); @@ -107,7 +107,7 @@ void fvec_weight(fvec_t *s, fvec_t *weight) { #endif /* HAVE_ACCELERATE */ } -void fvec_weighted_copy(fvec_t *in, fvec_t *weight, fvec_t *out) { +void fvec_weighted_copy(const fvec_t *in, const fvec_t *weight, fvec_t *out) { #ifndef HAVE_ACCELERATE uint_t j; uint_t length = MIN(out->length, weight->length); @@ -119,7 +119,7 @@ void fvec_weighted_copy(fvec_t *in, fvec_t *weight, fvec_t *out) { #endif /* HAVE_ACCELERATE */ } -void fvec_copy(fvec_t *s, fvec_t *t) { +void fvec_copy(const fvec_t *s, fvec_t *t) { if (s->length != t->length) { AUBIO_ERR("trying to copy %d elements to %d elements \n", s->length, t->length); diff --git a/src/fvec.h b/src/fvec.h index ceaec224..ee732a4f 100644 --- a/src/fvec.h +++ b/src/fvec.h @@ -89,7 +89,7 @@ void del_fvec(fvec_t *s); \param position sample position to read from */ -smpl_t fvec_get_sample(fvec_t *s, uint_t position); +smpl_t fvec_get_sample(const fvec_t *s, uint_t position); /** write sample value in a buffer @@ -105,14 +105,14 @@ void fvec_set_sample(fvec_t *s, smpl_t data, uint_t position); \param s vector to read from */ -smpl_t * fvec_get_data(fvec_t *s); +smpl_t * fvec_get_data(const fvec_t *s); /** print out fvec data \param s vector to print out */ -void fvec_print(fvec_t *s); +void fvec_print(const fvec_t *s); /** set all elements to a given value @@ -152,7 +152,7 @@ void fvec_rev(fvec_t *s); \param weight weighting coefficients */ -void fvec_weight(fvec_t *s, fvec_t *weight); +void fvec_weight(fvec_t *s, const fvec_t *weight); /** make a copy of a vector @@ -160,7 +160,7 @@ void fvec_weight(fvec_t *s, fvec_t *weight); \param t vector to copy to */ -void fvec_copy(fvec_t *s, fvec_t *t); +void fvec_copy(const fvec_t *s, fvec_t *t); /** make a copy of a vector, applying weights to each element @@ -169,7 +169,7 @@ void fvec_copy(fvec_t *s, fvec_t *t); \param out output vector */ -void fvec_weighted_copy(fvec_t *in, fvec_t *weight, fvec_t *out); +void fvec_weighted_copy(const fvec_t *in, const fvec_t *weight, fvec_t *out); #ifdef __cplusplus } diff --git a/src/lvec.c b/src/lvec.c index 07423fbc..dd63bf42 100644 --- a/src/lvec.c +++ b/src/lvec.c @@ -21,7 +21,7 @@ #include "aubio_priv.h" #include "lvec.h" -lvec_t * new_lvec( uint_t length) { +lvec_t * new_lvec(uint_t length) { lvec_t * s; if ((sint_t)length <= 0) { return NULL; @@ -45,13 +45,13 @@ lsmp_t lvec_get_sample(lvec_t *s, uint_t position) { return s->data[position]; } -lsmp_t * lvec_get_data(lvec_t *s) { +lsmp_t * lvec_get_data(const lvec_t *s) { return s->data; } /* helper functions */ -void lvec_print(lvec_t *s) { +void lvec_print(const lvec_t *s) { uint_t j; for (j=0; j< s->length; j++) { AUBIO_MSG(AUBIO_LSMP_FMT " ", s->data[j]); diff --git a/src/lvec.h b/src/lvec.h index fc261be5..bdcf4979 100644 --- a/src/lvec.h +++ b/src/lvec.h @@ -80,14 +80,14 @@ void lvec_set_sample(lvec_t *s, lsmp_t data, uint_t position); \param s vector to read from */ -lsmp_t * lvec_get_data(lvec_t *s); +lsmp_t * lvec_get_data(const lvec_t *s); /** print out lvec data \param s vector to print out */ -void lvec_print(lvec_t *s); +void lvec_print(const lvec_t *s); /** set all elements to a given value