Skip to content
Snippets Groups Projects
Commit a2da36b8 authored by Radek Hušek's avatar Radek Hušek Committed by Radek Hušek
Browse files

Simplify combine() operation

parent 1e3cfb71
Branches
No related tags found
No related merge requests found
...@@ -17,13 +17,11 @@ struct Mapping { ...@@ -17,13 +17,11 @@ struct Mapping {
inline T operator[] (size_t i) const { return data[i]; } inline T operator[] (size_t i) const { return data[i]; }
inline void assign(size_t i, T val) { data[i] = val; } inline void assign(size_t i, T val) { data[i] = val; }
Mapping& combine(T alpha, T beta, const Mapping& b) { Mapping& combine(T beta, const Mapping& b) {
Mapping &a = *this; size_t _size = size();
size_t size = a.size(); for (size_t i = 0; i < _size; i++)
for (size_t i = 0; i < size; i++) data[i] = Ring::plus(data[i], Ring::multiply(beta, b.data[i]));
data[i] = Ring::plus(Ring::multiply(alpha, a.data[i]), return *this;
Ring::multiply(beta, b.data[i]));
return a;
} }
}; };
......
...@@ -91,7 +91,7 @@ struct Tester : public AbstractTester { ...@@ -91,7 +91,7 @@ struct Tester : public AbstractTester {
Mapping& cannonize(Mapping& map) { Mapping& cannonize(Mapping& map) {
for (const auto &i : nonClassEdges) { for (const auto &i : nonClassEdges) {
if (map[i.first] != Ring::zero) if (map[i.first] != Ring::zero)
map.combine(Ring::one, map[i.first], i.second); map.combine(map[i.first], i.second);
} }
return map; return map;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment