[fvec] add fvec_vecadd
authorPaul Brossier <piem@piem.org>
Mon, 7 Jan 2019 21:19:48 +0000 (22:19 +0100)
committerPaul Brossier <piem@piem.org>
Mon, 7 Jan 2019 21:19:48 +0000 (22:19 +0100)
src/fvec.c
src/fvec.h

index 3bb0b17..60c3717 100644 (file)
@@ -98,6 +98,14 @@ void fvec_rev(fvec_t *s) {
   }
 }
 
+void fvec_vecadd(fvec_t *s, const fvec_t *bias) {
+  uint_t j;
+  uint_t length = MIN(s->length, bias->length);
+  for (j = 0; j < length; j++) {
+    s->data[j] += bias->data[j];
+  }
+}
+
 void fvec_weight(fvec_t *s, const fvec_t *weight) {
   uint_t length = MIN(s->length, weight->length);
 #if defined(HAVE_INTEL_IPP)
index bd8c5a6..1586e3f 100644 (file)
@@ -143,6 +143,16 @@ void fvec_ones(fvec_t *s);
 */
 void fvec_rev(fvec_t *s);
 
+/** add a vector b to vector a, modifying a
+
+  \param a  input vector to add b to
+  \param b  input vector of the values to be added to a
+
+  Upon return, he content of a[i] will be set to a[i] + b[i].
+
+*/
+void fvec_vecadd(fvec_t *a, const fvec_t *b);
+
 /** apply weight to vector
 
   If the weight vector is longer than s, only the first elements are used. If