Skip to content

Commit cb94875

Browse files
rafaelhamhostetter
authored andcommitted
Convert to int for faster mod
1 parent 5548ef0 commit cb94875

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/galois/_domains/_linalg.py

+6
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ def _lapack_linalg(field: Type[Array], a: Array, b: Array, function, out=None, n
5858
c = function(a, b)
5959
else:
6060
c = function(a, b, out=out)
61+
62+
if dtype in [np.float32, np.float64]:
63+
# Performing the modulo operation on an int is faster than a float. Convert back to int64 for the time
64+
# savings, if possible.
65+
c = c.astype(np.int64)
66+
6167
c = c % field.characteristic # Reduce the result mod p
6268

6369
if np.isscalar(c):

0 commit comments

Comments
 (0)