diff --git a/include/bw_buf.h b/include/bw_buf.h
index dbe82c4..7e249dc 100644
--- a/include/bw_buf.h
+++ b/include/bw_buf.h
@@ -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 {{{
*
+ * - Version 0.4.0:
+ *
+ * - Added `bw_buf_add()`.
+ *
+ *
* - Version 0.3.0:
*
* - First release.
@@ -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];