@@ -2482,6 +2482,7 @@ def test_to_unitary_with_global_phase():
24822482 (Circuit ().h (0 ).add_result_type (ResultType .Probability (target = [0 ])), gates .H ().to_matrix ()),
24832483 (Circuit ().h (1 ), gates .H ().to_matrix ()),
24842484 (Circuit ().h (2 ), gates .H ().to_matrix ()),
2485+ (Circuit ().h (2 ).measure (2 ), gates .H ().to_matrix ()),
24852486 (Circuit ().x (0 ), gates .X ().to_matrix ()),
24862487 (Circuit ().y (0 ), gates .Y ().to_matrix ()),
24872488 (Circuit ().z (0 ), gates .Z ().to_matrix ()),
@@ -2500,6 +2501,7 @@ def test_to_unitary_with_global_phase():
25002501 (Circuit ().cnot (0 , 1 ), gates .CNot ().to_matrix ()),
25012502 (Circuit ().cnot (0 , 1 ).add_result_type (ResultType .StateVector ()), gates .CNot ().to_matrix ()),
25022503 (Circuit ().cnot (2 , 4 ), gates .CNot ().to_matrix ()),
2504+ (Circuit ().cnot (2 , 4 ).measure ([2 , 4 ]), gates .CNot ().to_matrix ()),
25032505 (Circuit ().swap (0 , 1 ), gates .Swap ().to_matrix ()),
25042506 (Circuit ().swap (1 , 0 ), gates .Swap ().to_matrix ()),
25052507 (Circuit ().iswap (0 , 1 ), gates .ISwap ().to_matrix ()),
@@ -2592,7 +2594,7 @@ def test_to_unitary_with_global_phase():
25922594 ),
25932595 ),
25942596 (
2595- Circuit ().x (0 , control = 1 ),
2597+ Circuit ().x (3 , control = 7 ),
25962598 np .array (
25972599 [
25982600 [1.0 , 0.0 , 0.0 , 0.0 ],
@@ -2628,7 +2630,7 @@ def test_to_unitary_with_global_phase():
26282630 ),
26292631 ),
26302632 (
2631- Circuit ().ccnot (1 , 2 , 0 ),
2633+ Circuit ().ccnot (3 , 6 , 1 ),
26322634 np .array (
26332635 [
26342636 [1.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 ],
@@ -2644,7 +2646,7 @@ def test_to_unitary_with_global_phase():
26442646 ),
26452647 ),
26462648 (
2647- Circuit ().ccnot (2 , 1 , 0 ),
2649+ Circuit ().ccnot (6 , 3 , 1 ),
26482650 np .array (
26492651 [
26502652 [1.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 ],
@@ -2660,7 +2662,7 @@ def test_to_unitary_with_global_phase():
26602662 ),
26612663 ),
26622664 (
2663- Circuit ().ccnot (0 , 2 , 1 ),
2665+ Circuit ().ccnot (1 , 6 , 3 ),
26642666 np .array (
26652667 [
26662668 [1.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 ],
@@ -2676,7 +2678,7 @@ def test_to_unitary_with_global_phase():
26762678 ),
26772679 ),
26782680 (
2679- Circuit ().ccnot (2 , 0 , 1 ),
2681+ Circuit ().ccnot (6 , 1 , 3 ),
26802682 np .array (
26812683 [
26822684 [1.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 ],
@@ -2691,6 +2693,102 @@ def test_to_unitary_with_global_phase():
26912693 dtype = complex ,
26922694 ),
26932695 ),
2696+ (
2697+ Circuit ().cnot ([1 , 6 ], 3 ),
2698+ np .array (
2699+ [
2700+ [1.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 ],
2701+ [0.0 , 1.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 ],
2702+ [0.0 , 0.0 , 1.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 ],
2703+ [0.0 , 0.0 , 0.0 , 1.0 , 0.0 , 0.0 , 0.0 , 0.0 ],
2704+ [0.0 , 0.0 , 0.0 , 0.0 , 1.0 , 0.0 , 0.0 , 0.0 ],
2705+ [0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 1.0 ],
2706+ [0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 1.0 , 0.0 ],
2707+ [0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 1.0 , 0.0 , 0.0 ],
2708+ ],
2709+ dtype = complex ,
2710+ ),
2711+ ),
2712+ (
2713+ Circuit ().cnot ([6 , 1 ], 3 ),
2714+ np .array (
2715+ [
2716+ [1.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 ],
2717+ [0.0 , 1.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 ],
2718+ [0.0 , 0.0 , 1.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 ],
2719+ [0.0 , 0.0 , 0.0 , 1.0 , 0.0 , 0.0 , 0.0 , 0.0 ],
2720+ [0.0 , 0.0 , 0.0 , 0.0 , 1.0 , 0.0 , 0.0 , 0.0 ],
2721+ [0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 1.0 ],
2722+ [0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 1.0 , 0.0 ],
2723+ [0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 1.0 , 0.0 , 0.0 ],
2724+ ],
2725+ dtype = complex ,
2726+ ),
2727+ ),
2728+ (
2729+ Circuit ().x (3 , control = [6 , 1 ]),
2730+ np .array (
2731+ [
2732+ [1.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 ],
2733+ [0.0 , 1.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 ],
2734+ [0.0 , 0.0 , 1.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 ],
2735+ [0.0 , 0.0 , 0.0 , 1.0 , 0.0 , 0.0 , 0.0 , 0.0 ],
2736+ [0.0 , 0.0 , 0.0 , 0.0 , 1.0 , 0.0 , 0.0 , 0.0 ],
2737+ [0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 1.0 ],
2738+ [0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 1.0 , 0.0 ],
2739+ [0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 1.0 , 0.0 , 0.0 ],
2740+ ],
2741+ dtype = complex ,
2742+ ),
2743+ ),
2744+ (
2745+ Circuit ().x (3 , control = [1 , 6 ]),
2746+ np .array (
2747+ [
2748+ [1.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 ],
2749+ [0.0 , 1.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 ],
2750+ [0.0 , 0.0 , 1.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 ],
2751+ [0.0 , 0.0 , 0.0 , 1.0 , 0.0 , 0.0 , 0.0 , 0.0 ],
2752+ [0.0 , 0.0 , 0.0 , 0.0 , 1.0 , 0.0 , 0.0 , 0.0 ],
2753+ [0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 1.0 ],
2754+ [0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 1.0 , 0.0 ],
2755+ [0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 1.0 , 0.0 , 0.0 ],
2756+ ],
2757+ dtype = complex ,
2758+ ),
2759+ ),
2760+ (
2761+ Circuit ().i (3 ).cnot (6 , 1 ),
2762+ np .array (
2763+ [
2764+ [1.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 ],
2765+ [0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 1.0 , 0.0 , 0.0 ],
2766+ [0.0 , 0.0 , 1.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 ],
2767+ [0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 1.0 ],
2768+ [0.0 , 0.0 , 0.0 , 0.0 , 1.0 , 0.0 , 0.0 , 0.0 ],
2769+ [0.0 , 1.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 ],
2770+ [0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 1.0 , 0.0 ],
2771+ [0.0 , 0.0 , 0.0 , 1.0 , 0.0 , 0.0 , 0.0 , 0.0 ],
2772+ ],
2773+ dtype = complex ,
2774+ ),
2775+ ),
2776+ (
2777+ Circuit ().i (3 ).x (1 , control = [6 ]),
2778+ np .array (
2779+ [
2780+ [1.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 ],
2781+ [0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 1.0 , 0.0 , 0.0 ],
2782+ [0.0 , 0.0 , 1.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 ],
2783+ [0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 1.0 ],
2784+ [0.0 , 0.0 , 0.0 , 0.0 , 1.0 , 0.0 , 0.0 , 0.0 ],
2785+ [0.0 , 1.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 ],
2786+ [0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 1.0 , 0.0 ],
2787+ [0.0 , 0.0 , 0.0 , 1.0 , 0.0 , 0.0 , 0.0 , 0.0 ],
2788+ ],
2789+ dtype = complex ,
2790+ ),
2791+ ),
26942792 (
26952793 Circuit ().s (0 ).v (1 ).cnot (0 , 1 ).cnot (2 , 1 ),
26962794 np .dot (
0 commit comments