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}\]
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}\]
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}\]
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}\]
InvOrder

Return a FunctionBlock of inversing the order.

Yao.Interfaces.ResetConstant.
Reset
StatFunctional{N, AT}
StatFunctional(array::AT<:Array) -> StatFunctional{N, <:Array}
StatFunctional{N}(func::AT<:Function) -> StatFunctional{N, <:Function}

statistic functional, i.e. * if AT is an array, A[i,j,k...], it is defined on finite Hilbert space, which is ∫A[i,j,k...]p[i]p[j]p[k]... * if AT is a function, F(xᵢ,xⱼ,xₖ...), this functional is 1/C(r,n)... ∑ᵢⱼₖ...F(xᵢ,xⱼ,xₖ...), see U-statistics for detail.

References: U-statistics, http://personal.psu.edu/drh20/asymp/fall2006/lectures/ANGELchpt10.pdf

macro fn([name,] f)

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

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

Returns a rotation X gate.

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

Returns a rotation Y gate.

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

Returns a rotation Z gate.

Yao.Interfaces.addFunction.
add([T], n::Int) -> AddBlock
add([n], blocks) -> AddBlock
add(blocks...) -> AddBlock

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

This adds several blocks with the same size together.

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

Return a FunctionBlock of adding n bits.

autodiff(mode::Symbol, block::AbstractBlock) -> AbstractBlock
autodiff(mode::Symbol) -> Function

automatically mark differentiable items in a block tree as differentiable.

Yao.Interfaces.chainFunction.
chain([T], n::Int) -> ChainBlock
chain([n], blocks) -> ChainBlock
chain(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.

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

concentrate blocks on serveral addrs.

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

Constructs a ControlBlock

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

Construct a general matrix gate.

numdiff(loss, diffblock::AbstractDiff; δ::Real=1e-2)

Numeric differentiation.

opdiff(psifunc, diffblock::AbstractDiff, op::MatrixBlock)

Operator differentiation.

paulistring([n], blocks::PauliGate...) -> PauliString
paulistring([n], blocks::Pair{Int, PauliGate}...) -> PauliString

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

This krons several pauli gates, either dict (more flexible) like input and chain like input are allowed. i.e. paulistring(3, X, Y, Z) is equivalent to paulistring(3, 1=>X, 2=>Y, 3=>Z)

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

Returns a global phase gate.

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

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

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

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

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.

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.

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

Returns an arbitrary rotation gate on U.

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.shiftFunction.
shift([type=Yao.DefaultType], theta) -> PhaseGate{:shift}

Returns a phase shift gate.

statdiff(probfunc, diffblock::AbstractDiff, stat::StatFunctional{<:Any, <:AbstractArray}; initial::AbstractVector=probfunc())
statdiff(samplefunc, diffblock::AbstractDiff, stat::StatFunctional{<:Any, <:Function}; initial::AbstractVector=samplefunc())

Differentiation for statistic functionals.

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

Returns a swap gate on line1 and line2

timeevolve({block::MatrixBlock}, t::Real; tol::Real=1e-7) -> TimeEvolution

Make a time machine! If block is not provided, it will become lazy.

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

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

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

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

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

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

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, 4=>Y)

This will automatically generate a block list looks like

1 -- [X] --
2 ---------
3 -- [Z] --
4 -- [Y] --
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.