qubiter.UnitaryMat module¶
-
class
qubiter.UnitaryMat.
UnitaryMat
[source]¶ Bases:
object
This class contains only static methods and no constructor. It contains some functions associated with unitary matrices.
Note that any numpy array called arr can be saved and loaded from a text file called file_name using
np.savetxt(file_name, arr)- and
- arr = np.loadtxt(file_name)
-
static
global_phase_rads
(arr)[source]¶ Assuming that arr is a unitary matrix, this function returns delta such that arr = exp(i*delta) arr1, where arr1 is a special unitary matrix (det(arr1) = 1).
Parameters: arr (np.ndarray) – Returns: Return type: float
-
static
is_unitary
(arr)[source]¶ Returns True iff arr is a numpy array that represents a unitary matrix.
Parameters: arr (np.ndarray) – Returns: Return type: bool
-
static
params_from_u2
(arr)[source]¶ Assuming that arr is a U(2) matrix, this function returns the parameters (delta, rot_rads, unit_vec) such that arr = exp( i*delta)exp( i*rot_rads*sig_w) such that unit_vec = [wx, wy, wz] is a unit vector and sig_w = wx*sigx + wy*sigy + wz*sigz.
Parameters: arr (np.ndarray) – Returns: Return type: float, float, list[float]
-
static
u2_from_params
(delta, rot_rads, unit_vec)[source]¶ This function returns a numpy array arr = exp(i*delta)exp( i*rot_rads*sig_w) such that unit_vec = [wx, wy, wz] is a unit vector and sig_w = wx*sigx + wy*sigy + wz*sigz.
params_from_u2() maps arr -> (delta, rot_rads, unit_vec). This function maps (delta, rot_rads, unit_vec) -> arr so it is the inverse of params_from_u2(). But be careful, because delta, rot_rads are not single valued, they are only valid mod 2*pi.
Parameters: - delta (float) –
- rot_rads (float) –
- unit_vec (list[float]) –
Returns: Return type: np.ndarray
-
static
u2_zyz_decomp
(arr)[source]¶ Assuming that arr is a U(2) matrix, this function returns (delta, left_rads, center_rads, right_rads) such that
arr = exp(i*delta)* exp(i*left_rads*sigz) exp(i*center_rads*sigy) exp(i*right_rads*sigz)
If change axes by x->y, y->z, z->x, get xzx decomp with same angles.
Parameters: arr (np.ndarray) – Returns: Return type: float, float, float, float