From: Paul Brossier Date: Mon, 19 Oct 2009 12:58:31 +0000 (+0200) Subject: src/lvec.{c,h}: add some utils X-Git-Tag: bzr2git~95 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=b849106ada63ca4af6bc45313547d8f9aa38964c;p=aubio.git src/lvec.{c,h}: add some utils --- diff --git a/src/lvec.c b/src/lvec.c index 86763e33..1f3234f6 100644 --- a/src/lvec.c +++ b/src/lvec.c @@ -74,3 +74,20 @@ void lvec_print(lvec_t *s) { } } +void lvec_set(lvec_t *s, smpl_t val) { + uint_t i,j; + for (i=0; i< s->channels; i++) { + for (j=0; j< s->length; j++) { + s->data[i][j] = val; + } + } +} + +void lvec_zeros(lvec_t *s) { + lvec_set(s, 0.); +} + +void lvec_ones(lvec_t *s) { + lvec_set(s, 1.); +} + diff --git a/src/lvec.h b/src/lvec.h index c350c06e..400bab44 100644 --- a/src/lvec.h +++ b/src/lvec.h @@ -122,6 +122,28 @@ lsmp_t ** lvec_get_data(lvec_t *s); */ void lvec_print(lvec_t *s); +/** set all elements to a given value + + \param s vector to modify + \param val value to set elements to + +*/ +void lvec_set(lvec_t *s, smpl_t val); + +/** set all elements to zero + + \param s vector to modify + +*/ +void lvec_zeros(lvec_t *s); + +/** set all elements to ones + + \param s vector to modify + +*/ +void lvec_ones(lvec_t *s); + #ifdef __cplusplus } #endif