added bw_buf_neg()

This commit is contained in:
Stefano D'Angelo 2023-05-12 08:03:45 +02:00
parent c57ddb8877
commit 60ca76b9a3

View File

@ -20,13 +20,18 @@
/*! /*!
* module_type {{{ utility }}} * module_type {{{ utility }}}
* version {{{ 0.4.0 }}} * version {{{ 0.5.0 }}}
* requires {{{ bw_config bw_common }}} * requires {{{ bw_config bw_common }}}
* description {{{ * description {{{
* Common operations on buffers. * Common operations on buffers.
* }}} * }}}
* changelog {{{ * changelog {{{
* <ul> * <ul>
* <li>Version <strong>0.5.0</strong>:
* <ul>
* <li>Added <code>bw_buf_neg()</code>.</li>
* </ul>
* </li>
* <li>Version <strong>0.4.0</strong>: * <li>Version <strong>0.4.0</strong>:
* <ul> * <ul>
* <li>Added <code>bw_buf_fill()</code> and * <li>Added <code>bw_buf_fill()</code> and
@ -58,6 +63,13 @@ static inline void bw_buf_fill(float *dest, float k, int n_elems);
/*! <<<``` /*! <<<```
* Sets the first `n_elems` in `dest` to `k`. * Sets the first `n_elems` in `dest` to `k`.
* *
* #### bw_buf_neg()
* ```>>> */
static inline void bw_buf_neg(float *dest, const float *src, int n_elems);
/*! <<<```
* Inverts the sign of the first `n_elems` in `src` and stores the results in
* the first `n_elems` of `dest`.
*
* #### bw_buf_add() * #### bw_buf_add()
* ```>>> */ * ```>>> */
static inline void bw_buf_add(float *dest, const float *src, float k, int n_elems); static inline void bw_buf_add(float *dest, const float *src, float k, int n_elems);
@ -97,6 +109,11 @@ static inline void bw_buf_fill(float *dest, float k, int n_elems) {
dest[i] = k; dest[i] = k;
} }
static inline void bw_buf_neg(float *dest, const float *src, int n_elems) {
for (int i = 0; i < n_elems; i++)
dest[i] = -src[i];
}
static inline void bw_buf_add(float *dest, const float *src, float k, int n_elems) { static inline void bw_buf_add(float *dest, const float *src, float k, int n_elems) {
for (int i = 0; i < n_elems; i++) for (int i = 0; i < n_elems; i++)
dest[i] = k + src[i]; dest[i] = k + src[i];