Example #1
0
 def test_lazy_ptr_ppt_dot_mat_linear_op(self, psi_abc, psi_ab_mat):
     rho_ab = psi_abc.ptr(DIMS, [0, 1])
     rho_ab_pt = partial_transpose(rho_ab, DIMS[:-1])
     psi_out_expected = rho_ab_pt @ psi_ab_mat
     lo = lazy_ptr_ppt_linop(psi_abc, DIMS, 0, 1)
     psi_out_got = lo @ psi_ab_mat
     assert_allclose(psi_out_expected, psi_out_got)
Example #2
0
 def test_approx_spectral_function_ptr_ppt_lin_op(self, fn_approx_rtol,
                                                  psi_abc, psi_ab, bsz):
     fn, approx, rtol = fn_approx_rtol
     rho_ab_ppt = partial_transpose(psi_abc.ptr(DIMS, [0, 1]), DIMS[:-1], 0)
     actual_x = sum(fn(eigvalsh(rho_ab_ppt)))
     lo = lazy_ptr_ppt_linop(psi_abc, DIMS, sysa=0, sysb=1)
     approx_x = approx_spectral_function(lo, fn, K=20, R=20, bsz=bsz)
     assert_allclose(actual_x, approx_x, rtol=rtol)
Example #3
0
 def test_lazy_ptr_ppt_dot_linear_op(self, psi_abc, psi_ab):
     rho_ab = psi_abc.ptr(DIMS, [0, 1])
     rho_ab_pt = partial_transpose(rho_ab, DIMS[:-1])
     psi_out_expected = rho_ab_pt @ psi_ab
     lo = lazy_ptr_ppt_linop(psi_abc, DIMS, 0, 1)
     assert hasattr(lo, "H")
     assert lo.dtype == complex
     assert lo.shape == (DIMS[0] * DIMS[1], DIMS[0] * DIMS[1])
     psi_out_got = lo @ psi_ab
     assert_allclose(psi_out_expected, psi_out_got)
Example #4
0
 def test_lazy_ptr_ppt_dot_mat_manybody_linear_op(self, psi_mb_abc,
                                                  psi_mb_ab_mat):
     sysa = [0, 1, 7, 8]
     sysb = [2, 3, 9]
     rho_ab = psi_mb_abc.ptr(DIMS_MB, sysa + sysb)
     rho_ab = partial_transpose(rho_ab, [2] * 7, sysa=(0, 1, 4, 5))
     psi_out_expected = rho_ab @ psi_mb_ab_mat
     lo = lazy_ptr_ppt_linop(psi_mb_abc, DIMS_MB, sysa, sysb)
     psi_out_got = lo.dot(psi_mb_ab_mat)
     assert psi_out_got.shape[1] > 1
     assert_allclose(psi_out_expected, psi_out_got)
Example #5
0
 def test_lazy_ptr_ppt_dot_manybody_linear_op(self, psi_mb_abc, psi_mb_ab):
     sysa = [0, 1, 7, 8]
     sysb = [2, 3, 9]
     rho_ab = psi_mb_abc.ptr(DIMS_MB, sysa + sysb)
     rho_ab = partial_transpose(rho_ab, [2] * 7, sysa=(0, 1, 4, 5))
     psi_out_expected = rho_ab @ psi_mb_ab
     lo = lazy_ptr_ppt_linop(psi_mb_abc, DIMS_MB, sysa, sysb)
     assert hasattr(lo, "H")
     assert lo.dtype == complex
     assert lo.shape == (128, 128)
     psi_out_got = lo.dot(psi_mb_ab)
     assert_allclose(psi_out_expected, psi_out_got)