Changeset a7348ca5


Ignore:
Timestamp:
Feb 16, 2016, 9:47:46 PM (8 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
Children:
fc2d7fb
Parents:
4bf3731
Message:

src/fmat.c: add optimized fmat_vecmul

Location:
src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/fmat.c

    r4bf3731 ra7348ca5  
    155155}
    156156
     157void fmat_vecmul(fmat_t *s, fvec_t *scale, fvec_t *output) {
     158  uint_t k;
     159  assert(s->height == output->length);
     160  assert(s->length == scale->length);
     161#if !defined(HAVE_ACCELERATE) && !defined(HAVE_ATLAS)
     162  uint_t j;
     163  fvec_zeros(output);
     164  for (j = 0; j < s->length; j++) {
     165    for (k = 0; k < s->height; k++) {
     166      output->data[k] += scale->data[j]
     167          * s->data[k][j];
     168    }
     169  }
     170#elif defined(HAVE_ATLAS)
     171  for (k = 0; k < s->height; k++) {
     172    output->data[k] = aubio_cblas_dot( s->length, scale->data, 1, s->data[k], 1);
     173  }
     174#elif defined(HAVE_ACCELERATE)
     175#if 0
     176  // seems slower and less precise (and dangerous?)
     177  vDSP_mmul (s->data[0], 1, scale->data, 1, output->data, 1, s->height, 1, s->length);
     178#else
     179  for (k = 0; k < s->height; k++) {
     180    aubio_vDSP_dotpr( scale->data, 1, s->data[k], 1, &(output->data[k]), s->length);
     181  }
     182#endif
     183#endif
     184}
  • src/fmat.h

    r4bf3731 ra7348ca5  
    157157void fmat_copy(fmat_t *s, fmat_t *t);
    158158
     159/* compute the product of a matrix by a vector
     160
     161   \param s matrix to compute product with
     162   \param scale vector to compute product with
     163   \param output vector to store restults in
     164
     165*/
     166void fmat_vecmul(fmat_t *s, fvec_t *scale, fvec_t *output);
     167
    159168#ifdef __cplusplus
    160169}
Note: See TracChangeset for help on using the changeset viewer.