npn
v1.1
このパッケージはブールマッチャーです。それは、真実の表で表される特定のブール関数に対して、各NPN等価クラスに一意の標準的な代表者を単に計算するだけです。
このパッケージのバックエンドは、効率のためにC ++によって実装されます。
現在、このパッケージは、入力数のブール関数をサポートしています<= 8。
pip install npn import npn
# the truth table of f(x_2, x_1, x_0) as [f(0, 0, 0), f(0, 0, 1), f(0, 1, 0), f(0, 1, 1), ...]
tt = [ True , True , True , False , True , True , True , True ]
c = npn . npn_canonical_representative ( tt ) # [True, True, True, True, True, True, True, False]
c_int = npn . tt_to_int ( c ) # 254 (11111110)
c , phase , perm , output_inv = npn . npn_canonical_representative ( tt , return_details = True , refinement = True )return_detailsパラメーターをTrueに設定して、NPN変換情報( phase, perm, output_inv )を返すようにします。たとえば、 phase = [False, False, True] 、 perm = [0, 1, 2] 、およびoutput_inv = False (x_0, x_1, x_2) (x_0, x_1, x_2) x_2マッピングする必要があります。refinementパラメーターをTrueに設定して、辞書編集の順序の真実のテーブルを破壊しながら計算を加速します。詳細については、「より良いブールマッチャーと対称検出器の構築」を参照してください。 WindowsおよびLinux環境でCmakeを介して共有ライブラリlibnpn.dllとlibnpn.soをコンパイルし、 npnフォルダーに配置し、次にそれらを配置します。
python setup.py sdistPypiにアップロードするには、実行します
twine upload . d ist n pn-X.X.tar.gzpip install pytest # if you haven't install it
python -m pytest