2 Copyright (C) 2009-2015 Paul Brossier <piem@aubio.org>
4 This file is part of aubio.
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.
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.
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/>.
30 Matrix of real valued data
32 This file specifies the fmat_t type, which is used in aubio to store arrays
33 of floating point values.
39 /** Buffer for real data */
41 uint_t length; /**< length of matrix */
42 uint_t height; /**< height of matrix */
43 smpl_t **data; /**< data array of size [length] * [height] */
46 /** fmat_t buffer creation function
48 \param length the length of the matrix to create
49 \param height the height of the matrix to create
52 fmat_t * new_fmat(uint_t height, uint_t length);
54 /** fmat_t buffer deletion function
56 \param s buffer to delete as returned by new_fmat()
59 void del_fmat(fmat_t *s);
61 /** read sample value in a buffer
63 \param s vector to read from
64 \param channel channel to read from
65 \param position sample position to read from
68 smpl_t fmat_get_sample(const fmat_t *s, uint_t channel, uint_t position);
70 /** write sample value in a buffer
72 \param s vector to write to
73 \param data value to write in s->data[channel][position]
74 \param channel channel to write to
75 \param position sample position to write to
78 void fmat_set_sample(fmat_t *s, smpl_t data, uint_t channel, uint_t position);
80 /** read channel vector from a buffer
82 \param s vector to read from
83 \param channel channel to read from
84 \param output ::fvec_t to output to
87 void fmat_get_channel (const fmat_t *s, uint_t channel, fvec_t *output);
89 /** get vector buffer from an fmat data
91 \param s vector to read from
92 \param channel channel to read from
95 smpl_t * fmat_get_channel_data (const fmat_t *s, uint_t channel);
97 /** read data from a buffer
99 \param s vector to read from
102 smpl_t ** fmat_get_data(const fmat_t *s);
104 /** print out fmat data
106 \param s vector to print out
109 void fmat_print(const fmat_t *s);
111 /** set all elements to a given value
113 \param s vector to modify
114 \param val value to set elements to
117 void fmat_set(fmat_t *s, smpl_t val);
119 /** set all elements to zero
121 \param s vector to modify
124 void fmat_zeros(fmat_t *s);
126 /** set all elements to ones
128 \param s vector to modify
131 void fmat_ones(fmat_t *s);
133 /** revert order of vector elements
135 \param s vector to revert
138 void fmat_rev(fmat_t *s);
140 /** apply weight to vector
142 If the weight vector is longer than s, only the first elements are used. If
143 the weight vector is shorter than s, the last elements of s are not weighted.
145 \param s vector to weight
146 \param weight weighting coefficients
149 void fmat_weight(fmat_t *s, const fmat_t *weight);
151 /** make a copy of a matrix
153 \param s source vector
154 \param t vector to copy to
157 void fmat_copy(const fmat_t *s, fmat_t *t);
159 /** compute the product of a matrix by a vector
161 \param s matrix to compute product with
162 \param scale vector to compute product with
163 \param output vector to store restults in
166 void fmat_vecmul(const fmat_t *s, const fvec_t *scale, fvec_t *output);
172 #endif /* AUBIO_FMAT_H */