Changeset 116bd1b for src/mathutils.c


Ignore:
Timestamp:
Feb 16, 2016, 5:47:43 PM (4 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:
7cdabbe
Parents:
d21a4b1
Message:

src/mathutils.h: add fvec_ishift

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/mathutils.c

    rd21a4b1 r116bd1b  
    254254fvec_shift (fvec_t * s)
    255255{
     256  uint_t half = s->length / 2, start = half;
     257  // if length is odd, middle element is moved to the end
     258  if (2 * half < s->length) start ++;
    256259#ifndef HAVE_ATLAS
    257   uint_t j;
    258   for (j = 0; j < s->length / 2; j++) {
    259     ELEM_SWAP (s->data[j], s->data[j + s->length / 2]);
    260   }
    261 #else
    262   uint_t half = s->length / 2;
    263   aubio_cblas_swap(half, s->data, 1, s->data + half, 1);
    264 #endif
     260  for (uint_t j = 0; j < half; j++) {
     261    ELEM_SWAP (s->data[j], s->data[j + start]);
     262  }
     263#else
     264  aubio_cblas_swap(half, s->data, 1, s->data + start, 1);
     265#endif
     266  if (start != half) {
     267    for (uint_t j = 0; j < half; j++) {
     268      ELEM_SWAP (s->data[j + start - 1], s->data[j + start]);
     269    }
     270  }
     271}
     272
     273void
     274fvec_ishift (fvec_t * s)
     275{
     276  uint_t half = s->length / 2, start = half;
     277  // if length is odd, middle element is moved to the beginning
     278  if (2 * half < s->length) start ++;
     279#ifndef HAVE_ATLAS
     280  for (uint_t j = 0; j < half; j++) {
     281    ELEM_SWAP (s->data[j], s->data[j + start]);
     282  }
     283#else
     284  aubio_cblas_swap(half, s->data, 1, s->data + start, 1);
     285#endif
     286  if (start != half) {
     287    for (uint_t j = 0; j < half; j++) {
     288      ELEM_SWAP (s->data[half], s->data[j]);
     289    }
     290  }
    265291}
    266292
Note: See TracChangeset for help on using the changeset viewer.