コード例 #1
0
def mat_nherm_sparse():
    np.random.seed(1)
    u, v = qu.rand_uni(5), qu.rand_uni(5)
    a = u @ qu.ldmul(np.array([1, 2, 4, 3, 0.1]), v.H)
    a = qu.sparse(a)
    return u, v, a
コード例 #2
0
def mat_herm_sparse():
    np.random.seed(1)
    u = qu.rand_uni(4)
    a = u @ qu.ldmul(np.array([-1, 2, 4, -3]), u.H)
    a = qu.sparse(a)
    return u, a
コード例 #3
0
 def test_sparse_cut(self, ham1):
     h = qu.sparse(ham1)
     el = qu.eigvalsh_window(h, 0.5, 5, w_sz=0.3)
     assert_allclose(el, [1, 2, 3])
コード例 #4
0
 def test_norm_fro_sparse(self):
     a = qu.sparse([[3, 0], [4j, 0]])
     assert qu.norm(a, "fro") == (9 + 16)**0.5
コード例 #5
0
 def test_sparse(self, ham2, backend):
     h = qu.sparse(ham2)
     el = qu.eigvalsh_window(h, 0.5, 2, w_sz=0.1, backend=backend)
     assert_allclose(el, [1, 1.1])