...
 
Commits (2)
......@@ -11,6 +11,8 @@ public interface IPermutation<T> : IFiniteGroupElement<T>
int this[int index] { get; }
int SwapsCount { get; }
bool ReducibleTo(int length);
T GetNextPermutation(int maxLength);
T GetPreviousPermutation(int maxLength);
......
......@@ -115,6 +115,10 @@ public struct PermutationByte : IPermutation<P>
return FiniteGroupExtension.Times<P>(this, count);
}
public bool ReducibleTo(int length) {
return _value >> (length << _s) == 0;
}
public P GetNextPermutation(int maxLength, Order<int> match) {
int[] a = ToArray();
a.ApplyNextPermutation<int>(maxLength, match);
......
......@@ -122,6 +122,10 @@ public struct PermutationInt32 : IPermutation<P>
return FiniteGroupExtension.Times<P>(this, count);
}
public bool ReducibleTo(int length) {
return (_value & (-1 << (length << _s))) == 0;
}
public P GetNextPermutation(int maxLength, Order<int> match) {
int[] a = ToArray();
a.ApplyNextPermutation<int>(maxLength, match);
......
......@@ -127,6 +127,10 @@ public struct PermutationInt64 : IPermutation<P>
return FiniteGroupExtension.Times<P>(this, count);
}
public bool ReducibleTo(int length) {
return (_value & (-1L << (length << _s))) == 0L;
}
public P GetNextPermutation(int maxLength, Order<int> match) {
int[] a = ToArray();
a.ApplyNextPermutation<int>(maxLength, match);
......
......@@ -258,7 +258,7 @@ private sealed class InternalGroup : FiniteGroup<T>
v ^= ((b << p[1]) & 0xF ^ v) << 4;
/*//
for(byte i = 0, l = 2; i < _dimCount; ++i, l <<= 1)
v ^= ((1 << l) - 1 & (b << p[i]) ^ v) << l;
v ^= (((-1 << l) ^ -1) & (b << p[i]) ^ v) << l;
//*/
return PermutationByte.FromByteInternal((byte)v);
}
......
......@@ -113,7 +113,7 @@ private sealed class InternalGroup : FiniteGroup<T>
}
private const byte _dimCount = 3;
private const short _s = 4, _perm = (1 << _s) - 1;
private const short _s = 4, _perm = (-1 << _s) ^ -1;
public bool IsReflection { get { return !IsRotation; } }
public bool IsRotation {
......@@ -178,7 +178,7 @@ private sealed class InternalGroup : FiniteGroup<T>
int v = Vertex;
const int b = 0x11111111;
for(byte i = 0, l = 4; i < _dimCount; ++i, l <<= 1)
v ^= ((1 << l) - 1 & (b << p[i]) ^ v) << l;
v ^= (((-1 << l) ^ -1) & (b << p[i]) ^ v) << l;
return PermutationInt32.FromInt32Internal(v);
}
......
......@@ -96,7 +96,7 @@ private sealed class InternalGroup : FiniteGroup<T>
}
private const byte _dimCount = 4;
private const short _s = 8, _perm = (1 << _s) - 1;
private const short _s = 8, _perm = (-1 << _s) ^ -1;
public bool IsReflection { get { return !IsRotation; } }
public bool IsRotation {
......