Changeset 8982328 for src/mathutils.c


Ignore:
Timestamp:
Sep 5, 2015, 11:07:11 AM (4 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/constantq, feature/pitchshift, feature/pydocstrings, feature/timestretch, master, pitchshift, sampler, timestretch, yinfft+
Children:
c9e3a4e
Parents:
7166ef8
Message:

src/mathutils.c: optimized fvec_shift and aubio_level_lin

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/mathutils.c

    r7166ef8 r8982328  
    2929#ifdef HAVE_ACCELERATE
    3030#include <Accelerate/Accelerate.h>
     31#endif
     32
     33#if !HAVE_AUBIO_DOUBLE
     34#define aubio_cblas_xswap cblas_sswap
     35#define aubio_cblas_dot   cblas_sdot
     36#else
     37#define aubio_cblas_xswap cblas_dswap
     38#define aubio_cblas_dot   cblas_ddot
    3139#endif
    3240
     
    282290fvec_shift (fvec_t * s)
    283291{
     292#ifndef HAVE_ACCELERATE
    284293  uint_t j;
    285294  for (j = 0; j < s->length / 2; j++) {
    286295    ELEM_SWAP (s->data[j], s->data[j + s->length / 2]);
    287296  }
     297#else
     298  uint_t half = s->length / 2;
     299  aubio_cblas_xswap(half, s->data, 1, s->data + half, 1);
     300#endif
    288301}
    289302
     
    292305{
    293306  smpl_t energy = 0.;
     307#ifndef HAVE_ACCELERATE
    294308  uint_t j;
    295309  for (j = 0; j < f->length; j++) {
    296310    energy += SQR (f->data[j]);
    297311  }
     312#else
     313  energy = aubio_cblas_dot(f->length, f->data, 1, f->data, 1);
     314#endif
    298315  return energy / f->length;
    299316}
Note: See TracChangeset for help on using the changeset viewer.