From f775bba0207b6de9f28e9432502ab75320e2b583 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Radek=20Hu=C5=A1ek?= <PitelVonSacek@gmail.com> Date: Wed, 9 Dec 2015 15:54:39 +0100 Subject: [PATCH] Split ring definitions into separate file --- Makefile | 2 +- group-connectivity.h | 22 ++-------------------- rings.h | 24 ++++++++++++++++++++++++ 3 files changed, 27 insertions(+), 21 deletions(-) create mode 100644 rings.h diff --git a/Makefile b/Makefile index 572cac9..302acb9 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ default: groupConnectivity.so clean_obj -groupConnectivity.so: groupConnectivity.pyx group-connectivity.h setup.py compileTimeOptions.h parmap.py +groupConnectivity.so: groupConnectivity.pyx group-connectivity.h setup.py compileTimeOptions.h rings.h parmap.py python setup.py build_ext cp build/lib*/groupConnectivity.so . diff --git a/group-connectivity.h b/group-connectivity.h index af2ccb9..d059a16 100644 --- a/group-connectivity.h +++ b/group-connectivity.h @@ -1,28 +1,10 @@ #ifndef __GROUP_CONNECTIVITY_H__ #define __GROUP_CONNECTIVITY_H__ +#include <vector> #include "compileTimeOptions.h" +#include "rings.h" -namespace Ring { - -#define MakeRing(Name, Size, Plus, Negate, Multiply, One) \ -template < typename T_ > struct Name { \ - typedef T_ T; \ - enum { size = Size }; \ - static T plus(T a, T b) { return Plus; } \ - static T negate(T a) { return Negate; } \ - static T multiply(T a, T b) { return Multiply; } \ - static const T one = One; \ - static const T zero = 0; \ -} - -MakeRing(Z5, 5, (a + b) % 5, (5 - a) % 5, (a * b) % 5, 1); -MakeRing(Z4, 4, (a + b) & 3, (4 - a) & 3, (a * b) & 3, 1); -MakeRing(Z2_2, 4, a^b, a, a&b, 3); - -} - -#include <vector> typedef int EdgeId; typedef int DirectedEdgeId; diff --git a/rings.h b/rings.h new file mode 100644 index 0000000..46f6b3e --- /dev/null +++ b/rings.h @@ -0,0 +1,24 @@ +#ifndef __RINGS_H__ +#define __RINGS_H__ + +namespace Ring { + +#define MakeRing(Name, Size, Plus, Negate, Multiply, One) \ +template < typename T_ > struct Name { \ + typedef T_ T; \ + enum { size = Size }; \ + static T plus(T a, T b) { return Plus; } \ + static T negate(T a) { return Negate; } \ + static T multiply(T a, T b) { return Multiply; } \ + static const T one = One; \ + static const T zero = 0; \ +} + +MakeRing(Z5, 5, (a + b) % 5, (5 - a) % 5, (a * b) % 5, 1); +MakeRing(Z4, 4, (a + b) & 3, (4 - a) & 3, (a * b) & 3, 1); +MakeRing(Z2_2, 4, a^b, a, a&b, 3); + +} + +#endif + -- GitLab