double VectorMaxD(const double* src, unsigned length) { double res = DBL_MIN; #ifdef __APPLE__ // Use the Accelerate framework if we have it vDSP_maxvD(src, 1, &res, length); #else for (unsigned i = 0; i < length; ++i) { if (src[i] > res) { res = src[i]; } } #endif return res; }
smpl_t fvec_max (fvec_t * s) { #ifndef HAVE_ACCELERATE uint_t j; smpl_t tmp = 0.0; for (j = 0; j < s->length; j++) { tmp = (tmp > s->data[j]) ? tmp : s->data[j]; } #else smpl_t tmp = 0.; #if !HAVE_AUBIO_DOUBLE vDSP_maxv(s->data, 1, &tmp, s->length); #else vDSP_maxvD(s->data, 1, &tmp, s->length); #endif #endif return tmp; }