quantumA high-performance quantum computing simulator in Dinfio. This module lets you programme and simulate quantum algorithms, quantum information, and quantum machine learning.
bra_0 — This constant represents bra \(\bra{0}\)bra_1 — This constant represents bra \(\bra{1}\)e — Mathematical \(e\) constantgate_i — The matrix representation of \(I\) gategate_x — The matrix representation of \(X\) gategate_y — The matrix representation of \(Y\) gategate_z — The matrix representation of \(Z\) gateket_0 — This constant represents state \(\ket{0}\)ket_1 — This constant represents state \(\ket{1}\)negative_i — Negative \(i\) number (\(-\sqrt{-1}\))pi — Mathematical \(\pi\) constantpositive_i — Positive \(i\) number (\(\sqrt{-1}\))
from_binary() — Convert a binary string to number
quantum_circuit — This class models a quantum circuit, providing gate operations, quantum states, probabilities, quantum phases, expectation values, measurements, etc.
construct() — The constructor. Create an instance of class quantum_circuit barrier() — Add a barrier to the circuit bits() — Get total number of classical bits of the circuit ccx() — Apply \(CCX\) (also known as Toffoli) gate to the circuit classical_bits() — Get the measured classical bits cp() — Apply \(CP\) gate to the circuit cu() — Apply \(CU\) gate to the circuit
import quantum
qc = quantum_circuit(2)
qc.h(0)
qc.cx(0, 1)
qc.print_statevector()
qc.print_probability()
qc.draw()
' Example output:
'
' [ 0.707107 + 0i
' 0 + 0i
' 0 + 0i
' 0.707107 + 0i ]
' [ 0.5
' 0
' 0
' 0.5 ]
' ╭───╮
' q0 ─┤ H ├───●───
' ╰───╯ │
' ╭─┴─╮
' q1 ───────┤ X ├─
' ╰───╯