From: Paul Brossier Date: Fri, 10 Mar 2017 16:17:33 +0000 (+0100) Subject: src/mathutils.h: add fvec_push X-Git-Tag: 0.4.5~20^2~36 X-Git-Url: https://git.aubio.org/?a=commitdiff_plain;h=ee8a57c3905c9ce6bc5286dd0238d4fbc0c5b459;p=aubio.git src/mathutils.h: add fvec_push --- diff --git a/src/mathutils.c b/src/mathutils.c index 45f61c93..12cbe017 100644 --- a/src/mathutils.c +++ b/src/mathutils.c @@ -289,6 +289,14 @@ fvec_ishift (fvec_t * s) } } +void fvec_push(fvec_t *in, smpl_t new_elem) { + uint_t i; + for (i = 0; i < in->length - 1; i++) { + in->data[i] = in->data[i + 1]; + } + in->data[in->length - 1] = new_elem; +} + smpl_t aubio_level_lin (const fvec_t * f) { diff --git a/src/mathutils.h b/src/mathutils.h index 6638f692..7bef5a4e 100644 --- a/src/mathutils.h +++ b/src/mathutils.h @@ -117,6 +117,17 @@ of the resulting spectrum. See Amalia de Götzen's paper referred to above. */ void fvec_ishift (fvec_t * v); +/** push a new element to the end of a vector, erasing the first element and + * sliding all others + + \param in vector to push to + \param new_elem new_element to add at the end of the vector + + In numpy words, this is equivalent to: in = np.concatenate([in, [new_elem]])[1:] + +*/ +void fvec_push(fvec_t *in, smpl_t new_elem); + /** compute the sum of all elements of a vector \param v vector to compute the sum of