CPUCalculator
QuICT.ops.linalg.cpu_calculator ¶
MatrixPermutation ¶
permute A with mapping, inplace
Parameters:
-
A(np.array<np.complex>)–the matrix A
-
mapping(np.ndarray<int>)–the qubit mapping
-
changeInput(bool)–whether changes in A
Source code in QuICT/ops/linalg/cpu_calculator.py
MatrixTensorI ¶
Applying the Matrix Tensor operator to matrix A
Parameters:
-
A(np.array<np.complex>)–the matrix A
-
n(int)–the index of indentity
-
m(int)–the index of indentity
Returns:
-
–
np.array
: the tensor result I^n ⊗ A ⊗ I^m
Source code in QuICT/ops/linalg/cpu_calculator.py
VectorPermutation ¶
permutaion A with mapping, changeInput
Parameters:
-
A(np.array<np.complex>)–the matrix A
-
mapping(np.ndarray<int>)–the qubit mapping
-
changeInput(bool)–whether changes in A
Returns:
np.array
Source code in QuICT/ops/linalg/cpu_calculator.py
array_combination ¶
Applying the array combination of A and block qubits
Parameters:
-
A(np.array<np.complex>)–the state vector A
-
qubits(int)–the qubit number of A
-
block_qubits(int)–the block qubit number
Returns:
-
–
np.array
: [1 << qubits - block_qubits]
Source code in QuICT/ops/linalg/cpu_calculator.py
dot ¶
Applying the dot operator between A and B
Parameters:
-
A(np.array<np.complex>)–the matrix A
-
B(np.array<np.complex>)–the matrix B
Returns:
-
–
np.array
: A * B
Source code in QuICT/ops/linalg/cpu_calculator.py
matrix_dot_matrix ¶
matrix_dot_matrix(matrix_u: ndarray, matrix_g: 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:
-
matrix_u(ndarray) –The 2D numpy array, represent the unitary matrix / density matrix
-
matrix_g(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/linalg/cpu_calculator.py
multiply ¶
Applying the multiply operator between A and B
Parameters:
-
A(np.array<np.complex>)–the matrix A
-
B(np.array<np.complex>)–the matrix B
Returns:
-
–
np.array
: A x B
Source code in QuICT/ops/linalg/cpu_calculator.py
tensor ¶
Applying the tensor operator between A and B.
Parameters:
-
A(np.array<np.complex>)–the matrix A
-
B(np.array<np.complex>)–the matrix B
Returns:
-
–
np.array
: the tensor result A ⊗ B