qupy package¶
Submodules¶
qupy.operator module¶
-
qupy.operator.iqft(n)¶
-
qupy.operator.phase_shift(phi)¶
-
qupy.operator.qft(n)¶
-
qupy.operator.rx(phi)¶
-
qupy.operator.ry(phi)¶
-
qupy.operator.rz(phi)¶
qupy.qubit module¶
-
class
qupy.qubit.Qubits(size, **kargs)¶ Bases:
objectCreating qubits.
- Args:
- size (
int): - Number of qubits.
- dtype:
- Data type of the data array.
- gpu (
int): - GPU machine number.
- size (
- Attributes:
- data (
numpy.ndarrayorcupy.ndarray): - The state of qubits.
- size:
- Number of qubits.
- dtype:
- Data type of the data array.
- data (
-
expect(self, observable)¶ Method to get expected value of observable.
- Args:
- observable (
dictornumpy.ndarrayorcupy.ndarray): - Physical quantity operator.
If you input
numpy.ndarrayorcupy.ndarrayas observable, this method returns \(\langle \psi | \mathrm{observable} | \psi \rangle\), where \(| \psi \rangle\) is the states of qubits. If you usedictinput, you have to set {‘operator1’: coef1, ‘operator2’: coef2, ‘operator3’: coef3, …}, such as {‘XIX’: 0.32, ‘YYZ’: 0.11, ‘III’: 0.02}. If you inputdictas observable, this method returns \(\sum_i \mathrm{coef}i \langle \psi | \mathrm{operator}i | \psi \rangle\). - n_trial (:class: int):
- cumulative number.
- observable (
- Returns:
float: Expected value.
-
gate(self, operator, target, control=None, control_0=None)¶ Gate method.
- Args:
- operator (
numpy.ndarrayorcupy.ndarray): - Unitary operator
- target (None or
intortupleofint): - Operated qubits
- control (None or
intortupleofint): - Operate target qubits where all control qubits are 1
- control_0 (None or
intortupleofint): - Operate target qubits where all control qubits are 0
- operator (
-
get_state(self, flatten=True)¶ Get state.
- Args:
- flatten (
bool): - If you set flatten=False, you can get data format used in QuPy. otherwise, you get state reformated to 1D-array.
- flatten (
-
project(target)¶ projection(self, target)
Projection method.
- Args:
- target (None or
intortupleofint): - projected qubits
- target (None or
- Returns:
int: O or 1.
-
set_state(self, state)¶ Set state.
- Args:
- state (
strorlistornumpy.ndarrayorcupy.ndarray): - If you set state as
str, you can set state \(|\mathrm{state}\rangle\) (e.g. state=‘0110’ -> \(|0110\rangle\).) otherwise, qubit state is set that you entered as state.
- state (