Exemple #1
0
 def test_svd_full(self, mat_nherm_dense):
     u, v, a = mat_nherm_dense
     un, sn, vn = qu.svd(a)
     assert_allclose(sn, [4, 3, 2, 1, 0.1], atol=1e-14)
     for i, j, in zip((0, 1, 2, 3, 4), (2, 3, 1, 0, 4)):
         o = abs(un[:, i].H @ u[:, j])
         assert_allclose(o, 1.)
         o = abs(vn[i, :] @ v[:, j])
         assert_allclose(o, 1.)
    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
    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