From: Paul Brossier Date: Tue, 29 Jan 2019 02:32:04 +0000 (+0100) Subject: [fmat] add matmul with blas implementation X-Git-Url: https://git.aubio.org/?a=commitdiff_plain;h=7048b566a61e14219d4c8c2789ea312db4ca1dce;p=aubio.git [fmat] add matmul with blas implementation --- diff --git a/src/fmat.c b/src/fmat.c index dd4060f8..393847c9 100644 --- a/src/fmat.c +++ b/src/fmat.c @@ -226,3 +226,27 @@ void fvec_matmul(const fvec_t *scale, const fmat_t *s, fvec_t *output) { #endif #endif } + +void fmat_matmul(const fmat_t *a, const fmat_t *b, fmat_t *c) +{ + AUBIO_ASSERT (a->height == c->height); + AUBIO_ASSERT (a->length == b->height); + AUBIO_ASSERT (b->length == c->length); +#if !defined(HAVE_BLAS) + uint_t i, j, k; + for (i = 0; i < c->height; i++) { + for (j = 0; j < c->length; j++) { + smpl_t sum = 0.; + for (k = 0; k < a->length; k++) { + sum += a->data[0][i * a->length + k] + * b->data[0][k * b->length + j]; + } + c->data[0][i * c->length + j] = sum; + } + } +#else + aubio_cblas__gemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, a->height, + b->length, b->height, 1.F, a->data[0], a->length, b->data[0], + b->length, 0.F, c->data[0], b->length); +#endif +}