コード例 #1
0
    def test_estimate_rank_lo(self, dtype, k_start, use_qb):
        X = rand_tn1d_sect(30, 10, dtype=dtype)

        Ue, se, VHe = qu.svd(X.A)
        actual_rank = sum(se > se[0] * 1e-3)

        k = qu.estimate_rank(X, 1e-3, k_start=k_start,
                             use_qb=use_qb, use_sli=False)
        assert_allclose(k, actual_rank, rtol=0.3 if use_qb else 0.5)

        assert qu.estimate_rank(X, 1e-3, k_start=k_start, k_max=8) == 8
コード例 #2
0
    def test_estimate_rank(self, dtype, shape, k_start, use_qb):
        rnk = 100
        X = rand_rank(*shape, rnk, dtype=dtype)

        Ue, se, VHe = qu.svd(X)
        assert_allclose(se[rnk:], 0.0, atol=1e-5)

        k = qu.estimate_rank(X, 1e-3, k_start=k_start,
                             use_qb=use_qb, use_sli=False)
        assert_allclose(k, 100, rtol=0.3)

        assert qu.estimate_rank(X, 1e-3, k_start=k_start, k_max=50) == 50