diff options
author | Tim Peters <tim.peters@gmail.com> | 2004-07-18 06:16:08 (GMT) |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2004-07-18 06:16:08 (GMT) |
commit | 182b5aca27d376b08a2904bed42b751496f932f3 (patch) | |
tree | df13115820dbc879c0fe2eae488c9f8c0215a7da /Lib/lib-old/zmod.py | |
parent | e6ddc8b20b493fef2e7cffb2e1351fe1d238857e (diff) | |
download | cpython-182b5aca27d376b08a2904bed42b751496f932f3.zip cpython-182b5aca27d376b08a2904bed42b751496f932f3.tar.gz cpython-182b5aca27d376b08a2904bed42b751496f932f3.tar.bz2 |
Whitespace normalization, via reindent.py.
Diffstat (limited to 'Lib/lib-old/zmod.py')
-rw-r--r-- | Lib/lib-old/zmod.py | 86 |
1 files changed, 43 insertions, 43 deletions
diff --git a/Lib/lib-old/zmod.py b/Lib/lib-old/zmod.py index 7259bf8..55f49df 100644 --- a/Lib/lib-old/zmod.py +++ b/Lib/lib-old/zmod.py @@ -1,7 +1,7 @@ # module 'zmod' # Compute properties of mathematical "fields" formed by taking -# Z/n (the whole numbers modulo some whole number n) and an +# Z/n (the whole numbers modulo some whole number n) and an # irreducible polynomial (i.e., a polynomial with only complex zeros), # e.g., Z/5 and X**2 + 2. # @@ -30,65 +30,65 @@ P = poly.plus(poly.one(0, 2), poly.one(2, 1)) # 2 + x**2 # Return x modulo y. Returns >= 0 even if x < 0. def mod(x, y): - return divmod(x, y)[1] + return divmod(x, y)[1] # Normalize a polynomial modulo n and modulo p. def norm(a, n, p): - a = poly.modulo(a, p) - a = a[:] - for i in range(len(a)): a[i] = mod(a[i], n) - a = poly.normalize(a) - return a + a = poly.modulo(a, p) + a = a[:] + for i in range(len(a)): a[i] = mod(a[i], n) + a = poly.normalize(a) + return a # Make a list of all n^d elements of the proposed field. def make_all(mat): - all = [] - for row in mat: - for a in row: - all.append(a) - return all + all = [] + for row in mat: + for a in row: + all.append(a) + return all def make_elements(n, d): - if d == 0: return [poly.one(0, 0)] - sub = make_elements(n, d-1) - all = [] - for a in sub: - for i in range(n): - all.append(poly.plus(a, poly.one(d-1, i))) - return all + if d == 0: return [poly.one(0, 0)] + sub = make_elements(n, d-1) + all = [] + for a in sub: + for i in range(n): + all.append(poly.plus(a, poly.one(d-1, i))) + return all def make_inv(all, n, p): - x = poly.one(1, 1) - inv = [] - for a in all: - inv.append(norm(poly.times(a, x), n, p)) - return inv + x = poly.one(1, 1) + inv = [] + for a in all: + inv.append(norm(poly.times(a, x), n, p)) + return inv def checkfield(n, p): - all = make_elements(n, len(p)-1) - inv = make_inv(all, n, p) - all1 = all[:] - inv1 = inv[:] - all1.sort() - inv1.sort() - if all1 == inv1: print 'BINGO!' - else: - print 'Sorry:', n, p - print all - print inv + all = make_elements(n, len(p)-1) + inv = make_inv(all, n, p) + all1 = all[:] + inv1 = inv[:] + all1.sort() + inv1.sort() + if all1 == inv1: print 'BINGO!' + else: + print 'Sorry:', n, p + print all + print inv def rj(s, width): - if type(s) is not type(''): s = `s` - n = len(s) - if n >= width: return s - return ' '*(width - n) + s + if type(s) is not type(''): s = `s` + n = len(s) + if n >= width: return s + return ' '*(width - n) + s def lj(s, width): - if type(s) is not type(''): s = `s` - n = len(s) - if n >= width: return s - return s + ' '*(width - n) + if type(s) is not type(''): s = `s` + n = len(s) + if n >= width: return s + return s + ' '*(width - n) |