Example #1
0
File: Dsp.c Project: eriser/FxDSP
Error_t
VectorMinVID(double* value, unsigned* index, const double* src, unsigned length)
{
    
#ifdef __APPLE__
    // Use the Accelerate framework if we have it
    vDSP_minviD(src, 1, value, (unsigned long*)index, length);
#else
    double res = src[0];
    for (unsigned i = 0; i < length; ++i)
    {
        if (src[i] < res)
        {
            *value = res = src[i];
            *index = i;
        }
    }
#endif
    return NOERR;
}
Example #2
0
uint_t
fvec_min_elem (fvec_t * s)
{
#ifndef HAVE_ACCELERATE
  uint_t j, pos = 0.;
  smpl_t tmp = s->data[0];
  for (j = 0; j < s->length; j++) {
    pos = (tmp < s->data[j]) ? pos : j;
    tmp = (tmp < s->data[j]) ? tmp : s->data[j];
  }
#else
  smpl_t tmp = 0.;
  uint_t pos = 0.;
#if !HAVE_AUBIO_DOUBLE
  vDSP_minvi(s->data, 1, &tmp, (vDSP_Length *)&pos, s->length);
#else
  vDSP_minviD(s->data, 1, &tmp, (vDSP_Length *)&pos, s->length);
#endif
#endif
  return pos;
}