Interfaces

Interfaces

Yao.Blocks.HConstant.
H

The Hadamard gate acts on a single qubit. It maps the basis state $|0\rangle$ to $\frac{|0\rangle + |1\rangle}{\sqrt{2}}$ and $|1\rangle$ to $\frac{|0\rangle - |1\rangle}{\sqrt{2}}$, which means that a measurement will have equal probabilities to become 1 or 0. It is representated by the Hadamard matrix:

\[H = \frac{1}{\sqrt{2}} \begin{pmatrix} 1 & 1 \\ 1 & -1 \end{pmatrix}\]
source
Yao.Blocks.XConstant.
X

The Pauli-X gate acts on a single qubit. It is the quantum equivalent of the NOT gate for classical computers (with respect to the standard basis $|0\rangle$, $|1\rangle$). It is represented by the Pauli X matrix:

\[X = \begin{pmatrix} 0 & 1\\ 1 & 0 \end{pmatrix}\]
source
Yao.Blocks.YConstant.
Y

The Pauli-Y gate acts on a single qubit. It equates to a rotation around the Y-axis of the Bloch sphere by $\pi$ radians. It maps $|0\rangle$ to $i|1\rangle$ and $|1\rangle$ to $-i|0\rangle$. It is represented by the Pauli Y matrix:

\[Y = \begin{pmatrix} 0 & -i\\ i & 0 \end{pmatrix}\]
source
Yao.Blocks.ZConstant.
Z

The Pauli-Z gate acts on a single qubit. It equates to a rotation around the Z-axis of the Bloch sphere by $\pi$ radians. Thus, it is a special case of a phase shift gate (see shift) with $\theta = \pi$. It leaves the basis state $|0\rangle$ unchanged and maps $|1\rangle$ to $-|1\rangle$. Due to this nature, it is sometimes called phase-flip. It is represented by the Pauli Z matrix:

\[Z = \begin{pmatrix} 1 & 0\\ 0 & -1 \end{pmatrix}\]
source
InvOrder

Return a FunctionBlock of inversing the order.

source
Yao.Interfaces.ResetConstant.
Reset
source
macro fn([name,] f)

Define a in-place function on a register inside circuits.

source
Yao.Interfaces.RxFunction.
Rx([type=Yao.DefaultType], theta) -> RotationGate{1, type, X}

Returns a rotation X gate.

source
Yao.Interfaces.RyFunction.
Ry([type=Yao.DefaultType], theta) -> RotationGate{1, type, Y}

Returns a rotation Y gate.

source
Yao.Interfaces.RzFunction.
Rz([type=Yao.DefaultType], theta) -> RotationGate{1, type, Z}

Returns a rotation Z gate.

source
addbit(n::Int) -> FunctionBlock{:AddBit}

Return a FunctionBlock of adding n bits.

source
Yao.Interfaces.chainFunction.
chain([T], n::Int) -> ChainBlock
chain([n], blocks) -> ChainBlock

Returns a ChainBlock. This factory method can be called lazily if you missed the total number of qubits.

This chains several blocks with the same size together.

source
concentrate(nbit::Int, block::AbstractBlock, addrs::Vector{Int}) -> Concentrator{nbit}

concentrate blocks on serveral addrs.

source
control([total], controls, target) -> ControlBlock

Constructs a ControlBlock

source
matrixgate(matrix::AbstractMatrix) -> GeneralMatrixGate
matrixgate(matrix::MatrixBlock) -> GeneralMatrixGate

Construct a general matrix gate.

source
Yao.Interfaces.phaseFunction.
phase([type=Yao.DefaultType], theta) -> PhaseGate{:global}

Returns a global phase gate.

source
Yao.Interfaces.putMethod.
put([total::Int, ]pa::Pair) -> PutBlock{total}

put a block at the specific position(s), can be lazy constructed.

source
reflect(mirror::DefaultRegister{1}) -> ReflectBlock
reflect(mirror::Vector) -> ReflectBlock

Return an ReflectBlock along with state vector mirror as the axis.

source
Yao.Interfaces.rollFunction.
roll([n::Int, ], blocks...,) -> Roller{n}

Construct a Roller block, which is a faster than KronBlock to calculate similar small blocks tile on the whole address.

source
rollrepeat([n::Int,] block::MatrixBlock) -> Roller{n}

Construct a Roller block, which is a faster than KronBlock to calculate similar small blocks tile on the whole address.

source
Yao.Interfaces.rotFunction.
rot([type=Yao.DefaultType], U, theta) -> RotationGate{N, type, U}

Returns an arbitrary rotation gate on U.

source

Returns a Sequential block. This factory method can be called lazily if you missed the total number of qubits.

This is the loose version of sequence, that does not support the mat related interfaces.

source
Yao.Interfaces.shiftFunction.
shift([type=Yao.DefaultType], theta) -> PhaseGate{:shift}

Returns a phase shift gate.

source
Yao.Interfaces.swapFunction.
swap([n], [type], line1, line2) -> Swap

Returns a swap gate on line1 and line2

source
with!(f, register)

Provide a writable context for blocks operating this register.

source
with(f, register)

Provide a copy context for blocks operating this register.

source
XGate{T} <: ConstantGate{1, T}

The block type for Pauli-X gate. See docs for X for more information.

source
YGate{T} <: ConstantGate{1, T}

The block type for Pauli-Y gate. See docs for Y for more information.

source
ZGate{T} <: ConstantGate{1, T}

The block type for Pauli-Z gate. See docs for Z for more information.

source
Base.kronMethod.
kron([total::Int, ]block0::Pair, blocks::Union{MatrixBlock, Pair}...,) -> KronBlock{total}

create a KronBlock with a list of blocks or tuple of heads and blocks. If total is not provided, return a lazy constructor.

Example

kron(4, 1=>X, 3=>Z, Y)

This will automatically generate a block list looks like

1 -- [X] --
2 ---------
3 -- [Z] --
4 -- [Y] --
source
Base.repeatMethod.
repeat([n::Int,] x::MatrixBlock, [addrs]) -> RepeatedBlock{n}

Construct a RepeatedBlock, if n (the number of qubits) not supplied, using lazy evaluation. If addrs not supplied, blocks will fill the qubit space.

source