Intrinsics
AddressConflictError <: ExceptionAddress conflict error in Block Construction.
Yao.Intrinsics.IterControl — Type.IterControl{N, C}N is the size of hilbert space, C is the number of shifts.
QubitMismatchError <: ExceptionQubit number mismatch error when applying a Block to a Register or concatenating Blocks.
LinearAlgebra.ishermitian — Method.ishermitian(op) -> Boolcheck if this operator is hermitian.
Yao.Intrinsics.baddrs — Method.baddrs(b::Integer) -> Vectorget the locations of nonzeros bits, i.e. the inverse operation of bmask.
Yao.Intrinsics.basis — Method.basis([IntType], num_bit::Int) -> UnitRange{IntType}
basis([IntType], state::AbstractArray) -> UnitRange{IntType}Returns the UnitRange for basis in Hilbert Space of num_bit qubits. If an array is supplied, it will return a basis having the same size with the first diemension of array.
Yao.Intrinsics.batch_normalize — Function.batch_normalizenormalize a batch of vector.
Yao.Intrinsics.batch_normalize! — Function.batch_normalize!(matrix)normalize a batch of vector.
Yao.Intrinsics.bdistance — Method.bdistance(i::Integer, j::Integer) -> IntReturn number of different bits.
Yao.Intrinsics.bfloat — Method.bfloat(b::Integer; nbit::Int=bit_length(b)) -> Float64float view, with big end qubit 1.
Yao.Intrinsics.bfloat_r — Method.bfloat_r(b::Integer; nbit::Int) -> Float64float view, with bits read in inverse order.
Yao.Intrinsics.bint — Method.bint(b; nbit=nothing) -> Intinteger view, with little end qubit 1.
Yao.Intrinsics.bint_r — Method.bint_r(b; nbit::Int) -> Integerinteger read in inverse order.
Yao.Intrinsics.bit_length — Method.bit_length(x::Integer) -> IntReturn the number of bits required to represent input integer x.
Yao.Intrinsics.bitarray — Method.bitarray(v::Vector, [num_bit::Int]) -> BitArray
bitarray(v::Int, num_bit::Int) -> BitArray
bitarray(num_bit::Int) -> FunctionConstruct BitArray from an integer vector, if num_bit not supplied, it is 64. If an integer is supplied, it returns a function mapping a Vector/Int to bitarray.
Yao.Intrinsics.bmask — Function.bmask([IntType], ibit::Int...) -> IntType
bmask([IntType], bits::UnitRange{Int}) ->IntTypeReturn an integer with specific position masked, which is offten used as a mask for binary operations.
Yao.Intrinsics.breflect — Function.breflect(num_bit::Int, b::Integer[, masks::Vector{Integer}]) -> IntegerReturn left-right reflected integer.
Yao.Intrinsics.bsizeof — Method.bsizeof(x) -> IntReturn the size of object, in number of bit.
Yao.Intrinsics.controldo — Method.controldo(func::Function, ic::IterControl{N, C})Faster than for i in ic ... end.
Yao.Intrinsics.controller — Method.controller(cbits, cvals) -> FunctionReturn a function that test whether a basis at cbits takes specific value cvals.
Yao.Intrinsics.cunapply! — Function.control-unitary
Yao.Intrinsics.cunmat — Function.cunmat(nbit::Int, cbits::NTuple{C, Int}, cvals::NTuple{C, Int}, U0::AbstractMatrix, locs::NTuple{M, Int}) where {C, M} -> AbstractMatrixcontrol-unitary matrix
Yao.Intrinsics.fidelity_mix — Method.fidelity_mix(m1::Matrix, m2::Matrix)Fidelity for mixed states.
Reference: http://iopscience.iop.org/article/10.1088/1367-2630/aa6a4b/meta
Yao.Intrinsics.fidelity_pure — Method.fidelity for pure states.
Yao.Intrinsics.flip — Method.flip(index::Integer, mask::Integer) -> IntegerReturn an Integer with bits at masked position flipped.
Yao.Intrinsics.general_c1_gates — Method.general_c1_gates(num_bit::Int, projector::AbstractMatrix, cbit::Int, gates::Vector{AbstractMatrix}, locs::Vector{Int}) -> AbstractMatrixgeneral (low performance) construction method for control gate on different lines.
Yao.Intrinsics.general_controlled_gates — Method.general_controlled_gates(num_bit::Int, projectors::Vector{Tp}, cbits::Vector{Int}, gates::Vector{AbstractMatrix}, locs::Vector{Int}) -> AbstractMatrixReturn general multi-controlled gates in hilbert space of num_bit qubits,
- projectorsare often chosen as- P0and- P1for inverse-Control and Control at specific position.
- cbitsshould have the same length as- projectors, specifing the controling positions.
- gatesare a list of controlled single qubit gates.
- locsshould have the same length as- gates, specifing the gates positions.
Yao.Intrinsics.getcol — Method.getcol(csc::SDparseMatrixCSC, icol::Int) -> (View, View)get specific col of a CSC matrix, returns a slice of (rowval, nzval)
Yao.Intrinsics.hilbertkron — Method.hilbertkron(num_bit::Int, gates::Vector{AbstractMatrix}, locs::Vector{Int}) -> AbstractMatrixReturn general kronecher product form of gates in Hilbert space of num_bit qubits.
- gatesare a list of matrices.
- start_locsshould have the same length as- gates, specifing the gates starting positions.
Yao.Intrinsics.hypercubic — Method.hypercubic(A::Union{Array, DefaultRegister}) -> Arrayget the hypercubic representation for an array or a regiseter.
Yao.Intrinsics.indices_with — Method.indices_with(num_bit::Int, poss::Vector{Int}, vals::Vector{Int}) -> Vector{Int}Return indices with specific positions poss with value vals in a hilbert space of num_bit qubits.
Yao.Intrinsics.iscommute — Method.iscommute(ops...) -> Boolcheck if operators are commute.
Yao.Intrinsics.isreflexive — Method.isreflexive(op) -> Boolcheck if this operator is reflexive.
Yao.Intrinsics.isunitary — Method.isunitary(op) -> Boolcheck if this operator is a unitary operator.
Yao.Intrinsics.itercontrol — Method.itercontrol(num_bit::Int, poss::Vector{Int}, vals::Vector{Int}) -> IterControlReturn the iterator for basis with poss controlled to values vals, with the total number of bits num_bit.
Yao.Intrinsics.linop2dense — Method.linop2dense(applyfunc!::Function, num_bit::Int) -> Matrixget the dense matrix representation given matrix*matrix function.
Yao.Intrinsics.log2i — Function.log2i(x::Integer) -> IntegerReturn log2(x), this integer version of log2 is fast but only valid for number equal to 2^n.
Yao.Intrinsics.matvec — Function.matvec(x::VecOrMat) -> MatOrVecReturn vector if a matrix is a column vector, else untouched.
Yao.Intrinsics.mulcol! — Function.mulcol!(v::AbstractVector, i::Int, f) -> VecOrMatmultiply col i of v by f inplace.
Yao.Intrinsics.mulrow! — Function.mulrow!(v::AbstractVector, i::Int, f) -> VecOrMatmultiply row i of v by f inplace.
Yao.Intrinsics.neg — Method.neg(index::Integer, num_bit::Int) -> IntegerReturn an integer with all bits flipped (with total number of bit num_bit).
Yao.Intrinsics.onehotvec — Method.onehotvec(::Type{T}, num_bit::Int, x::Integer) -> Vector{T}one-hot wave vector.
Yao.Intrinsics.packbits — Method.packbits(arr::AbstractArray) -> AbstractArraypack bits to integers, usually take a BitArray as input.
Yao.Intrinsics.rand_hermitian — Method.rand_hermitian(N::Int) -> MatrixRandom hermitian matrix.
Yao.Intrinsics.rand_unitary — Method.rand_unitary(N::Int) -> MatrixRandom unitary matrix.
Yao.Intrinsics.reordered_basis — Method.Reordered Basis
Yao.Intrinsics.setbit — Method.setbit(index::Integer, mask::Integer) -> Integerset the bit at masked position to 1.
Yao.Intrinsics.setcol! — Method.setcol!(csc::SparseMatrixCSC, icol::Int, rowval::AbstractVector, nzval) -> SparseMatrixCSCset specific col of a CSC matrix
Yao.Intrinsics.swapbits — Method.swapbits(num::Integer, mask12::Integer) -> IntegerReturn an integer with bits at i and j flipped.
Yao.Intrinsics.swapcols! — Function.swapcols!(v::VecOrMat, i::Int, j::Int[, f1, f2]) -> VecOrMatswap col i and col j of v inplace, with f1, f2 factors applied on i and j (before swap).
Yao.Intrinsics.swaprows! — Function.swaprows!(v::VecOrMat, i::Int, j::Int[, f1, f2]) -> VecOrMatswap row i and row j of v inplace, with f1, f2 factors applied on i and j (before swap).
Yao.Intrinsics.takebit — Method.takebit(index::Integer, bits::Int...) -> IntReturn a bit(s) at specific position.
Yao.Intrinsics.testall — Method.testall(index::Integer, mask::Integer) -> BoolReturn true if all masked position of index is 1.
Yao.Intrinsics.testany — Method.testany(index::Integer, mask::Integer) -> BoolReturn true if any masked position of index is 1.
Yao.Intrinsics.testval — Method.testval(index::Integer, mask::Integer, onemask::Integer) -> BoolReturn true if values at positions masked by mask with value 1 at positions masked by onemask and 0 otherwise.
Yao.Intrinsics.u1rows! — Function.u1rows!(state::VecOrMat, i::Int, j::Int, a, b, c, d) -> VecOrMatapply u1 on row i and row j of state inplace.
Yao.Intrinsics.unmat — Method.unmat(nbit::Int, U::AbstractMatrix, locs::NTuple) -> AbstractMatrixReturns the matrix representation of putting matrix at locs.
Base.sort — Method.sort(t::Tuple; lt=isless, by=identity, rev::Bool=false) -> ::TupleSorts the tuple t.
Base.sortperm — Method.sortperm(t::Tuple; lt=isless, by=identity, rev::Bool=false) -> ::TupleComputes a tuple that contains the permutation required to sort t.
Yao.Intrinsics.autostatic — Method.turn a vector/matrix to static vector/matrix (only if its length <= 256).
Yao.Intrinsics.u1ij! — Function.u1ij!(target, i, j, a, b, c, d)single u1 matrix into a target matrix.
Note: For coo, we take a additional parameter * ptr: starting position to store new data.
Yao.nactive — Method.nactive(m::AbstractArray) -> IntReturns the log-size of its first dimension.