diff --git a/src/galois/_fields/_array.py b/src/galois/_fields/_array.py index 2b978dc36..3fb817798 100644 --- a/src/galois/_fields/_array.py +++ b/src/galois/_fields/_array.py @@ -1044,7 +1044,7 @@ def multiplicative_order(self) -> int | np.ndarray: k = np.log(x) # x as an exponent of α order = (field.order - 1) // np.gcd(field.order - 1, k) else: - d = np.array(divisors(field.order - 1)) # Divisors d such that d | p^m - 1 + d = np.array(divisors(field.order - 1), dtype=field.dtypes[-1]) # Divisors d such that d | p^m - 1 y = np.power.outer(x, d) # x^d -- the first divisor d for which x^d == 1 is the order of x idxs = np.argmin(y, axis=-1) # First index of divisors, which is the order of x order = d[idxs] # The order of each element of x diff --git a/tests/fields/test_arithmetic_methods.py b/tests/fields/test_arithmetic_methods.py index bb6a2ddf3..ca7805527 100644 --- a/tests/fields/test_arithmetic_methods.py +++ b/tests/fields/test_arithmetic_methods.py @@ -6,6 +6,8 @@ import numpy as np import pytest +import galois + def test_additive_order(field_additive_order): GF, X, Z = field_additive_order["GF"], field_additive_order["X"], field_additive_order["Z"] @@ -34,6 +36,14 @@ def test_multiplicative_order(field_multiplicative_order): GF.Range(0, 2).multiplicative_order() +def test_issue_532(): + """ + https://github.com/mhostetter/galois/issues/532 + """ + GF = galois.GF(2**64 - 59) + assert GF(1).multiplicative_order() == 1 + + def test_characteristic_poly_element(field_characteristic_poly_element): GF, X, Z = ( field_characteristic_poly_element["GF"],