ref: 98d8d2b198574194cde97b1b82b475011ede9419
parent: e06ac8f3d4241ceaa3ca4b146998ec9606edd647
author: Paul Brossier <piem@piem.org>
date: Wed Sep 2 10:27:52 EDT 2015
src/mathutils.c: Accelerate fvec_sum and fvec_mean
--- a/src/mathutils.c
+++ b/src/mathutils.c
@@ -158,22 +158,39 @@
smpl_t
fvec_mean (fvec_t * s)
{
- uint_t j;
smpl_t tmp = 0.0;
+#ifndef HAVE_ACCELERATE
+ uint_t j;
for (j = 0; j < s->length; j++) {
tmp += s->data[j];
}
return tmp / (smpl_t) (s->length);
+#else
+#if !HAVE_AUBIO_DOUBLE
+ vDSP_meanv(s->data, 1, &tmp, s->length);
+#else /* HAVE_AUBIO_DOUBLE */
+ vDSP_meanvD(s->data, 1, &tmp, s->length);
+#endif /* HAVE_AUBIO_DOUBLE */
+ return tmp;
+#endif /* HAVE_ACCELERATE */
}
smpl_t
fvec_sum (fvec_t * s)
{
- uint_t j;
smpl_t tmp = 0.0;
+#ifndef HAVE_ACCELERATE
+ uint_t j;
for (j = 0; j < s->length; j++) {
tmp += s->data[j];
}
+#else
+#if !HAVE_AUBIO_DOUBLE
+ vDSP_sve(s->data, 1, &tmp, s->length);
+#else /* HAVE_AUBIO_DOUBLE */
+ vDSP_sveD(s->data, 1, &tmp, s->length);
+#endif /* HAVE_AUBIO_DOUBLE */
+#endif /* HAVE_ACCELERATE */
return tmp;
}