Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/mathutils.c

    r7c07af2 r9499eefb  
    2727#include "config.h"
    2828
    29 #ifdef HAVE_ACCELERATE
    30 #include <Accelerate/Accelerate.h>
    31 #endif
    3229
    3330/** Window types */
     
    173170fvec_max (fvec_t * s)
    174171{
    175 #ifndef HAVE_ACCELERATE
    176172  uint_t j;
    177173  smpl_t tmp = 0.0;
     
    179175    tmp = (tmp > s->data[j]) ? tmp : s->data[j];
    180176  }
    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
    189177  return tmp;
    190178}
     
    193181fvec_min (fvec_t * s)
    194182{
    195 #ifndef HAVE_ACCELERATE
    196183  uint_t j;
    197184  smpl_t tmp = s->data[0];
     
    199186    tmp = (tmp < s->data[j]) ? tmp : s->data[j];
    200187  }
    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
    209188  return tmp;
    210189}
     
    213192fvec_min_elem (fvec_t * s)
    214193{
    215 #ifndef HAVE_ACCELERATE
    216194  uint_t j, pos = 0.;
    217195  smpl_t tmp = s->data[0];
     
    220198    tmp = (tmp < s->data[j]) ? tmp : s->data[j];
    221199  }
    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
    231200  return pos;
    232201}
     
    235204fvec_max_elem (fvec_t * s)
    236205{
    237 #ifndef HAVE_ACCELERATE
    238206  uint_t j, pos = 0;
    239207  smpl_t tmp = 0.0;
     
    242210    tmp = (tmp > s->data[j]) ? tmp : s->data[j];
    243211  }
    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
    253212  return pos;
    254213}
     
    409368}
    410369
     370smpl_t fvec_quadint (fvec_t * x, uint_t pos) {
     371  smpl_t s0, s1, s2;
     372  uint_t x0 = (pos < 1) ? pos : pos - 1;
     373  uint_t x2 = (pos + 1 < x->length) ? pos + 1 : pos;
     374  if (x0 == pos) return (x->data[pos] <= x->data[x2]) ? pos : x2;
     375  if (x2 == pos) return (x->data[pos] <= x->data[x0]) ? pos : x0;
     376  s0 = x->data[x0];
     377  s1 = x->data[pos];
     378  s2 = x->data[x2];
     379  return pos + 0.5 * (s2 - s0 ) / (s2 - 2.* s1 + s0);
     380}
     381
    411382smpl_t fvec_quadratic_peak_pos (fvec_t * x, uint_t pos) {
    412383  smpl_t s0, s1, s2;
    413   if (pos == 0 || pos == x->length - 1) return pos;
    414384  uint_t x0 = (pos < 1) ? pos : pos - 1;
    415385  uint_t x2 = (pos + 1 < x->length) ? pos + 1 : pos;
Note: See TracChangeset for help on using the changeset viewer.