quara.objects.state_typical module
- generate_state_density_mat_from_name(state_name)[source]
Return the density matrix ( \(|\rho\rangle\) ) of state specified by name.
- Parameters
state_name (str) – name of the state. See the ‘state_name’ argument of generate_state_pure_state_vector_from_name() for available names.
- Returns
density matrix ( \(|\rho\rangle\) )
- Return type
np.ndarray
- generate_state_density_matrix_vector_from_name(basis, state_name)[source]
Return the density matrix vector ( \(|\rho\rangle\rangle\) ) of state specified by name.
- Parameters
basis (MatrixBasis) – basis
state_name (str) – name of the state. See the ‘state_name’ argument of generate_state_pure_state_vector_from_name() for available names.
- Returns
density matrix vector ( \(|\rho\rangle\rangle\) )
- Return type
np.ndarray
- generate_state_from_name(c_sys, state_name, is_physicality_required=True)[source]
Return the state object specified by name.
- Parameters
c_sys (CompositeSystem) – composite system.
state_name (str) – name of the state. See the ‘state_name’ argument of generate_state_pure_state_vector_from_name() for available names.
is_physicality_required (bool = True) – whether the generated object is physicality required, by default True
- Returns
State object
- Return type
- generate_state_object_from_state_name_object_name(state_name, object_name, c_sys=None, is_physicality_required=True)[source]
[summary]
- Parameters
state_name (str) – Name of the state. See the ‘state_name’ argument of generate_state_pure_state_vector_from_name() for available names.
object_name (str) – Name of the format of the object to generate. one of (“pure_state_vector” | “density_mat” | “density_matrix_vector” | “state”)
c_sys (CompositeSystem, optional) – Specify if object_name is “state” or “density_matrix_vector”, by default None.
is_physicality_required (bool = True) – whether the generated object is physicality required, by default True
- Returns
The state specified by state_name is returned in an object of the form specified by object_name.
- Return type
Union[State, np.ndarray]
- Raises
ValueError – object_name or state_name is out of range.
- generate_state_pure_state_vector_from_name(state_name)[source]
Return the pure state vector for state specified by name. Use get_state_names() to get a list of all available names.
- Parameters
state_name (str) –
name of the state.
1 qubit: “x0”, “x1”, “y0”, “y1”, “z0”, “a”
2 qubit: “bell_psi_plus”, “bell_psi_minus”, “bell_phi_minus”, “bell_phi_plus”, or tensor product of 1 qubit (“z0_z0”, “z0_z1”, etc).
3 qubit: “ghz”, “werner”, or tensor product of 1 qubit (“z0_z0_z0”, “z0_x0_y0”, etc).
1 qutrit: Specify a combination of level (“01” | “12” | “02”), axis (“x” | “y” | “z”), and d (“0”, “1”) and “v012”.
For example, “01x0” means level is “01”, axis is “x”, and d is “0”. Use get_state_names_1qutrit() to get a list of available names.
2 qutrit: tensor product of 1 qutrit (“01x0_01y0”, “01x0_01x1”, etc) and “v001122”.
- Returns
pure state vector
- Return type
np.ndarray
- Raises
ValueError – ‘state_name’ is out of range.
- get_state_00_11_22_superposition_pure_state_vector()[source]
Return the pure state vector for v001122. \(|v001122\rangle := \frac{1}{\sqrt{3}} (|00\rangle + |11\rangle + |22\rangle)\)
- Returns
the pure state vector for v001122.
- Return type
np.ndarray
- get_state_01x0_pure_state_vector()[source]
returns the pure state vector of \(\frac{1}{\sqrt{2}} (|0\rangle + |1\rangle)\).
- Returns
the pure state vector.
- Return type
np.ndarray
- get_state_01x1_pure_state_vector()[source]
returns the pure state vector of \(\frac{1}{\sqrt{2}} (|0\rangle - |1\rangle)\).
- Returns
the pure state vector.
- Return type
np.ndarray
- get_state_01y0_pure_state_vector()[source]
returns the pure state vector of \(\frac{1}{\sqrt{2}} (|0\rangle + j|1\rangle)\).
- Returns
the pure state vector.
- Return type
np.ndarray
- get_state_01y1_pure_state_vector()[source]
returns the pure state vector of \(\frac{1}{\sqrt{2}} (|0\rangle - j|1\rangle)\).
- Returns
the pure state vector.
- Return type
np.ndarray
- get_state_01z0_pure_state_vector()[source]
returns the pure state vector of \(|0\rangle\).
- Returns
the pure state vector.
- Return type
np.ndarray
- get_state_01z1_pure_state_vector()[source]
returns the pure state vector of \(|1\rangle\).
- Returns
the pure state vector.
- Return type
np.ndarray
- get_state_02x0_pure_state_vector()[source]
returns the pure state vector of \(\frac{1}{\sqrt{2}} (|0\rangle + |2\rangle)\).
- Returns
the pure state vector.
- Return type
np.ndarray
- get_state_02x1_pure_state_vector()[source]
returns the pure state vector of \(\frac{1}{\sqrt{2}} (|0\rangle - |2\rangle)\).
- Returns
the pure state vector.
- Return type
np.ndarray
- get_state_02y0_pure_state_vector()[source]
returns the pure state vector of \(\frac{1}{\sqrt{2}} (|0\rangle + j|2\rangle)\).
- Returns
the pure state vector.
- Return type
np.ndarray
- get_state_02y1_pure_state_vector()[source]
returns the pure state vector of \(\frac{1}{\sqrt{2}} (|0\rangle - j|2\rangle)\).
- Returns
the pure state vector.
- Return type
np.ndarray
- get_state_02z0_pure_state_vector()[source]
returns the pure state vector of \(|0\rangle\).
- Returns
the pure state vector.
- Return type
np.ndarray
- get_state_02z1_pure_state_vector()[source]
returns the pure state vector of \(|2\rangle\).
- Returns
the pure state vector.
- Return type
np.ndarray
- get_state_0_1_2_superposition_pure_state_vector()[source]
Return the pure state vector for v012. \(|v012\rangle := \frac{1}{\sqrt{3}} (|0\rangle + |1\rangle + |2\rangle)\)
- Returns
the pure state vector for v012.
- Return type
np.ndarray
- get_state_12x0_pure_state_vector()[source]
returns the pure state vector of \(\frac{1}{\sqrt{2}} (|1\rangle + |2\rangle)\).
- Returns
the pure state vector.
- Return type
np.ndarray
- get_state_12x1_pure_state_vector()[source]
returns the pure state vector of \(\frac{1}{\sqrt{2}} (|1\rangle - |2\rangle)\).
- Returns
the pure state vector.
- Return type
np.ndarray
- get_state_12y0_pure_state_vector()[source]
returns the pure state vector of \(\frac{1}{\sqrt{2}} (|1\rangle + j|2\rangle)\).
- Returns
the pure state vector.
- Return type
np.ndarray
- get_state_12y1_pure_state_vector()[source]
returns the pure state vector of \(\frac{1}{\sqrt{2}} (|1\rangle - j|2\rangle)\).
- Returns
the pure state vector.
- Return type
np.ndarray
- get_state_12z0_pure_state_vector()[source]
returns the pure state vector of \(|1\rangle\).
- Returns
the pure state vector.
- Return type
np.ndarray
- get_state_12z1_pure_state_vector()[source]
returns the pure state vector of \(|2\rangle\).
- Returns
the pure state vector.
- Return type
np.ndarray
- get_state_a_pure_state_vector()[source]
Return the pure state vector for A state.
\(|A\rangle := \frac{1}{\sqrt{2}} (|0\rangle + \exp(iπ/4)|1\rangle)\)
- Returns
the pure state vector for A state.
- Return type
np.ndarray
- get_state_bell_2q(c_sys)[source]
returns vec of Bell state, \(\frac{1}{2} (|00\rangle + |11\rangle)(\langle00| + \langle11|)\) , with the basis of
c_sys.- Parameters
c_sys (CompositeSystem) – CompositeSystem containing state.
- Returns
vec of state.
- Return type
- get_state_bell_pure_state_vector(name)[source]
Return the pure state vector for bell.
- Parameters
name (str) –
type of bell, one of (“bell_psi_plus” | “bell_psi_minus” | “bell_phi_plus” | “bell_phi_minus”)
”bell_psi_plus”: \(|\Psi^+\rangle := |0\rangle|1\rangle + |1\rangle|0\rangle\)
”bell_psi_minus”: \(|\Psi^-\rangle := |0\rangle|1\rangle - |1\rangle|0\rangle\)
”bell_phi_plus”: \(|\Phi^+\rangle := |0\rangle|0\rangle + |1\rangle|1\rangle\)
”bell_phi_minus”: \(|\Phi^-\rangle := |0\rangle|0\rangle - |1\rangle|1\rangle\)
- Returns
the pure state vector for bell state.
- Return type
np.ndarray
- Raises
ValueError – ‘name’ is out of range.
- get_state_ghz_pure_state_vector()[source]
Return the pure state vector for GHZ. \(|GHZ\rangle := \frac{1}{\sqrt{2}} (|0\rangle|0\rangle|0\rangle + |1\rangle|1\rangle|1\rangle)\)
- Returns
the pure state vector for GHZ state.
- Return type
np.ndarray
- get_state_names_1qubit()[source]
Return the list of valid gate names of 1-qubit states.
- Return type
List[str]
- get_state_names_1qutrit()[source]
Return the list of valid gate names of 1-qutrit states.
- Return type
List[str]
- get_state_names_2qubit()[source]
Return the list of valid gate names of 2-qubit states.
- Return type
List[str]
- get_state_names_2qutrit()[source]
Return the list of valid gate names of 2-qubit states.
- Return type
List[str]
- get_state_names_3qubit()[source]
Return the list of valid gate names of 3-qubit states.
- Return type
List[str]
- get_state_werner_pure_state_vector()[source]
Return the pure state vector for Werner. \(|W\rangle := \frac{1}{\sqrt{3}} (|0\rangle|0\rangle|1\rangle + |0\rangle|1\rangle|0\rangle + |1\rangle|0\rangle|0\rangle)\)
- Returns
the pure state vector for Werner state.
- Return type
np.ndarray
- get_state_x0_1q(c_sys)[source]
returns vec of state
X_0with the basis ofc_sys.- Parameters
c_sys (CompositeSystem) – CompositeSystem containing state.
- Returns
vec of state.
- Return type
np.ndarray
- get_state_x0_pure_state_vector()[source]
Returns the pure state vector for \(|+\rangle\).
\(|+\rangle := \frac{1}{\sqrt{2}} (|0\rangle + |1\rangle)\)
- Returns
the pure state vector.
- Return type
np.ndarray
- get_state_x1_1q(c_sys)[source]
returns vec of state
X_1with the basis ofc_sys.- Parameters
c_sys (CompositeSystem) – CompositeSystem containing state.
- Returns
vec of state.
- Return type
np.ndarray
- get_state_x1_pure_state_vector()[source]
Returns the pure state vector for \(|-\rangle\).
\(|-\rangle := \frac{1}{\sqrt{2}} (|0\rangle - |1\rangle)\)
- Returns
the pure state vector.
- Return type
np.ndarray
- get_state_y0_1q(c_sys)[source]
returns vec of state
Y_0with the basis ofc_sys.- Parameters
c_sys (CompositeSystem) – CompositeSystem containing state.
- Returns
vec of state.
- Return type
np.ndarray
- get_state_y0_pure_state_vector()[source]
Returns the pure state vector for \(|i\rangle\).
\(|i\rangle := \frac{1}{\sqrt{2}} (|0\rangle + i|1\rangle)\)
- Returns
the pure state vector.
- Return type
np.ndarray
- get_state_y1_1q(c_sys)[source]
returns vec of state
Y_1with the basis ofc_sys.- Parameters
c_sys (CompositeSystem) – CompositeSystem containing state.
- Returns
vec of state.
- Return type
np.ndarray
- get_state_y1_pure_state_vector()[source]
Returns the pure state vector for \(|i\rangle\).
\(|-i\rangle := \frac{1}{\sqrt{2}} (|0\rangle - i|1\rangle)\)
- Returns
the pure state vector.
- Return type
np.ndarray
- get_state_z0_1q(c_sys)[source]
returns vec of state
Z_0with the basis ofc_sys.- Parameters
c_sys (CompositeSystem) – CompositeSystem containing state.
- Returns
vec of state.
- Return type
np.ndarray
- get_state_z0_pure_state_vector()[source]
Returns the pure state vector for \(|0\rangle\).
- Returns
the pure state vector.
- Return type
np.ndarray
- get_state_z1_1q(c_sys)[source]
returns vec of state
Z_1with the basis ofc_sys.- Parameters
c_sys (CompositeSystem) – CompositeSystem containing state.
- Returns
vec of state.
- Return type
np.ndarray