test.py 文件源码

python
阅读 46 收藏 0 点赞 0 评论 0

项目:fastmat 作者: EMS-TU-Ilmenau 项目源码 文件源码
def testLargestSV(test):
    query={TEST.TYPE_EXPECTED: np.float64}
    instance=test[TEST.INSTANCE]

    # account for "extra computation stage" (gram) in largestSV
    query[TEST.TOL_POWER]=test.get(TEST.TOL_POWER, 1.) * 2
    query[TEST.TOL_MINEPS]=_getTypeEps(safeTypeExpansion(instance.dtype))

    # determine reference result
    largestSV=np.linalg.svd(test[TEST.REFERENCE], compute_uv=False)[0]
    query[TEST.RESULT_REF]=np.array(
        largestSV, dtype=np.promote_types(largestSV.dtype, np.float64))

    # largestSV may not converge fast enough for a bad random starting point
    # so retry some times before throwing up
    for tries in range(9):
        maxSteps=100. * 10. ** (tries / 2.)
        query[TEST.RESULT_OUTPUT]=np.array(
            instance.getLargestSV(maxSteps=maxSteps, alwaysReturn=True))
        result=compareResults(test, query)
        if result[TEST.RESULT]:
            break
    return result


################################################## test: gram (property)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号