unsigned long staticity( method const& m ) { unsigned long s = 0ul; //1ul; for ( int i=0, b=m.bells(); i!=b-1; ++i) { int j=0, l=m.size(); while ( j!=l && ( m[j].findswap(i) || m[j].findplace(i) && m[j].findplace(i+1) ) ) ++j; if (j==l) return static_cast<unsigned long>(-1); for ( int k=j; k<j+l; ++k ) { int k0=k; while ( k!=j+l && ( m[k%l].findswap(i) || m[k%l].findplace(i) && m[k%l].findplace(i+1) ) ) ++k; if (k!=k0) { // s *= ipower( 2, k-k0-1 ); s += k-k0-1; } } } return s; }
bool has_mirror_symmetry( const method& m ) { const int n( m.size() ); for ( int i=0; i<n; ++i ) if ( m[i] != m[i].reverse() ) return false; return true; }
bool has_glide_symmetry( const method& m ) { const int n( m.size() ); if ( n % 2 == 1 ) return false; for ( int i=0; i<n/2; ++i ) if ( m[i] != m[(i + n/2) % n].reverse() ) return false; return true; }
bool has_conventional_symmetry( const method& m ) { const int n( m.size() ); for ( int i=0; i < (n%2==0 ? n/2 : n); ++i ) { // try m[i] as the sym point bool ok(true); for ( int j=1; ok && j<(n%2==0 ? n/2 : n/2+1); ++j ) if ( m[(i+j) % n] != m[(i-j+n) % n] ) ok = false; if (ok) return true; } return false; }
bool has_rotational_symmetry( const method &m ) { const int n( m.size() ); { // Rotational symmetry about a change for ( int i=0; i<n/2+1; ++i ) { // Try m[i] as the rotational symmetry point bool ok = true; for ( int j=0; j<n/2+1 && ok; ++j ) if ( m[ (i+j)%n ] != m[ (n+i-j)%n ].reverse() ) ok = false; if (ok) return true; } } { // Rotational symmetry about a row for ( int i=0; i<n/2+1; ++i ) { // Try m[i] / m[(i+1)%n] as the rotational symmetry point bool ok = true; for ( int j=0; j<n/2 && ok; ++j ) if ( m[ (i+j+1)%n ] != m[ (n+i-j)%n ].reverse() ) ok = false; if (ok) return true; } } return false; }