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
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
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])
def test_norm_fro_sparse(self): a = qu.sparse([[3, 0], [4j, 0]]) assert qu.norm(a, "fro") == (9 + 16)**0.5
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])