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

Bit-packed GF2 #583

Draft
wants to merge 22 commits into
base: release/0.4.x
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
f2e1112
Take a first pass at bitpacked fields.
amirebrahimi Dec 6, 2024
a209f86
Check in WIP on implicit bitpacking
amirebrahimi Dec 10, 2024
3ec5def
Clean up formatting and move towards a more explicit version.
amirebrahimi Dec 11, 2024
27048bc
Check in working matmul (w/ updated numpy)
amirebrahimi Dec 11, 2024
3410deb
Clean up matmul function
amirebrahimi Dec 11, 2024
c63655d
Merge remote-tracking branch 'upstream/main' into explicit
amirebrahimi Dec 11, 2024
d9ba03c
Remove class-level bitpacked field
amirebrahimi Dec 11, 2024
7bf44e4
Fix matmul shape bug and __new__
amirebrahimi Dec 12, 2024
7054295
Override np.packbits and np.unpackbits
amirebrahimi Dec 14, 2024
b9d75e0
Disallow unsupported numpy functions
amirebrahimi Dec 14, 2024
1186fa4
Start work on concatenate, inv, and indexing
amirebrahimi Dec 20, 2024
c07ba0f
Add additional indexing support
amirebrahimi Dec 21, 2024
7c15a85
Add tests for setitem and implement
amirebrahimi Dec 24, 2024
6c1d62f
Get inv working
amirebrahimi Dec 24, 2024
f2b286a
Fix up repacked_index
amirebrahimi Dec 24, 2024
913b95d
Implement bit-packed outer product
amirebrahimi Dec 26, 2024
28267d1
Try normalizing indexing
amirebrahimi Dec 27, 2024
7d44824
Clean up indexing rules
amirebrahimi Dec 31, 2024
57bf589
Fix shape / slice bugs
amirebrahimi Dec 31, 2024
8d2ad26
Normalize to positive indexing; .shape is now the unpacked shape; fix…
amirebrahimi Jan 10, 2025
b2f316c
Add additional tests; Fix multiply/outer product broadcasting
amirebrahimi Jan 11, 2025
c535cd6
Fix up broadcasting in add, sub, div
amirebrahimi Jan 11, 2025
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
4 changes: 2 additions & 2 deletions requirements-min.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
numpy==1.26.0; python_version=="3.12"
numpy==1.23.2; python_version=="3.11"
numpy==1.21.3; python_version=="3.10"
numpy==1.21.0; python_version=="3.9"
numpy==2.0.0; python_version=="3.9"
numpy==1.21.0; python_version=="3.8"
numpy==1.21.0; python_version=="3.7"
numba==0.59.0; python_version=="3.12"
numba==0.57.0; python_version=="3.11"
numba==0.55.0; python_version=="3.10"
numba==0.55.0; python_version=="3.9"
numba==0.60.0; python_version=="3.9"
numba==0.55.0; python_version=="3.8"
numba==0.55.0; python_version=="3.7"
typing_extensions==4.0.0
26 changes: 16 additions & 10 deletions src/galois/_domains/_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,6 @@ class FunctionMixin(np.ndarray, metaclass=ArrayMeta):

_UNSUPPORTED_FUNCTIONS = [
# Unary
np.packbits,
np.unpackbits,
np.unwrap,
np.around,
np.round,
Expand Down Expand Up @@ -334,6 +332,9 @@ class FunctionMixin(np.ndarray, metaclass=ArrayMeta):
np.convolve: "_convolve",
np.fft.fft: "_fft",
np.fft.ifft: "_ifft",
np.packbits: "_packbits",
np.unpackbits: "_unpackbits",
np.concatenate: "_concatenate",
}

_convolve: Function
Expand All @@ -351,9 +352,14 @@ def __array_function__(self, func, types, args, kwargs):
Override the standard NumPy function calls with the new finite field functions.
"""
field = type(self)
output = None

if func in field._OVERRIDDEN_FUNCTIONS:
output = getattr(field, field._OVERRIDDEN_FUNCTIONS[func])(*args, **kwargs)
try:
output = getattr(field, field._OVERRIDDEN_FUNCTIONS[func])(*args, **kwargs)
except AttributeError:
# fall through to use the default numpy function
pass

elif func in field._UNSUPPORTED_FUNCTIONS:
raise NotImplementedError(
Expand All @@ -364,16 +370,16 @@ def __array_function__(self, func, types, args, kwargs):
"`array = array.view(np.ndarray)` and then call the function."
)

else:
if func is np.insert:
args = list(args)
args[2] = self._verify_array_like_types_and_values(args[2])
args = tuple(args)
if func is np.insert:
args = list(args)
args[2] = self._verify_array_like_types_and_values(args[2])
args = tuple(args)

if output is None:
output = super().__array_function__(func, types, args, kwargs)

if func in field._FUNCTIONS_REQUIRING_VIEW:
output = field._view(output) if not np.isscalar(output) else field(output, dtype=self.dtype)
if func in field._FUNCTIONS_REQUIRING_VIEW:
output = field._view(output) if not np.isscalar(output) else field(output, dtype=self.dtype)

return output

Expand Down
Loading