当前位置: 首页>>代码示例>>Python>>正文


Python _multiarray_tests.solve_diophantine方法代码示例

本文整理汇总了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) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:22,代码来源:test_mem_overlap.py

示例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)) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:15,代码来源:test_mem_overlap.py


注:本文中的numpy.core._multiarray_tests.solve_diophantine方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。