• R/O
  • SSH

コミット

タグ

よく使われているワード(クリックで追加)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

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


コミットメタ情報

リビジョン3e43d3f153fea219b8401accdcf5277d39eacf2e (tree)
日時2020-02-16 18:06:20
作者Eric Hopper <hopper@omni...>
コミッターEric Hopper

ログメッセージ

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

変更サマリ

差分

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()