Permutation¶
Generalized Permutation Matrix¶
A general permutation matrix can be expressed as the multiplication of a permutation matrix and a diagonal matrix. For instance, we can decompose a 4 \(\times\) 4 general permutation matrix as follows:
cuStateVec API custatevecApplyPermutationMatrix applies a general permutation matrix like \(A\) to a state vector.
The API may require external workspace for large matrices,
and custatevecApplyPermutationMatrix_bufferSize provides the size of workspace.
Use case¶
// check the size of external workspace
custatevecApplyPermutationMatrix_bufferSize(
handle, svDataType, permutation, diagonals, diagonalsDataType, adjoint,
nTargets, &extraWorkspaceSizeInBytes);
// allocate external workspace if necessary
void* extraWorkspace = nullptr;
if (extraWorkspaceSizeInBytes > 0)
cudaMalloc(&extraWorkspace, extraWorkspaceSizeInBytes);
// perform permutation
custatevecApplyPermutationMatrix(
handle, sv, svDataType, nIndexBits, permutation, diagonals,
diagonalsDataType, adjoint, targets, nTargets, controls, nControls,
extraWorkspace, extraWorkspaceSizeInBytes);
API reference¶
custatevecApplyPermutationMatrix_bufferSize¶
Warning
doxygenfunction: Cannot find function “custatevecApplyPermutationMatrix_bufferSize” in doxygen xml output for project “cuStateVec” from directory: _xml
custatevecApplyPermutationMatrix¶
Warning
doxygenfunction: Cannot find function “custatevecApplyPermutationMatrix” in doxygen xml output for project “cuStateVec” from directory: _xml
Swap of qubits¶
Note
This API is not available in this version.
Warning
doxygenfunction: Cannot find function “custatevecSwapIndexBits” in doxygen xml output for project “cuStateVec” from directory: _xml