# README.md
# qcpy - A Quantum Computing Library for Python
qcpy is an open source python library and collaborative project for flexible simulations and visualizations of quantum circuits. This library contains a set of tools to teach computer scientists about the emerging discipline of quantum computing and improve overall understanding.
[Join The Discord](https://discord.gg/dDwPhn6E)
You can download the package using pip:
```txt
pip install qcpydev
```
---
# Qubit
> ## qcpy.`qubit`(*initial=’z’*)
*Object representation of a qubit.*
### Parameters:
`initial (chr)` default: `z` - Character input for starting direction in the *x*, *y*, or *z* axis.
### Attributes:
`None`
### Example:
```python
from qcpy import qubit
qx = qubit(initial_state = 'x')
qy = qubit(initial_state = 'y')
qz = qubit(initial_state = 'z')
print("x:\n", qx)
print("y:\n", qy)
print("z:\n", qz)
# x:
# [[0.70710677+0.j]
# [0.70710677+0.j]]
# y:
# [[0.70710677+0.j]
# [0.+0.70710677j]]
# z:
# [[1.+0.j]
# [0.+0.j]]
```
---
# Quantum Gates
> ## quantumgate.`identity`()
*Gate that does not modify the quantum state.*
### Parameters:
`None`
```python
identity=[1+0j, 0+0j],
[0+0j, 1+0j]
```
### Example:
```python
from qcpy import gates as qg
print(qg.identity())
# [[1.+0.j 0.+0.j]
# [0.+0.j 1.+0.j]]
```
> ## quantumgate.`paulix`()
*Quantum equivalent of the NOT gate in classical computing with respect to the standard basis |0>, |1>.*
### Parameters:
`None`
```python
PauliX = [0+0j, 1+0j],
[1+0j, 0+0j]
```
### Example:
```python
from qcpy import gates as qg
print(qg.paulix())
# [[1.+0.j 0.+0.j]
# [0.+0.j 1.+0.j]]
```
> ## quantumgate.`pauliy`()
*Rotation around y-axis of the bloch sphere by π radiains, mapping |0> to i|1> and |1> to -i|0>.*
### Parameters:
`None`
```python
PauliY = [0+0j, 0-1j],
[0+1j, 0+0j]
```
### Example:
```python
from qcpy import gates as qg
print(qg.pauliy())
# [[0+0j, 0-1j]
# [0+1j, 0+0j]]
```
> ## quantumgate.`pauliz`()
*Rotation around z-axis of the bloch sphere by π radiains, mapping |1> to -|1>; known as the phase-flip.*
### Parameters:
`None`
```python
PauliZ = [1+0j, 0+0j],
[0+0j, -1+0j]
```
### Example:
```python
from qcpy import gates as qg
print(qg.pauliz())
# [[1+0j, 0+0j],
# [0+0j, -1+0j]]
```
> ## quantumgate.`hadamard`()
*Maps the basis states |0> to |+> and |1> to |->, creating a superposition state if given a computation basis state.*
### Parameters:
`None`
```python
Hadamard = [1, 1]
[1, -1] * (1/sqrt(2))
```
### Example:
```python
from qcpy import gates as qg
print(qg.hadamard())
# [[ 0.70710677+0.j 0.70710677+0.j]
# [ 0.70710677+0.j -0.70710677+0.j]]
```
> ## quantumgate.`cnot`(*little_endian=False*)
*Controlled gate acts on two or more qubits, performing the NOT operation of the target qubit only if the control qubits are |1>, can act as a quantum regiester and is used to entangle and disentangle Bell states.*
### Parameters:
`little_endian (bool)` - if the gate is an inverse, with the target being above the control.
```python
# regular
CNot = [1+0j, 0+0j, 0+0j, 0+0j],
[0+0j, 1+0j, 0+0j, 0+0j],
[0+0j, 0+0j, 0+0j, 1+0j],
[0+0j, 0+0j, 1+0j, 0+0j]
# little_endian = True
CNot = [1+0j, 0+0j, 0+0j, 0+0j],
[0+0j, 0+0j, 0+0j, 1+0j],
[0+0j, 0+0j, 1+0j, 0+0j],
[0+0j, 1+0j, 0+0j, 0+0j]
```
### Example:
```python
from qcpy import gates as qg
print(qg.cnot())
# [[1.+0.j 0.+0.j 0.+0.j 0.+0.j]
# [0.+0.j 1.+0.j 0.+0.j 0.+0.j]
# [0.+0.j 0.+0.j 0.+0.j 1.+0.j]
# [0.+0.j 0.+0.j 1.+0.j 0.+0.j]]
# [[1.+0.j 0.+0.j 0.+0.j 0.+0.j]
# [0.+0.j 0.+0.j 0.+0.j 1.+0.j]
# [0.+0.j 0.+0.j 1.+0.j 0.+0.j]
# [0.+0.j 1.+0.j 0.+0.j 0.+0.j]]
```
> ## quantumgate.`swap`()
*Swaps two qubits, with respect to the basis |00>, |01>, |10>, and |11>.*
### Parameters:
`None`
```python
Swap = [1+0j, 0+0j, 0+0j, 0+0j],
[0+0j, 0+0j, 1+0j, 0+0j],
[0+0j, 1+0j, 0+0j, 0+0j],
[0+0j, 0+0j, 0+0j, 1+0j]
```
### Example:
```python
from qcpy import gates as qg
print(qg.swap())
# [1+0j, 0+0j, 0+0j, 0+0j],
# [0+0j, 0+0j, 1+0j, 0+0j],
# [0+0j, 1+0j, 0+0j, 0+0j],
# [0+0j, 0+0j, 0+0j, 1+0j]
```
> ## quantumgate.`toffoli`()
*Universal reversible logic gate, known as the “controlled-controlled-NOT” gate; if the two control bits are set to 1, it will invert the target.*
### Parameters:
`None`
```python
Toffoli = [1+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j],
[0+0j, 1+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j],
[0+0j, 0+0j, 1+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j],
[0+0j, 0+0j, 0+0j, 1+0j, 0+0j, 0+0j, 0+0j, 0+0j],
[0+0j, 0+0j, 0+0j, 0+0j, 1+0j, 0+0j, 0+0j, 0+0j],
[0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 1+0j, 0+0j, 0+0j],
[0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 1+0j],
[0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 1+0j, 0+0j]
```
### Example:
```python
from qcpy import gates as qg
print(qg.toffoli())
# [1+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j],
# [0+0j, 1+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j],
# [0+0j, 0+0j, 1+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j],
# [0+0j, 0+0j, 0+0j, 1+0j, 0+0j, 0+0j, 0+0j, 0+0j],
# [0+0j, 0+0j, 0+0j, 0+0j, 1+0j, 0+0j, 0+0j, 0+0j],
# [0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 1+0j, 0+0j, 0+0j],
# [0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 1+0j],
# [0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 1+0j, 0+0j]
```
> ## quantumgate.`phase`(*theta=numpy.pi/2*)
*Applies a rotation of theta around the z-axis.*
### Parameters:
`theta (float)` default: `numpy.pi/2` - angle of rotation around z-axis.
```python
Phase = [1+0j, 0+0j],
[0+0j, numpy.exp(0+1j * theta)]
```
### Example:
```python
from qcpy import gates as qg
print(qg.phase())
# [1+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j],
# [0+0j, 1+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j],
# [0+0j, 0+0j, 1+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j],
# [0+0j, 0+0j, 0+0j, 1+0j, 0+0j, 0+0j, 0+0j, 0+0j],
# [0+0j, 0+0j, 0+0j, 0+0j, 1+0j, 0+0j, 0+0j, 0+0j],
# [0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 1+0j, 0+0j, 0+0j],
# [0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 1+0j],
# [0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 1+0j, 0+0j]
```
> ## quantumgate.`s`()
*Equivalent to a pi/2 rotation around the z-axis.*
### Parameters:
`None`
```python
S.matrix = [1+0j, 0+0j],
[0+0j, 0+1j]
```
### Example:
```python
from qcpy import gates as qg
print(qg.s())
# [1+0j, 0+0j],
# [0+0j, 0+1j]
```
> ## quantumgate.`sdg`()
*Inverse of S gate; a -pi/2 rotation around the z-axis.*
### Parameters:
`None`
```python
Sdg.matrix = [1+0j, 0+0j],
[0+0j, 0-1j]
```
### Example:
```python
from qcpy import gates as qg
print(qg.sdg())
# [1+0j, 0+0j],
# [0+0j, 0-1j]
```
> ## quantumgate.`t`()
*Square of S gate; where T = S^2.*
### Parameters:
`None`
```python
T.matrix = [1+0j, 0+0j],
[0+0j, numpy.exp((0+1j * numpy.pi) / 4)]
```
### Example:
```python
from qcpy import gates as qg
print(qg.t())
# [[1.+0.j 0.+0.j]
# [0.+0.j 0.70710677+0.70710677j]]
```
> ## quantumgate.`tdg`()
*Inverse of T gate.*
### Parameters:
`None`
```python
Tdg = [1+0j, 0+0j],
[0+0j, numpy.exp((0-1j * numpy.pi) / 4)]
```
### Example:
```python
from qcpy import gates as qg
print(qg.tdg())
# [[1.+0.j 0.+0.j]
# [0.+0.j 0.70710677-0.70710677j]]
```
> ## quantumgate.`rz`(*theta=numpy.pi/2*)
*Rotation of qubit around the z-axis.*
### Parameters:
`theta (float)` default: `numpy.pi/2` - angle of rotation around z-axis.
```python
from qcpy import gates as qg
print(qg.rz())
# [numpy.exp((0-1j * (theta / 2))), 0+0j],
# [0+0j, numpy.exp(0+1j * (theta / 2))]
```
> ## quantumgate.`rx`(*theta=numpy.pi/2*)
*Rotation of qubit around the x-axis.*
### Parameters:
`theta (float)` default: `numpy.pi/2` - angle of rotation around x-axis.
```python
Rx = [numpy.cos(theta / 2), 0-1j * numpy.sin(theta / 2)],
[0-1j * numpy.sin(theta / 2), numpy.cos(theta / 2)]
```
### Example:
```python
from qcpy import gates as qg
print(qg.rx())
# [[0.70710677+0.j 0.-0.70710677j]
# [0.-0.70710677j 0.70710677+0.j]]
```
> ## quantumgate.`ry`(*theta=numpy.pi/2*)
*Rotation of qubit around the y-axis.*
### Parameters:
`theta (float)`default: `numpy.pi/2` - angle of rotation around y-axis.
```python
Ry = [numpy.cos(theta / 2), -1 * numpy.sin(theta / 2)],
[numpy.sin(theta / 2), numpy.cos(theta / 2)]
```
### Example:
```python
from qcpy import gates as qg
print(qg.ry())
# [[ 0.70710677+0.j -0.70710677+0.j]
# [ 0.70710677+0.j 0.70710677+0.j]]
```
> ## quantumgate.`sx`()
*Rotation around the x-axis by 90 degrees in the counter-clockwise direction. Also known as the “square-root X gate” due to the fact that applying the SX gate twice results in an X gate.*
### Parameters:
`None`
```python
Sx = [1+1j, 1-1j],
[1-1j, 1+1j] * (1 / 2)
```
### Example:
```python
from qcpy import gates as qg
print(qg.sx())
# [[0.5+0.5j 0.5-0.5j]
# [0.5-0.5j 0.5+0.5j]]
```
> ## quantumgate.`sxdg`()
*Inverse of the Sx gate.*
### Parameters:
`None`
```python
Sxdg = [1-1j, 1+1j],
[1+1j, 1-1j] * (1 / 2)
```
### Example:
```python
from qcpy import gates as qg
print(qg.sxdg())
# [[0.5-0.5j 0.5+0.5j]
# [0.5+0.5j 0.5-0.5j]]
```
> ## quantumgate.`u`(*theta=numpy.pi/2, phi=numpy.pi/2, lmbda=numpy.pi/2*)
*Rotation of qubit with respect to theta, phi, and lambda, in Euler angles.*
### Parameters:
`theta (float)` default: `numpy.pi/2` - angle of rotation around Euler angle theta.
`phi (float)` default: `numpy.pi/2` - angle of rotation around Euler angle phi.
`lmbda (float)` default: `numpy.pi/2` - angle of rotation around Eulear angle lambda.
```python
U.matrix = [numpy.cos(theta / 2), -1 * numpy.exp(0+1j * lmbda) * numpy.sin(theta / 2)],
[numpy.exp(0+1j * phi) * numpy.sin(theta / 2), numpy.exp(0+1j * (lmbda + phi)) * numpy.cos(theta / 2)]]
```
### Example:
```python
from qcpy import gates as qg
print(qg.u())
# [[0.7071+0.j -0.-0.7071j]
# [0.+0.7071j -0.7071+0.j]]
```
> ## quantumgate.`rxx`(*theta=numpy.pi/2*)
*Rotation about XX, maximally entangling at theta = pi/2.*
### Parameters:
`theta (float)` default: `numpy.pi/2` - angle of rotation around XX.
```python
Rxx.matrix = [numpy.cos(theta / 2), 0+0j, 0+0j, 0-1j * numpy.sin(theta / 2)],
[0+0j, numpy.cos(theta / 2), 0-1j * numpy.sin(theta / 2), 0+0j],
[0+0j, 0-1j * numpy.sin(theta / 2), numpy.cos(theta / 2), 0+0j],
[0-1j * numpy.sin(theta / 2), 0+0j, 0+0j, numpy.cos(theta / 2)]
```
### Example:
```python
from qcpy import gates as qg
print(qg.rxx())
# [[0.70710677+0.j 0+0.j 0+0.j 0-0.70710677j]
# [0+0.j 0.70710677+0.j 0-0.70710677j 0+0.j]
# [0+0.j 0-0.70710677j 0.70710677+0.j 0+0.j]
# [0-0.70710677j 0+0.j 0.+0.j 0.70710677+0.j]]
```
> ## quantumgate.`rzz`(*theta=numpy.pi/2*)
*Rotation about ZZ, maximally entangling at theta = pi/2.*
### Parameters:
`theta (float)` default: `numpy.pi/2` - angle of rotation around ZZ.
```python
Rzz.matrix = [numpy.exp(0-1j * (theta / 2)), 0+0j, 0+0j, 0+0j],
[0+0j, numpy.exp(0+1j * (theta / 2)), 0+0j, 0+0j],
[0+0j, 0+0j, numpy.exp(0+1j * (theta / 2)), 0+0j],
[0+0j, 0+0j, 0+0j, numpy.exp(0-1j * (theta / 2))]
```
### Example:
```python
from qcpy import gates as qg
print(qg.rzz())
# [[0.70710677-0.70710677j 0+0.j 0+0.jn 0+0.j]
# [0+0.j 0.70710677+0.70710677j 0+0.j 0+0.j]
# [0+0.j 0+0.j 0.70710677+0.70710677j 0+0.j]
# [0+0.j 0+0.j 0+0.j 0.70710677-0.70710677j]]
```
> ## quantumgate.`cr`(*theta=numpy.pi/2*)
*Controlled phase shift rotation in theta radians; generalization of Cz gate.*
### Parameters:
`theta (float)` default: `numpy.pi/2` - angle of rotation in theta radians.
```python
Cr = [1+0j, 0+0j, 0+0j, 0+0j],
[0+0j, 1+0j, 0+0j, 0+0j],
[0+0j, 0+0j, 1+0j, 0+0j],
[0+0j, 0+0j, 0+0j, exp(theta * 0+1j)]
```
### Example:
```python
from qcpy import gates as qg
print(qg.cr())
# [[1+0.j 0+0.j 0+0.j 0+0.j]
# [0+0.j 1+0.j 0+0.j 0+0.j]
# [0+0.j 0+0.j 1+0.j 0+0.j]
# [0+0.j 0+0.j 0+0.j 0.5403023+0.84147096j]]
```
> ## quantumgate.`cz`(*theta=numpy.pi/2*)
*Controlled phase shift rotation in theta radians.*
### Parameters:
`theta (float)` default: `numpy.pi/2` - angle of rotation in theta radians.
```python
Cz = [1+0j, 0+0j, 0+0j, 0+0j],
[0+0j, 1+0j, 0+0j, 0+0j],
[0+0j, 0+0j, 1+0j, 0+0j],
[0+0j, 0+0j, 0+0j, -1+0j]
```
### Example:
```python
from qcpy import gates as qg
print(qg.cz())
# [[ 1.+0.j 0.+0.j 0.+0.j 0.+0.j]
# [ 0.+0.j 1.+0.j 0.+0.j 0.+0.j]
# [ 0.+0.j 0.+0.j 1.+0.j 0.+0.j]
# [ 0.+0.j 0.+0.j 0.+0.j -1.+0.j]]
```
---
# Quantum Circuit
> ## *class* qcpy.`quantumcircuit`(*qubits: int*, *big_endian: bool=False*, *prep: char='z'*, *gpu: bool='false'*, *sparse: bool='false'*)
*Quantum circuit that represents the state of a quantum system and performs operations on select qubits.*
### Parameters:
`qubits (int)` - number of qubits in the circuit.
`little_endian (bool)` default: `False` - order of qubits and tensor products.
`prep (char)` options: [`z`, `y`, `x`] - initial direction of the qubits' phase angle.
`gpu (bool)` default: `False` - initialize GPU usage for the quantum circuit.
`sparse (bool)` default: `False` - use sparse matrix for the quantum circuit.
> ## quantumcircuit.`state`
*Returns state of the quantum circuit.*
### Parameters:
`None`
### Returns:
`state (numpy.ndarray)` - array of quantum circuit's state.
### Example:
```python
from qcpy import quantumcircuit
qc = quantumcircuit(2)
qc.h(0)
qc.cnot(0, 1)
print(qc.state)
# [[0.707+0.j]
# [0. +0.j]
# [0. +0.j]
# [0.707+0.j]]
```
> ## quantumcircuit.`size`
*Returns the number of qubits in the quantum circuit.*
### Parameters:
`None`
### Returns:
`qubits (int)` - number of qubits.
### Example:
```python
from qcpy import quantumcircuit
qc = quantumcircuit(2)
print(qc.size)
```
> ## quantumcircuit.`ccx`(*control_1: int*, *control_2: int*, *target: int*)
*A 3-qubit quantum gate that takes in two control qubits and one target qubit.*
### Parameters:
`control_one (int)` - first control qubit.
`control_two (int)` - second control qubit.
`target (int)` - target qubit.
### Returns:
`None`
### Example:
```python
from qcpy import quantumcircuit
qc = quantumcircuit(3)
qc.h(0)
qc.h(1)
qc.ccx(0,1,2)
print(qc.state)
# [[0.5+0.j]
# [0. +0.j]
# [0.5+0.j]
# [0. +0.j]
# [0.5+0.j]
# [0. +0.j]
# [0. +0.j]
# [0.5+0.j]]
```
> ## quantumcircuit.`rccx`(*control_1*, *control_2*, *target*)
*A 3-qubit quantum gate that takes in two control qubits and one target qubit.*
### Parameters:
`control_1 (int)` - first control qubit.
`control_2 (int)` - second control qubit.
`target (int)` - target qubit.
### Returns:
`None`
### Example:
```python
from qcpy import quantumcircuit
qc = quantumcircuit(3)
qc.h(0)
qc.h(1)
qc.rccx(0,1,2)
print(qc.state)
# [[ 0.5-0.j ]
# [ 0. +0.j ]
# [ 0.5-0.j ]
# [ 0. +0.j ]
# [ 0.5-0.j ]
# [ 0. +0.j ]
# [-0. +0.j ]
# [ 0. +0.5j]]
```
> ## quantumcircuit.`rc3x`(*qubit_1: int*, *qubit_2: int*, *qubit_3: int*, *qubit_4: int*)
*A 4-qubit quantum gate that takes in 4 unique qubits.*
### Parameters:
`qubit_1 (int)` - first input qubit.
`qubit_2 (int)` - second input qubit.
`qubit_3 (int)` - third input qubit.
`qubit_4 (int)` - fourth input qubit.
### Returns:
`None`
### Example:
```python
from qcpy import quantumcircuit
qc = quantumcircuit(4)
qc.h(0)
qc.h(1)
qc.h(2)
qc.rc3x(0,1,2,3)
print(qc.state)
# [[ 0.354-0.j ]
# [ 0. +0.j ]
# [ 0.354-0.j ]
# [ 0. +0.j ]
# [ 0.354-0.j ]
# [ 0. +0.j ]
# [ 0.354-0.j ]
# [ 0. +0.j ]
# [ 0.354-0.j ]
# [ 0. +0.j ]
# [ 0.354-0.j ]
# [ 0. +0.j ]
# [ 0. +0.354j]
# [-0. +0.j ]
# [ 0. -0.j ]
# [-0.354+0.j ]]
```
> ## quantumcircuit.`cx`(*control: int*, *target: int*)
*A 2-qubit quantum gate that takes in a control qubit and one target qubit.*
### Parameters:
`control (int)` - control qubit.
`target (int)` - target qubit.
### Returns:
`None`
### Example:
```python
from qcpy import quantumcircuit
qc = quantumcircuit(2)
qc.h(0)
qc.cx(0,1)
print(qc.state)
# [[0.707+0.j]
# [0. +0.j]
# [0. +0.j]
# [0.707+0.j]]
```
> ## quantumcircuit.`ch`(*control: int*, *target: int*)
*A controlled Hadamard gate to use in the quantum circuit.*
### Parameters:
`control (int)` - control qubit.
`target (int)` - target qubit.
### Returns:
`None`
### Example:
```python
from qcpy import quantumcircuit
qc = quantumcircuit(2)
qc.ch(0,1)
print(qc.state)
```
> ## quantumcircuit.`cy`(*control: int*, *target: int*)
*A controlled PauliY gate to use in the quantum circuit.*
### Parameters:
`control (int)` - control qubit.
`target (int)` - target qubit.
### Returns:
`None`
### Example:
```python
from qcpy import quantumcircuit
qc = quantumcircuit(2)
qc.cy(0,1)
print(qc.state)
```
> ## quantumcircuit.`cz`(*control: int*, *target: int*)
*A 2-qubit quantum gate that takes in a control qubit and one target qubit.*
### Parameters:
`control (int)` - control qubit.
`target (int)` - target qubit.
### Returns:
`None`
### Example:
```python
from qcpy import quantumcircuit
qc = quantumcircuit(2)
qc.h(0)
qc.cz(0,1)
print(qc.state)
# [[0.707+0.j]
# [0. +0.j]
# [0.707+0.j]
# [0. +0.j]]
```
> ## quantumcircuit.`crx`(*control: int*, *target: int*)
*A controlled RX gate to use in the quantum circuit.*
### Parameters:
`control (int)` - control qubit.
`target (int)` - target qubit.
### Returns:
`None`
### Example:
```python
from qcpy import quantumcircuit
qc = quantumcircuit(2)
qc.cry(0,1)
print(qc.state)
```
> ## quantumcircuit.`crx`(*control: int*, *target: int*)
*A controlled RY gate to use in the quantum circuit.*
### Parameters:
`control (int)` - control qubit.
`target (int)` - target qubit.
### Returns:
`None`
### Example:
```python
from qcpy import quantumcircuit
qc = quantumcircuit(2)
qc.cry(0,1)
print(qc.state)
```
> ## quantumcircuit.`crz`(*control: int*, *target: int*)
*A controlled RZ gate to use in the quantum circuit.*
### Parameters:
`control (int)` - control qubit.
`target (int)` - target qubit.
### Returns:
`None`
### Example:
```python
from qcpy import quantumcircuit
qc = quantumcircuit(2)
qc.crz(0,1)
print(qc.state)
```
> ## quantumcircuit.`cr1`(*control: int*, *target: int*)
*A controlled R1 gate to use in the quantum circuit.*
### Parameters:
`control (int)` - control qubit.
`target (int)` - target qubit.
### Returns:
`None`
### Example:
```python
from qcpy import quantumcircuit
qc = quantumcircuit(2)
qc.cr1(0,1)
print(qc.state)
```
> ## quantumcircuit.`qft`(*qubit_one: int*, *qubit_two: int* *qubit_three: int*)
*Use the QFt algorithm in the quantum circuit.*
### Parameters:
`qubit_one (int)` - first qubit.
`qubit_two (int)` - second qubit.
`qubit_three (int)` - third qubit.
### Returns:
`None`
### Example:
```python
from qcpy import quantumcircuit
qc = quantumcircuit(2)
qc.qft(0,1)
print(qc.state)
```
> ## quantumcircuit.`swap`(*qubit_1: int*, *qubit_2: int*)
*A 2-qubit quantum gate that takes in 2 qubits to swap there properties.*
### Parameters:
`qubit_1 (int)` - first qubit to swap.
`qubit_2 (int)` - second qubit to swap.
### Returns:
`None`
### Example:
```python
from qcpy import quantumcircuit
qc = quantumcircuit(2)
qc.h(0)
qc.swap(0,1)
print(qc.state)
# [[0.707+0.j]
# [0.707+0.j]
# [0. +0.j]
# [0. +0.j]]
```
> ## quantumcircuit.`rxx`(*qubit_1: int*, *qubit_2: int*, *theta: float=numpy.pi/2*)
*A 2-qubit quantum gate that takes in two qubits and a representation of theta to initialize in the quantum state.*
### Parameters:
`qubit_1 (int)` - first qubit input.
`qubit_2 (int)` - second qubit input.
`theta (float)` default: `numpy.pi/2` - angle of rotation around z-axis.
### Returns:
`None`
### Example:
```python
from qcpy import quantumcircuit
qc = quantumcircuit(2)
qc.h(0)
qc.rxx(0,1)
print(qc.state)
# [[0.5+0.j ]
# [0. -0.5j]
# [0.5+0.j ]
# [0. -0.5j]]
```
> ## quantumcircuit.`rzz`(*qubit_1*, *qubit_2*, *theta=numpy.pi/2*)
*A 2-qubit quantum gate that takes in two qubits and a representation of theta to initialize in the quantum state.*
### Parameters:
`qubit_1 (int)` - first qubit input.
`qubit_2 (int)` - second qubit input.
`theta (float)` default: `numpy.pi/2` - angle of rotation around z-axis.
### Returns:
`None`
### Example:
```python
from qcpy import quantumcircuit
qc = quantumcircuit(2)
qc.h(0)
qc.rxx(0,1)
print(qc.state)
# [[0.5+0.j ]
# [0. -0.5j]
# [0.5+0.j ]
# [0. -0.5j]]
```
> ## quantumcircuit.`multicustom`(*control: int*, *target: int*, *gate: np.array*)
*Inset a custom controlled gate into the quantum circuit.*
### Parameters:
`control (int)` - control qubit for given matrix.
`target (int)` - target qubit for given matrix.
`gate (np.array)` - (2,2) matrix to be applied to the quantum circuit.
### Returns:
`None`
### Example:
```python
from qcpy import quantumcircuit, paulix
qc = quantumcircuit(2)
qc.h(0)
qc.multicustom(0,1, paulix())
print(qc.state)
# [[0.707+0.j]
# [0. +0.j]
# [0. +0.j]
# [0.707+0.j]]
```
> ## quantumcircuit.`i`(*qubit: int*)
*Used to confirm value that a qubit is representing and does nothing to manipulate the value of such qubit.*
### Parameters:
`qubit (int)` - the qubit to have the identity gate be applied to the quantum wire.
### Returns:
`None`
### Example:
```python
from qcpy import quantumcircuit
qc = quantumcircuit(2)
qc.i(0)
print(qc.state)
# [[1.+0.j]
# [0.+0.j]
# [0.+0.j]
# [0.+0.j]]
```
> ## quantumcircuit.`x`(*qubit: int*)
*Used to invert the value of what a qubit is representing.*
### Parameters:
`qubit (int)` - the qubit to have the Pauli-X gate be applied to the quantum wire.
### Returns:
`None`
### Example:
```python
from qcpy import quantumcircuit
qc = quantumcircuit(2)
qc.x(0)
print(qc.state)
# [[0.+0.j]
# [0.+0.j]
# [1.+0.j]
# [0.+0.j]]
```
> ## quantumcircuit.`h`(*qubit: int*)
*Used to put a given qubit into superposition.*
### Parameters:
`qubit (int)` - the qubit to have the Hadamard gate be applied to the quantum wire.
### Returns:
`None`
### Example:
```python
from qcpy import quantumcircuit
qc = quantumcircuit(2)
qc.h(0)
print(qc.state)
# [[0.707+0.j]
# [0. +0.j]
# [0.707+0.j]
# [0. +0.j]]
```
> ## quantumcircuit.`y`(*qubit: int*)
*Changes the state of a qubit by pi around the y-axis of a Bloch Sphere.*
### Parameters:
`qubit (int)` - the qubit to have the Pauli-Y gate be applied to the quantum wire.
### Returns:
`None`
### Example:
```python
from qcpy import quantumcircuit
qc = quantumcircuit(2)
qc.y(0)
print(qc.state)
# [[0.+0.j]
# [0.+0.j]
# [0.+1.j]
# [0.+0.j]]
```
> ## quantumcircuit.`z`(*qubit: int*)
*Changes the state of a qubit by pi around the z-axis of a Bloch Sphere.*
### Parameters:
`qubit (int)` - the qubit to have the Pauli-Z gate be applied to the quantum wire.
### Returns:
`None`
### Example:
```python
from qcpy import quantumcircuit
qc = quantumcircuit(2)
qc.h(0)
qc.z(0)
print(qc.state)
# [[ 0.707+0.j]
# [ 0. +0.j]
# [-0.707+0.j]
# [ 0. +0.j]]
```
> ## quantumcircuit.`p`(*qubit: int*, *theta: float=numpy.pi/2*)
*Commits to a rotation around the z-axis based off of the inputted theta value.*
### Parameters:
`qubit (int)` - the qubit to have the Phase gate be applied to the quantum wire.
`theta (float)` default: `numpy.pi/2` - angle of rotation around z-axis.
### Returns:
`None`
### Example:
```python
from qcpy import quantumcircuit
qc = quantumcircuit(2)
qc.h(0)
qc.p(0)
print(qc.state)
# [[0.707+0.j ]
# [0. +0.j ]
# [0. +0.707j]
# [0. +0.j ]]
```
> ## quantumcircuit.`s`(*qubit: int*)
*Is a Phase gate where the inputted theta value is given as a constant of theta = pi / 2.*
### Parameters:
`qubit (int)` - the qubit to have the Pauli-Z gate be applied to the quantum wire.
### Returns:
`None`
### Example:
```python
from qcpy import quantumcircuit
qc = quantumcircuit(2)
qc.h(0)
qc.s(0)
print(qc.state)
# [[0.707+0.j ]
# [0. +0.j ]
# [0. +0.707j]
# [0. +0.j ]]
```
> ## quantumcircuit.`sdg`(*qubit: int*)
*Is a Phase gate and inverse of the S gate where the inputted theta value is given as a constant of theta = -pi / 2.*
### Parameters:
`qubit (int)` - the qubit to have the Sdg gate be applied to the quantum wire.
### Returns:
`None`
### Example:
```python
from qcpy import quantumcircuit
qc = quantumcircuit(2)
qc.h(0)
qc.sdg(0)
print(qc.state)
# [[0.707+0.j ]
# [0. +0.j ]
# [0. -0.707j]
# [0. +0.j ]]
```
> ## quantumcircuit.`t`(*qubit: int*)
*T gate is a special use case gate that in implemented from the P Gate.*
### Parameters:
`qubit (int)` - the qubit to have the T gate be applied to the quantum wire.
### Returns:
`None`
### Example:
```python
from qcpy import quantumcircuit
qc = quantumcircuit(2)
qc.h(0)
qc.t(0)
print(qc.state)
# [[0.707+0.j ]
# [0. +0.j ]
# [0.5 +0.5j]
# [0. +0.j ]]
```
> ## quantumcircuit.`tdg`(*qubit: int*)
*Tdg gate is a special use case gate that in implemented from the P Gate and is the inverse of the T gate.*
### Parameters:
`qubit (int)` - the qubit to have the Tdg gate be applied to the quantum wire.
### Returns:
`None`
### Example:
```python
from qcpy import quantumcircuit
qc = quantumcircuit(2)
qc.h(0)
qc.tdg(0)
print(qc.state)
# [[0.707+0.j ]
# [0. +0.j ]
# [0.5 -0.5j]
# [0. +0.j ]]
```
> ## quantumcircuit.`rz`(*qubit: int*, *theta: float=numpy.pi/2*)
*RZ gate commits a rotation around the z-axis for a qubit.*
### Parameters:
`qubit (int)` - the qubit to have the Rz gate be applied to the quantum wire.
`theta (float)` default: `numpy.pi/2` - angle of rotation around z-axis.
### Returns:
`None`
### Example:
```python
from qcpy import quantumcircuit
qc = quantumcircuit(2)
qc.h(0)
qc.rz(0)
print(qc.state)
# [[0.5-0.5j]
# [0. +0.j ]
# [0.5+0.5j]
# [0. +0.j ]]
```
> ## quantumcircuit.`ry`(*qubit: int*, *theta: float=numpy.pi/2*)
*RY gate commits a rotation around the y-axis for a qubit.*
### Parameters:
`qubit (int)` - the qubit to have the Ry gate be applied to the quantum wire.
`theta (float)` default: `numpy.pi/2` - angle of rotation around y-axis.
### Returns:
`None`
### Example:
```python
from qcpy import quantumcircuit
qc = quantumcircuit(2)
qc.ry(0)
print(qc.state)
# [[0.707+0.j]
# [0. +0.j]
# [0.707+0.j]
# [0. +0.j]]
```
> ## quantumcircuit.`rx`(*qubit: int*, *theta: float=numpy.pi/2*)
*RX gate commits a rotation around the x-axis for a qubit.*
### Parameters:
`qubit (int)` - the qubit to have the Ry gate be applied to the quantum wire.
`theta (float)` default: `numpy.pi/2` - angle of rotation around x-axis.
### Returns:
`None`
### Example:
```python
from qcpy import quantumCircuit
qc = quantumcircuit(2)
qc.rx(0)
print(qc.state)
# [[0.707+0.j ]
# [0. +0.j ]
# [0. -0.707j]
# [0. +0.j ]]
```
> ## quantumcircuit.`sx`(*qubit: int*)
*SX gate is the square root of the Inverse gate (X, PauliX Gate).*
### Parameters:
`qubit (int)` - the qubit to have the Sx gate be applied to the quantum wire.
### Returns:
`None`
### Example:
```python
from qcpy import quantumcircuit
qc = quantumcircuit(2)
qc.sx(0)
print(qc.state)
# [[0.5+0.5j]
# [0. +0.j ]
# [0.5-0.5j]
# [0. +0.j ]]
```
> ## quantumcircuit.`sxdg`(*qubit: int*)
*SXDG gate is the negative square root of the Inverse gate (X, PauliX Gate) and inverse of the SX gate.*
### Parameters:
`qubit (int)` - the qubit to have the SXdg gate be applied to the quantum wire.
### Returns:
`None`
### Example:
```python
from qcpy import quantumcircuit
qc = quantumcircuit(2)
qc.sxdg(0)
print(qc.state)
# [[0.5-0.5j]
# [0. +0.j ]
# [0.5+0.5j]
# [0. +0.j ]]
```
> ## quantumcircuit.`u`(*qubit: int*, *theta: float=numpy.pi/2*, *phi: float=numpy.pi/2*, *lmbda: float=numpy.pi/2*)
*U gate is given three inputs (theta, phi, and lambda) that allow the inputs to manipulate the base matrix to allow for the position of the enacted qubit around the bloch sphere representation.*
### Parameters:
`qubit (int)` - the qubit to have the U gate be applied to the quantum wire.
`theta (float)` default: `numpy.pi/2` - angle representation to rotate the qubit's representation.
`phi (float)` default: `numpy.pi/2` - angle representation to rotate the qubit's representation.
`lmbda (float)` default: `numpy.pi/2` - angle representation to rotate the qubit's representation.
### Returns:
`None`
### Example:
```python
from qcpy import quantumcircuit
qc = quantumcircuit(2)
qc.u(0)
print(qc.state)
# [[0.5-0.5j]
# [0. +0.j ]
# [0.5+0.5j]
# [0. +0.j ]]
```
> ## quantumcircuit.`custom`(*qubit: int*, *custom_matrix: np.array*)
*Will take in a custom single qubit quantum gate and implement it on a qubit.*
### Parameters:
`qubit (int)` - the qubit to have the U gate be applied to the quantum wire.
`custom_matrix (np.array)` - matrix to be applied to the quantum circuit.
### Returns:
`None`
### Example:
```python
from qcpy import quantumcircuit, gates as qg
qc = quantumcircuit(2)
qc.custom(0, qg.cx())
print(qc.state)
# [[0.+0.j]
# [0.+0.j]
# [1.+0.j]
# [0.+0.j]]
```
> ## quantumcircuit.`gatearray`(*custom_matrix: List*)
*Will take in a custom single qubit quantum gate and implement it on a qubit.*
### Parameters:
`custom_matrix (List)` - Array of (2,2) matrix to apply to the quantum circuit.
### Returns:
`None`
### Example:
```python
from qcpy import quantumcircuit, gates as qg
qc = quantumcircuit(2)
arr = [qg.hadamard()] * 2
qc.gatearray(arr)
print(qc.state)
# [[0.5+0.j]
# [0.5+0.j]
# [0.5+0.j]
# [0.5+0.j]]
```
# Visualize
*A collection of tools to visualize the quantum circuit*
> ## qcpy.visualize.qsphere(*quantumstate: (ndarray, QuantumCircuit), *path: str="qsphere.png"*, *save: bool=False*, *show: bool=True*, *light: bool=False*)
*Returns a Q-Sphere that plots a global visualization of the quantum states in a 3D global view*
### Parameters:
`quantumstate (quantumcircuit)` - quantum circuit to represent.
`path (str)` - name of the image to be saved.
`save (bool)` - save the image.
`show (bool)` - present in matplotlib.
`light (bool)` - toggle light and dark mode.
### Returns:
`None`
### Example:
```python
from qcpy import quantumcircuit, visualize
qc = quantumcircuit(3)
qc.h(0)
qc.h(1)
qc.h(2)
visualize.qsphere(qc)
```
> ## qcpy.visualize.bloch(*quantumstate: (ndarray, QuantumCircuit), *path: str="BlochSphere.png"*, *save: bool=False*, *show: bool=True*, *light: bool=False*)
*Returns a Bloch Sphere that plots the quantum state of a single qubit in a 3D global view*
### Parameters:
`quantumstate (quantumcircuit)` - quantum circuit to represent.
`path (str)` - name of the image to be saved.
`save (bool)` - save the image.
`show (bool)` - present in matplotlib.
`light (bool)` - toggle light and dark mode.
### Returns:
`None`
### Example:
```python
from qcpy import quantumcircuit, visualize
qc = quantumcircuit(3)
qc.h(0)
qc.h(1)
qc.h(2)
visualize.bloch(qc)
```
> ## qcpy.visualize.statevector(*quantumstate: (ndarray, QuantumCircuit), *path: str="statevector.png"*, *save: bool=False*, *show: bool=True*, *light: bool=False*)
*Returns a graph that plots all the amplitudes of the qubits being measured*
### Parameters:
`quantumstate (quantumcircuit)` - quantum circuit to represent.
`path (str)` - name of the image to be saved.
`save (bool)` - save the image.
`show (bool)` - present in matplotlib.
`light (bool)` - toggle light and dark mode.
### Returns:
`None`
### Example:
```python
from qcpy import quantumcircuit, visualize
qc = quantumcircuit(3)
qc.h(0)
qc.h(1)
qc.h(2)
visualize.statevector(qc)
```
> ## qcpy.visualize.probability(*quantumstate: (ndarray, QuantumCircuit), *path: str="probability.png"*, *save: bool=True*, *show: bool=True*, *light: bool=False*)
*Returns a graph that plots all the probabilities of the qubits being measured*
### Parameters:
`quantumstate (quantumcircuit)` - quantum circuit to represent.
`path (str)` - name of the image to be saved.
`save (bool)` - save the image.
`show (bool)` - present in matplotlib.
`light (bool)` - toggle light and dark mode.
### Returns:
`None`
### Example:
```python
from qcpy import quantumcircuit, visualize
qc = quantumcircuit(3)
qc.h(0)
qc.h(1)
qc.h(2)
visualize.probability(qc)
```
# Tools
*A collection of tools to represent a quantum state*
> ## qcpy.tools.probability(*quantumstate: (ndarray, QuantumCircuit)*, *show_percent: bool=False*, *show_bit: int=-1*, *round: int=3*)
*Returns an array of the probability of the quantum circuit*
### Parameters:
`quantumstate (quantumcircuit)` - quantum circuit to represent.
`show_bit (int, str)` - Output a single value from the calculation, enter either a binary string or integer.
`round (int)` - Round the the nth decimal point.
`show_percent (bool)` - Output the probability in percentages instead of floats.
### Returns:
`NDArray`
### Example:
```python
from qcpy import quantumcircuit, probability
qc = quantumcircuit(3)
qc.h(0)
qc.h(1)
qc.h(2)
probability(qc)
```
> ## qcpy.tools.amplitude(*quantumstate: (ndarray, QuantumCircuit)*, *show_bit: (str, int)=-1*, *round: int=3*, *radian: bool=True*)
*Returns an array of the amplitude of the quantum circuit*
### Parameters:
`quantumstate (quantumcircuit)` - quantum circuit to represent.
`show_bit (int, str)` - Output a single value from the calculation, enter either a binary string or integer.
`round (int)` - Round the the nth decimal point.
`radians (bool)` - Output the calculation in radians.
### Returns:
`NDArray`
### Example:
```python
from qcpy import quantumcircuit, amplitude
qc = quantumcircuit(3)
qc.h(0)
qc.h(1)
qc.h(2)
amplitude(qc)
```
> ## qcpy.tools.phaseangle(*quantumstate: (ndarray, QuantumCircuit)*, *show_bit: (str, int)*, *round: int=3*, *radian: bool=True*)
*Returns a graph that plots all the probabilities of the qubits being measured*
### Parameters:
`quantumstate (quantumcircuit)` - quantum circuit to represent.
`show_bit (int, str)` - Output a single value from the calculation, enter either a binary string or integer.
`round (int)` - Round the the nth decimal point.
`radians (bool)` - Output the calculation in radians.
### Returns:
`NDArray`
### Example:
```python
from qcpy import quantumcircuit, phaseangle
qc = quantumcircuit(3)
qc.h(0)
qc.h(1)
qc.h(2)
phaseangle(qc)
```
> ## qcpy.tools.measure(*quantumstate: (ndarray, QuantumCircuit)*)
*Returns a binary string that could be outputted from the quantum circuit.*
### Parameters:
`quantumstate (quantumcircuit)` - quantum circuit to represent.
### Returns:
`str`
### Example:
```python
from qcpy import quantumcircuit, measure
qc = quantumcircuit(3)
qc.h(0)
qc.h(1)
qc.h(2)
measure(qc)
```
Raw data
{
"_id": null,
"home_page": "https://github.com/QCpython/qcpy",
"name": "qcpydev",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": null,
"author": "Brennan Freeze, Paris Osuch, Aundre Barras",
"author_email": "freezebrennan@gmail.com",
"download_url": null,
"platform": null,
"description": "# README.md\n\n# qcpy - A Quantum Computing Library for Python\n\nqcpy is an open source python library and collaborative project for flexible simulations and visualizations of quantum circuits. This library contains a set of tools to teach computer scientists about the emerging discipline of quantum computing and improve overall understanding.\n[Join The Discord](https://discord.gg/dDwPhn6E)\nYou can download the package using pip:\n\n```txt\npip install qcpydev\n```\n---\n\n# Qubit\n\n> ## qcpy.`qubit`(*initial=\u2019z\u2019*)\n\n*Object representation of a qubit.*\n\n### Parameters:\n\n`initial (chr)` default: `z` - Character input for starting direction in the *x*, *y*, or *z* axis.\n\n### Attributes:\n\n`None`\n\n### Example:\n\n```python\nfrom qcpy import qubit\n\nqx = qubit(initial_state = 'x')\nqy = qubit(initial_state = 'y')\nqz = qubit(initial_state = 'z')\nprint(\"x:\\n\", qx)\nprint(\"y:\\n\", qy)\nprint(\"z:\\n\", qz)\n\n\n# x:\n# [[0.70710677+0.j]\n# [0.70710677+0.j]]\n# y:\n# [[0.70710677+0.j]\n# [0.+0.70710677j]]\n# z:\n# [[1.+0.j]\n# [0.+0.j]]\n```\n---\n\n# Quantum Gates\n\n> ## quantumgate.`identity`()\n\n*Gate that does not modify the quantum state.*\n\n### Parameters:\n\n`None`\n\n```python\nidentity=[1+0j, 0+0j], \n [0+0j, 1+0j]\n```\n### Example:\n\n```python\nfrom qcpy import gates as qg \n\nprint(qg.identity())\n\n# [[1.+0.j 0.+0.j]\n# [0.+0.j 1.+0.j]]\n```\n> ## quantumgate.`paulix`()\n\n*Quantum equivalent of the NOT gate in classical computing with respect to the standard basis |0>, |1>.*\n\n### Parameters:\n\n`None`\n\n```python\nPauliX = [0+0j, 1+0j], \n\t [1+0j, 0+0j]\n```\n### Example:\n\n```python\nfrom qcpy import gates as qg\n\nprint(qg.paulix())\n\n# [[1.+0.j 0.+0.j]\n# [0.+0.j 1.+0.j]]\n```\n> ## quantumgate.`pauliy`()\n\n*Rotation around y-axis of the bloch sphere by \u03c0 radiains, mapping |0> to i|1> and |1> to -i|0>.*\n\n### Parameters:\n\n`None`\n\n```python\nPauliY = [0+0j, 0-1j],\n [0+1j, 0+0j]\n```\n### Example:\n\n```python\nfrom qcpy import gates as qg\n\nprint(qg.pauliy())\n\n# [[0+0j, 0-1j]\n# [0+1j, 0+0j]]\n```\n> ## quantumgate.`pauliz`()\n\n*Rotation around z-axis of the bloch sphere by \u03c0 radiains, mapping |1> to -|1>; known as the phase-flip.*\n\n### Parameters:\n\n`None`\n\n```python\nPauliZ = [1+0j, 0+0j], \n [0+0j, -1+0j]\n```\n### Example:\n\n```python\nfrom qcpy import gates as qg\n\nprint(qg.pauliz())\n\n# [[1+0j, 0+0j], \n# [0+0j, -1+0j]]\n```\n> ## quantumgate.`hadamard`()\n\n*Maps the basis states |0> to |+> and |1> to |->, creating a superposition state if given a computation basis state.*\n\n### Parameters:\n\n`None`\n\n```python\nHadamard = [1, 1] \n [1, -1] * (1/sqrt(2))\n```\n### Example:\n\n```python\nfrom qcpy import gates as qg\n\nprint(qg.hadamard())\n\n# [[ 0.70710677+0.j 0.70710677+0.j]\n# [ 0.70710677+0.j -0.70710677+0.j]]\n```\n> ## quantumgate.`cnot`(*little_endian=False*)\n\n*Controlled gate acts on two or more qubits, performing the NOT operation of the target qubit only if the control qubits are |1>, can act as a quantum regiester and is used to entangle and disentangle Bell states.*\n\n### Parameters:\n\n`little_endian (bool)` - if the gate is an inverse, with the target being above the control.\n\n```python\n# regular\nCNot = [1+0j, 0+0j, 0+0j, 0+0j],\n [0+0j, 1+0j, 0+0j, 0+0j],\n [0+0j, 0+0j, 0+0j, 1+0j],\n [0+0j, 0+0j, 1+0j, 0+0j]\n# little_endian = True\nCNot = [1+0j, 0+0j, 0+0j, 0+0j],\n [0+0j, 0+0j, 0+0j, 1+0j],\n [0+0j, 0+0j, 1+0j, 0+0j],\n [0+0j, 1+0j, 0+0j, 0+0j] \n```\n### Example:\n\n```python\nfrom qcpy import gates as qg\n\nprint(qg.cnot())\n\n# [[1.+0.j 0.+0.j 0.+0.j 0.+0.j]\n# [0.+0.j 1.+0.j 0.+0.j 0.+0.j]\n# [0.+0.j 0.+0.j 0.+0.j 1.+0.j]\n# [0.+0.j 0.+0.j 1.+0.j 0.+0.j]]\n\n# [[1.+0.j 0.+0.j 0.+0.j 0.+0.j]\n# [0.+0.j 0.+0.j 0.+0.j 1.+0.j]\n# [0.+0.j 0.+0.j 1.+0.j 0.+0.j]\n# [0.+0.j 1.+0.j 0.+0.j 0.+0.j]]\n```\n> ## quantumgate.`swap`()\n\n*Swaps two qubits, with respect to the basis |00>, |01>, |10>, and |11>.*\n\n### Parameters:\n\n`None`\n\n```python\nSwap = [1+0j, 0+0j, 0+0j, 0+0j],\n [0+0j, 0+0j, 1+0j, 0+0j],\n [0+0j, 1+0j, 0+0j, 0+0j],\n [0+0j, 0+0j, 0+0j, 1+0j]\n```\n### Example:\n\n```python\nfrom qcpy import gates as qg\n\nprint(qg.swap())\n\n# [1+0j, 0+0j, 0+0j, 0+0j],\n# [0+0j, 0+0j, 1+0j, 0+0j],\n# [0+0j, 1+0j, 0+0j, 0+0j],\n# [0+0j, 0+0j, 0+0j, 1+0j]\n```\n> ## quantumgate.`toffoli`()\n\n*Universal reversible logic gate, known as the \u201ccontrolled-controlled-NOT\u201d gate; if the two control bits are set to 1, it will invert the target.*\n\n### Parameters:\n\n`None`\n\n```python\nToffoli = [1+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j],\n [0+0j, 1+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j],\n [0+0j, 0+0j, 1+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j],\n [0+0j, 0+0j, 0+0j, 1+0j, 0+0j, 0+0j, 0+0j, 0+0j],\n [0+0j, 0+0j, 0+0j, 0+0j, 1+0j, 0+0j, 0+0j, 0+0j],\n [0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 1+0j, 0+0j, 0+0j],\n [0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 1+0j],\n [0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 1+0j, 0+0j]\n```\n### Example:\n\n```python\nfrom qcpy import gates as qg\n\nprint(qg.toffoli())\n\n# [1+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j],\n# [0+0j, 1+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j],\n# [0+0j, 0+0j, 1+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j],\n# [0+0j, 0+0j, 0+0j, 1+0j, 0+0j, 0+0j, 0+0j, 0+0j],\n# [0+0j, 0+0j, 0+0j, 0+0j, 1+0j, 0+0j, 0+0j, 0+0j],\n# [0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 1+0j, 0+0j, 0+0j],\n# [0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 1+0j],\n# [0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 1+0j, 0+0j]\n```\n> ## quantumgate.`phase`(*theta=numpy.pi/2*)\n\n*Applies a rotation of theta around the z-axis.*\n\n### Parameters:\n\n`theta (float)` default: `numpy.pi/2` - angle of rotation around z-axis.\n\n```python\nPhase = [1+0j, 0+0j],\n\t[0+0j, numpy.exp(0+1j * theta)]\n```\n### Example:\n\n```python\nfrom qcpy import gates as qg\n\nprint(qg.phase())\n\n# [1+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j],\n# [0+0j, 1+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j],\n# [0+0j, 0+0j, 1+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j],\n# [0+0j, 0+0j, 0+0j, 1+0j, 0+0j, 0+0j, 0+0j, 0+0j],\n# [0+0j, 0+0j, 0+0j, 0+0j, 1+0j, 0+0j, 0+0j, 0+0j],\n# [0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 1+0j, 0+0j, 0+0j],\n# [0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 1+0j],\n# [0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 1+0j, 0+0j]\n```\n> ## quantumgate.`s`()\n\n*Equivalent to a pi/2 rotation around the z-axis.*\n\n### Parameters:\n\n`None`\n\n```python\nS.matrix = [1+0j, 0+0j],\n [0+0j, 0+1j]\n```\n### Example:\n\n```python\nfrom qcpy import gates as qg\n\nprint(qg.s())\n\n# [1+0j, 0+0j],\n# [0+0j, 0+1j]\n```\n> ## quantumgate.`sdg`()\n\n*Inverse of S gate; a -pi/2 rotation around the z-axis.*\n\n### Parameters:\n\n`None`\n\n```python\nSdg.matrix = [1+0j, 0+0j],\n [0+0j, 0-1j]\n```\n### Example:\n\n```python\nfrom qcpy import gates as qg\n\nprint(qg.sdg())\n\n# [1+0j, 0+0j],\n# [0+0j, 0-1j]\n```\n> ## quantumgate.`t`()\n\n*Square of S gate; where T = S^2.*\n\n### Parameters:\n\n`None`\n\n```python\nT.matrix = [1+0j, 0+0j],\n [0+0j, numpy.exp((0+1j * numpy.pi) / 4)]\n```\n### Example:\n\n```python\nfrom qcpy import gates as qg\n\nprint(qg.t())\n\n# [[1.+0.j 0.+0.j]\n# [0.+0.j 0.70710677+0.70710677j]]\n```\n> ## quantumgate.`tdg`()\n\n*Inverse of T gate.*\n\n### Parameters:\n\n`None`\n\n```python\nTdg = [1+0j, 0+0j],\n [0+0j, numpy.exp((0-1j * numpy.pi) / 4)]\n```\n### Example:\n\n```python\nfrom qcpy import gates as qg\n\nprint(qg.tdg())\n\n# [[1.+0.j 0.+0.j]\n# [0.+0.j 0.70710677-0.70710677j]]\n```\n> ## quantumgate.`rz`(*theta=numpy.pi/2*)\n\n*Rotation of qubit around the z-axis.*\n\n### Parameters:\n\n`theta (float)` default: `numpy.pi/2` - angle of rotation around z-axis.\n\n```python\nfrom qcpy import gates as qg\nprint(qg.rz())\n\n# [numpy.exp((0-1j * (theta / 2))), 0+0j],\n# [0+0j, numpy.exp(0+1j * (theta / 2))]\n```\n\n> ## quantumgate.`rx`(*theta=numpy.pi/2*)\n\n*Rotation of qubit around the x-axis.*\n\n### Parameters:\n\n`theta (float)` default: `numpy.pi/2` - angle of rotation around x-axis.\n\n```python\nRx = [numpy.cos(theta / 2), 0-1j * numpy.sin(theta / 2)],\n [0-1j * numpy.sin(theta / 2), numpy.cos(theta / 2)]\n```\n### Example:\n\n```python\nfrom qcpy import gates as qg\n\nprint(qg.rx())\n\n# [[0.70710677+0.j 0.-0.70710677j]\n# [0.-0.70710677j 0.70710677+0.j]]\n```\n> ## quantumgate.`ry`(*theta=numpy.pi/2*)\n\n*Rotation of qubit around the y-axis.*\n\n### Parameters:\n\n`theta (float)`default: `numpy.pi/2` - angle of rotation around y-axis.\n\n```python\nRy = [numpy.cos(theta / 2), -1 * numpy.sin(theta / 2)],\n [numpy.sin(theta / 2), numpy.cos(theta / 2)]\n```\n### Example:\n\n```python\nfrom qcpy import gates as qg\n\nprint(qg.ry())\n\n# [[ 0.70710677+0.j -0.70710677+0.j]\n# [ 0.70710677+0.j 0.70710677+0.j]]\n```\n> ## quantumgate.`sx`()\n\n*Rotation around the x-axis by 90 degrees in the counter-clockwise direction. Also known as the \u201csquare-root X gate\u201d due to the fact that applying the SX gate twice results in an X gate.*\n\n### Parameters:\n\n`None`\n\n```python\nSx = [1+1j, 1-1j], \n [1-1j, 1+1j] * (1 / 2)\n```\n### Example:\n\n```python\nfrom qcpy import gates as qg\n\nprint(qg.sx())\n\n# [[0.5+0.5j 0.5-0.5j]\n# [0.5-0.5j 0.5+0.5j]]\n```\n> ## quantumgate.`sxdg`()\n\n*Inverse of the Sx gate.*\n\n### Parameters:\n\n`None`\n\n```python\nSxdg = [1-1j, 1+1j], \n [1+1j, 1-1j] * (1 / 2)\n```\n### Example:\n\n```python\nfrom qcpy import gates as qg\n\nprint(qg.sxdg())\n\n# [[0.5-0.5j 0.5+0.5j]\n# [0.5+0.5j 0.5-0.5j]]\n```\n> ## quantumgate.`u`(*theta=numpy.pi/2, phi=numpy.pi/2, lmbda=numpy.pi/2*)\n\n*Rotation of qubit with respect to theta, phi, and lambda, in Euler angles.*\n\n### Parameters:\n\n`theta (float)` default: `numpy.pi/2` - angle of rotation around Euler angle theta.\n\n`phi (float)` default: `numpy.pi/2` - angle of rotation around Euler angle phi.\n\n`lmbda (float)` default: `numpy.pi/2` - angle of rotation around Eulear angle lambda.\n\n```python\nU.matrix = [numpy.cos(theta / 2), -1 * numpy.exp(0+1j * lmbda) * numpy.sin(theta / 2)], \n [numpy.exp(0+1j * phi) * numpy.sin(theta / 2), numpy.exp(0+1j * (lmbda + phi)) * numpy.cos(theta / 2)]]\n```\n### Example:\n\n```python\nfrom qcpy import gates as qg\n\nprint(qg.u())\n\n# [[0.7071+0.j -0.-0.7071j]\n# [0.+0.7071j -0.7071+0.j]]\n```\n> ## quantumgate.`rxx`(*theta=numpy.pi/2*)\n\n*Rotation about XX, maximally entangling at theta = pi/2.*\n\n### Parameters:\n\n`theta (float)` default: `numpy.pi/2` - angle of rotation around XX.\n\n```python\nRxx.matrix = [numpy.cos(theta / 2), 0+0j, 0+0j, 0-1j * numpy.sin(theta / 2)],\n [0+0j, numpy.cos(theta / 2), 0-1j * numpy.sin(theta / 2), 0+0j],\n [0+0j, 0-1j * numpy.sin(theta / 2), numpy.cos(theta / 2), 0+0j],\n [0-1j * numpy.sin(theta / 2), 0+0j, 0+0j, numpy.cos(theta / 2)]\n```\n### Example:\n\n```python\nfrom qcpy import gates as qg\n\nprint(qg.rxx())\n\n# [[0.70710677+0.j 0+0.j 0+0.j 0-0.70710677j]\n# [0+0.j 0.70710677+0.j 0-0.70710677j 0+0.j]\n# [0+0.j 0-0.70710677j 0.70710677+0.j 0+0.j]\n# [0-0.70710677j 0+0.j 0.+0.j 0.70710677+0.j]]\n```\n> ## quantumgate.`rzz`(*theta=numpy.pi/2*)\n\n*Rotation about ZZ, maximally entangling at theta = pi/2.*\n\n### Parameters:\n\n`theta (float)` default: `numpy.pi/2` - angle of rotation around ZZ.\n\n```python\nRzz.matrix = [numpy.exp(0-1j * (theta / 2)), 0+0j, 0+0j, 0+0j],\n [0+0j, numpy.exp(0+1j * (theta / 2)), 0+0j, 0+0j],\n [0+0j, 0+0j, numpy.exp(0+1j * (theta / 2)), 0+0j],\n [0+0j, 0+0j, 0+0j, numpy.exp(0-1j * (theta / 2))]\n```\n### Example:\n\n```python\nfrom qcpy import gates as qg\n\nprint(qg.rzz())\n\n# [[0.70710677-0.70710677j 0+0.j 0+0.jn 0+0.j]\n# [0+0.j 0.70710677+0.70710677j 0+0.j 0+0.j]\n# [0+0.j 0+0.j 0.70710677+0.70710677j 0+0.j]\n# [0+0.j 0+0.j 0+0.j 0.70710677-0.70710677j]]\n```\n> ## quantumgate.`cr`(*theta=numpy.pi/2*)\n\n*Controlled phase shift rotation in theta radians; generalization of Cz gate.*\n\n### Parameters:\n\n`theta (float)` default: `numpy.pi/2` - angle of rotation in theta radians.\n\n```python\nCr = [1+0j, 0+0j, 0+0j, 0+0j],\n [0+0j, 1+0j, 0+0j, 0+0j],\n [0+0j, 0+0j, 1+0j, 0+0j],\n [0+0j, 0+0j, 0+0j, exp(theta * 0+1j)]\n```\n### Example:\n\n```python\nfrom qcpy import gates as qg\n\nprint(qg.cr())\n\n# [[1+0.j 0+0.j 0+0.j 0+0.j]\n# [0+0.j 1+0.j 0+0.j 0+0.j]\n# [0+0.j 0+0.j 1+0.j 0+0.j]\n# [0+0.j 0+0.j 0+0.j 0.5403023+0.84147096j]]\n```\n> ## quantumgate.`cz`(*theta=numpy.pi/2*)\n\n*Controlled phase shift rotation in theta radians.*\n\n### Parameters:\n\n`theta (float)` default: `numpy.pi/2` - angle of rotation in theta radians.\n\n```python\nCz = [1+0j, 0+0j, 0+0j, 0+0j],\n [0+0j, 1+0j, 0+0j, 0+0j],\n [0+0j, 0+0j, 1+0j, 0+0j],\n [0+0j, 0+0j, 0+0j, -1+0j]\n```\n### Example:\n\n```python\nfrom qcpy import gates as qg\n\nprint(qg.cz())\n\n# [[ 1.+0.j 0.+0.j 0.+0.j 0.+0.j]\n# [ 0.+0.j 1.+0.j 0.+0.j 0.+0.j]\n# [ 0.+0.j 0.+0.j 1.+0.j 0.+0.j]\n# [ 0.+0.j 0.+0.j 0.+0.j -1.+0.j]]\n```\n---\n# Quantum Circuit\n> ## *class* qcpy.`quantumcircuit`(*qubits: int*, *big_endian: bool=False*, *prep: char='z'*, *gpu: bool='false'*, *sparse: bool='false'*)\n\n*Quantum circuit that represents the state of a quantum system and performs operations on select qubits.*\n\n### Parameters:\n\n`qubits (int)` - number of qubits in the circuit.\n\n`little_endian (bool)` default: `False` - order of qubits and tensor products.\n\n`prep (char)` options: [`z`, `y`, `x`] - initial direction of the qubits' phase angle.\n\n`gpu (bool)` default: `False` - initialize GPU usage for the quantum circuit.\n\n`sparse (bool)` default: `False` - use sparse matrix for the quantum circuit.\n\n> ## quantumcircuit.`state`\n\n*Returns state of the quantum circuit.*\n\n### Parameters:\n\n`None`\n\n### Returns:\n\n`state (numpy.ndarray)` - array of quantum circuit's state.\n\n### Example:\n\n```python\nfrom qcpy import quantumcircuit\n\nqc = quantumcircuit(2)\n\nqc.h(0)\nqc.cnot(0, 1)\n\nprint(qc.state)\n\n# [[0.707+0.j]\n# [0. +0.j]\n# [0. +0.j]\n# [0.707+0.j]]\n```\n\n> ## quantumcircuit.`size`\n\n*Returns the number of qubits in the quantum circuit.*\n\n### Parameters:\n\n`None`\n\n### Returns:\n\n`qubits (int)` - number of qubits.\n\n### Example:\n\n```python\nfrom qcpy import quantumcircuit\n\nqc = quantumcircuit(2)\n\n\nprint(qc.size)\n\n```\n> ## quantumcircuit.`ccx`(*control_1: int*, *control_2: int*, *target: int*)\n\n*A 3-qubit quantum gate that takes in two control qubits and one target qubit.*\n\n### Parameters:\n\n`control_one (int)` - first control qubit.\n\n`control_two (int)` - second control qubit.\n\n`target (int)` - target qubit.\n\n\n### Returns:\n`None`\n\n### Example:\n\n```python\nfrom qcpy import quantumcircuit\n\nqc = quantumcircuit(3)\n\nqc.h(0)\n\nqc.h(1)\n\nqc.ccx(0,1,2)\n\nprint(qc.state)\n\n# [[0.5+0.j]\n# [0. +0.j]\n# [0.5+0.j]\n# [0. +0.j]\n# [0.5+0.j]\n# [0. +0.j]\n# [0. +0.j]\n# [0.5+0.j]]\n```\n\n> ## quantumcircuit.`rccx`(*control_1*, *control_2*, *target*)\n\n*A 3-qubit quantum gate that takes in two control qubits and one target qubit.*\n\n### Parameters:\n\n`control_1 (int)` - first control qubit.\n\n`control_2 (int)` - second control qubit.\n\n`target (int)` - target qubit.\n\n\n### Returns:\n`None`\n\n### Example:\n\n```python\nfrom qcpy import quantumcircuit\nqc = quantumcircuit(3)\n\nqc.h(0)\n\nqc.h(1)\n\nqc.rccx(0,1,2)\n\nprint(qc.state)\n\n# [[ 0.5-0.j ]\n# [ 0. +0.j ]\n# [ 0.5-0.j ]\n# [ 0. +0.j ]\n# [ 0.5-0.j ]\n# [ 0. +0.j ]\n# [-0. +0.j ]\n# [ 0. +0.5j]]\n```\n\n> ## quantumcircuit.`rc3x`(*qubit_1: int*, *qubit_2: int*, *qubit_3: int*, *qubit_4: int*)\n\n*A 4-qubit quantum gate that takes in 4 unique qubits.*\n\n### Parameters:\n\n`qubit_1 (int)` - first input qubit.\n\n`qubit_2 (int)` - second input qubit.\n\n`qubit_3 (int)` - third input qubit.\n\n`qubit_4 (int)` - fourth input qubit.\n\n\n### Returns:\n`None`\n\n### Example:\n\n```python\nfrom qcpy import quantumcircuit\nqc = quantumcircuit(4)\n\nqc.h(0)\n\nqc.h(1)\n\nqc.h(2)\n\nqc.rc3x(0,1,2,3)\n\nprint(qc.state)\n\n# [[ 0.354-0.j ]\n# [ 0. +0.j ]\n# [ 0.354-0.j ]\n# [ 0. +0.j ]\n# [ 0.354-0.j ]\n# [ 0. +0.j ]\n# [ 0.354-0.j ]\n# [ 0. +0.j ]\n# [ 0.354-0.j ]\n# [ 0. +0.j ]\n# [ 0.354-0.j ]\n# [ 0. +0.j ]\n# [ 0. +0.354j]\n# [-0. +0.j ]\n# [ 0. -0.j ]\n# [-0.354+0.j ]]\n```\n> ## quantumcircuit.`cx`(*control: int*, *target: int*)\n\n*A 2-qubit quantum gate that takes in a control qubit and one target qubit.*\n\n### Parameters:\n\n`control (int)` - control qubit.\n\n`target (int)` - target qubit.\n\n\n### Returns:\n`None`\n\n### Example:\n\n```python\nfrom qcpy import quantumcircuit\nqc = quantumcircuit(2)\n\nqc.h(0)\n\nqc.cx(0,1)\n\nprint(qc.state)\n\n# [[0.707+0.j]\n# [0. +0.j]\n# [0. +0.j]\n# [0.707+0.j]]\n```\n\n> ## quantumcircuit.`ch`(*control: int*, *target: int*)\n\n*A controlled Hadamard gate to use in the quantum circuit.*\n\n### Parameters:\n\n`control (int)` - control qubit.\n\n`target (int)` - target qubit.\n\n\n### Returns:\n`None`\n\n### Example:\n\n```python\nfrom qcpy import quantumcircuit\nqc = quantumcircuit(2)\n\nqc.ch(0,1)\n\nprint(qc.state)\n```\n> ## quantumcircuit.`cy`(*control: int*, *target: int*)\n\n*A controlled PauliY gate to use in the quantum circuit.*\n\n### Parameters:\n\n`control (int)` - control qubit.\n\n`target (int)` - target qubit.\n\n\n### Returns:\n`None`\n\n### Example:\n\n```python\nfrom qcpy import quantumcircuit\nqc = quantumcircuit(2)\n\nqc.cy(0,1)\n\nprint(qc.state)\n```\n\n\n> ## quantumcircuit.`cz`(*control: int*, *target: int*)\n\n*A 2-qubit quantum gate that takes in a control qubit and one target qubit.*\n\n### Parameters:\n\n`control (int)` - control qubit.\n\n`target (int)` - target qubit.\n\n\n### Returns:\n`None`\n\n### Example:\n\n```python\nfrom qcpy import quantumcircuit\nqc = quantumcircuit(2)\n\nqc.h(0)\n\nqc.cz(0,1)\n\nprint(qc.state)\n\n# [[0.707+0.j]\n# [0. +0.j]\n# [0.707+0.j]\n# [0. +0.j]]\n```\n\n> ## quantumcircuit.`crx`(*control: int*, *target: int*)\n\n*A controlled RX gate to use in the quantum circuit.*\n\n### Parameters:\n\n`control (int)` - control qubit.\n\n`target (int)` - target qubit.\n\n\n### Returns:\n`None`\n\n### Example:\n\n```python\nfrom qcpy import quantumcircuit\nqc = quantumcircuit(2)\n\nqc.cry(0,1)\n\nprint(qc.state)\n```\n\n> ## quantumcircuit.`crx`(*control: int*, *target: int*)\n\n*A controlled RY gate to use in the quantum circuit.*\n\n### Parameters:\n\n`control (int)` - control qubit.\n\n`target (int)` - target qubit.\n\n\n### Returns:\n`None`\n\n### Example:\n\n```python\nfrom qcpy import quantumcircuit\nqc = quantumcircuit(2)\n\nqc.cry(0,1)\n\nprint(qc.state)\n```\n\n> ## quantumcircuit.`crz`(*control: int*, *target: int*)\n\n*A controlled RZ gate to use in the quantum circuit.*\n\n### Parameters:\n\n`control (int)` - control qubit.\n\n`target (int)` - target qubit.\n\n\n### Returns:\n`None`\n\n### Example:\n\n```python\nfrom qcpy import quantumcircuit\nqc = quantumcircuit(2)\n\nqc.crz(0,1)\n\nprint(qc.state)\n```\n> ## quantumcircuit.`cr1`(*control: int*, *target: int*)\n\n*A controlled R1 gate to use in the quantum circuit.*\n\n### Parameters:\n\n`control (int)` - control qubit.\n\n`target (int)` - target qubit.\n\n\n### Returns:\n`None`\n\n### Example:\n\n```python\nfrom qcpy import quantumcircuit\nqc = quantumcircuit(2)\n\nqc.cr1(0,1)\n\nprint(qc.state)\n```\n> ## quantumcircuit.`qft`(*qubit_one: int*, *qubit_two: int* *qubit_three: int*)\n\n*Use the QFt algorithm in the quantum circuit.*\n\n### Parameters:\n\n`qubit_one (int)` - first qubit.\n\n`qubit_two (int)` - second qubit.\n\n`qubit_three (int)` - third qubit.\n\n### Returns:\n`None`\n\n### Example:\n\n```python\nfrom qcpy import quantumcircuit\nqc = quantumcircuit(2)\n\nqc.qft(0,1)\n\nprint(qc.state)\n```\n\n> ## quantumcircuit.`swap`(*qubit_1: int*, *qubit_2: int*)\n\n*A 2-qubit quantum gate that takes in 2 qubits to swap there properties.*\n\n### Parameters:\n\n`qubit_1 (int)` - first qubit to swap.\n\n`qubit_2 (int)` - second qubit to swap.\n\n\n### Returns:\n`None`\n\n### Example:\n\n```python\nfrom qcpy import quantumcircuit\nqc = quantumcircuit(2)\n\nqc.h(0)\n\nqc.swap(0,1)\n\nprint(qc.state)\n\n# [[0.707+0.j]\n# [0.707+0.j]\n# [0. +0.j]\n# [0. +0.j]]\n```\n\n> ## quantumcircuit.`rxx`(*qubit_1: int*, *qubit_2: int*, *theta: float=numpy.pi/2*)\n\n*A 2-qubit quantum gate that takes in two qubits and a representation of theta to initialize in the quantum state.*\n\n### Parameters:\n\n`qubit_1 (int)` - first qubit input.\n\n`qubit_2 (int)` - second qubit input.\n\n`theta (float)` default: `numpy.pi/2` - angle of rotation around z-axis.\n\n### Returns:\n`None`\n\n### Example:\n\n```python\nfrom qcpy import quantumcircuit\nqc = quantumcircuit(2)\n\nqc.h(0)\n\nqc.rxx(0,1)\n\nprint(qc.state)\n\n# [[0.5+0.j ]\n# [0. -0.5j]\n# [0.5+0.j ]\n# [0. -0.5j]]\n```\n\n> ## quantumcircuit.`rzz`(*qubit_1*, *qubit_2*, *theta=numpy.pi/2*)\n\n*A 2-qubit quantum gate that takes in two qubits and a representation of theta to initialize in the quantum state.*\n\n### Parameters:\n\n`qubit_1 (int)` - first qubit input.\n\n`qubit_2 (int)` - second qubit input.\n\n`theta (float)` default: `numpy.pi/2` - angle of rotation around z-axis.\n\n\n### Returns:\n`None`\n\n### Example:\n\n```python\nfrom qcpy import quantumcircuit\nqc = quantumcircuit(2)\n\nqc.h(0)\n\nqc.rxx(0,1)\n\nprint(qc.state)\n\n# [[0.5+0.j ]\n# [0. -0.5j]\n# [0.5+0.j ]\n# [0. -0.5j]]\n```\n\n> ## quantumcircuit.`multicustom`(*control: int*, *target: int*, *gate: np.array*)\n\n*Inset a custom controlled gate into the quantum circuit.*\n\n### Parameters:\n\n`control (int)` - control qubit for given matrix.\n\n`target (int)` - target qubit for given matrix.\n\n`gate (np.array)` - (2,2) matrix to be applied to the quantum circuit.\n\n\n### Returns:\n`None`\n\n### Example:\n\n```python\nfrom qcpy import quantumcircuit, paulix\n\nqc = quantumcircuit(2)\n\nqc.h(0)\n\nqc.multicustom(0,1, paulix())\n\nprint(qc.state)\n\n# [[0.707+0.j]\n# [0. +0.j]\n# [0. +0.j]\n# [0.707+0.j]]\n```\n\n> ## quantumcircuit.`i`(*qubit: int*)\n\n*Used to confirm value that a qubit is representing and does nothing to manipulate the value of such qubit.*\n\n### Parameters:\n\n`qubit (int)` - the qubit to have the identity gate be applied to the quantum wire.\n\n### Returns:\n`None`\n\n### Example:\n\n```python\nfrom qcpy import quantumcircuit\n\nqc = quantumcircuit(2)\n\nqc.i(0)\n\nprint(qc.state)\n\n# [[1.+0.j]\n# [0.+0.j]\n# [0.+0.j]\n# [0.+0.j]]\n```\n\n> ## quantumcircuit.`x`(*qubit: int*)\n\n*Used to invert the value of what a qubit is representing.*\n\n### Parameters:\n\n`qubit (int)` - the qubit to have the Pauli-X gate be applied to the quantum wire.\n\n### Returns:\n`None`\n\n### Example:\n\n```python\nfrom qcpy import quantumcircuit\n\nqc = quantumcircuit(2)\n\nqc.x(0)\n\nprint(qc.state)\n\n# [[0.+0.j]\n# [0.+0.j]\n# [1.+0.j]\n# [0.+0.j]]\n```\n\n\n> ## quantumcircuit.`h`(*qubit: int*)\n\n*Used to put a given qubit into superposition.*\n\n### Parameters:\n\n`qubit (int)` - the qubit to have the Hadamard gate be applied to the quantum wire.\n\n### Returns:\n`None`\n\n### Example:\n\n```python\nfrom qcpy import quantumcircuit\n\nqc = quantumcircuit(2)\n\nqc.h(0)\n\nprint(qc.state)\n\n# [[0.707+0.j]\n# [0. +0.j]\n# [0.707+0.j]\n# [0. +0.j]]\n```\n\n> ## quantumcircuit.`y`(*qubit: int*)\n\n*Changes the state of a qubit by pi around the y-axis of a Bloch Sphere.*\n\n### Parameters:\n\n`qubit (int)` - the qubit to have the Pauli-Y gate be applied to the quantum wire.\n\n### Returns:\n`None`\n\n### Example:\n\n```python\nfrom qcpy import quantumcircuit\n\nqc = quantumcircuit(2)\n\nqc.y(0)\n\nprint(qc.state)\n\n# [[0.+0.j]\n# [0.+0.j]\n# [0.+1.j]\n# [0.+0.j]]\n```\n\n\n> ## quantumcircuit.`z`(*qubit: int*)\n\n*Changes the state of a qubit by pi around the z-axis of a Bloch Sphere.*\n\n### Parameters:\n\n`qubit (int)` - the qubit to have the Pauli-Z gate be applied to the quantum wire.\n\n### Returns:\n`None`\n\n### Example:\n\n```python\nfrom qcpy import quantumcircuit\n\nqc = quantumcircuit(2)\n\nqc.h(0)\n\nqc.z(0)\n\nprint(qc.state)\n\n# [[ 0.707+0.j]\n# [ 0. +0.j]\n# [-0.707+0.j]\n# [ 0. +0.j]]\n```\n\n> ## quantumcircuit.`p`(*qubit: int*, *theta: float=numpy.pi/2*)\n\n*Commits to a rotation around the z-axis based off of the inputted theta value.*\n\n### Parameters:\n\n`qubit (int)` - the qubit to have the Phase gate be applied to the quantum wire.\n\n`theta (float)` default: `numpy.pi/2` - angle of rotation around z-axis.\n\n### Returns:\n`None`\n\n### Example:\n\n```python\nfrom qcpy import quantumcircuit\n\nqc = quantumcircuit(2)\n\nqc.h(0)\n\nqc.p(0)\n\nprint(qc.state)\n\n# [[0.707+0.j ]\n# [0. +0.j ]\n# [0. +0.707j]\n# [0. +0.j ]]\n```\n\n> ## quantumcircuit.`s`(*qubit: int*)\n\n*Is a Phase gate where the inputted theta value is given as a constant of theta = pi / 2.*\n\n### Parameters:\n\n`qubit (int)` - the qubit to have the Pauli-Z gate be applied to the quantum wire.\n\n### Returns:\n`None`\n\n### Example:\n\n```python\nfrom qcpy import quantumcircuit\n\nqc = quantumcircuit(2)\n\nqc.h(0)\n\nqc.s(0)\n\nprint(qc.state)\n\n# [[0.707+0.j ]\n# [0. +0.j ]\n# [0. +0.707j]\n# [0. +0.j ]]\n```\n\n> ## quantumcircuit.`sdg`(*qubit: int*)\n\n*Is a Phase gate and inverse of the S gate where the inputted theta value is given as a constant of theta = -pi / 2.*\n\n### Parameters:\n\n`qubit (int)` - the qubit to have the Sdg gate be applied to the quantum wire.\n\n### Returns:\n`None`\n\n### Example:\n\n```python\nfrom qcpy import quantumcircuit\n\nqc = quantumcircuit(2)\n\nqc.h(0)\n\nqc.sdg(0)\n\nprint(qc.state)\n\n# [[0.707+0.j ]\n# [0. +0.j ]\n# [0. -0.707j]\n# [0. +0.j ]]\n```\n\n> ## quantumcircuit.`t`(*qubit: int*)\n\n*T gate is a special use case gate that in implemented from the P Gate.*\n\n### Parameters:\n\n`qubit (int)` - the qubit to have the T gate be applied to the quantum wire.\n\n### Returns:\n`None`\n\n### Example:\n\n```python\nfrom qcpy import quantumcircuit\n\nqc = quantumcircuit(2)\n\nqc.h(0)\n\nqc.t(0)\n\nprint(qc.state)\n\n# [[0.707+0.j ]\n# [0. +0.j ]\n# [0.5 +0.5j]\n# [0. +0.j ]]\n```\n\n> ## quantumcircuit.`tdg`(*qubit: int*)\n\n*Tdg gate is a special use case gate that in implemented from the P Gate and is the inverse of the T gate.*\n\n### Parameters:\n\n`qubit (int)` - the qubit to have the Tdg gate be applied to the quantum wire.\n\n### Returns:\n`None`\n\n### Example:\n\n```python\nfrom qcpy import quantumcircuit\n\nqc = quantumcircuit(2)\n\nqc.h(0)\n\nqc.tdg(0)\n\nprint(qc.state)\n\n# [[0.707+0.j ]\n# [0. +0.j ]\n# [0.5 -0.5j]\n# [0. +0.j ]]\n```\n\n> ## quantumcircuit.`rz`(*qubit: int*, *theta: float=numpy.pi/2*)\n\n*RZ gate commits a rotation around the z-axis for a qubit.*\n\n### Parameters:\n\n`qubit (int)` - the qubit to have the Rz gate be applied to the quantum wire.\n\n`theta (float)` default: `numpy.pi/2` - angle of rotation around z-axis.\n\n### Returns:\n`None`\n\n### Example:\n\n```python\nfrom qcpy import quantumcircuit\n\nqc = quantumcircuit(2)\n\nqc.h(0)\n\nqc.rz(0)\n\nprint(qc.state)\n\n# [[0.5-0.5j]\n# [0. +0.j ]\n# [0.5+0.5j]\n# [0. +0.j ]]\n```\n\n> ## quantumcircuit.`ry`(*qubit: int*, *theta: float=numpy.pi/2*)\n\n*RY gate commits a rotation around the y-axis for a qubit.*\n\n### Parameters:\n\n`qubit (int)` - the qubit to have the Ry gate be applied to the quantum wire.\n\n`theta (float)` default: `numpy.pi/2` - angle of rotation around y-axis.\n\n### Returns:\n`None`\n\n### Example:\n\n```python\nfrom qcpy import quantumcircuit\n\nqc = quantumcircuit(2)\n\nqc.ry(0)\n\nprint(qc.state)\n\n# [[0.707+0.j]\n# [0. +0.j]\n# [0.707+0.j]\n# [0. +0.j]]\n```\n\n> ## quantumcircuit.`rx`(*qubit: int*, *theta: float=numpy.pi/2*)\n\n*RX gate commits a rotation around the x-axis for a qubit.*\n\n### Parameters:\n\n`qubit (int)` - the qubit to have the Ry gate be applied to the quantum wire.\n\n`theta (float)` default: `numpy.pi/2` - angle of rotation around x-axis.\n\n### Returns:\n`None`\n\n### Example:\n\n```python\nfrom qcpy import quantumCircuit\n\nqc = quantumcircuit(2)\n\nqc.rx(0)\n\nprint(qc.state)\n\n# [[0.707+0.j ]\n# [0. +0.j ]\n# [0. -0.707j]\n# [0. +0.j ]]\n```\n\n> ## quantumcircuit.`sx`(*qubit: int*)\n\n*SX gate is the square root of the Inverse gate (X, PauliX Gate).*\n\n### Parameters:\n\n`qubit (int)` - the qubit to have the Sx gate be applied to the quantum wire.\n\n### Returns:\n`None`\n\n### Example:\n\n```python\nfrom qcpy import quantumcircuit\n\nqc = quantumcircuit(2)\n\nqc.sx(0)\n\nprint(qc.state)\n\n# [[0.5+0.5j]\n# [0. +0.j ]\n# [0.5-0.5j]\n# [0. +0.j ]]\n```\n\n> ## quantumcircuit.`sxdg`(*qubit: int*)\n\n*SXDG gate is the negative square root of the Inverse gate (X, PauliX Gate) and inverse of the SX gate.*\n\n### Parameters:\n\n`qubit (int)` - the qubit to have the SXdg gate be applied to the quantum wire.\n\n### Returns:\n`None`\n\n### Example:\n\n```python\nfrom qcpy import quantumcircuit\n\nqc = quantumcircuit(2)\n\nqc.sxdg(0)\n\nprint(qc.state)\n\n# [[0.5-0.5j]\n# [0. +0.j ]\n# [0.5+0.5j]\n# [0. +0.j ]]\n```\n\n> ## quantumcircuit.`u`(*qubit: int*, *theta: float=numpy.pi/2*, *phi: float=numpy.pi/2*, *lmbda: float=numpy.pi/2*)\n\n*U gate is given three inputs (theta, phi, and lambda) that allow the inputs to manipulate the base matrix to allow for the position of the enacted qubit around the bloch sphere representation.*\n\n### Parameters:\n\n`qubit (int)` - the qubit to have the U gate be applied to the quantum wire.\n\n`theta (float)` default: `numpy.pi/2` - angle representation to rotate the qubit's representation.\n\n`phi (float)` default: `numpy.pi/2` - angle representation to rotate the qubit's representation.\n\n`lmbda (float)` default: `numpy.pi/2` - angle representation to rotate the qubit's representation.\n\n### Returns:\n`None`\n\n### Example:\n\n```python\nfrom qcpy import quantumcircuit\n\nqc = quantumcircuit(2)\n\nqc.u(0)\n\nprint(qc.state)\n\n# [[0.5-0.5j]\n# [0. +0.j ]\n# [0.5+0.5j]\n# [0. +0.j ]]\n```\n\n> ## quantumcircuit.`custom`(*qubit: int*, *custom_matrix: np.array*)\n\n*Will take in a custom single qubit quantum gate and implement it on a qubit.*\n\n### Parameters:\n\n`qubit (int)` - the qubit to have the U gate be applied to the quantum wire.\n\n`custom_matrix (np.array)` - matrix to be applied to the quantum circuit.\n\n### Returns:\n`None`\n\n### Example:\n\n```python\nfrom qcpy import quantumcircuit, gates as qg\n\nqc = quantumcircuit(2)\n\nqc.custom(0, qg.cx())\n\nprint(qc.state)\n\n# [[0.+0.j]\n# [0.+0.j]\n# [1.+0.j]\n# [0.+0.j]]\n```\n\n> ## quantumcircuit.`gatearray`(*custom_matrix: List*)\n\n*Will take in a custom single qubit quantum gate and implement it on a qubit.*\n\n### Parameters:\n\n`custom_matrix (List)` - Array of (2,2) matrix to apply to the quantum circuit.\n\n### Returns:\n`None`\n\n### Example:\n\n```python\nfrom qcpy import quantumcircuit, gates as qg\n\n\nqc = quantumcircuit(2)\narr = [qg.hadamard()] * 2\nqc.gatearray(arr)\nprint(qc.state)\n\n# [[0.5+0.j]\n# [0.5+0.j]\n# [0.5+0.j]\n# [0.5+0.j]]\n\n```\n# Visualize\n\n*A collection of tools to visualize the quantum circuit*\n\n> ## qcpy.visualize.qsphere(*quantumstate: (ndarray, QuantumCircuit), *path: str=\"qsphere.png\"*, *save: bool=False*, *show: bool=True*, *light: bool=False*)\n\n*Returns a Q-Sphere that plots a global visualization of the quantum states in a 3D global view*\n\n### Parameters:\n\n`quantumstate (quantumcircuit)` - quantum circuit to represent.\n\n`path (str)` - name of the image to be saved.\n\n`save (bool)` - save the image.\n\n`show (bool)` - present in matplotlib.\n\n`light (bool)` - toggle light and dark mode.\n\n### Returns:\n\n`None`\n\n### Example:\n\n```python\nfrom qcpy import quantumcircuit, visualize\n\nqc = quantumcircuit(3)\n\nqc.h(0)\nqc.h(1)\nqc.h(2)\n\nvisualize.qsphere(qc)\n```\n\n> ## qcpy.visualize.bloch(*quantumstate: (ndarray, QuantumCircuit), *path: str=\"BlochSphere.png\"*, *save: bool=False*, *show: bool=True*, *light: bool=False*)\n\n*Returns a Bloch Sphere that plots the quantum state of a single qubit in a 3D global view*\n\n### Parameters:\n\n`quantumstate (quantumcircuit)` - quantum circuit to represent.\n\n`path (str)` - name of the image to be saved.\n\n`save (bool)` - save the image.\n\n`show (bool)` - present in matplotlib.\n\n`light (bool)` - toggle light and dark mode.\n\n### Returns:\n\n`None`\n\n### Example:\n\n```python\nfrom qcpy import quantumcircuit, visualize\n\nqc = quantumcircuit(3)\n\nqc.h(0)\nqc.h(1)\nqc.h(2)\n\nvisualize.bloch(qc)\n```\n\n> ## qcpy.visualize.statevector(*quantumstate: (ndarray, QuantumCircuit), *path: str=\"statevector.png\"*, *save: bool=False*, *show: bool=True*, *light: bool=False*)\n\n*Returns a graph that plots all the amplitudes of the qubits being measured*\n\n### Parameters:\n\n`quantumstate (quantumcircuit)` - quantum circuit to represent.\n\n`path (str)` - name of the image to be saved.\n\n`save (bool)` - save the image.\n\n`show (bool)` - present in matplotlib.\n\n`light (bool)` - toggle light and dark mode.\n\n### Returns:\n\n`None`\n\n### Example:\n\n```python\nfrom qcpy import quantumcircuit, visualize\n\nqc = quantumcircuit(3)\n\nqc.h(0)\nqc.h(1)\nqc.h(2)\n\nvisualize.statevector(qc)\n```\n\n> ## qcpy.visualize.probability(*quantumstate: (ndarray, QuantumCircuit), *path: str=\"probability.png\"*, *save: bool=True*, *show: bool=True*, *light: bool=False*)\n\n*Returns a graph that plots all the probabilities of the qubits being measured*\n\n### Parameters:\n\n`quantumstate (quantumcircuit)` - quantum circuit to represent.\n\n`path (str)` - name of the image to be saved.\n\n`save (bool)` - save the image.\n\n`show (bool)` - present in matplotlib.\n\n`light (bool)` - toggle light and dark mode.\n\n### Returns:\n\n`None`\n\n### Example:\n\n```python\nfrom qcpy import quantumcircuit, visualize\n\nqc = quantumcircuit(3)\n\nqc.h(0)\nqc.h(1)\nqc.h(2)\n\nvisualize.probability(qc)\n```\n\n# Tools\n\n*A collection of tools to represent a quantum state*\n\n> ## qcpy.tools.probability(*quantumstate: (ndarray, QuantumCircuit)*, *show_percent: bool=False*, *show_bit: int=-1*, *round: int=3*)\n\n*Returns an array of the probability of the quantum circuit*\n\n### Parameters:\n\n`quantumstate (quantumcircuit)` - quantum circuit to represent.\n\n`show_bit (int, str)` - Output a single value from the calculation, enter either a binary string or integer.\n\n`round (int)` - Round the the nth decimal point.\n\n`show_percent (bool)` - Output the probability in percentages instead of floats.\n\n### Returns:\n\n`NDArray`\n\n### Example:\n```python\nfrom qcpy import quantumcircuit, probability\n\nqc = quantumcircuit(3)\n\nqc.h(0)\nqc.h(1)\nqc.h(2)\nprobability(qc)\n```\n\n> ## qcpy.tools.amplitude(*quantumstate: (ndarray, QuantumCircuit)*, *show_bit: (str, int)=-1*, *round: int=3*, *radian: bool=True*)\n\n*Returns an array of the amplitude of the quantum circuit*\n\n### Parameters:\n\n`quantumstate (quantumcircuit)` - quantum circuit to represent.\n\n`show_bit (int, str)` - Output a single value from the calculation, enter either a binary string or integer.\n\n`round (int)` - Round the the nth decimal point.\n\n`radians (bool)` - Output the calculation in radians.\n\n### Returns:\n\n`NDArray`\n\n### Example:\n```python\nfrom qcpy import quantumcircuit, amplitude\n\nqc = quantumcircuit(3)\n\nqc.h(0)\nqc.h(1)\nqc.h(2)\namplitude(qc)\n```\n\n> ## qcpy.tools.phaseangle(*quantumstate: (ndarray, QuantumCircuit)*, *show_bit: (str, int)*, *round: int=3*, *radian: bool=True*)\n\n*Returns a graph that plots all the probabilities of the qubits being measured*\n\n### Parameters:\n\n`quantumstate (quantumcircuit)` - quantum circuit to represent.\n\n`show_bit (int, str)` - Output a single value from the calculation, enter either a binary string or integer.\n\n`round (int)` - Round the the nth decimal point.\n\n`radians (bool)` - Output the calculation in radians.\n\n### Returns:\n\n`NDArray`\n\n### Example:\n```python\nfrom qcpy import quantumcircuit, phaseangle\n\nqc = quantumcircuit(3)\n\nqc.h(0)\nqc.h(1)\nqc.h(2)\nphaseangle(qc)\n```\n\n> ## qcpy.tools.measure(*quantumstate: (ndarray, QuantumCircuit)*)\n\n*Returns a binary string that could be outputted from the quantum circuit.*\n\n### Parameters:\n\n`quantumstate (quantumcircuit)` - quantum circuit to represent.\n\n### Returns:\n\n`str`\n\n### Example:\n```python\nfrom qcpy import quantumcircuit, measure\n\nqc = quantumcircuit(3)\n\nqc.h(0)\nqc.h(1)\nqc.h(2)\nmeasure(qc)\n```\n",
"bugtrack_url": null,
"license": null,
"summary": "qcpy is an open source python library and collaborative project for flexible simulations and visualizations of quantum circuits.",
"version": "1.1.2rc0",
"project_urls": {
"Homepage": "https://github.com/QCpython/qcpy"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "ff64e0185ab855985c1ff4db907516715a4fff1240e231441ca05940cc21300e",
"md5": "a21450c628c23b13883b2f16277c37ad",
"sha256": "0723e3dd31fd6c6ef5377f4ab77826494ca9c1a1b1989816b56dd31d8bfc6457"
},
"downloads": -1,
"filename": "qcpydev-1.1.2rc0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "a21450c628c23b13883b2f16277c37ad",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 100653,
"upload_time": "2024-12-08T00:18:29",
"upload_time_iso_8601": "2024-12-08T00:18:29.942688Z",
"url": "https://files.pythonhosted.org/packages/ff/64/e0185ab855985c1ff4db907516715a4fff1240e231441ca05940cc21300e/qcpydev-1.1.2rc0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-08 00:18:29",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "QCpython",
"github_project": "qcpy",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "matplotlib",
"specs": [
[
">=",
"3.7.2"
]
]
},
{
"name": "numpy",
"specs": [
[
">=",
"1.25.1"
]
]
},
{
"name": "setuptools",
"specs": [
[
">=",
"65.5.0"
]
]
},
{
"name": "scipy",
"specs": [
[
">=",
"1.11.2"
]
]
},
{
"name": "pytest",
"specs": [
[
">=",
"7.4.2"
]
]
},
{
"name": "black",
"specs": [
[
">=",
"23.11.0"
]
]
},
{
"name": "pillow",
"specs": [
[
">=",
"10.3.0"
]
]
},
{
"name": "pyparsing",
"specs": [
[
">=",
"3.1.2"
]
]
},
{
"name": "python-dateutil",
"specs": [
[
">=",
"2.9.0.post0"
]
]
},
{
"name": "scipy",
"specs": [
[
">=",
"1.13.0"
]
]
},
{
"name": "six",
"specs": [
[
">=",
"1.16.0"
]
]
},
{
"name": "cupy-cuda12x",
"specs": [
[
">=",
"13.0.0"
]
]
}
],
"lcname": "qcpydev"
}