Pauli Simulator
Snowflurry provides tools for the efficient storage and manipulation of Pauli group elements.
Snowflurry.PauliGroupElement — TypePauliGroupElementA Pauli group element which is represented using the approach of Dehaene and De Moor (2003).
The get_pauli functions should be used to generate PauliGroupElement objects.
Snowflurry.get_pauli — Functionget_pauli(
circuit::QuantumCircuit;
imaginary_exponent::Integer=0,
negative_exponent::Integer=0
)::PauliGroupElementReturns a PauliGroupElement given a circuit containing Pauli gates.
A Pauli group element corresponds to $i^\delta (-1)^\epsilon \sigma_a$, where $\delta$ and $\epsilon$ are set by specifying imaginary_exponent and negative_exponent, respectively. The exponents must be 0 or 1. Their default value is 0. As for $\sigma_a$, it is a tensor product of Pauli operators. The Pauli operators are specified in the circuit.
Examples
julia> circuit = QuantumCircuit(qubit_count = 2);
julia> push!(circuit, sigma_x(1), sigma_y(2))
Quantum Circuit Object:
qubit_count: 2
bit_count: 2
q[1]:──X───────
q[2]:───────Y──
julia> get_pauli(circuit, imaginary_exponent=1, negative_exponent=1)
Pauli Group Element:
-1.0im*X(1)*Y(2)
If multiple Pauli gates are applied to the same qubit in the circuit, the gates are multiplied with the first gate in the circuit being the rightmost gate in the multiplication.
julia> circuit = QuantumCircuit(qubit_count = 1);
julia> push!(circuit, sigma_x(1), sigma_z(1))
Quantum Circuit Object:
qubit_count: 1
bit_count: 1
q[1]:──X────Z──
julia> get_pauli(circuit)
Pauli Group Element:
1.0im*Y(1)
get_pauli(
gate::AbstractGateSymbol,
num_qubits::Integer;
imaginary_exponent::Integer=0,
negative_exponent::Integer=0
)::PauliGroupElementReturns a PauliGroupElement given a gate and the number of qubits.
A Pauli group element corresponds to $i^\delta (-1)^\epsilon \sigma_a$, where $\delta$ and $\epsilon$ are set by specifying imaginary_exponent and negative_exponent, respectively. The exponents must be 0 or 1. Their default value is 0. As for $\sigma_a$, it is a tensor product of Pauli operators. In this variant of the get_pauli function, a single Pauli operator is set by providing a gate. The number of qubits is specified by num_qubits.
Examples
julia> gate = sigma_x(2);
julia> num_qubits = 3;
julia> get_pauli(gate, num_qubits)
Pauli Group Element:
1.0*X(2)
Base.:* — MethodBase.:*(p1::PauliGroupElement, p2::PauliGroupElement)::PauliGroupElementReturns the product of two PauliGroupElement objects.
The PauliGroupElement objects must be associated with the same number of qubits.
Examples
julia> pauli_z = get_pauli(sigma_z(1), 1)
Pauli Group Element:
1.0*Z(1)
julia> pauli_y = get_pauli(sigma_y(1), 1)
Pauli Group Element:
1.0*Y(1)
julia> pauli_z*pauli_y
Pauli Group Element:
-1.0im*X(1)
Snowflurry.get_quantum_circuit — Functionget_quantum_circuit(pauli::PauliGroupElement)::QuantumCircuitReturns the Pauli gates of a PauliGroupElement as a QuantumCircuit.
Examples
julia> circuit = QuantumCircuit(qubit_count = 2);
julia> push!(circuit, sigma_x(1), sigma_y(2))
Quantum Circuit Object:
qubit_count: 2
bit_count: 2
q[1]:──X───────
q[2]:───────Y──
julia> pauli = get_pauli(circuit, imaginary_exponent = 1, negative_exponent = 1)
Pauli Group Element:
-1.0im*X(1)*Y(2)
julia> get_quantum_circuit(pauli)
Quantum Circuit Object:
qubit_count: 2
bit_count: 2
q[1]:──X───────
q[2]:───────Y──
Snowflurry.get_negative_exponent — Functionget_negative_exponent(pauli::PauliGroupElement)::IntReturns the negative exponent of a PauliGroupElement.
Examples
julia> gate = sigma_x(2);
julia> num_qubits = 3;
julia> pauli = get_pauli(gate, num_qubits, negative_exponent = 1)
Pauli Group Element:
-1.0*X(2)
julia> get_negative_exponent(pauli)
1
Snowflurry.get_imaginary_exponent — Functionget_imaginary_exponent(pauli::PauliGroupElement)::IntReturns the imaginary exponent of a PauliGroupElement.
Examples
julia> gate = sigma_x(2);
julia> num_qubits = 3;
julia> pauli = get_pauli(gate, num_qubits, imaginary_exponent = 1)
Pauli Group Element:
1.0im*X(2)
julia> get_imaginary_exponent(pauli)
1