shithub: aubio

Download patch

ref: b849106ada63ca4af6bc45313547d8f9aa38964c
parent: b01bd4a8331c5e24f88bb0659a1f723fe7bf12ca
author: Paul Brossier <piem@piem.org>
date: Mon Oct 19 10:58:31 EDT 2009

src/lvec.{c,h}: add some utils

--- a/src/lvec.c
+++ b/src/lvec.c
@@ -74,3 +74,20 @@
   }
 }
 
+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.);
+}
+
--- a/src/lvec.h
+++ b/src/lvec.h
@@ -122,6 +122,28 @@
 */
 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