...
 
Commits (4)
......@@ -26,6 +26,52 @@ public static int GetCyclesCountNonTrivial<T>(this T _this)
return _this.GetCyclesCount(i => i > 1);
}
public static byte GetNext<T>(this byte v, T p)
where T : IPermutation<T>, new()
{
return (byte)GetNext<T>(v, p, 8);
}
public static byte GetPrev<T>(this byte v, T p)
where T : IPermutation<T>, new()
{
return (byte)GetPrev<T>(v, p, 8);
}
public static short GetNext<T>(this short v, T p)
where T : IPermutation<T>, new()
{
return (short)GetNext<T>(v, p, 16);
}
public static short GetPrev<T>(this short v, T p)
where T : IPermutation<T>, new()
{
return (short)GetPrev<T>(v, p, 16);
}
public static int GetNext<T>(this int v, T p)
where T : IPermutation<T>, new()
{
return GetNext<T>(v, p, 32);
}
public static int GetPrev<T>(this int v, T p)
where T : IPermutation<T>, new()
{
return GetPrev<T>(v, p, 32);
}
public static int GetNext<T>(this int v, T p, byte size)
where T : IPermutation<T>, new()
{
int r = 0;
for(byte i = 0; i < size; ++i)
r |= (v >> p[i] & 1) << i;
return r;
}
public static int GetPrev<T>(this int v, T p, byte size)
where T : IPermutation<T>, new()
{
int r = 0;
for(byte i = 0; i < size; ++i)
r |= (v >> i & 1) << p[i];
return r;
}
public static int GetNextVertex<T>(this T p, int v)
where T : IPermutation<T>, new()
{
......
......@@ -194,19 +194,19 @@ private sealed class RotationsGroup : FlipRotateGroup
public T InverseElement {
get {
P p = -Permutation;
return new T(p, p.GetNextVertex<P>(Vertex));
return new T(p, _vertex.GetPrev<P>(p));
}
}
public T Add(T other) {
P p = Permutation;
return new T(p + other.Permutation,
p.GetNextVertex<P>(other.Vertex) ^ Vertex
_vertex ^ other._vertex.GetPrev<P>(p)
);
}
public T Subtract(T other) {
P p = Permutation - other.Permutation;
return new T(p,
p.GetNextVertex<P>(other.Vertex) ^ Vertex
_vertex ^ other._vertex.GetPrev<P>(p)
);
}
public T Times(int count) {
......
......@@ -220,19 +220,19 @@ private sealed class RotationsGroup : FlipRotateGroup
public T InverseElement {
get {
P p = -Permutation;
return new T(p._value, p.GetNextVertex<P>(Vertex));
return new T(p._value, Vertex.GetPrev<P>(p, _dimCount));
}
}
public T Add(T other) {
P p = Permutation;
return new T((p + other.Permutation)._value,
p.GetNextVertex<P>(other.Vertex) ^ Vertex
Vertex ^ other.Vertex.GetPrev<P>(p, _dimCount)
);
}
public T Subtract(T other) {
P p = Permutation - other.Permutation;
return new T(p._value,
p.GetNextVertex<P>(other.Vertex) ^ Vertex
Vertex ^ other.Vertex.GetPrev<P>(p, _dimCount)
);
}
public T Times(int count) {
......
......@@ -194,19 +194,19 @@ private sealed class RotationsGroup : FlipRotateGroup
public T InverseElement {
get {
P p = -Permutation;
return new T(p, p.GetNextVertex<P>(Vertex));
return new T(p, Vertex.GetPrev<P>(p, _dimCount));
}
}
public T Add(T other) {
P p = Permutation;
return new T(p + other.Permutation,
p.GetNextVertex<P>(other.Vertex) ^ Vertex
Vertex ^ other.Vertex.GetPrev<P>(p, _dimCount)
);
}
public T Subtract(T other) {
P p = Permutation - other.Permutation;
return new T(p,
p.GetNextVertex<P>(other.Vertex) ^ Vertex
Vertex ^ other.Vertex.GetPrev<P>(p, _dimCount)
);
}
public T Times(int count) {
......
......@@ -203,19 +203,19 @@ private sealed class RotationsGroup : FlipRotateGroup
public T InverseElement {
get {
P p = -Permutation;
return new T(p, p.GetNextVertex<P>(Vertex));
return new T(p, Vertex.GetPrev<P>(p, _dimCount));
}
}
public T Add(T other) {
P p = Permutation;
return new T(p + other.Permutation,
p.GetNextVertex<P>(other.Vertex) ^ Vertex
Vertex ^ other.Vertex.GetPrev<P>(p, _dimCount)
);
}
public T Subtract(T other) {
P p = Permutation - other.Permutation;
return new T(p,
p.GetNextVertex<P>(other.Vertex) ^ Vertex
Vertex ^ other.Vertex.GetPrev<P>(p, _dimCount)
);
}
public T Times(int count) {
......