added bw_buf_add

This commit is contained in:
Stefano D'Angelo 2023-03-01 07:36:28 +01:00
parent 6fe46ef56b
commit 1843233c96

View File

@ -20,13 +20,18 @@
/*!
* module_type {{{ utility }}}
* version {{{ 0.3.0 }}}
* version {{{ 0.4.0 }}}
* requires {{{ bw_config bw_common }}}
* description {{{
* Common operations on buffers.
* }}}
* changelog {{{
* <ul>
* <li>Version <strong>0.4.0</strong>:
* <ul>
* <li>Added `bw_buf_add()`.</li>
* </ul>
* </li>
* <li>Version <strong>0.3.0</strong>:
* <ul>
* <li>First release.</li>
@ -46,6 +51,13 @@ extern "C" {
#endif
/*! api {{{
* #### bw_buf_add()
* ```>>> */
static inline void bw_buf_add(float *dest, const float *src, float k, int n_elems);
/*! <<<```
* Adds `k` to the first `n_elems` in `src` and stores the results in the
* first `n_elems` of `dest`.
*
* #### bw_buf_scale()
* ```>>> */
static inline void bw_buf_scale(float *dest, const float *src, float k, int n_elems);
@ -73,6 +85,11 @@ static inline void bw_buf_mul(float *dest, const float *src1, const float *src2,
/* WARNING: This part of the file is not part of the public API. Its content may
* change at any time in future versions. Please, do not use it directly. */
static inline void bw_buf_add(float *dest, const float *src, float k, int n_elems) {
for (int i = 0; i < n_elems; i++)
dest[i] = k + src[i];
}
static inline void bw_buf_scale(float *dest, const float *src, float k, int n_elems) {
for (int i = 0; i < n_elems; i++)
dest[i] = k * src[i];