controlled {QuantumOps}R Documentation

controlled

Description

Creates a matrix representing a controlled gate on a system of qubits. The target and control qubits can be located at arbitrary positions.

Usage

controlled(gate,n,cQubits,tQubit)

Arguments

gate

single qubit gate to create controlled version of

n

Number of qubits in the ket, including target, control, and all other qubits

cQubits

Vector of qubit indices. There can be between 1 and n-1 control qubits, where n is the number of qubits in the ket. Qubits are indexed from 0, starting at the most significant qubit

tQubit

Index of the target qubit. Qubits are indexed from 0, starting at the most significant qubit

Value

A matrix representing the operation of a controlled qubit gate on any subset of the input ket

Examples

 controlled(X(),n=2,cQubits=0,tQubit=1)
 controlled(X(),n=4,cQubits=c(0,1,2),tQubit=3)

[Package QuantumOps version 3.0.1 Index]