cpu
QuICT.ops.gate_kernel.cpu ¶
diagonal_matrix ¶
diagonal_matrix(vec: ndarray, mat: ndarray, control_args: ndarray = None, target_args: ndarray = None, is_control: bool = False)
Applying the operator between diagonal matrix and state vector.
Parameters:
-
vec(ndarray) –The state vector of qubits.
-
mat(ndarray) –The 2D numpy array, represent the quantum gate's matrix.
-
control_args(ndarray, default:None) –The control qubits of quantum gate.
-
target_args(ndarray, default:None) –The target qubits of quantum gate.
-
is_control(bool, default:False) –Whether the matrix type is Control or Diagonal.
Source code in QuICT/ops/gate_kernel/cpu.py
get_measured_probability ¶
Get the probability of measured 1.
Parameters:
-
index(int) –The index of target qubit
-
vec(array) –The state vector of qubits
Source code in QuICT/ops/gate_kernel/cpu.py
matrix_dot_vector ¶
matrix_dot_vector(vec: ndarray, mat: ndarray, control_args: ndarray = None, target_args: ndarray = None)
Dot the quantum gate's matrix and qubits'state vector, depending on the target qubits of gate.
Parameters:
-
vec(ndarray) –The state vector of qubits
-
mat(ndarray) –The 2D numpy array, represent the quantum gate's matrix
-
control_args(ndarray, default:None) –The control qubits of quantum gate
-
target_args(ndarray, default:None) –The target qubits of quantum gate
Raises:
-
TypeError–matrix and vector should be complex and with same precision
Returns:
-
–
np.ndarray: updated state vector
Source code in QuICT/ops/gate_kernel/cpu.py
measure_gate_apply ¶
Measured the state vector for target qubit
Parameters:
-
index(int) –The index of target qubit
-
vec(array) –The state vector of qubits
Returns:
-
bool–The measured result 0 or 1.
Source code in QuICT/ops/gate_kernel/cpu.py
reset_gate_apply ¶
Reset the state vector for target qubit
Parameters:
-
index(int) –The index of target qubit
-
vec(array) –The state vector of qubits
Source code in QuICT/ops/gate_kernel/cpu.py
reverse_matrix ¶
reverse_matrix(vec: ndarray, mat: ndarray, control_args: ndarray = None, target_args: ndarray = None)
Applying the operator between Reverse Matrix and state vector.
** Do not support The Quantum Gate which has two or more target qubits.
Parameters:
-
vec(ndarray) –The state vector of qubits.
-
mat(ndarray) –The 2D numpy array, represent the quantum gate's matrix.
-
control_args(ndarray, default:None) –The control qubits of quantum gate.
-
target_args(ndarray, default:None) –The target qubits of quantum gate.
Source code in QuICT/ops/gate_kernel/cpu.py
swap_matrix ¶
Applying the operator between Swap Gate's matrix and state vector.
Parameters:
-
vec(ndarray) –The state vector of qubits.
-
mat(ndarray) –The 2D numpy array, represent the quantum gate's matrix.
-
control_args(ndarray, default:None) –The control qubits of quantum gate.
-
target_args(ndarray, default:None) –The target qubits of quantum gate.