return s->data;
}
+/* helper functions */
+
void fvec_print(fvec_t *s) {
uint_t i,j;
for (i=0; i< s->channels; i++) {
AUBIO_MSG("\n");
}
}
+
+void fvec_set(fvec_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 fvec_zeros(fvec_t *s) {
+ fvec_set(s, 0.);
+}
+
+void fvec_ones(fvec_t *s) {
+ fvec_set(s, 1.);
+}
+
+void fvec_rev(fvec_t *s) {
+ uint_t i,j;
+ for (i=0; i< s->channels; i++) {
+ for (j=0; j< FLOOR(s->length/2); j++) {
+ ELEM_SWAP(s->data[i][j], s->data[i][s->length-1-j]);
+ }
+ }
+}
+
+void fvec_weight(fvec_t *s, fvec_t *weight) {
+ uint_t i,j;
+ uint_t length = MIN(s->length, weight->length);
+ for (i=0; i< s->channels; i++) {
+ for (j=0; j< length; j++) {
+ s->data[i][j] *= weight->data[0][j];
+ }
+ }
+}
+
+void fvec_copy(fvec_t *s, fvec_t *t) {
+ uint_t i,j;
+ uint_t channels = MIN(s->channels, t->channels);
+ uint_t length = MIN(s->length, t->length);
+ if (s->channels != t->channels) {
+ AUBIO_ERR("warning, trying to copy %d channels to %d channels\n",
+ s->channels, t->channels);
+ }
+ if (s->length != t->length) {
+ AUBIO_ERR("warning, trying to copy %d elements to %d elements \n",
+ s->length, t->length);
+ }
+ for (i=0; i< channels; i++) {
+ for (j=0; j< length; j++) {
+ t->data[i][j] = s->data[i][j];
+ }
+ }
+}
+
*/
void fvec_print(fvec_t *s);
+/** set all elements to a given value
+
+ \param s vector to modify
+ \param val value to set elements to
+
+*/
+void fvec_set(fvec_t *s, smpl_t val);
+
+/** set all elements to zero
+
+ \param s vector to modify
+
+*/
+void fvec_zeros(fvec_t *s);
+
+/** set all elements to ones
+
+ \param s vector to modify
+
+*/
+void fvec_ones(fvec_t *s);
+
+/** revert order of vector elements
+
+ \param s vector to revert
+
+*/
+void fvec_rev(fvec_t *s);
+
+/** apply weight to vector
+
+ If the weight vector is longer than s, only the first elements are used. If
+ the weight vector is shorter than s, the last elements of s are not weighted.
+
+ \param s vector to weight
+ \param weight weighting coefficients
+
+*/
+void fvec_weight(fvec_t *s, fvec_t *weight);
+
+/** make a copy of a vector
+
+ \param s source vector
+ \param t vector to copy to
+
+*/
+void fvec_copy(fvec_t *s, fvec_t *t);
+
#ifdef __cplusplus
}
#endif