Zoo

Zoo

GroverIter{N, T}

GroverIter(oracle, ref::ReflectBlock{N, T}, psi::DefaultRegister, niter::Int)

an iterator that perform Grover operations step by step. An Grover operation consists of applying oracle and Reflection.

source
RotBasis{T} <: PrimitiveBlock{1, Complex{T}}

A special rotation block that transform basis to angle θ and ϕ in bloch sphere.

source
cnot_entangler([n::Int, ] pairs::Vector{Pair}) = ChainBlock

Arbitrary rotation unit, support lazy construction.

source
collect_rotblocks(blk::AbstractBlock) -> Vector{RotationGate}

filter out all rotation gates, which is differentiable.

source
diff_circuit(n, nlayer, pairs) -> ChainBlock

A kind of widely used differentiable quantum circuit, angles in the circuit is randomely initialized.

ref: 1. Kandala, A., Mezzacapo, A., Temme, K., Takita, M., Chow, J. M., & Gambetta, J. M. (2017). Hardware-efficient Quantum Optimizer for Small Molecules and Quantum Magnets. Nature Publishing Group, 549(7671), 242–246. https://doi.org/10.1038/nature23879.

source
groverblock(oracle, ref::ReflectBlock{N, T}, niter::Int=-1)
groverblock(oracle, psi::DefaultRegister, niter::Int=-1)

Return a ChainBlock/Sequential as Grover Iteration, the default niter will stop at the first optimal step.

source
inference_oracle([nbit::Int,] locs::Vector{Int}) -> ControlBlock

A simple inference oracle, e.g. inference([-1, -8, 5]) is a control block that flip the bit if values of bits on position [1, 8, 5] match [0, 0, 1].

source
Yao.Zoo.num_gradientFunction.
num_gradient(lossfunc, rots::Vector{<:RotationGate}, δ::Float64=1e-2) -> Vector

Compute gradient numerically.

source
num_grover_step(psi::DefaultRegister, oracle) -> Int

Return number of grover steps needed to match the oracle.

source
Yao.Zoo.openboxFunction.

For a black box, like QFTBlock, you can get its white box (loyal simulation) using this function.

source
Yao.Zoo.opgradMethod.
opgrad(op_expect, rots::Vector{<:RotationGate}) -> Vector

get the gradient of an operator expectation function.

References: Mitarai, K., Negoro, M., Kitagawa, M., & Fujii, K. (2018). Quantum Circuit Learning, 1–3. Retrieved from http://arxiv.org/abs/1803.00745

source
Yao.Zoo.perturbMethod.
perturb(func, gates::Vector{<:RotationGate}, diff::Real) -> Matrix

perturb every rotation gates, and evaluate losses. The i-th element of first column of resulting Matrix corresponds to Gi(θ+δ), and the second corresponds to Gi(θ-δ).

source
Yao.Zoo.polar2uMethod.
polar2u(vec::Array) -> Array

transform polar angle to su(2) state vector, apply to the first dimension of size 2.

source
prob_match_oracle(psi, oracle) -> Float64

Return the probability that psi matches oracle.

source
Yao.Zoo.randpolarMethod.
randpolar(params::Int...) -> Array

random polar basis, number of basis

source
Yao.Zoo.rotterFunction.
rotter(noleading::Bool=false, notrailing::Bool=false) -> ChainBlock{1, ComplexF64}

Arbitrary rotation unit, set parameters notrailing, noleading true to remove trailing and leading Z gates.

source
Yao.Zoo.u2polarMethod.
u2polar(vec::Array) -> Array

transform su(2) state vector to polar angle, apply to the first dimension of size 2.

source
target_space(oracle) -> Vector{Bool}

Return a mask, that disired subspace of an oracle are masked true.

source