def test_composite_vec(): """ Composite: Tests compositing states and density operators. """ k1 = rand_ket(5) k2 = rand_ket(7) r1 = operator_to_vector(ket2dm(k1)) r2 = operator_to_vector(ket2dm(k2)) r3 = operator_to_vector(rand_dm(3)) r4 = operator_to_vector(rand_dm(4)) assert_(composite(k1, k2) == tensor(k1, k2)) assert_(composite(r3, r4) == super_tensor(r3, r4)) assert_(composite(k1, r4) == super_tensor(r1, r4)) assert_(composite(r3, k2) == super_tensor(r3, r2))
def test_composite_oper(): """ Composite: Tests compositing unitaries and superoperators. """ U1 = rand_unitary(3) U2 = rand_unitary(5) S1 = to_super(U1) S2 = to_super(U2) S3 = rand_super(4) S4 = rand_super(7) assert_(composite(U1, U2) == tensor(U1, U2)) assert_(composite(S3, S4) == super_tensor(S3, S4)) assert_(composite(U1, S4) == super_tensor(S1, S4)) assert_(composite(S3, U2) == super_tensor(S3, S2))