Private types and functions
MimiqCircuitsBase.LazyArg
— TypeLazyArg()
Placeholder for a lazy argument in a LazyExpr
.
MimiqCircuitsBase.LazyExpr
— TypeLazyExpr(type, args)
Helps evaluating expressions lazily.
Evaluation occurs only then the LazyExpr
is called with some arguments, and the arguments will be passed to the inner part of the expression.
MimiqCircuitsBase.UnexpectedSymbolics
— TypeUnexpectedSymbolics(sym, expr)
Error to be thrown when a unexpected symbolics is present in an expression.
Base.append!
— Methodappend!(circuit1::Circuit, circuit2::Circuit)
Append all instructions from circuit2
to circuit1
.
Arguments
circuit1::Circuit
: The target circuit to which instructions will be appended.circuit2::Circuit
: The circuit whose instructions will be appended.
Examples
```jldoctests julia> c=Circuit() empty circuit
julia> push!(c, GateX(), 1:4) # Applies X to all 4 targets 4-qubit circuit with 4 instructions: ├── X @ q[1] ├── X @ q[2] ├── X @ q[3] └── X @ q[4]
julia> c1 = Circuit() empty circuit
julia> push!(c1, GateH(), 1:4) 4-qubit circuit with 4 instructions: ├── H @ q[1] ├── H @ q[2] ├── H @ q[3] └── H @ q[4]
julia> append!(c,c1) 4-qubit circuit with 8 instructions: ├── X @ q[1] ├── X @ q[2] ├── X @ q[3] ├── X @ q[4] ├── H @ q[1] ├── H @ q[2] ├── H @ q[3] └── H @ q[4]
Base.insert!
— Methodinsert!(circuit::Circuit, index::Integer, instruction::Instruction)
Insert an instruction into the circuit at the specified index.
Arguments
circuit::Circuit
: The quantum circuit where the instruction will be inserted.index::Integer
: The position at which the instruction will be inserted.instruction::Instruction
: The instruction to insert.
Examples
```jldoctests julia> c=Circuit() empty circuit
julia> c=Circuit() empty circuit
julia> push!(c, GateX(), 1:4) 4-qubit circuit with 4 instructions: ├── X @ q[1] ├── X @ q[2] ├── X @ q[3] └── X @ q[4]
julia> insert!(c, 2, Instruction(GateH(), 1)) 4-qubit circuit with 5 instructions: ├── X @ q[1] ├── H @ q[1] ├── X @ q[2] ├── X @ q[3] └── X @ q[4]
Base.insert!
— Methodinsert!(circuit1::Circuit, index::Integer, circuit2::Circuit)
Insert all instructions from circuit2
into circuit1
at the specified index.
Arguments
circuit1::Circuit
: The target circuit where instructions will be inserted.index::Integer
: The position at which the instructions fromcircuit2
will be inserted.circuit2::Circuit
: The circuit whose instructions will be inserted.
Examples
```jldoctests julia> c = Circuit() empty circuit
julia> push!(c, GateX(), 1:4) 4-qubit circuit with 4 instructions: ├── X @ q[1] ├── X @ q[2] ├── X @ q[3] └── X @ q[4]
julia> c1 = Circuit() empty circuit
julia> push!(c1, GateH(), 1:4) 4-qubit circuit with 4 instructions: ├── H @ q[1] ├── H @ q[2] ├── H @ q[3] └── H @ q[4]
julia> insert!(c,1,c1) 4-qubit circuit with 8 instructions: ├── H @ q[1] ├── H @ q[2] ├── H @ q[3] ├── H @ q[4] ├── X @ q[1] ├── X @ q[2] ├── X @ q[3] └── X @ q[4]
julia>
Base.insert!
— Methodinsert!(c::Circuit, i::Integer, operation_type::Type{T}, targets...)
Insert a non-parametric operation of a specific type into the circuit at a given position.
Arguments
c::Circuit
: The quantum circuit where the operation will be inserted.i::Integer
: The position (1-based index) in the circuit where the operation will be inserted.operation_type::Type{T}
: The type of the operation to apply.targets
: The target qubits, bits, or z-variables for the operation.
Errors
ArgumentError
: Raised if the operation type is parametric (i.e., it requires parameters).
Examples
julia> c = Circuit()
empty circuit
julia> c=Circuit()
empty circuit
julia> push!(c, GateX(), 1:4)
4-qubit circuit with 4 instructions:
├── X @ q[1]
├── X @ q[2]
├── X @ q[3]
└── X @ q[4]
julia> insert!(c, 3, GateRX(π/2), 5)
5-qubit circuit with 5 instructions:
├── X @ q[1]
├── X @ q[2]
├── RX(π/2) @ q[5]
├── X @ q[3]
└── X @ q[4]
Base.push!
— Methodpush!(circuit::Circuit, instruction::Instruction)
Add an instruction to the circuit.
Arguments
circuit::Circuit
: The quantum circuit to which the instruction will be added.instruction::Instruction
: The instruction to add.
Examples
julia> c=Circuit()
empty circuit
julia> push!(c, Instruction(GateX(),1))
1-qubit circuit with 1 instructions:
└── X @ q[1]
julia> push!(c, Instruction(GateCX(),1, 2))
2-qubit circuit with 2 instructions:
├── X @ q[1]
└── CX @ q[1], q[2]
Base.push!
— Methodpush!(circuit::Circuit, operation::Operation, targets::Vararg{Int})
Add an operation to the circuit with the specified qubit, bit, or zvar targets.
This function allows you to push quantum operations onto a circuit, specifying the exact qubits, classical bits, or zvars (if applicable) that the operation acts on.
Arguments
circuit::Circuit
: The quantum circuit to which the operation will be added.operation::Operation{N,M,L}
: The operation to apply. It works on N qubits, M classical bits, and L zvars.targets::Vararg{Any,K}
: The target qubits, bits, or zvars for the operation.
Throws
ArgumentError
: If the wrong number of targets is provided.ArgumentError
: If any targets are invalid or not distinct.
Examples
julia> c=Circuit()
empty circuit
julia> push!(c, GateCX(), [1, 2], 3) # Adds `CX @ q1, q3` and `CX @ q2, q3`
3-qubit circuit with 2 instructions:
├── CX @ q[1], q[3]
└── CX @ q[2], q[3]
julia> push!(c, GateX(), 1:4) # Applies X to all 4 targets
4-qubit circuit with 6 instructions:
├── CX @ q[1], q[3]
├── CX @ q[2], q[3]
├── X @ q[1]
├── X @ q[2]
├── X @ q[3]
└── X @ q[4]
julia> push!(c, GateH(), 8)
8-qubit circuit with 7 instructions:
├── CX @ q[1], q[3]
├── CX @ q[2], q[3]
├── X @ q[1]
├── X @ q[2]
├── X @ q[3]
├── X @ q[4]
└── H @ q[8]
Base.push!
— Methodpush!(circuit::Circuit, operation_type::Type{T}, targets...)
Add an operation of a specific type to the circuit with the given targets.
Arguments
circuit::Circuit
: The quantum circuit to which the operation will be added.operation_type::Type{T}
: The type of the operation to apply.targets
: The target qubits, bits, or zvars for the operation.
Errors
ArgumentError
: Raised if the operation type requires parameters (i.e., it is a parametric operation), but none were provided.
Examples
julia> c = Circuit()
empty circuit
julia> push!(c, GateRX(π/2), 1:4)
4-qubit circuit with 4 instructions:
├── RX(π/2) @ q[1]
├── RX(π/2) @ q[2]
├── RX(π/2) @ q[3]
└── RX(π/2) @ q[4]
MimiqCircuitsBase._displaypi
— MethodRewrite number in units of π, if number is rational multiple of π.
MimiqCircuitsBase.add_noise_to_gate_parallel!
— Methodadd_noise_to_gate_parallel!(c, g, noise; before=false)
Add a block of noise operations noise
after/before every block of a given operation g
.
The function identifies blocks of consecutive transversal operations of type g
and adds after each such block a block of transversal noise operations noise
. The noise operation noise
can be a Kraus channel or a gate and will act on the same qubits as the operation g
it is being added to.
See add_noise!
for more information.
MimiqCircuitsBase.add_noise_to_gate_single!
— Methodadd_noise_to_gate_single!(c, g, noise; before=false)
Add a noise operation noise
after/before every instance of a given operation g
.
The noise operation noise
can be a Kraus channel or a gate and will act on the same qubits as the operation g
it is being added to.
See add_noise!
for more information.
MimiqCircuitsBase.exponent
— Methodexponent(poweroperation)
Exponent associated with a power operation
Examples
julia> MimiqCircuitsBase.exponent(power(GateH(), 2))
2
julia> MimiqCircuitsBase.exponent(GateSX())
1//2
MimiqCircuitsBase.isCPTP
— MethodisCPTP(krauschannel)
Whether the Kraus channel is Completely Positive, and Trace Preserving.
If the Kraus operators fulfill $\sum_k E_k^\dagger E_k = I$ then the quantum operation is CPTP. If $\sum_k E_k^\dagger E_k < I$, then it's not CPTP.
Currently, all noise channels are CPTP.
MimiqCircuitsBase.isidentity
— Methodisidentity(operation)
Check if the given operation is equivalent to an isidentity.
MimiqLink.DEFAULT_INTERVAL
— Constantconst DEFAULT_INTERVAL
Default refresh interval for tokens (in seconds)
MimiqLink.Connection
— Typestruct Connection
Connection with the MIMIQ Services.
Attributes
uri
: the URI of the connected instancetokens_channel
: channel updated with the latest refreshed tokenrefresher
: task that refreshes the token on a configured interval
MimiqLink.Execution
— Typestruct Execution
Structure referring to an execution on the MIMIQ Services.
MimiqLink.Tokens
— Typestruct Tokens
Store access and refresh tokens
MimiqLink.deletefiles
— Methoddeletefiles(conn, req)"
Delete the files associated with a request.
MimiqLink.printrequests
— Methodprintrequests(conn; kwargs...)
Print the list of requests on the MIMIQ Cloud Services.
Keyword arguments
status
: filter by status. Can beNEW
,RUNNING
,ERROR
,CANCELED
,DONE
.userEmail
: filter by user email.limit
: limit the number of requests to retrieve. Can be [10, 50, 100, 200].page
: page number to retrieve.
MimiqLink.refresh
— Methodrefresh(tokens, uri)
Refresh the tokens at the given uri / instance of MIMIQ.
MimiqLink.requests
— Methodrequests(conn; kwargs...)
Retrieve the list of requests on the MIMIQ Cloud Services.
It is only possible to retrieve the requests that the user has permissions to see. This is often limited to the requests that the user has created, for normal users, and to all organization requests, for organization administrators.
Keyword arguments
status
: filter by status. Can beNEW
,RUNNING
,ERROR
,CANCELED
,DONE
.userEmail
: filter by user email.limit
: limit the number of requests to retrieve. Can be [10, 50, 100, 200].page
: page number to retrieve.
MimiqLink.stopexecution
— Methodstopexecution(conn, req)
Stop the execution of a request.