|
15 | 15 | __all__ = [ |
16 | 16 | "apply_gates", |
17 | 17 | "gate_1d", |
18 | | - "canonize_mps", |
| 18 | + "rx", |
| 19 | + "ry", |
| 20 | + "rz", |
| 21 | + "rxx", |
| 22 | + "ryy", |
| 23 | + "rzz", |
| 24 | + "u3", |
| 25 | + "su4", |
19 | 26 | ] |
20 | 27 |
|
21 | 28 |
|
@@ -63,6 +70,98 @@ def _to_torch(x, dtype=target_dtype, device=target_device): |
63 | 70 | return None |
64 | 71 |
|
65 | 72 |
|
| 73 | +def rx(theta): |
| 74 | + """Return a one-qubit RX gate for angle ``theta``. |
| 75 | +
|
| 76 | + Parameters |
| 77 | + ---------- |
| 78 | + theta : float |
| 79 | + Rotation angle. |
| 80 | + """ |
| 81 | + return qtn.circuit.rx_gate_param_gen([theta]) |
| 82 | + |
| 83 | + |
| 84 | +def ry(theta): |
| 85 | + """Return a one-qubit RY gate for angle ``theta``. |
| 86 | +
|
| 87 | + Parameters |
| 88 | + ---------- |
| 89 | + theta : float |
| 90 | + Rotation angle. |
| 91 | + """ |
| 92 | + return qtn.circuit.ry_gate_param_gen([theta]) |
| 93 | + |
| 94 | + |
| 95 | +def rz(theta): |
| 96 | + """Return a one-qubit RZ gate for angle ``theta``. |
| 97 | +
|
| 98 | + Parameters |
| 99 | + ---------- |
| 100 | + theta : float |
| 101 | + Rotation angle. |
| 102 | + """ |
| 103 | + return qtn.circuit.rz_gate_param_gen([theta]) |
| 104 | + |
| 105 | + |
| 106 | +def rzz(theta): |
| 107 | + """Return a two-qubit RZZ gate for angle ``theta``. |
| 108 | +
|
| 109 | + Parameters |
| 110 | + ---------- |
| 111 | + theta : float |
| 112 | + Rotation angle. |
| 113 | + """ |
| 114 | + return qtn.circuit.rzz_param_gen([theta]) |
| 115 | + |
| 116 | + |
| 117 | +def rxx(theta): |
| 118 | + """Return a two-qubit RXX gate for angle ``theta``. |
| 119 | +
|
| 120 | + Parameters |
| 121 | + ---------- |
| 122 | + theta : float |
| 123 | + Rotation angle. |
| 124 | + """ |
| 125 | + return qtn.circuit.rxx_param_gen([theta]) |
| 126 | + |
| 127 | + |
| 128 | +def ryy(theta): |
| 129 | + """Return a two-qubit RYY gate for angle ``theta``. |
| 130 | +
|
| 131 | + Parameters |
| 132 | + ---------- |
| 133 | + theta : float |
| 134 | + Rotation angle. |
| 135 | + """ |
| 136 | + return qtn.circuit.ryy_param_gen([theta]) |
| 137 | + |
| 138 | + |
| 139 | +def su4(params): |
| 140 | + """Return a two-qubit SU(4) gate from 15 parameters. |
| 141 | +
|
| 142 | + Parameters |
| 143 | + ---------- |
| 144 | + params : sequence |
| 145 | + Sequence of exactly 15 parameters. |
| 146 | + """ |
| 147 | + if len(params) != 15: |
| 148 | + raise ValueError("su4 expects exactly 15 parameters.") |
| 149 | + return qtn.circuit.su4_gate_param_gen(params) |
| 150 | + |
| 151 | + |
| 152 | +def u3(params): |
| 153 | + """Return a one-qubit U3 gate from 3 parameters. |
| 154 | +
|
| 155 | + Parameters |
| 156 | + ---------- |
| 157 | + params : sequence |
| 158 | + Sequence of exactly 3 parameters. |
| 159 | + """ |
| 160 | + if len(params) != 3: |
| 161 | + raise ValueError("u3 expects exactly 3 parameters.") |
| 162 | + return qtn.circuit.u3_gate_param_gen(params) |
| 163 | + |
| 164 | + |
66 | 165 | def gen_long_range_swap_path( # pylint: disable=too-many-branches,too-many-locals,too-many-statements |
67 | 166 | ij_a, ij_b, sequence=None |
68 | 167 | ): |
@@ -427,15 +526,6 @@ def apply_gates( # pylint: disable=too-many-arguments,too-many-positional-argum |
427 | 526 | return peps |
428 | 527 |
|
429 | 528 |
|
430 | | -def canonize_mps(p, where, cur_orthog): |
431 | | - xmin, xmax = sorted(where) |
432 | | - p.canonize([xmin, xmax], cur_orthog=cur_orthog, |
433 | | - #info=info_c |
434 | | - ) |
435 | | - # update cur_orthog in place (preserving reference) |
436 | | - cur_orthog[:] = [xmin, xmax] |
437 | | - |
438 | | - |
439 | 529 | def gate_1d(tn, where, G, ind_id="k{}", site_tags="I{}", |
440 | 530 | cutoff=1.e-12, contract='split-gate', |
441 | 531 | inplace=False): |
|
0 commit comments