Skip to content

Commit e18115a

Browse files
[no ci] Make fock non-mutating
1 parent d8f83cc commit e18115a

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/qobj/states.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ function fock(N::Int, j::Int = 0; dims::Union{Int,AbstractVector{Int},Tuple} = N
3737
if getVal(sparse)
3838
array = sparsevec([j + 1], [1.0 + 0im], N)
3939
else
40-
array = zeros(ComplexF64, N)
41-
array[j+1] = 1
40+
array = [j == i ? 1.0 + 0im : 0.0 + 0im for j in 1:N]
4241
end
4342
return QuantumObject(array; type = Ket, dims = dims)
4443
end

0 commit comments

Comments
 (0)