Internal APIs for developers
DynamicQuantumCircuits.Conversion.conv_ast — Methodconv_ast(ast::MainProgram, state_vector::StateVector, num_qubits::Int64)::MainProgramConverts a non-unitary quantum circuit so it can be tested for equality with its equivalent a unitary circuit
DynamicQuantumCircuits.Conversion.conv_prog — Methodconv_prog(a::Any, state_vector::StateVector, num_qubits::Int, section::Int)::AnyPattern matches a Prog element and returns it with the new address, based on the conversion from the StateVector
DynamicQuantumCircuits.Conversion.conv_qop — Methodconv_qop(cx::CXGate, state_vector::StateVector, section::Int)::CXGateConverts the adresses of a CXGate based on the state vector and section in the dynamic circuit.
DynamicQuantumCircuits.Conversion.conv_qop — Methodconv_qop(inst::Instruction, state_vector::StateVector, section::Int)::InstructionConverts the adresses of a quantum operation based on the state vector and section in the dynamic circuit.
DynamicQuantumCircuits.Conversion.conv_qop — Methodconv_qop(m::Measure, state_vector::StateVector, section::Int)::MeasureConverts the adresses of a Meausment Operation based on the state vector and section in the dynamic circuit.
DynamicQuantumCircuits.Conversion.conv_qop — Methodconv_qop(r::Reset, state_vector::StateVector, section::Int)::ResetReturn the Reset Operation unchanged
FIXME check if this is according to specifaction
DynamicQuantumCircuits.Conversion.conv_regdecl — Methodconv_regdecl(reg::RegDecl, num_qubits::Integer)::RegDeclSets num_qubits bits as the number of bits in a quantum RegDecl
DynamicQuantumCircuits.Conversion.create_bit — Methodcreate_bit(state_vector::StateVector, i::Bit)::BitCreate a Bit from a the state vector and the old bit adress
DynamicQuantumCircuits.Conversion.remove_measurements — Methodremove_measurements(ast::MainProgram)::MainProgramRemoves all measurements from a quantum circuit
DynamicQuantumCircuits.Conversion.remove_resets — Methodremove_resets(ast::MainProgram)::MainProgramRemoves all resets from a quantum circuit
DynamicQuantumCircuits.Conversion.zip_prog_section — Methodzip_prog_section(progs::Vector{Any})Zip the index of each section with a prog element. Increment index after each Measure
DynamicQuantumCircuits.Reorder.calulate_indices — Methodcalulate_indices(state_vector::StateVector)::Array{Int}Create indices for reordering based
Example
julia> calulate_indices(StateVector([1,0], [2]))
Int8[0, 1, 4, 5, 2, 3, 6, 7]DynamicQuantumCircuits.Reorder.create_bit_matrix — Methodcreate_bit_matrix(n::Int)::Matrix{Int}Create matrix for all possible n bit combinations
DynamicQuantumCircuits.Reorder.matrix_row_to_bit — Methodmatrix_row_to_bit(x::Vector{Int})::Intparses an array of ints as a bit
Example
julia> matrix_row_to_bit([0,1,0])
2DynamicQuantumCircuits.Reorder.reorder_columns — Methodreorder_columns(matrix::Matrix{Any}, column_indices::Vector{Int})::MatrixReorder matrix based on column_indices
Example
julia> n = 3 # Number of bits
julia> m = create_bit_matrix(n)
julia> m_reordered = reorder_columns(original_matrix, column_indices)DynamicQuantumCircuits.Reorder.reorder_operator — Methodreorder_operator(operator::Matrix{ComplexF64})::Matrix{ComplexF64}Calculate the new indices and peform the reordering of an operator
DynamicQuantumCircuits.Reorder.reorder_rows — Methodreorder_rows(operator, indices)::MatrixReorder the rows of a matrix based on the indices
DynamicQuantumCircuits.QuantumInformation.density_matrix — Methoddensity_matrix(matrix)::MatrixCalculate the density matrix assuming phi is the first quantum state in Z Basis
Definition
\[M |ϕ⟩ ⟨ϕ| M^\dagger\]
DynamicQuantumCircuits.QuantumInformation.fidelity — Methodfidelity(U1, U2)::Float64Fidelity is a measure of distance between quantum states ϕ and ρ
Definition
The fidelity of two quantum state for qudits is defined as:
\[F(ϕ, σ) = tr(\sqrt{\sqrt{ϕ}ρ\sqrt{ρ}})\]
DynamicQuantumCircuits.QuantumInformation.inner_product — Methodinner_product(x, y)::VectorCalculate the inner product
Examples
The product is written as a bra standing on the left and a ket standing on the right, for example,
\[ ⟨β|α⟩= (⟨β|) ⋅(|α⟩)\]
TODO Doctest
Source
(1.46) Quantum Mechanics Book
DynamicQuantumCircuits.QuantumInformation.outer_product — Methodouter_product(x, y)::MatrixDefinition
\[(|β⟩) ⋅ (⟨α|) = |β⟩⟨α|\]
$|β⟩⟨α|$ is known as the outer product of $|β⟩$ and $⟨α|$. We will emphasize in a moment that |β⟩⟨α| is to be regarded as an operator; hence it is fundamentally different from the inner product ⟨β|α⟩, which is just a number.
There are also “illegal products.” We have already mentioned that an operator must stand on the left of a ket or on the right of a bra.
Examples
TODO Doctest
Source
(1.46) Quantum Mechanics Book
DynamicQuantumCircuits.QuantumInformation.qc_trace_distance — Methodequality(M, M_prime)::Float64Test the equality of two matrices by converting them to density matrices and calculating their trace distance
DynamicQuantumCircuits.QuantumInformation.tracedist — Methodtracedist(A::Matrix, B::Matrix)::Float64Return the trace distance of register1 and register2.
Definition
Trace distance is defined as following:
\[\frac{1}{2} || A - B ||_{\rm tr}\]
Examples
TODO Doctest
References
- https://en.wikipedia.org/wiki/Trace_distance
DynamicQuantumCircuits.QuantumInformation.verify_equivalence — Functionverify_equivalence(traditional_circuit, dynamic_circuit, use_zx::Bool, transform_dynamic_circuit::Bool)::Float64Verify the equality of a traditional_circuit and a reconstruced circuit, returning the trace distance and fidelity as a tuple
TODO change api to differentiate between exact and similar qc
DynamicQuantumCircuits.Tools.combine — Methodcombine(s::StateVector)::Array{Int}Return the combined states of the state vector
DynamicQuantumCircuits.Tools.convert_address — Methodconvert_address(state::State, section::Int, address::Int)::Int64Replaces the address of a qubit based on the state vector, section and position using a lookup table
Objective
This function converts old addresses into new addresses required for the ideal unitary circuit
DynamicQuantumCircuits.Tools.drop_gate_of_type — Methoddrop_gate_of_type(arr, gate_type::Type)Filters any gate which matches the gate type
DynamicQuantumCircuits.Tools.get_controls — Methodget_controls(ast :: MainProgram)::Array{CXGate}Return all control operations of the quantum circuit
DynamicQuantumCircuits.Tools.get_measurements — Methodget_measurements(ast :: MainProgram)::Array{Measure}Return all measurement operations of the quantum circuit
DynamicQuantumCircuits.Tools.get_num_of_qubits — Methodget_num_of_qubits(ast :: MainProgram)::IntReturns the number of qubits, which have been specified in the first quantum register
DynamicQuantumCircuits.Tools.prepare_for_ZXCalculus — Methodprepare_for_ZXCalculus(ast::MainProgram)preparre for import in the ZXCalculus by removing measurements, barriers and #TODO applying custom gates
DynamicQuantumCircuits.Tools.read_qasm_from_file — Methodread_qasm_from_file(filename)::StringRead the qasm from a file
DynamicQuantumCircuits.Tools.state_vector — Methodstate_vector(ast::MainProgram)::StateVectorCreates the reordered StateVector based on the ast of a quantum circuit
DynamicQuantumCircuits.Transformations.acts_on — Methodacts_on?(operation::Any, qubit::Bit)Does the operation act on the qubit
DynamicQuantumCircuits.Transformations.create_bit — Methodcreate_bit(state_vector::StateVector, i::Bit)::BitCreate a Bit from a the state vector and the old bit adress
DynamicQuantumCircuits.Transformations.defeer_measurements — Methoddefeer_measurements(prog::Vector{Any})::Vector{Any}Delay all meausrements to the end and replace phase roations controlled by meausrement outcomes with phase gates controlled by the respective circuits
DynamicQuantumCircuits.Transformations.overcome_resets — Methodovercome_resets(ast::MainProgram, state_vector::StateVector, num_qubits::Int64)::Vector{Any}overcomes resets operations by eliminating qubit reuse
This transforms a n qubit circuit circuit containing r reset operations into a n+r qubit quantum circuits
Algorithm
Overcome resets by interpreting a reset as measuring a qubit and applying an X operation on the measurement being |1⟩ and discarding the measurement result. To overcome the resets replace by introducing a new qubit and applying subsequent operations involving the qubit to the new qubit
DynamicQuantumCircuits.Transformations.remove_measurements — Methodremove_measurements(ast::MainProgram)::MainProgramRemoves all measurements from a quantum circuit
DynamicQuantumCircuits.Transformations.remove_resets — Methodremove_resets(ast::MainProgram)::MainProgramRemoves all resets from a quantum circuit
DynamicQuantumCircuits.Transformations.trans_ast — Methodtrans_ast(ast::MainProgram, state_vector::StateVector, num_qubits::Int64)::MainProgramtransform the dynamic primitives to unveil the underlying unitary functionality
How
- Overcome resets
- Apply the /defered measurement principle/
DynamicQuantumCircuits.Transformations.trans_if_stmt — Methodtrans_if_stmt(stmt, state_vector, section)transforms the qargs of a IfStmt
DynamicQuantumCircuits.Transformations.trans_prog — Methodtrans_prog(a::Any, state_vector::StateVector, num_qubits::Int, section::Int)::AnyPattern matches a Prog element and returns it with the new address, based on the transformation from the StateVector
DynamicQuantumCircuits.Transformations.trans_qop — Methodtrans_qop(cx::CXGate, state_vector::StateVector, section::Int)::CXGatetransforms the adresses of a CXGate based on the state vector and section in the dynamic circuit.
DynamicQuantumCircuits.Transformations.trans_qop — Methodtrans_qop(inst::Instruction, state_vector::StateVector, section::Int)::Instructiontransforms the adresses of a quantum operation based on the state vector and section in the dynamic circuit.
DynamicQuantumCircuits.Transformations.trans_qop — Methodtrans_qop(m::Measure, state_vector::StateVector, section::Int)::Measuretransforms the adresses of a Meausment Operation based on the state vector and section in the dynamic circuit.
DynamicQuantumCircuits.Transformations.trans_qop — Methodtrans_qop(r::Reset, state_vector::StateVector, section::Int)::ResetReturn the Reset Operation unchanged
FIXME check if this is according to specifaction
DynamicQuantumCircuits.Transformations.trans_regdecl — Methodtrans_regdecl(reg::RegDecl, num_qubits::Integer)::RegDeclSets num_qubits bits as the number of bits in a quantum RegDecl
DynamicQuantumCircuits.Transformations.zip_prog_section — Methodzip_prog_section(progs::Vector{Any})Zip the index of each section with a prog element. Increment index after each Measure
```