1
1
function initialize! (sv:: CuStateVec , sv_type:: custatevecStateVectorType_t )
2
2
custatevecInitializeStateVector (handle (), sv. data, eltype (sv), sv. nbits, sv_type)
3
- sv
3
+ return sv
4
4
end
5
5
6
6
function applyPauliExp! (sv:: CuStateVec , theta:: Float64 , paulis:: Vector{<:Pauli} , targets:: Vector{Int32} , controls:: Vector{Int32} , controlValues:: Vector{Int32} = fill (one (Int32), length (controls)))
7
7
cupaulis = CuStateVecPauli .(paulis)
8
8
custatevecApplyPauliRotation (handle (), sv. data, eltype (sv), sv. nbits, theta, cupaulis, targets, length (targets), controls, controlValues, length (controls))
9
- sv
9
+ return sv
10
10
end
11
11
12
12
function applyMatrix! (sv:: CuStateVec , matrix:: Union{Matrix, CuMatrix} , adjoint:: Bool , targets:: Vector{<:Integer} , controls:: Vector{<:Integer} , controlValues:: Vector{<:Integer} = fill (one (Int32), length (controls)))
@@ -18,7 +18,7 @@ function applyMatrix!(sv::CuStateVec, matrix::Union{Matrix, CuMatrix}, adjoint::
18
18
with_workspace (handle (). cache, bufferSize) do buffer
19
19
custatevecApplyMatrix (handle (), sv. data, eltype (sv), sv. nbits, matrix, eltype (matrix), CUSTATEVEC_MATRIX_LAYOUT_COL, Int32 (adjoint), convert (Vector{Int32}, targets), length (targets), convert (Vector{Int32}, controls), convert (Vector{Int32}, controlValues), length (controls), compute_type (eltype (sv), eltype (matrix)), buffer, sizeof (buffer))
20
20
end
21
- sv
21
+ return sv
22
22
end
23
23
24
24
function applyMatrixBatched! (sv:: CuStateVec , n_svs:: Int , map_type:: custatevecMatrixMapType_t , matrix_inds:: Vector{Int} , matrix:: Union{Vector, CuVector} , n_matrices:: Int , adjoint:: Bool , targets:: Vector{<:Integer} , controls:: Vector{<:Integer} , controlValues:: Vector{<:Integer} = fill (one (Int32), length (controls)))
@@ -32,7 +32,7 @@ function applyMatrixBatched!(sv::CuStateVec, n_svs::Int, map_type::custatevecMat
32
32
with_workspace (handle (). cache, bufferSize) do buffer
33
33
custatevecApplyMatrixBatched (handle (), sv. data, eltype (sv), n_index_bits, n_svs, sv_stride, map_type, matrix_inds, matrix, eltype (matrix), CUSTATEVEC_MATRIX_LAYOUT_COL, Int32 (adjoint), n_matrices, convert (Vector{Int32}, targets), length (targets), convert (Vector{Int32}, controls), convert (Vector{Int32}, controlValues), length (controls), compute_type (eltype (sv), eltype (matrix)), buffer, sizeof (buffer))
34
34
end
35
- sv
35
+ return sv
36
36
end
37
37
38
38
function applyGeneralizedPermutationMatrix! (sv:: CuStateVec , permutation:: Union{Vector{<:Integer}, CuVector{<:Integer}} , diagonals:: Union{Vector, CuVector} , adjoint:: Bool , targets:: Vector{<:Integer} , controls:: Vector{<:Integer} , controlValues:: Vector{<:Integer} = fill (one (Int32), length (controls)))
@@ -44,7 +44,7 @@ function applyGeneralizedPermutationMatrix!(sv::CuStateVec, permutation::Union{V
44
44
with_workspace (handle (). cache, bufferSize) do buffer
45
45
custatevecApplyGeneralizedPermutationMatrix (handle (), sv. data, eltype (sv), sv. nbits, permutation, diagonals, eltype (diagonals), Int32 (adjoint), convert (Vector{Int32}, targets), length (targets), convert (Vector{Int32}, controls), convert (Vector{Int32}, controlValues), length (controls), buffer, sizeof (buffer))
46
46
end
47
- sv
47
+ return sv
48
48
end
49
49
50
50
function abs2SumOnZBasis (sv:: CuStateVec , basisInds:: Vector{<:Integer} )
56
56
57
57
function collapseOnZBasis! (sv:: CuStateVec , parity:: Int , basisInds:: Vector{<:Integer} , norm:: Float64 )
58
58
custatevecCollapseOnZBasis (handle (), sv. data, eltype (sv), sv. nbits, parity, convert (Vector{Int32}, basisInds), length (basisInds), norm)
59
- sv
59
+ return sv
60
60
end
61
61
62
62
function measureOnZBasis! (sv:: CuStateVec , basisInds:: Vector{<:Integer} , randnum:: Float64 , collapse:: custatevecCollapseOp_t = CUSTATEVEC_COLLAPSE_NONE)
68
68
69
69
function collapseByBitString! (sv:: CuStateVec , bitstring:: Union{Vector{<:Integer}, BitVector, Vector{Bool}} , bitordering:: Vector{<:Integer} , norm:: Float64 )
70
70
custatevecCollapseByBitString (handle (), sv. data, eltype (sv), sv. nbits, convert (Vector{Int32}, bitstring), convert (Vector{Int32}, bitordering), length (bitstring), norm)
71
- sv
71
+ return sv
72
72
end
73
73
74
74
function collapseByBitStringBatched! (sv:: CuStateVec , n_svs:: Int , bitstrings:: Vector{<:Integer} , bitordering:: Vector{<:Integer} , norms:: Vector{Float64} )
@@ -82,7 +82,7 @@ function collapseByBitStringBatched!(sv::CuStateVec, n_svs::Int, bitstrings::Vec
82
82
with_workspace (handle (). cache, bufferSize) do buffer
83
83
custatevecCollapseByBitStringBatched (handle (), sv. data, eltype (sv), n_index_bits, n_svs, sv_stride, convert (Vector{custatevecIndex_t}, bitstrings), convert (Vector{Int32}, bitordering), n_index_bits, norms, buffer, sizeof (buffer))
84
84
end
85
- sv
85
+ return sv
86
86
end
87
87
88
88
function abs2SumArray (sv:: CuStateVec , bitordering:: Vector{<:Integer} , maskBitString:: Vector{<:Integer} , maskOrdering:: Vector{<:Integer} )
110
110
function batchMeasureWithOffset! (sv:: CuStateVec , bitordering:: Vector{<:Integer} , randnum:: Float64 , offset:: Float64 , abs2sum:: Float64 , collapse:: custatevecCollapseOp_t = CUSTATEVEC_COLLAPSE_NONE)
111
111
0.0 <= randnum < 1.0 || throw (ArgumentError (" randnum $randnum must be in the interval [0, 1)." ))
112
112
bitstring = zeros (Int32, length (bitordering))
113
- custatevecBatchMeasure (handle (), sv. data, eltype (sv), sv. nbits, convert (Vector{Int32}, bitstring), convert (Vector{Int32}, bitordering), length (bitstring), randnum, collapse, offset, abs2sum)
113
+ custatevecBatchMeasureWithOffset (handle (), sv. data, eltype (sv), sv. nbits, convert (Vector{Int32}, bitstring), convert (Vector{Int32}, bitordering), length (bitstring), randnum, collapse, offset, abs2sum)
114
114
return sv, bitstring
115
115
end
116
116
147
147
148
148
function swapIndexBits! (sv:: CuStateVec , bitSwaps:: Vector{Pair{T, T}} , maskBitString:: Vector{<:Integer} , maskOrdering:: Vector{<:Integer} ) where {T<: Integer }
149
149
custatevecSwapIndexBits (handle (), sv. data, eltype (sv), sv. nbits, convert (Vector{Pair{Int32, Int32}}, bitSwaps), length (bitSwaps), convert (Vector{Int32}, maskBitString), convert (Vector{Int32}, maskOrdering), length (maskOrdering))
150
- sv
150
+ return sv
151
151
end
152
152
153
153
function swapIndexBitsMultiDevice! (sub_svs:: Vector{CuStateVec} , devices:: Vector{CuDevice} , indexBitSwaps:: Vector{Pair{T, T}} , maskBitString:: Vector{<:Integer} , maskOrdering:: Vector{<:Integer} , device_network_type:: custatevecDeviceNetworkType_t ) where {T<: Integer }
0 commit comments