本文整理匯總了Python中numpy.core._multiarray_tests.solve_diophantine方法的典型用法代碼示例。如果您正苦於以下問題:Python _multiarray_tests.solve_diophantine方法的具體用法?Python _multiarray_tests.solve_diophantine怎麽用?Python _multiarray_tests.solve_diophantine使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類numpy.core._multiarray_tests
的用法示例。
在下文中一共展示了_multiarray_tests.solve_diophantine方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_internal_overlap_diophantine
# 需要導入模塊: from numpy.core import _multiarray_tests [as 別名]
# 或者: from numpy.core._multiarray_tests import solve_diophantine [as 別名]
def test_internal_overlap_diophantine():
def check(A, U, exists=None):
X = solve_diophantine(A, U, 0, require_ub_nontrivial=1)
if exists is None:
exists = (X is not None)
if X is not None:
assert_(sum(a*x for a, x in zip(A, X)) == sum(a*u//2 for a, u in zip(A, U)))
assert_(all(0 <= x <= u for x, u in zip(X, U)))
assert_(any(x != u//2 for x, u in zip(X, U)))
if exists:
assert_(X is not None, repr(X))
else:
assert_(X is None, repr(X))
# Smoke tests
check((3, 2), (2*2, 3*2), exists=True)
check((3*2, 2), (15*2, (3-1)*2), exists=False)
示例2: test_diophantine_overflow
# 需要導入模塊: from numpy.core import _multiarray_tests [as 別名]
# 或者: from numpy.core._multiarray_tests import solve_diophantine [as 別名]
def test_diophantine_overflow():
# Smoke test integer overflow detection
max_intp = np.iinfo(np.intp).max
max_int64 = np.iinfo(np.int64).max
if max_int64 <= max_intp:
# Check that the algorithm works internally in 128-bit;
# solving this problem requires large intermediate numbers
A = (max_int64//2, max_int64//2 - 10)
U = (max_int64//2, max_int64//2 - 10)
b = 2*(max_int64//2) - 10
assert_equal(solve_diophantine(A, U, b), (1, 1))