Base

The Base module of Yao is defined in YaoBase.jl, it provides:

Math Functions

YaoBase.autostaticMethod
autostatic(A[; threshold=8])

Staticize dynamic array A by a threshold.

YaoBase.density_fidelityMethod
density_fidelity(ρ1, ρ2)

General fidelity (including mixed states) between two density matrix for qubits.

Definition

\[F(ρ, σ)^2 = tr(ρσ) + 2 \sqrt{det(ρ)det(σ)}\]
YaoBase.general_c1_gatesMethod
general_c1_gates(num_bit::Int, projector::AbstractMatrix, cbit::Int, gates::Vector{AbstractMatrix}, locs::Vector{Int}) -> AbstractMatrix

general (low performance) construction method for control gate on different lines.

YaoBase.general_controlled_gatesMethod
general_controlled_gates(num_bit::Int, projectors::Vector{Tp}, cbits::Vector{Int}, gates::Vector{AbstractMatrix}, locs::Vector{Int}) -> AbstractMatrix

Return general multi-controlled gates in hilbert space of num_bit qubits,

  • projectors are often chosen as P0 and P1 for inverse-Control and Control at specific position.
  • cbits should have the same length as projectors, specifing the controling positions.
  • gates are a list of controlled single qubit gates.
  • locs should have the same length as gates, specifing the gates positions.
YaoBase.hilbertkronMethod
hilbertkron(num_bit::Int, gates::Vector{AbstractMatrix}, locs::Vector{Int}) -> AbstractMatrix

Return general kronecher product form of gates in Hilbert space of num_bit qubits.

  • gates are a list of matrices.
  • start_locs should have the same length as gates, specifing the gates starting positions.
YaoBase.linop2denseMethod
linop2dense([T=ComplexF64], linear_map!::Function, n::Int) -> Matrix

Returns the dense matrix representation given linear map function.

YaoBase.nucnormMethod

nucnorm(m)

Computes the nuclear norm of a matrix m.

YaoBase.purification_fidelityMethod
purification_fidelity(m1::Matrix, m2::Matrix)

Fidelity for mixed states via purification.

Reference: http://iopscience.iop.org/article/10.1088/1367-2630/aa6a4b/meta

YaoBase.rand_hermitianMethod
rand_hermitian([T=ComplexF64], N::Int) -> Matrix

Create a random hermitian matrix.

YaoBase.rand_unitaryMethod
rand_unitary([T=ComplexF64], N::Int) -> Matrix

Create a random unitary matrix.

YaoBase.rotmatMethod
rotmat(M::AbstractMatrix, θ::Real)

Returns rotated M: $exp(-\frac{imθ}{2} M)$.

YaoBase.sprand_unitaryMethod
sprand_unitary([T=ComplexF64], N::Int, density) -> SparseMatrixCSC

Create a random sparse unitary matrix.

YaoBase.trnormMethod

trnorm(m)

Computes the trace norm of a matrix m.

General Properties

YaoBase.isunitaryMethod
isunitary(op) -> Bool

check if this operator is a unitary operator.

Error and Exceptions

YaoBase.QubitMismatchErrorType
QubitMismatchError <: Exception

Qubit number mismatch error when applying a Block to a Register or concatenating Blocks.

YaoBase.islocs_inboundsMethod
islocs_inbounds(n, locs) -> Bool

Check if the input locations are inside given bounds n.

YaoBase.@assert_locs_inboundsMacro
@assert_locs_inbounds <number of total qubits> <locations list> [<msg>]

Assert if all the locations are inbounds.

YaoBase.@assert_locs_safeMacro
@assert_locs_safe <number of total qubits> <locations list> [<msg>]

Assert if all the locations are: - inbounds. - do not have any conflict.

Constants

defined constants
$CNOT$
$CZ$
$H$
$I2$
$P0$
$P1$
$Pd$
$Pu$
$S$
$SWAP$
$Sdag$
$T$
$Tdag$
$Toffoli$
$X$
$Y$
$Z$