From 18a72daa4c250459de1334522cf7a914ce8d8068 Mon Sep 17 00:00:00 2001 From: Ahmet Inan Date: Sat, 10 Oct 2020 23:30:17 +0200 Subject: [PATCH] initialize buffer with provided neutral element --- sma.hh | 3 +++ swa.hh | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/sma.hh b/sma.hh index aaac5e1..5000c76 100644 --- a/sma.hh +++ b/sma.hh @@ -85,6 +85,9 @@ class SMA4 struct Add { TYPE operator () (TYPE a, TYPE b) { return a + b; } }; SWA swa; public: + SMA4() : swa(0) + { + } TYPE operator () (TYPE input) { if (NORM) diff --git a/swa.hh b/swa.hh index c92e649..9909232 100644 --- a/swa.hh +++ b/swa.hh @@ -15,10 +15,10 @@ class SWA int leaf; OP op; public: - SWA() : leaf(NUM) + SWA(TYPE ident) : leaf(NUM) { for (int i = 0; i < 2 * NUM; ++i) - tree[i] = 0; + tree[i] = ident; } TYPE operator () (TYPE input) {