私のPythonコードでは、を使用していくつかの計算を定期的に検証していnumpy.allclose
ます。一方、これらのチェックとは別に、実装は多倍長(mpmath.mpc
)数を処理できます。番号の確認コードを実行したい場合は、次のmpmath
ようになります。
>>> check(H)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "module.py", line 19, in check_H
assert(numpy.allclose(H, I, rtol=rtol, atol=atol))
File "/home/gereon/python/numpy/core/numeric.py", line 2025, in allclose
xinf = isinf(x)
TypeError: ufunc 'isinf' not supported for the input types, and the inputs could
not be safely coerced to any supported types according to the casting rule ''safe''
2つの多倍長配列が十分に等しいかどうかを確認する最良の方法は何ですか?