コード例 #1
0
def symplectic_2_gcd(n):
    """Returns GCD(m_1(G), m_2(G)) for G=Sp(2n, 2)
    """
    if n == 3:
        return 3
    if n == 4:
        return 6
    if n == 5:
        return 3
    if n == 6:
        return 15
    if n >= 7 and numeric.is_power_of_two(n + 1):
        return 2**((n + 1) // 2) - 1
    if n >= 8 and numeric.is_power_of_two(n):
        return 2**(n // 2) - 1
    if n >= 9 and numeric.is_power_of_two(n - 1):
        return 2 * (2**((n - 1) // 2) - 1)
    if n >= 10 and numeric.is_power_of_two(n - 2):
        return 2**(n // 2 - 1) - 1
    if n >= 11 and _is_power_of_two_by_three(n + 1):
        return 2**((n + 1) // 3) - 1
    if n >= 12 and _is_power_of_two_by_three(n):
        return 2**(n // 3) - 1
    if n >= 13 and _is_power_of_two_by_three(n - 1):
        return 2 * (2**((n - 1) // 3) - 1)
    if n >= 14 and _is_power_of_two_by_three(n - 2):
        return 2**((2 * n - 4) // 3) - 1
    if n % 2 == 1:
        two_p = 2**(((n - 1) // 3).bit_length())
        return 2 * (2**two_p - 1)
    if n % 2 == 0:
        two_p = 2**((n // 3).bit_length())
        return 2**two_p - 1
コード例 #2
0
ファイル: max_orders.py プロジェクト: hobbitzero/calculations
def symplectic_2_gcd(n):
    """Returns GCD(m_1(G), m_2(G)) for G=Sp(2n, 2)
    """
    if n == 3:
        return 3
    if n == 4:
        return 6
    if n == 5:
        return 3
    if n == 6:
        return 15
    if n >= 7 and numeric.is_power_of_two(n + 1):
        return 2 ** ((n + 1) // 2) - 1
    if n >= 8 and numeric.is_power_of_two(n):
        return 2 ** (n // 2) - 1
    if n >= 9 and numeric.is_power_of_two(n - 1):
        return 2 * (2 ** ((n - 1) // 2) - 1)
    if n >= 10 and numeric.is_power_of_two(n - 2):
        return 2 ** (n // 2 - 1) - 1
    if n >= 11 and _is_power_of_two_by_three(n + 1):
        return 2 ** ((n + 1) // 3) - 1
    if n >= 12 and _is_power_of_two_by_three(n):
        return 2 ** (n // 3) - 1
    if n >= 13 and _is_power_of_two_by_three(n - 1):
        return 2 * (2 ** ((n - 1) // 3) - 1)
    if n >= 14 and _is_power_of_two_by_three(n - 2):
        return 2 ** ((2 * n - 4) // 3) - 1
    if n % 2 == 1:
        two_p = 2 ** (((n - 1) // 3).bit_length())
        return 2 * (2 ** two_p - 1)
    if n % 2 == 0:
        two_p = 2 ** ((n // 3).bit_length())
        return 2 ** two_p - 1
コード例 #3
0
def symplectic_2(n):
    """Returns tuple with two maximal orders for Sp(2n, 2)
    """
    if n == 3:
        return 15, 12
    if n == 4:
        return 30, 24
    if n == 5:
        return 60, 51
    if n == 6:
        return 120, 105
    if n >= 7 and numeric.is_power_of_two(n + 1):
        return 2 ** (n + 1) - 1, 2 * (2 ** ((n + 1) // 2) - 1) * (
            2 ** ((n - 1) // 2) - 1)
    if n >= 8 and numeric.is_power_of_two(n):
        return 2 ** (n + 1) - 2, (2 ** (n // 2) - 1) * (2 ** (n // 2 + 1) - 1)
    if n >= 9 and numeric.is_power_of_two(n - 1):
        return 2 ** (n + 1) - 4, 2 * (2 ** ((n + 1) // 2) - 1) * (
            2 ** ((n - 1) // 2) - 1)
    if n >= 10 and numeric.is_power_of_two(n - 2):
        return 2 ** (n + 1) - 8, (2 ** (n // 2 - 1) - 1) * (
            2 ** (n // 2 + 2) - 1)
    if n >= 11 and _is_power_of_two_by_three(n + 1):
        return (2 ** ((2 * n + 2) // 3) + 1) * (2 ** ((n + 1) // 3) - 1), 2 * (
            2 ** ((n + 1) // 3) - 1) * (2 ** ((2 * n - 1) // 3) - 1)
    if n >= 12 and _is_power_of_two_by_three(n):
        return (2 ** (2 * n // 3) - 1) * (2 ** (n // 3 + 1) - 1), 2 * (
            2 ** (n // 3) - 1) * (2 ** (2 * n // 3) + 1)
    if n >= 13 and _is_power_of_two_by_three(n - 1):
        return 2 * (2 ** ((2 * n - 2) // 3) - 1) * (
            2 ** ((n + 2) // 3) - 1), 4 * (2 ** ((n - 1) // 3) - 1) * (
            2 ** ((2 * n - 2) // 3) + 1)
    if n >= 14 and _is_power_of_two_by_three(n - 2):
        return (2 ** ((2 * n - 4) // 3) - 1) * (2 ** ((n + 7) // 3) - 1), 4 * (
            2 ** ((2 * n - 4) // 3) - 1) * (2 ** ((n + 1) // 3) - 1)
    if n % 2 == 1:
        two_p = 2 ** (((n - 1) // 3).bit_length())
        return 2 * (2 ** two_p - 1) * (2 ** (n - two_p) - 1), 8 * (
            2 ** two_p - 1) * (2 ** (n - two_p - 2) - 1)
    if n % 2 == 0:
        two_p = 2 ** ((n // 3).bit_length())
        return (2 ** two_p - 1) * (2 ** (n + 1 - two_p) - 1), 4 * (
            2 ** two_p - 1) * (2 ** (n - 1 - two_p) - 1)
コード例 #4
0
def _is_power_of_two_by_three(n):
    """Returns whether n is a power of 2 multiplied by 3
    """
    return n % 3 == 0 and numeric.is_power_of_two(n // 3)
コード例 #5
0
ファイル: max_orders.py プロジェクト: hobbitzero/calculations
def _is_power_of_two_by_three(n):
    """Returns whether n is a power of 2 multiplied by 3
    """
    return n % 3 == 0 and numeric.is_power_of_two(n // 3)