GPUCalculator
QuICT.ops.linalg.gpu_calculator ¶
MatrixPermutation ¶
permute mat with mapping, inplace
Parameters:
-
A(np.array<np.complex>)–the matrix A.
-
mapping(np.array<int>)–the qubit mapping.
-
changeInput(bool)–whether changes in A.
-
gpu_out(bool)–return result from GPU.
-
sync(bool)–Whether sync mode of async mode
Source code in QuICT/ops/linalg/gpu_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
-
gpu_out(bool)–return result from GPU into CPU
-
sync(bool)–Whether sync mode of async mode
Returns:
-
–
np.array
: the tensor result I^n ⊗ A ⊗ I^m
Source code in QuICT/ops/linalg/gpu_calculator.py
VectorPermutation ¶
permutaion A with mapping, inplace
Parameters:
-
A(np.array<np.complex>)–the matrix A.
-
mapping(np.array<int>)–the qubit mapping.
-
changeInput(bool)–whether changes in A.
-
gpu_out(bool)–return result from GPU.
-
sync(bool)–Whether sync mode of async mode
Returns:
-
–
np.array
: the result of Permutation
Source code in QuICT/ops/linalg/gpu_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
-
gpu_out(bool)–return result from GPU into CPU
-
sync(bool)–Whether sync mode of async mode
Returns:
-
–
np.array
: A * B
Source code in QuICT/ops/linalg/gpu_calculator.py
matrix_dot_matrix ¶
matrix_dot_matrix(mat_u: Union[ndarray, ndarray], mat_g: Union[ndarray, ndarray], control_args: ndarray = None, target_args: ndarray = None, sync: bool = True)
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
-
vec_bit(int) –The number of qubits
-
mat(ndarray) –The 2D numpy array, represent the quantum gate's matrix
-
mat_args(List[int]) –The qubits' indexes of matrix.
-
sync(bool)–Whether sync mode of async mode.
Returns:
-
–
np.ndarray: updated state vector
Source code in QuICT/ops/linalg/gpu_calculator.py
matrix_dot_vector ¶
matrix_dot_vector(vec: Union[ndarray, ndarray], vec_bit: int, mat: Union[ndarray, ndarray], mat_args: List[int], sync: bool = True)
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
-
vec_bit(int) –The number of qubits
-
mat(ndarray) –The 2D numpy array, represent the quantum gate's matrix
-
mat_args(List[int]) –The qubits' indexes of matrix.
-
sync(bool)–Whether sync mode of async mode.
Returns:
-
–
np.ndarray: updated state vector
Source code in QuICT/ops/linalg/gpu_calculator.py
partial_sv_sampling ¶
partial_sv_sampling(partial_prob, state_vector, shots: int, num_qubits: int, block_qubits: int, target_qubits: list = None, sync: bool = True, seed: int = -1)
permute mat with mapping, inplace
Parameters:
-
A(cp.array<float32>)–the cdf vector A.
-
shots(int)–The number of sample.
-
num_qubits(int)–The number of quantum qubits.
-
target_qubits(list, default:None) –The List of target sample qubits.
-
sync(bool)–Whether sync mode of async mode
Source code in QuICT/ops/linalg/gpu_calculator.py
partial_sv_sampling_for_all_qubits ¶
partial_sv_sampling_for_all_qubits(partial_prob, state_vector, shots: int, num_qubits: int, block_qubits: int, sync: bool = True, seed: int = -1)
permute mat with mapping, inplace
Parameters:
-
partial_prob(cp.array<float32>)–the cdf of state vector with block qubits.
-
state_vector(cp.array<complex128>)–The State Vector.
-
shots(int)–The number of sample.
-
num_qubits(int)–The number of quantum qubits.
-
block_qubits(int)–The number of block qubits.
-
sync(bool)–Whether sync mode of async mode
Source code in QuICT/ops/linalg/gpu_calculator.py
sv_sampling ¶
sv_sampling(A, shots: int, num_qubits: int, target_qubits: list = None, sync: bool = True, seed: int = -1)
permute mat with mapping, inplace
Parameters:
-
A(cp.array<float32>)–the cdf vector A.
-
shots(int)–The number of sample.
-
num_qubits(int)–The number of quantum qubits.
-
target_qubits(list, default:None) –The List of target sample qubits.
-
sync(bool)–Whether sync mode of async mode
Source code in QuICT/ops/linalg/gpu_calculator.py
sv_sampling_for_all_qubits ¶
permute mat with mapping, inplace
Parameters:
-
A(cp.array<float32>)–the cdf vector A.
-
shots(int)–The number of sample.
-
num_qubits(int)–The number of quantum qubits.
-
sync(bool)–Whether sync mode of async mode
Source code in QuICT/ops/linalg/gpu_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
-
gpu_out(bool)–return result from GPU into CPU
-
sync(bool)–Whether sync mode of async mode
Returns:
-
–
np.array
: the tensor result A ⊗ B