Quantum computation simulation library with qubits and quantum logic gates implemented as complex matrices
Download the release and run the following command
pip install <release-file>
quantSim.cplx
: ComplexquantSim.qgates
: Quantum gatesquantSim.qubit
: Qubits
-
c = cnum(r, i)
: wherer
is the real part andi
is the imaginary part (defaulted 0) -
~c
: complex conjugate ofc
-
abs(c)
: modulus ofc
(Euclidean norm) -
c1 + c2
,c1 * c2
: complex addition/multiplication -
c @ cm
: complex scalar times complex matrixcm
-
c.to_string(rem0, condensed)
andc.display(rem0, condensed)
: get/print the string representationrem0
: replace 0 values with empty space (defaultTrue
)condensed
: condense the output by removing spaces (defaultFalse
)
-
cexp(x)
: get the complex exponentiale^(xi)
wherex
is a constant
cm = cmat(rows, cols, entries)
: whererows
,cols
refer to the number of rows and columbs in the matrix respectively, andentries
refers to the non-zero entries of the matrixentries = {(r_1, c_1):cnum(a_1, b_1), (r_2, c_2):cnum(a_2, b_2),..., (r_n, c_n):cnum(a_n, b_n)}
where ther_j``c_j
entry of the matrix has valuea_j + b_j i
cm.transpose()
: transpose ofcm
~cm
: dagger ofcm
cm1 * cm2
: returns the tensor (Kronecker) product ofcm1
andcm2
cm1 @ cm2
: matrix multiplicationcm**n
: matrix exponentiation to the power ofn
c.display(rem0, condensed)
: print the string representationrem0
: replace 0 values with empty space (defaultTrue
)condensed
: condense the output by removing spaces (defaultFalse
)
I()
: IdentityH()
: HadamardX()
: Pauli-XY()
: Pauli-YZ()
: Pauli-ZS()
: PhaseT()
: pi/8 (T^2 = S)CX()
: Controlled Not X (2 qubits)CY()
: Controlled Not Y (2 qubits)CZ()
: Controlled Not Z (2 qubits)SWAP()
: Swap (2 qubits)CCNOT()
: Toffoli (3 qubits)
zero()
,one()
: qubits initialized with 0 and 1 respectivelyprob(c)
: calculates the probability corresponding to complex numberc
(a^2 + b^2)read(cm)
: reads superpositioned qubits as a matrixcm
and destroys qubit dataket(cm, rem0, condensed)
: prints the data in a superpositioned qubit as a matrixcm
in ket (Dirac) notationrem0
: replace 0 values with empty space (defaultTrue
)condensed
: condense the output by removing spaces (defaultFalse
)