Skip to content

Commit

Permalink
global phase start
Browse files Browse the repository at this point in the history
  • Loading branch information
purva-thakre committed Jun 12, 2021
1 parent 9ea0504 commit d7adb86
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/qutip_qip/decompositions/general_decompositions.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def normalize_matrix(input_array)-> np.array:
quantum gate.
Args:
input_array : Matrix of a gate in array form.
input_array : Matrix of a gate in Numpy array form.
"""
if not isinstance(input_array, np.ndarray):
raise TypeError("Not a valid input : A Numpy input array must be provided.")
Expand Down Expand Up @@ -70,6 +70,9 @@ def normalize_matrix(input_array)-> np.array:
# Accessing individual elements of Qobj array could be problematic.
def check_unitary(input_array)-> bool:
"""Checks if the input matrix is unitary or not.
Args:
input_array : Matrix of a gate in Numpy array form.
"""
input_array = normalize_matrix(input_array)
identity_matrix = np.eye(input_array.shape[0])
Expand All @@ -80,3 +83,15 @@ def check_unitary(input_array)-> bool:
raise ArithmeticError("Unitary product assertions do not match.")
check_unitary = check_unitary_left
return(check_unitary)

def extract_global_phase(input_array):
"""Express input array as a product of some global phase factor and a special
unitary matrix array (returned in the form of a list containing `phasegate`
and some other special unitary array).
Args:
input_array : Matrix of a gate in Numpy array form.
"""
if check_unitary == True:
input_array = normalize_matrix(input_array)

0 comments on commit d7adb86

Please sign in to comment.