diff --git a/Makefile b/Makefile index 572cac9d2733af7d59da56f26fb11da42ee70f88..302acb997c5878f5648c507bc14c60372307f85a 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 af2ccb972a82225d065012bd0f8d5ff973cb1419..d059a169fb36e64963b9bedd40cd56541321d160 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 0000000000000000000000000000000000000000..46f6b3edce909d7a96e2726f18d5fb073bce9caf --- /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 +