[4c33f81] | 1 | /* |
---|
| 2 | Copyright (C) 2018 Paul Brossier <piem@aubio.org> |
---|
| 3 | |
---|
| 4 | This file is part of aubio. |
---|
| 5 | |
---|
| 6 | aubio is free software: you can redistribute it and/or modify |
---|
| 7 | it under the terms of the GNU General Public License as published by |
---|
| 8 | the Free Software Foundation, either version 3 of the License, or |
---|
| 9 | (at your option) any later version. |
---|
| 10 | |
---|
| 11 | aubio is distributed in the hope that it will be useful, |
---|
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 14 | GNU General Public License for more details. |
---|
| 15 | |
---|
| 16 | You should have received a copy of the GNU General Public License |
---|
| 17 | along with aubio. If not, see <http://www.gnu.org/licenses/>. |
---|
| 18 | |
---|
| 19 | */ |
---|
| 20 | |
---|
| 21 | #ifndef AUBIO_TENSOR_H |
---|
| 22 | #define AUBIO_TENSOR_H |
---|
| 23 | |
---|
| 24 | #ifdef __cplusplus |
---|
| 25 | extern "C" { |
---|
| 26 | #endif |
---|
| 27 | |
---|
| 28 | typedef struct { |
---|
[9ca7923] | 29 | uint_t ndim; //< number of dimensions |
---|
| 30 | uint_t shape[8]; //< dimensions array |
---|
| 31 | smpl_t **data; //< buffer of values |
---|
| 32 | uint_t size; //< total number of elements |
---|
[4c33f81] | 33 | } aubio_tensor_t; |
---|
| 34 | |
---|
[5010e61] | 35 | aubio_tensor_t *new_aubio_tensor(uint_t ndim, uint_t *shape); |
---|
[4c33f81] | 36 | |
---|
| 37 | void del_aubio_tensor(aubio_tensor_t *c); |
---|
| 38 | |
---|
| 39 | uint_t aubio_tensor_as_fvec(aubio_tensor_t *c, fvec_t *o); |
---|
| 40 | uint_t aubio_fvec_as_tensor(fvec_t *o, aubio_tensor_t *c); |
---|
| 41 | |
---|
| 42 | uint_t aubio_tensor_as_fmat(aubio_tensor_t *c, fmat_t *o); |
---|
| 43 | uint_t aubio_fmat_as_tensor(fmat_t *o, aubio_tensor_t *c); |
---|
| 44 | |
---|
| 45 | smpl_t aubio_tensor_max(aubio_tensor_t *t); |
---|
| 46 | |
---|
| 47 | #define AUBIO_ASSERT_EQUAL_SHAPE(t1, t2) { \ |
---|
| 48 | AUBIO_ASSERT(t1 && t2); \ |
---|
[5010e61] | 49 | AUBIO_ASSERT(t1->ndim == t2->ndim); \ |
---|
[4c33f81] | 50 | uint_t nn; \ |
---|
[5010e61] | 51 | for (nn = 0; nn < t1->ndim; nn++) \ |
---|
| 52 | AUBIO_ASSERT(t1->shape[nn] == t2->shape[nn]); \ |
---|
[4c33f81] | 53 | } |
---|
| 54 | |
---|
| 55 | #ifdef __cplusplus |
---|
| 56 | } |
---|
| 57 | #endif |
---|
| 58 | |
---|
| 59 | #endif /* AUBIO_TENSOR_H */ |
---|