Exemplo n.º 1
0
Arquivo: Dsp.c Projeto: eriser/FxDSP
Error_t
VectorMaxVID(double* value, unsigned* index, const double* src, unsigned length)
{
#ifdef __APPLE__
    // Use the Accelerate framework if we have it
    vDSP_maxviD(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;
}
Exemplo n.º 2
0
uint_t
fvec_max_elem (fvec_t * s)
{
#ifndef HAVE_ACCELERATE
  uint_t j, pos = 0;
  smpl_t tmp = 0.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_maxvi(s->data, 1, &tmp, (vDSP_Length *)&pos, s->length);
#else
  vDSP_maxviD(s->data, 1, &tmp, (vDSP_Length *)&pos, s->length);
#endif
#endif
  return pos;
}