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): whereris the real part andiis 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)wherexis a constant
cm = cmat(rows, cols, entries): whererows,colsrefer to the number of rows and columbs in the matrix respectively, andentriesrefers 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_jentry of the matrix has valuea_j + b_j i
cm.transpose(): transpose ofcm~cm: dagger ofcmcm1 * cm2: returns the tensor (Kronecker) product ofcm1andcm2cm1 @ cm2: matrix multiplicationcm**n: matrix exponentiation to the power ofnc.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 matrixcmand destroys qubit dataket(cm, rem0, condensed): prints the data in a superpositioned qubit as a matrixcmin ket (Dirac) notationrem0: replace 0 values with empty space (defaultTrue)condensed: condense the output by removing spaces (defaultFalse)