...
 
Commits (3)
......@@ -18,10 +18,6 @@ public struct PermutationByte : IPermutation<P>
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
internal readonly byte _value;
internal PermutationByte(byte value) { _value = value; }
internal PermutationByte(short value) {
value = (short)(((short)(value >> 2) | value) & 0x0F0F);
_value = (byte)((short)(value >> 4) | value);
}
public PermutationByte(params byte[] array) : this((IEnumerable<byte>)array) { }
public PermutationByte(IEnumerable<byte> collection) {
if(ReferenceEquals(collection, null))
......@@ -262,6 +258,9 @@ public struct PermutationByte : IPermutation<P>
}
return new P((byte)(_mix ^ value));
}
internal static P FromByteInternal(byte value) {
return new P((byte)(value ^ _mix));
}
public static P FromByte(byte value) {
byte startIndex = 0;
for(byte digit = 0; digit < _count; ++digit) {
......@@ -278,6 +277,11 @@ public struct PermutationByte : IPermutation<P>
}
return new P((byte)(_mix ^ value));
}
private static P FromInt16Internal(short value) {
value = (short)(((short)(value >> 2) | value) & 0x0F0F);
value = (short)(((short)(value >> 4) | value) & 0x00FF);
return new P((byte)(value ^ _mix));
}
public static P FromInt16(short value) {
if((value & -0x3334) != 0)
_throwInt16(string.Format(
......@@ -294,10 +298,10 @@ public struct PermutationByte : IPermutation<P>
"Digit \'{0}\' is not found.",
(char)(digit | '0')
));
else return new P((short)(((1 << (digit << 2)) - 1) & 0x3210 ^ value));
else return FromInt16Internal((short)((-1 << (digit << 2)) & 0x3210 ^ value));
else if(startIndex < i) startIndex = i;
}
return new P((short)(0x3210 ^ value));
return FromInt16Internal(value);
}
[DebuggerStepThrough]
private static void _throwString(string message) {
......
......@@ -195,10 +195,12 @@ private sealed class InternalGroup : FiniteGroup<T>
/// </return></summary>
public bool IsSwapDimensions { get { return Value > 3; } }
P IFlipRotate<T, P>.Permutation {
public P Permutation {
get { return new P((byte)((Value >> 2) * 5)); }
}
public int Vertex { get { return 0x6C9C >> (Value << 1) & 3; } }
public int Vertex {
get { return 0x6C9C >> (Value << 1) & 3; }
}
/// <summary>
/// The order of a cyclic group that can be generated by this element.
......@@ -258,7 +260,7 @@ private sealed class InternalGroup : FiniteGroup<T>
for(byte i = 0, l = 2; i < _dimCount; ++i, l <<= 1)
v ^= ((1 << l) - 1 & (b << p[i]) ^ v) << l;
//*/
return new PermutationByte((byte)(v ^ 0xE4));
return PermutationByte.FromByteInternal((byte)v);
}
public RotateFlipType ToRotateFlipType() {
return (RotateFlipType)(0x31756420 >> (Value << 2) & 7);
......