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.StatFunctional
— Type.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
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.add
— Function.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.
Yao.Interfaces.addbit
— Method.addbit(n::Int) -> FunctionBlock{:AddBit}
Return a FunctionBlock
of adding n bits.
Yao.Interfaces.autodiff
— Function.autodiff(mode::Symbol, block::AbstractBlock) -> AbstractBlock
autodiff(mode::Symbol) -> Function
automatically mark differentiable items in a block tree as differentiable.
Yao.Interfaces.chain
— Function.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.
Yao.Interfaces.concentrate
— Method.concentrate(nbit::Int, block::AbstractBlock, addrs) -> 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.numdiff
— Method.numdiff(loss, diffblock::AbstractDiff; δ::Real=1e-2)
Numeric differentiation.
Yao.Interfaces.opdiff
— Method.opdiff(psifunc, diffblock::AbstractDiff, op::MatrixBlock)
Operator differentiation.
Yao.Interfaces.paulistring
— Function.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.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.statdiff
— Method.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.swap
— Function.swap([n], [type], line1, line2) -> Swap
Returns a swap gate on line1
and line2
Yao.Interfaces.timeevolve
— Function.timeevolve({block::MatrixBlock}, t::Real; tol::Real=1e-7) -> TimeEvolution
Make a time machine! If block is not provided, it will become lazy.
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, 4=>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.