def test_add_mpo(self): h = MPO_rand_herm(12, 5) h2 = h + h assert max(h2[6].shape) == 10 t = h.trace() t2 = h2.trace() assert_allclose(2 * t, t2)
def test_mpo_rand_herm_trace_and_identity_like(self): op = MPO_rand_herm(20, bond_dim=5, phys_dim=3, upper_ind_id='foo{}') t = op.trace() assert t != 0.0 Id = MPO_identity_like(op) assert_allclose(Id.trace(), 3**20) Id.site[0] *= 3 / 3**20 op += Id assert_allclose(op.trace(), t + 3)
def test_mpo_rand_herm_and_trace(self, dtype, cyclic): op = MPO_rand_herm(20, bond_dim=5, phys_dim=3, dtype=dtype, cyclic=cyclic) assert_allclose(op.H @ op, 1.0) tr_val = op.trace() assert tr_val != 0.0 assert_allclose(tr_val.imag, 0.0, atol=1e-14)
def test_sites_mpo_mps_product(self, cyclic): k = MPS_rand_state(13, 7, cyclic=cyclic) X = MPO_rand_herm(3, 5, sites=[3, 6, 7], nsites=13, cyclic=cyclic) b = k.H align_TN_1D(k, X, b, inplace=True) assert (k & X & b) ^ ...
def test_sites_mpo_mps_product(self, cyclic): k = MPS_rand_state(13, 7, cyclic=cyclic) X = MPO_rand_herm(3, 5, sites=[3, 6, 7], nsites=13, cyclic=cyclic) b = k.H k.align_(X, b) assert (k & X & b) ^ ...
def test_approx_fn(self, fn): A = MPO_rand_herm(10, 7, normalize=True) xe = sum(fn(eigvalsh(A.to_dense()))) xf = approx_spectral_function(A, fn, tol=0.1, verbosity=2) assert_allclose(xe, xf, rtol=0.5)
def test_constructing_tridiag_works(self): A = MPO_rand_herm(10, 7) for _ in construct_lanczos_tridiag_MPO(A, 5): pass