Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes bug in multiplicative_order() #533

Merged
merged 2 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Wait on build.yaml to build the wheel
uses: lewagon/wait-on-check-action@v1.0.0
uses: lewagon/wait-on-check-action@v1.3.1
with:
# When triggered on a pull request, github.sha is a temporary merge commit for the PR. The wait
# action must wait on the SHA of the commit that triggered the workflow, which is the HEAD of the
Expand Down
2 changes: 1 addition & 1 deletion src/galois/_fields/_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions tests/fields/test_arithmetic_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down Expand Up @@ -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"],
Expand Down
Loading