Example #1
0
def test_eigvec_to_fockbasis():
    "BR Tools : eigvector to fockbasis"
    N = 10
    for kk in range(50):
        H = rand_herm(N,0.5)
        h = H.full('F')
        R = rand_dm(N,0.5)
        r = mat2vec(R.full()).ravel()
        eigvals = np.zeros(N,dtype=float)
        Z = _test_zheevr(H.full('F'), eigvals)
        eig_vec = mat2vec(R.transform(H.eigenstates()[1]).full()).ravel()
        out = _test_eigvec_to_fockbasis(eig_vec, Z, N)
        assert_(np.allclose(r,out))
Example #2
0
def test_eigvec_to_fockbasis():
    "BR Tools : eigvector to fockbasis"
    dimension = 10
    for _ in range(50):
        H = qutip.rand_herm(dimension, 0.5)
        basis = H.eigenstates()[1]
        R = qutip.rand_dm(dimension, 0.5)
        target = qutip.mat2vec(R.full()).ravel()
        _eigenvalues = np.empty((dimension, ), dtype=np.float64)
        evecs_zheevr = _test_zheevr(H.full('F'), _eigenvalues)
        flat_eigenvectors = qutip.mat2vec(R.transform(basis).full()).ravel()
        calculated = _test_eigvec_to_fockbasis(flat_eigenvectors, evecs_zheevr,
                                               dimension)
        np.testing.assert_allclose(target, calculated, atol=1e-12)