initialize buffer with provided neutral element

This commit is contained in:
Ahmet Inan 2020-10-10 23:30:17 +02:00
commit 18a72daa4c
2 changed files with 5 additions and 2 deletions

3
sma.hh
View file

@ -85,6 +85,9 @@ class SMA4
struct Add { TYPE operator () (TYPE a, TYPE b) { return a + b; } }; struct Add { TYPE operator () (TYPE a, TYPE b) { return a + b; } };
SWA<TYPE, Add, NUM> swa; SWA<TYPE, Add, NUM> swa;
public: public:
SMA4() : swa(0)
{
}
TYPE operator () (TYPE input) TYPE operator () (TYPE input)
{ {
if (NORM) if (NORM)

4
swa.hh
View file

@ -15,10 +15,10 @@ class SWA
int leaf; int leaf;
OP op; OP op;
public: public:
SWA() : leaf(NUM) SWA(TYPE ident) : leaf(NUM)
{ {
for (int i = 0; i < 2 * NUM; ++i) for (int i = 0; i < 2 * NUM; ++i)
tree[i] = 0; tree[i] = ident;
} }
TYPE operator () (TYPE input) TYPE operator () (TYPE input)
{ {