Main Content

cryGate

Controlled y-axis rotation gate

Since R2023a

Installation Required: This functionality requires MATLAB Support Package for Quantum Computing.

Description

g = cryGate(controlQubit,targetQubit,theta) applies a controlled y-axis rotation gate to a target qubit based on the state of a control qubit and returns a quantum.gate.SimpleGate object. If the control qubit is in the |0 state, then this gate does nothing. If the control qubit is in the |1 state, then this gate rotates the target qubit state around the y-axis by an angle of theta.

  • If controlQubit, targetQubit, and theta are vectors of the same length, cryGate returns a column vector of gates, where g(i) represents a controlled y-axis rotation gate applied to the ith element triplet of controlQubit, targetQubit, and theta.

  • If any of controlQubit, targetQubit, or theta is a scalar, and at least one of the inputs is a vector, then MATLAB® expands the scalar to match the size of the vector input.

  • The qubit indices in each element pair of controlQubit and targetQubit must not be the same.

example

Examples

collapse all

Create a controlled y-axis rotation gate that acts on a control qubit with index 1 and a target qubit with index 2 using a rotation angle of pi/2.

g = cryGate(1,2,pi/2)
g = 

  SimpleGate with properties:

             Type: "cry"
    ControlQubits: 1
     TargetQubits: 2
           Angles: 1.5708

Get the matrix representation of the gate.

M = getMatrix(g)
M =

    1.0000         0         0         0
         0    1.0000         0         0
         0         0    0.7071   -0.7071
         0         0    0.7071    0.7071

Create an array of three controlled y-axis rotation gates. The first gate acts on control qubit 1 and target qubit 2 with rotation angle pi/4, the next gate acts on control qubit 2 and target qubit 3 with rotation angle pi/2, and the final gate acts on control qubit 3 and target qubit 4 with rotation angle 3*pi/4.

g = cryGate(1:3,2:4,pi/4*(1:3))
g = 

  3×1 SimpleGate array with gates:

    Id   Gate   Control   Target   Angle
     1   cry    1         2        pi/4 
     2   cry    2         3        pi/2 
     3   cry    3         4        3pi/4

Input Arguments

collapse all

Control qubit of the gate, specified as a positive integer scalar index or vector of qubit indices.

Example: 2

Example: 6:8

Target qubit of the gate, specified as a positive integer scalar index or vector of qubit indices.

Example: 1

Example: 3:5

Rotation angle, specified as a real scalar or vector.

Example: pi

Example: (1:3)*pi/2

More About

collapse all

Matrix Representation of Controlled y-Axis Rotation Gate

The matrix representation of a controlled y-axis rotation gate applied to control qubit 1 and target qubit 2 with a rotation angle of θ is

[1000010000cos(θ2)sin(θ2)00sin(θ2)cos(θ2)].

Version History

Introduced in R2023a