Skip to content

Commit

Permalink
Default d = 2 in ket and proj
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastiendesignolle committed Jun 27, 2024
1 parent 87bfe77 commit 93f4fe3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/basic.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"""
ket([T=ComplexF64,] i::Integer, d::Integer)
ket([T=ComplexF64,] i::Integer, d::Integer = 2)
Produces a ket of dimension `d` with nonzero element `i`.
"""
function ket(::Type{T}, i::Integer, d::Integer) where {T<:Number}
function ket(::Type{T}, i::Integer, d::Integer = 2) where {T<:Number}
psi = zeros(T, d)
psi[i] = 1
return psi
Expand All @@ -22,11 +22,11 @@ end
export ketbra

"""
proj([T=ComplexF64,] i::Integer, d::Integer)
proj([T=ComplexF64,] i::Integer, d::Integer = 2)
Produces a projector onto the basis state `i` in dimension `d`.
"""
function proj(::Type{T}, i::Integer, d::Integer) where {T<:Number}
function proj(::Type{T}, i::Integer, d::Integer = 2) where {T<:Number}
p = LA.Hermitian(zeros(T, d, d))
p[i, i] = 1
return p
Expand Down

0 comments on commit 93f4fe3

Please sign in to comment.