Loading...
Searching...
No Matches
fmat.h
Go to the documentation of this file.
/*
Copyright (C) 2009-2015 Paul Brossier <piem@aubio.org>
This file is part of aubio.
aubio is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
aubio is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with aubio. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef AUBIO_FMAT_H
#define AUBIO_FMAT_H
#ifdef __cplusplus
extern "C" {
#endif
/** \file
Matrix of real valued data
This file specifies the fmat_t type, which is used in aubio to store arrays
of floating point values.
\example test-fmat.c
*/
/** Buffer for real data */
typedef struct {
uint_t length; /**< length of matrix */
uint_t height; /**< height of matrix */
smpl_t **data; /**< data array of size [length] * [height] */
} fmat_t;
/** fmat_t buffer creation function
\param length the length of the matrix to create
\param height the height of the matrix to create
*/
fmat_t * new_fmat(uint_t height, uint_t length);
/** fmat_t buffer deletion function
\param s buffer to delete as returned by new_fmat()
*/
void del_fmat(fmat_t *s);
/** read sample value in a buffer
\param s vector to read from
\param channel channel to read from
\param position sample position to read from
*/
smpl_t fmat_get_sample(const fmat_t *s, uint_t channel, uint_t position);
/** write sample value in a buffer
\param s vector to write to
\param data value to write in s->data[channel][position]
\param channel channel to write to
\param position sample position to write to
*/
void fmat_set_sample(fmat_t *s, smpl_t data, uint_t channel, uint_t position);
/** read channel vector from a buffer
\param s vector to read from
\param channel channel to read from
\param output ::fvec_t to output to
*/
void fmat_get_channel (const fmat_t *s, uint_t channel, fvec_t *output);
/** get vector buffer from an fmat data
\param s vector to read from
\param channel channel to read from
*/
smpl_t * fmat_get_channel_data (const fmat_t *s, uint_t channel);
/** read data from a buffer
\param s vector to read from
*/
smpl_t ** fmat_get_data(const fmat_t *s);
/** print out fmat data
\param s vector to print out
*/
void fmat_print(const fmat_t *s);
/** set all elements to a given value
\param s vector to modify
\param val value to set elements to
*/
void fmat_set(fmat_t *s, smpl_t val);
/** set all elements to zero
\param s vector to modify
*/
void fmat_zeros(fmat_t *s);
/** set all elements to ones
\param s vector to modify
*/
void fmat_ones(fmat_t *s);
/** revert order of vector elements
\param s vector to revert
*/
void fmat_rev(fmat_t *s);
/** apply weight to vector
If the weight vector is longer than s, only the first elements are used. If
the weight vector is shorter than s, the last elements of s are not weighted.
\param s vector to weight
\param weight weighting coefficients
*/
void fmat_weight(fmat_t *s, const fmat_t *weight);
/** make a copy of a matrix
\param s source vector
\param t vector to copy to
*/
void fmat_copy(const fmat_t *s, fmat_t *t);
/** compute the product of a matrix by a vector
\param s matrix to compute product with
\param scale vector to compute product with
\param output vector to store restults in
*/
void fmat_vecmul(const fmat_t *s, const fvec_t *scale, fvec_t *output);
#ifdef __cplusplus
}
#endif
#endif /* AUBIO_FMAT_H */
fmat_get_channel_data
smpl_t * fmat_get_channel_data(const fmat_t *s, uint_t channel)
get vector buffer from an fmat data
fmat_zeros
void fmat_zeros(fmat_t *s)
set all elements to zero
fmat_print
void fmat_print(const fmat_t *s)
print out fmat data
del_fmat
void del_fmat(fmat_t *s)
fmat_t buffer deletion function
fmat_weight
void fmat_weight(fmat_t *s, const fmat_t *weight)
apply weight to vector
fmat_copy
void fmat_copy(const fmat_t *s, fmat_t *t)
make a copy of a matrix
fmat_rev
void fmat_rev(fmat_t *s)
revert order of vector elements
fmat_set_sample
void fmat_set_sample(fmat_t *s, smpl_t data, uint_t channel, uint_t position)
write sample value in a buffer
fmat_get_data
smpl_t ** fmat_get_data(const fmat_t *s)
read data from a buffer
fmat_ones
void fmat_ones(fmat_t *s)
set all elements to ones
fmat_vecmul
void fmat_vecmul(const fmat_t *s, const fvec_t *scale, fvec_t *output)
compute the product of a matrix by a vector
fmat_set
void fmat_set(fmat_t *s, smpl_t val)
set all elements to a given value
fmat_get_channel
void fmat_get_channel(const fmat_t *s, uint_t channel, fvec_t *output)
read channel vector from a buffer
new_fmat
fmat_t * new_fmat(uint_t height, uint_t length)
fmat_t buffer creation function
fmat_get_sample
smpl_t fmat_get_sample(const fmat_t *s, uint_t channel, uint_t position)
read sample value in a buffer
fmat_t
Buffer for real data.
Definition fmat.h:40
fmat_t::data
smpl_t ** data
data array of size [length] * [height]
Definition fmat.h:43
fmat_t::length
uint_t length
length of matrix
Definition fmat.h:41
fmat_t::height
uint_t height
height of matrix
Definition fmat.h:42
fvec_t
Buffer for real data.
Definition fvec.h:67
uint_t
unsigned int uint_t
unsigned integer
Definition types.h:60
smpl_t
float smpl_t
short sample format (32 or 64 bits)
Definition types.h:41