Interfaces
Yao.Blocks.H
— Constant.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:
Yao.Blocks.X
— Constant.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:
Yao.Blocks.Y
— Constant.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:
Yao.Blocks.Z
— Constant.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:
Yao.Interfaces.InvOrder
— Constant.InvOrder
Return a FunctionBlock
of inversing the order.
Yao.Interfaces.Reset
— Constant.Reset
Yao.Interfaces.@fn
— Macro.macro fn([name,] f)
Define a in-place function on a register inside circuits.
Yao.Interfaces.Rx
— Function.Rx([type=Yao.DefaultType], theta) -> RotationGate{1, type, X}
Returns a rotation X gate.
Yao.Interfaces.Ry
— Function.Ry([type=Yao.DefaultType], theta) -> RotationGate{1, type, Y}
Returns a rotation Y gate.
Yao.Interfaces.Rz
— Function.Rz([type=Yao.DefaultType], theta) -> RotationGate{1, type, Z}
Returns a rotation Z gate.
Yao.Interfaces.addbit
— Method.addbit(n::Int) -> FunctionBlock{:AddBit}
Return a FunctionBlock
of adding n bits.
Yao.Interfaces.chain
— Function.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.
Yao.Interfaces.concentrate
— Method.concentrate(nbit::Int, block::AbstractBlock, addrs::Vector{Int}) -> Concentrator{nbit}
concentrate blocks on serveral addrs.
Yao.Interfaces.control
— Function.control([total], controls, target) -> ControlBlock
Constructs a ControlBlock
Yao.Interfaces.matrixgate
— Method.matrixgate(matrix::AbstractMatrix) -> GeneralMatrixGate
matrixgate(matrix::MatrixBlock) -> GeneralMatrixGate
Construct a general matrix gate.
Yao.Interfaces.phase
— Function.phase([type=Yao.DefaultType], theta) -> PhaseGate{:global}
Returns a global phase gate.
Yao.Interfaces.put
— Method.put([total::Int, ]pa::Pair) -> PutBlock{total}
put a block at the specific position(s), can be lazy constructed.
Yao.Interfaces.reflect
— Function.reflect(mirror::DefaultRegister{1}) -> ReflectBlock
reflect(mirror::Vector) -> ReflectBlock
Return an ReflectBlock along with state vector mirror as the axis.
Yao.Interfaces.roll
— Function.Yao.Interfaces.rollrepeat
— Function.Yao.Interfaces.rot
— Function.rot([type=Yao.DefaultType], U, theta) -> RotationGate{N, type, U}
Returns an arbitrary rotation gate on U.
Yao.Interfaces.sequence
— Function.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.
Yao.Interfaces.shift
— Function.shift([type=Yao.DefaultType], theta) -> PhaseGate{:shift}
Returns a phase shift gate.
Yao.Interfaces.swap
— Function.swap([n], [type], line1, line2) -> Swap
Returns a swap gate on line1
and line2
Yao.Interfaces.with!
— Method.with!(f, register)
Provide a writable context for blocks operating this register.
Yao.Interfaces.with
— Method.with(f, register)
Provide a copy context for blocks operating this register.
Yao.Blocks.XGate
— Type.XGate{T} <: ConstantGate{1, T}
The block type for Pauli-X gate. See docs for X
for more information.
Yao.Blocks.YGate
— Type.YGate{T} <: ConstantGate{1, T}
The block type for Pauli-Y gate. See docs for Y
for more information.
Yao.Blocks.ZGate
— Type.ZGate{T} <: ConstantGate{1, T}
The block type for Pauli-Z gate. See docs for Z
for more information.
Base.kron
— Method.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] --
Base.repeat
— Method.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.