Changeset 7c07af2 for src/mathutils.c


Ignore:
Timestamp:
Oct 16, 2013, 1:21:29 AM (6 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:
cdd24f0
Parents:
7609f6d
Message:

src/mathutils.c: use vDSP if available

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/mathutils.c

    r7609f6d r7c07af2  
    2727#include "config.h"
    2828
     29#ifdef HAVE_ACCELERATE
     30#include <Accelerate/Accelerate.h>
     31#endif
    2932
    3033/** Window types */
     
    170173fvec_max (fvec_t * s)
    171174{
     175#ifndef HAVE_ACCELERATE
    172176  uint_t j;
    173177  smpl_t tmp = 0.0;
     
    175179    tmp = (tmp > s->data[j]) ? tmp : s->data[j];
    176180  }
     181#else
     182  smpl_t tmp = 0.;
     183#if !HAVE_AUBIO_DOUBLE
     184  vDSP_maxv(s->data, 1, &tmp, s->length);
     185#else
     186  vDSP_maxvD(s->data, 1, &tmp, s->length);
     187#endif
     188#endif
    177189  return tmp;
    178190}
     
    181193fvec_min (fvec_t * s)
    182194{
     195#ifndef HAVE_ACCELERATE
    183196  uint_t j;
    184197  smpl_t tmp = s->data[0];
     
    186199    tmp = (tmp < s->data[j]) ? tmp : s->data[j];
    187200  }
     201#else
     202  smpl_t tmp = 0.;
     203#if !HAVE_AUBIO_DOUBLE
     204  vDSP_minv(s->data, 1, &tmp, s->length);
     205#else
     206  vDSP_minvD(s->data, 1, &tmp, s->length);
     207#endif
     208#endif
    188209  return tmp;
    189210}
     
    192213fvec_min_elem (fvec_t * s)
    193214{
     215#ifndef HAVE_ACCELERATE
    194216  uint_t j, pos = 0.;
    195217  smpl_t tmp = s->data[0];
     
    198220    tmp = (tmp < s->data[j]) ? tmp : s->data[j];
    199221  }
     222#else
     223  smpl_t tmp = 0.;
     224  uint_t pos = 0.;
     225#if !HAVE_AUBIO_DOUBLE
     226  vDSP_minvi(s->data, 1, &tmp, (vDSP_Length *)&pos, s->length);
     227#else
     228  vDSP_minviD(s->data, 1, &tmp, (vDSP_Length *)&pos, s->length);
     229#endif
     230#endif
    200231  return pos;
    201232}
     
    204235fvec_max_elem (fvec_t * s)
    205236{
     237#ifndef HAVE_ACCELERATE
    206238  uint_t j, pos = 0;
    207239  smpl_t tmp = 0.0;
     
    210242    tmp = (tmp > s->data[j]) ? tmp : s->data[j];
    211243  }
     244#else
     245  smpl_t tmp = 0.;
     246  uint_t pos = 0.;
     247#if !HAVE_AUBIO_DOUBLE
     248  vDSP_maxvi(s->data, 1, &tmp, (vDSP_Length *)&pos, s->length);
     249#else
     250  vDSP_maxviD(s->data, 1, &tmp, (vDSP_Length *)&pos, s->length);
     251#endif
     252#endif
    212253  return pos;
    213254}
Note: See TracChangeset for help on using the changeset viewer.