2
votes

I can't figure out how to get specific elements/ values of a ket vector in Julia language. I tried to call a specific index of the ket vector using [index], like one does with a regular vector, but that does not seem to work with kets.

Kets are available in the QuantumOptics.jl package. So for a simple example, if I would define a ket myself:

basis = FockBasis(2)
x = Ket(basis, [1,3,2])

which gives output:

Ket(dim=3)
 basis: Fock(cutoff=2)
 1.0
 3.0
 2.0

If I then try to get an element of the ket, I would try it like this:

x[1]

which gives an error:

MethodError: no method matching getindex(::Ket{FockBasis{Int64},Array{Int64,1}}, ::Int64)

and I can't access the seperate elements of the ket.

github.com/qojulia/QuantumOptics.jl/issues/299 it simply doesn't have getindex implemented - jling