Main Content

initGate

Initialization gate with specified qubit states

Since R2023b

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

    Description

    cg = initGate(targetQubits,state) returns a quantum.gate.CompositeGate object that initializes the target qubits to the specified state up to a global phase, that is, scaled by a constant factor. The target qubits must be in the |0 state.

    example

    cg = initGate(targetQubits,state,RotationThreshold=thresh) also removes single-qubit rotation gates that have an angle magnitude less than the rotation threshold.

    Examples

    collapse all

    Create an initialization gate that initializes three target qubits to amplitudes between pi/4 and 2*pi.

    cg = initGate(1:3,pi/4*(1:8))
    cg = 
      CompositeGate with properties:
    
                 Name: "init"
        ControlQubits: [1x0 double]
         TargetQubits: [1 2 3]
                Gates: [3x1 quantum.gate.CompositeGate]
    
    

    Plot the initialization gate. The plotted gate consists of three inverse UCRY gates. The first inverse UCRY gate acts on qubit 1, the second inverse UCRY gate acts on qubits 1 and 2, and the third inverse UCRY gate acts on qubits 1, 2, and 3.

    plot(cg)

    Figure contains an object of type quantum.gate.quantumcircuitchart. The chart of type quantum.gate.quantumcircuitchart has title CompositeGate: init.

    Simulate a quantum circuit with the initialization gate. Here, the global phase is 0.28/pi.

    s = simulate(quantumCircuit(cg));
    formula(s)
    ans = 
        "0.070014 * |000> +
         0.14003  * |001> +
         0.21004  * |010> +
         0.28006  * |011> +
         0.35007  * |100> +
         0.42008  * |101> +
         0.4901   * |110> +
         0.56011  * |111>"
    
    

    Create an initialization gate for six target qubits. Use a basis string to initialize three qubits to the + state and three qubits to the - state.

    cg = initGate(1:6,"+++---")
    cg = 
      CompositeGate with properties:
    
                 Name: "init"
        ControlQubits: [1x0 double]
         TargetQubits: [1 2 3 4 5 6]
                Gates: [9x1 quantum.gate.SimpleGate]
    
    

    Plot the initialization gate.

    plot(cg)

    Figure contains an object of type quantum.gate.quantumcircuitchart. The chart of type quantum.gate.quantumcircuitchart has title CompositeGate: init.

    Simulate a quantum circuit with the initialization gate and verify that the qubits are initialized to the input state, up to a global phase.

    s = simulate(quantumCircuit(cg));
    formula(s)
    ans = 
    "1 * |+++--->"
    

    Input Arguments

    collapse all

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

    Example: 1

    Example: 3:5

    Target state to initialize, specified as one of these values:

    • String scalar containing "0", "1", "+", or "-" with as many characters as the number of target qubits. For example, to specify four qubits with a target state of |0+1, use "0+1-".

    • Numeric vector containing amplitudes of the target states. The vector must have length 2n, where n is the number of target qubits. The initGate function normalizes the amplitudes as state/norm(state).

    • QuantumState object that has the same number of qubits as the number of target qubits.

    Rotation threshold, specified as one of these values:

    • positive real number

    • "auto" — Set the threshold to the default value of 2*pi*eps.

    • "none" — Do not remove gates.

    The initGate function removes single-qubit rotation gates that have an angle magnitude less than this rotation threshold.

    References

    [1] Shende, Vivek V., Stephen S. Bullock, and Igor L. Markov. "Synthesis of Quantum Logic Circuits." IEEE Transactions on Computer-Aided Design of Integrated Circuits and Systems 25, no. 6 (June 2006): 1000–1010. https://doi.org/10.1109/TCAD.2005.855930.

    Version History

    Introduced in R2023b