Ejemplo n.º 1
0
def test_pmps_dm_to_array(nr_sites, local_dim, rank, rgen):

    pmps = factory.random_mpa(nr_sites, (local_dim, local_dim), rank,
                              randstate=rgen, dtype=np.complex_)
    mpo = mm.pmps_to_mpo(pmps)
    op = mpo.to_array()
    op2 = mm.pmps_dm_to_array(pmps)
    assert_array_almost_equal(op2, op)
    op = mpo.to_array_global()
    op2 = mm.pmps_dm_to_array(pmps, True)
    assert_array_almost_equal(op2, op)
Ejemplo n.º 2
0
def test_pmps_dm_to_array(nr_sites, local_dim, rank, rgen):

    pmps = factory.random_mpa(nr_sites, (local_dim, local_dim), rank,
                              randstate=rgen, dtype=np.complex_)
    mpo = mm.pmps_to_mpo(pmps)
    op = mpo.to_array()
    op2 = mm.pmps_dm_to_array(pmps)
    assert_array_almost_equal(op2, op)
    op = mpo.to_array_global()
    op2 = mm.pmps_dm_to_array(pmps, True)
    assert_array_almost_equal(op2, op)
Ejemplo n.º 3
0
def test_pmps_reduction_array_fast(nr_sites, local_dim, rank, keep, rgen,
                                   benchmark):
    pmps = factory.random_mpa(nr_sites, (local_dim, local_dim),
                              rank,
                              dtype=np.complex_,
                              normalized=True,
                              randstate=rgen)
    benchmark(lambda: mm.pmps_dm_to_array(mm.pmps_reduction(pmps, keep)))
Ejemplo n.º 4
0
def test_pmps_reduction_dm_to_array(nr_sites, local_dim, rank, keep, rgen):

    pmps = factory.random_mpa(nr_sites, (local_dim, local_dim), rank,
                              dtype=np.complex_, randstate=rgen)
    rho = mm.pmps_to_mpo(pmps).to_array_global()
    traceout = [pos for pos in range(nr_sites) if pos not in keep]
    red = utils.partial_trace(rho, traceout)
    pmps_red = mm.pmps_reduction(pmps, keep)
    red2 = mm.pmps_dm_to_array(pmps_red, True)
    assert_array_almost_equal(red2, red)
Ejemplo n.º 5
0
def test_pmps_reduction_dm_to_array(nr_sites, local_dim, rank, keep, rgen):

    pmps = factory.random_mpa(nr_sites, (local_dim, local_dim), rank,
                              dtype=np.complex_, randstate=rgen)
    rho = mm.pmps_to_mpo(pmps).to_array_global()
    traceout = [pos for pos in range(nr_sites) if pos not in keep]
    red = utils.partial_trace(rho, traceout)
    pmps_red = mm.pmps_reduction(pmps, keep)
    red2 = mm.pmps_dm_to_array(pmps_red, True)
    assert_array_almost_equal(red2, red)
Ejemplo n.º 6
0
def test_pmps_reduction_array_fast(nr_sites, local_dim, rank, keep, rgen,
                                   benchmark):
    pmps = factory.random_mpa(nr_sites, (local_dim, local_dim), rank,
                              dtype=np.complex_, normalized=True,
                              randstate=rgen)
    benchmark(lambda: mm.pmps_dm_to_array(mm.pmps_reduction(pmps, keep)))