General functions

MimiqCircuitsBase.getoperationFunction
getoperation(operation)
getoperation(instruction)

Returns the quantum operation associated to the given instruction.

See also iswrapper.

Examples

julia> getoperation(Instruction(GateX(), 1))
X

julia> getoperation(GateSX())
X

julia> getoperation(GateCX())
X
source
MimiqCircuitsBase.numbitsFunction
numbits(instruction)
numbits(circuit)

Number of classical bits on which the given operation or instruction is defined.

See also numqubits.

Examples

julia> numbits(GateCX())
0

julia> numbits(Measure())
1

julia> c = Circuit(); push!(c, Measure(), 1, 1); push!(c, Measure(),1,3)
1-qubit circuit with 2 instructions:
├── M @ q[1], c[1]
└── M @ q[1], c[3]

julia> numbits(c)
3
source
MimiqCircuitsBase.numqubitsFunction
numqubits(operation)
numqubits(instruction)
numqubits(circuit)

Number of qubits on which the given operation or instruction is defined.

See also numbits.

Examples

julia> numqubits(GateCX())
2

julia> numqubits(Measure())
1

julia> c = Circuit(); push!(c, GateX(), 1); push!(c, GateCX(),3,6)
6-qubit circuit with 2 instructions:
├── X @ q[1]
└── CX @ q[3], q[6]

julia> numqubits(c)
6
source
MimiqCircuitsBase.opnameFunction
opname(instruction)
opname(operation)

Name of the underlying quantum operation in a human readable format.

See also numqubits, numbits.

Examples

julia> opname(GateX())
"X"

julia> opname(GateRX(π/2))
"RX"

julia> opname(Instruction(GateCX(),1,2))
"CX"

julia> opname(QFT(4))
"QFT"
source
MimiqCircuitsBase.powerFunction
power(operation, exponent)

Elevate an operation to a given exponent.

It performs simplifications when possible otherwise wraps the operation in a Power object.

See also Power, inverse, Inverse.

Examples

julia> power(GateX(), 1//2)
SX

julia> power(GateX(), 0.5)
X^0.5

julia> GateX()^2
ID

julia> GateCSX()^2
CX
source
Symbolics.inverseFunction
inverse(circuit)
inverse(instruction)
inverse(operation)

Inverse of the given circuit, instruction or operation.

When the inverse is not a known operation, it will return an Inverse object that wraps the original operation.

Details

It throws an error if the object is not invertible. Such for example, in the case of non unitary operations, or circuits containing Measure or Reset.

See also matrix, isunitary, power.

Examples

julia> inverse(GateRX(λ))
RX(-λ)

julia> inverse(GateCSX())
C(SX†)
source
MimiqCircuitsBase.evaluateFunction
evaluate(object, dictionary)

Evaluate all the parametric expression in object using the values specified in the given in the variable, value dictionary, returning a new object constructed on the evaluated parameters.

Examples

Evaluate a single parametric gate

julia> @variables θ
1-element Vector{Symbolics.Num}:
 θ

julia> g  = GateRX(θ)
RX(θ)

julia> evaluate(g, Dict(θ => 3π))
RX(3π)
source
MimiqCircuitsBase.issymbolicFunction
issymbolic(obj)

Checks whether the circuit contains any symbolic (unevaluated) parameters.

This method examines each instruction in the circuit to determine if any parameter remains symbolic (i.e., unevaluated). It recursively checks through each instruction and its nested operations, if any. Returns True if any parameter is symbolic (unevaluated), False if all parameters are fully evaluated.

Examples

julia> c = Circuit()
empty circuit


julia> push!(c, GateH(), 1)
1-qubit circuit with 1 instructions:
└── H @ q[1]

julia> issymbolic(c)
false

julia> @variables x y
2-element Vector{Symbolics.Num}:
 x
 y

julia> push!(c,Control(3,GateP(x+y)),1,2,3,4)
4-qubit circuit with 2 instructions:
├── H @ q[1]
└── C₃P(x + y) @ q[1:3], q[4]

julia> issymbolic(c)
true
source
MimiqCircuitsBase.MeasureType
Measure()

Single qubit measurement operation in the computational basis

The operation projects the quantum state and stores the result of such measurement in a classical register.

Warn

Measure is non-reversible.

See also Operation, Reset.

Examples

julia> Measure()
M

julia> c = push!(Circuit(), Measure, 1, 1)
1-qubit circuit with 1 instructions:
└── M @ q[1], c[1]

julia> push!(c, Measure(), 3, 4)
3-qubit circuit with 2 instructions:
├── M @ q[1], c[1]
└── M @ q[3], c[4]
source
MimiqCircuitsBase.MeasureXType
MeasureX()

Single qubit measurement operation in the X basis.

The operation projects the quantum state and stores the result of such measurement in a classical register.

This operation is equivalent to the sequence GateH, Measure, GateH.

Warn

Measure is non-reversible.

See also Measure, Operation, Reset.

Examples

julia> Measure()
M

julia> decompose(MeasureX())
1-qubit circuit with 3 instructions:
├── H @ q[1]
├── M @ q[1], c[1]
└── H @ q[1]

julia> c = push!(Circuit(), Measure, 1, 1)
1-qubit circuit with 1 instructions:
└── M @ q[1], c[1]

julia> push!(c, Measure(), 3, 4)
3-qubit circuit with 2 instructions:
├── M @ q[1], c[1]
└── M @ q[3], c[4]
source
MimiqCircuitsBase.MeasureYType
MeasureY()

Single qubit measurement operation in the Y basis.

The operation projects the quantum state and stores the result of such measurement in a classical register.

This operation is equivalent to the sequence GateSDG, GateH, Measure, GateH, GateS.

Warn

Measure is non-reversible.

See also Measure, Operation, Reset.

Examples

julia> MeasureY()
MeasureY

julia> decompose(MeasureY())
1-qubit circuit with 3 instructions:
├── HYZ @ q[1]
├── M @ q[1], c[1]
└── HYZ @ q[1]

julia> c = push!(Circuit(), MeasureY, 1, 1)
1-qubit circuit with 1 instructions:
└── MeasureY @ q[1], c[1]

julia> push!(c, MeasureY(), 3, 4)
3-qubit circuit with 2 instructions:
├── MeasureY @ q[1], c[1]
└── MeasureY @ q[3], c[4]
source

Serialization

MimiqCircuitsBase.loadprotoFunction
loadproto(fname, Circuit)
loadproto(fname, QCSResults)

Deserialize a Circuit or a QCSResults object from a ProtoBuf file.

source
MimiqCircuitsBase.saveprotoFunction
saveproto(fname, c::Circuit)
saveproto(fname, c::QCSResults)

Serialize a Circuit or a QCSResults object to a ProtoBuf file.

source