@@ -94,6 +94,12 @@ impl Gate {
9494 . collect ( )
9595 }
9696
97+ /// Create Identity gate on multiple qubits
98+ #[ must_use]
99+ pub fn i ( qubits : & [ impl Into < QubitId > + Copy ] ) -> Self {
100+ Self :: simple ( GateType :: I , qubits. iter ( ) . map ( |& q| q. into ( ) ) . collect ( ) )
101+ }
102+
97103 /// Create X gate on multiple qubits
98104 #[ must_use]
99105 pub fn x ( qubits : & [ impl Into < QubitId > + Copy ] ) -> Self {
@@ -118,6 +124,54 @@ impl Gate {
118124 Self :: simple ( GateType :: H , qubits. iter ( ) . map ( |& q| q. into ( ) ) . collect ( ) )
119125 }
120126
127+ /// Create SX gate (sqrt-X) on multiple qubits
128+ #[ must_use]
129+ pub fn sx ( qubits : & [ impl Into < QubitId > + Copy ] ) -> Self {
130+ Self :: simple ( GateType :: SX , qubits. iter ( ) . map ( |& q| q. into ( ) ) . collect ( ) )
131+ }
132+
133+ /// Create `SXdg` gate (sqrt-X dagger) on multiple qubits
134+ #[ must_use]
135+ pub fn sxdg ( qubits : & [ impl Into < QubitId > + Copy ] ) -> Self {
136+ Self :: simple ( GateType :: SXdg , qubits. iter ( ) . map ( |& q| q. into ( ) ) . collect ( ) )
137+ }
138+
139+ /// Create SY gate (sqrt-Y) on multiple qubits
140+ #[ must_use]
141+ pub fn sy ( qubits : & [ impl Into < QubitId > + Copy ] ) -> Self {
142+ Self :: simple ( GateType :: SY , qubits. iter ( ) . map ( |& q| q. into ( ) ) . collect ( ) )
143+ }
144+
145+ /// Create `SYdg` gate (sqrt-Y dagger) on multiple qubits
146+ #[ must_use]
147+ pub fn sydg ( qubits : & [ impl Into < QubitId > + Copy ] ) -> Self {
148+ Self :: simple ( GateType :: SYdg , qubits. iter ( ) . map ( |& q| q. into ( ) ) . collect ( ) )
149+ }
150+
151+ /// Create SZ gate (sqrt-Z) on multiple qubits
152+ #[ must_use]
153+ pub fn sz ( qubits : & [ impl Into < QubitId > + Copy ] ) -> Self {
154+ Self :: simple ( GateType :: SZ , qubits. iter ( ) . map ( |& q| q. into ( ) ) . collect ( ) )
155+ }
156+
157+ /// Create `SZdg` gate (sqrt-Z dagger) on multiple qubits
158+ #[ must_use]
159+ pub fn szdg ( qubits : & [ impl Into < QubitId > + Copy ] ) -> Self {
160+ Self :: simple ( GateType :: SZdg , qubits. iter ( ) . map ( |& q| q. into ( ) ) . collect ( ) )
161+ }
162+
163+ /// Create T gate on multiple qubits
164+ #[ must_use]
165+ pub fn t ( qubits : & [ impl Into < QubitId > + Copy ] ) -> Self {
166+ Self :: simple ( GateType :: T , qubits. iter ( ) . map ( |& q| q. into ( ) ) . collect ( ) )
167+ }
168+
169+ /// Create Tdg gate on multiple qubits
170+ #[ must_use]
171+ pub fn tdg ( qubits : & [ impl Into < QubitId > + Copy ] ) -> Self {
172+ Self :: simple ( GateType :: Tdg , qubits. iter ( ) . map ( |& q| q. into ( ) ) . collect ( ) )
173+ }
174+
121175 /// Create CX gate from flat qubit list (control1, target1, control2, target2, ...)
122176 ///
123177 /// # Panics
@@ -139,6 +193,48 @@ impl Gate {
139193 Self :: cx_vec ( & flat_qubits)
140194 }
141195
196+ /// Create CY gate from flat qubit list (control1, target1, control2, target2, ...)
197+ ///
198+ /// # Panics
199+ ///
200+ /// Panics if the number of qubits is not even, as `CY` gates require pairs of qubits.
201+ #[ must_use]
202+ pub fn cy_vec ( qubits : & [ impl Into < QubitId > + Copy ] ) -> Self {
203+ assert ! (
204+ qubits. len( ) . is_multiple_of( 2 ) ,
205+ "CY gate requires an even number of qubits"
206+ ) ;
207+ Self :: simple ( GateType :: CY , qubits. iter ( ) . map ( |& q| q. into ( ) ) . collect ( ) )
208+ }
209+
210+ /// Create CY gate on multiple qubit pairs
211+ #[ must_use]
212+ pub fn cy ( qubit_pairs : & [ ( impl Into < QubitId > + Copy , impl Into < QubitId > + Copy ) ] ) -> Self {
213+ let flat_qubits = Self :: flatten_qubit_pairs ( qubit_pairs) ;
214+ Self :: cy_vec ( & flat_qubits)
215+ }
216+
217+ /// Create CZ gate from flat qubit list (control1, target1, control2, target2, ...)
218+ ///
219+ /// # Panics
220+ ///
221+ /// Panics if the number of qubits is not even, as `CZ` gates require pairs of qubits.
222+ #[ must_use]
223+ pub fn cz_vec ( qubits : & [ impl Into < QubitId > + Copy ] ) -> Self {
224+ assert ! (
225+ qubits. len( ) . is_multiple_of( 2 ) ,
226+ "CZ gate requires an even number of qubits"
227+ ) ;
228+ Self :: simple ( GateType :: CZ , qubits. iter ( ) . map ( |& q| q. into ( ) ) . collect ( ) )
229+ }
230+
231+ /// Create CZ gate on multiple qubit pairs
232+ #[ must_use]
233+ pub fn cz ( qubit_pairs : & [ ( impl Into < QubitId > + Copy , impl Into < QubitId > + Copy ) ] ) -> Self {
234+ let flat_qubits = Self :: flatten_qubit_pairs ( qubit_pairs) ;
235+ Self :: cz_vec ( & flat_qubits)
236+ }
237+
142238 /// Create SZZ gate from flat qubit list (`qubit1_1`, `qubit2_1`, `qubit1_2`, `qubit2_2`, ...)
143239 ///
144240 /// # Panics
@@ -181,6 +277,62 @@ impl Gate {
181277 Self :: szzdg_vec ( & flat_qubits)
182278 }
183279
280+ /// Create RXX gate from flat qubit list (`qubit1_1`, `qubit2_1`, `qubit1_2`, `qubit2_2`, ...)
281+ ///
282+ /// # Panics
283+ ///
284+ /// Panics if the number of qubits is not even, as `RXX` gates require pairs of qubits.
285+ #[ must_use]
286+ pub fn rxx_vec ( theta : Angle64 , qubits : & [ impl Into < QubitId > + Copy ] ) -> Self {
287+ assert ! (
288+ qubits. len( ) . is_multiple_of( 2 ) ,
289+ "RXX gate requires an even number of qubits"
290+ ) ;
291+ Self :: with_angles (
292+ GateType :: RXX ,
293+ vec ! [ theta] ,
294+ qubits. iter ( ) . map ( |& q| q. into ( ) ) . collect ( ) ,
295+ )
296+ }
297+
298+ /// Create RXX gate on multiple qubit pairs
299+ #[ must_use]
300+ pub fn rxx (
301+ theta : Angle64 ,
302+ qubit_pairs : & [ ( impl Into < QubitId > + Copy , impl Into < QubitId > + Copy ) ] ,
303+ ) -> Self {
304+ let flat_qubits = Self :: flatten_qubit_pairs ( qubit_pairs) ;
305+ Self :: rxx_vec ( theta, & flat_qubits)
306+ }
307+
308+ /// Create RYY gate from flat qubit list (`qubit1_1`, `qubit2_1`, `qubit1_2`, `qubit2_2`, ...)
309+ ///
310+ /// # Panics
311+ ///
312+ /// Panics if the number of qubits is not even, as `RYY` gates require pairs of qubits.
313+ #[ must_use]
314+ pub fn ryy_vec ( theta : Angle64 , qubits : & [ impl Into < QubitId > + Copy ] ) -> Self {
315+ assert ! (
316+ qubits. len( ) . is_multiple_of( 2 ) ,
317+ "RYY gate requires an even number of qubits"
318+ ) ;
319+ Self :: with_angles (
320+ GateType :: RYY ,
321+ vec ! [ theta] ,
322+ qubits. iter ( ) . map ( |& q| q. into ( ) ) . collect ( ) ,
323+ )
324+ }
325+
326+ /// Create RYY gate on multiple qubit pairs
327+ #[ must_use]
328+ pub fn ryy (
329+ theta : Angle64 ,
330+ qubit_pairs : & [ ( impl Into < QubitId > + Copy , impl Into < QubitId > + Copy ) ] ,
331+ ) -> Self {
332+ let flat_qubits = Self :: flatten_qubit_pairs ( qubit_pairs) ;
333+ Self :: ryy_vec ( theta, & flat_qubits)
334+ }
335+
184336 /// Create RZZ gate from flat qubit list (`qubit1_1`, `qubit2_1`, `qubit1_2`, `qubit2_2`, ...)
185337 ///
186338 /// # Panics
0 commit comments