• R/O
  • SSH

Commit

Tags

Frequently used words (click to add to your profile)

javaandroidc++linuxc#objective-ccocoa誰得qtrubypythonwindowsphpgamebathyscapheguic翻訳omegattwitterframeworkbtronvb.net計画中(planning stage)testdomarduinodirectxpreviewerゲームエンジン

A small kernel of code for playing with Galois fields of arbitrary characteristic


Commit MetaInfo

Revision3e43d3f153fea219b8401accdcf5277d39eacf2e (tree)
Time2020-02-16 18:06:20
AuthorEric Hopper <hopper@omni...>
CommiterEric Hopper

Log Message

Add a function to print out a group table for presentation.

Change Summary

Incremental Difference

diff -r 0b77fa2db6fa -r 3e43d3f153fe numtheory_utils.py
--- a/numtheory_utils.py Sun Jan 12 14:45:56 2020 -0800
+++ b/numtheory_utils.py Sun Feb 16 01:06:20 2020 -0800
@@ -40,3 +40,17 @@
4040 # (1 * 16 - 0 * 23) - 2 * (1 * 23 - 1 * 16) = 3 * 16 - 2 * 23 = 2
4141 # (1 * 23 - 1 * 16) - 3 * (3 * 16 - 2 * 23) = 7 * 23 - 10 * 16 = 1
4242 # 13 * 16 - 9 * 23 = 1
43+
44+
45+def print_group_table(elements, op):
46+ width = max(len(str(x)) for x in elements)
47+ print(f'{" ":{width}} |', end='')
48+ for a in elements:
49+ print(f' {a:{width}} |', end='')
50+ print()
51+ for a in elements:
52+ print(f'{a:{width}} |', end='')
53+ for b in elements:
54+ result = op(a, b)
55+ print(f' {result:{width}} |', end='')
56+ print()