controlled: controlled

Description Usage Arguments Value Examples

View source: R/controlled.R

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

1
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

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

Example output

Attaching package:QuantumOpsThe following object is masked frompackage:stats:

    dist

The following objects are masked frompackage:base:

    I, norm, single

     [,1] [,2] [,3] [,4]
[1,] 1+0i 0+0i 0+0i 0+0i
[2,] 0+0i 1+0i 0+0i 0+0i
[3,] 0+0i 0+0i 0+0i 1+0i
[4,] 0+0i 0+0i 1+0i 0+0i
      [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13]
 [1,] 1+0i 0+0i 0+0i 0+0i 0+0i 0+0i 0+0i 0+0i 0+0i  0+0i  0+0i  0+0i  0+0i
 [2,] 0+0i 1+0i 0+0i 0+0i 0+0i 0+0i 0+0i 0+0i 0+0i  0+0i  0+0i  0+0i  0+0i
 [3,] 0+0i 0+0i 1+0i 0+0i 0+0i 0+0i 0+0i 0+0i 0+0i  0+0i  0+0i  0+0i  0+0i
 [4,] 0+0i 0+0i 0+0i 1+0i 0+0i 0+0i 0+0i 0+0i 0+0i  0+0i  0+0i  0+0i  0+0i
 [5,] 0+0i 0+0i 0+0i 0+0i 1+0i 0+0i 0+0i 0+0i 0+0i  0+0i  0+0i  0+0i  0+0i
 [6,] 0+0i 0+0i 0+0i 0+0i 0+0i 1+0i 0+0i 0+0i 0+0i  0+0i  0+0i  0+0i  0+0i
 [7,] 0+0i 0+0i 0+0i 0+0i 0+0i 0+0i 1+0i 0+0i 0+0i  0+0i  0+0i  0+0i  0+0i
 [8,] 0+0i 0+0i 0+0i 0+0i 0+0i 0+0i 0+0i 1+0i 0+0i  0+0i  0+0i  0+0i  0+0i
 [9,] 0+0i 0+0i 0+0i 0+0i 0+0i 0+0i 0+0i 0+0i 1+0i  0+0i  0+0i  0+0i  0+0i
[10,] 0+0i 0+0i 0+0i 0+0i 0+0i 0+0i 0+0i 0+0i 0+0i  1+0i  0+0i  0+0i  0+0i
[11,] 0+0i 0+0i 0+0i 0+0i 0+0i 0+0i 0+0i 0+0i 0+0i  0+0i  1+0i  0+0i  0+0i
[12,] 0+0i 0+0i 0+0i 0+0i 0+0i 0+0i 0+0i 0+0i 0+0i  0+0i  0+0i  1+0i  0+0i
[13,] 0+0i 0+0i 0+0i 0+0i 0+0i 0+0i 0+0i 0+0i 0+0i  0+0i  0+0i  0+0i  1+0i
[14,] 0+0i 0+0i 0+0i 0+0i 0+0i 0+0i 0+0i 0+0i 0+0i  0+0i  0+0i  0+0i  0+0i
[15,] 0+0i 0+0i 0+0i 0+0i 0+0i 0+0i 0+0i 0+0i 0+0i  0+0i  0+0i  0+0i  0+0i
[16,] 0+0i 0+0i 0+0i 0+0i 0+0i 0+0i 0+0i 0+0i 0+0i  0+0i  0+0i  0+0i  0+0i
      [,14] [,15] [,16]
 [1,]  0+0i  0+0i  0+0i
 [2,]  0+0i  0+0i  0+0i
 [3,]  0+0i  0+0i  0+0i
 [4,]  0+0i  0+0i  0+0i
 [5,]  0+0i  0+0i  0+0i
 [6,]  0+0i  0+0i  0+0i
 [7,]  0+0i  0+0i  0+0i
 [8,]  0+0i  0+0i  0+0i
 [9,]  0+0i  0+0i  0+0i
[10,]  0+0i  0+0i  0+0i
[11,]  0+0i  0+0i  0+0i
[12,]  0+0i  0+0i  0+0i
[13,]  0+0i  0+0i  0+0i
[14,]  1+0i  0+0i  0+0i
[15,]  0+0i  0+0i  1+0i
[16,]  0+0i  1+0i  0+0i

QuantumOps documentation built on Feb. 3, 2020, 5:07 p.m.