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:
object
Creating qubits.
- Args:
- size (
int
): - Number of qubits.
- dtype:
- Data type of the data array.
- gpu (
int
): - GPU machine number.
- size (
- Attributes:
- data (
numpy.ndarray
orcupy.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 (
dict
ornumpy.ndarray
orcupy.ndarray
): - Physical quantity operator.
If you input
numpy.ndarray
orcupy.ndarray
as observable, this method returns \(\langle \psi | \mathrm{observable} | \psi \rangle\), where \(| \psi \rangle\) is the states of qubits. If you usedict
input, you have to set {‘operator1’: coef1, ‘operator2’: coef2, ‘operator3’: coef3, …}, such as {‘XIX’: 0.32, ‘YYZ’: 0.11, ‘III’: 0.02}. If you inputdict
as 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.ndarray
orcupy.ndarray
): - Unitary operator
- target (None or
int
ortuple
ofint
): - Operated qubits
- control (None or
int
ortuple
ofint
): - Operate target qubits where all control qubits are 1
- control_0 (None or
int
ortuple
ofint
): - 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
int
ortuple
ofint
): - projected qubits
- target (None or
- Returns:
int
: O or 1.
-
set_state
(self, state)¶ Set state.
- Args:
- state (
str
orlist
ornumpy.ndarray
orcupy.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 (