A small kernel of code for playing with Galois fields of arbitrary characteristic
Revision | 04d1d84758fa34787698a919567bdc9df96ddf84 (tree) |
---|---|
Zeit | 2016-05-01 11:08:07 |
Autor | Eric Hopper <hopper@omni...> |
Commiter | Eric Hopper |
Utilities for working with Galois fields.
@@ -0,0 +1,16 @@ | ||
1 | +# <gf.gfMeta(5, (1, 4, 1, 4, 1, 4, 1))((0, 0, 0, 0, 1, 3))> | |
2 | + | |
3 | +def gen_groups(l, prime): | |
4 | + size = len(l) | |
5 | + yield (0,) | |
6 | + members = set((0,)) | |
7 | + for i in range(0, len(l)): | |
8 | + if i in members: | |
9 | + continue | |
10 | + group = [] | |
11 | + member = i | |
12 | + while member not in group: | |
13 | + group.append(member) | |
14 | + members.add(member) | |
15 | + member = member * prime % size | |
16 | + yield tuple(group) |