You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Generates a fock state ``\ket{\psi}`` of dimension `N`.
30
31
31
32
It is also possible to specify the list of dimensions `dims` if different subsystems are present.
32
33
33
34
!!! warning "Beware of type-stability!"
34
35
If you want to keep type stability, it is recommended to use `fock(N, j, dims=dims, sparse=Val(sparse))` instead of `fock(N, j, dims=dims, sparse=sparse)`. Consider also to use `dims` as a `Tuple` or `SVector` from [StaticArrays.jl](https://github.com/JuliaArrays/StaticArrays.jl) instead of `Vector`. See [this link](https://docs.julialang.org/en/v1/manual/performance-tips/#man-performance-value-type) and the [related Section](@ref doc:Type-Stability) about type stability for more details.
36
+
37
+
!!! note
38
+
`basis(N, j; dims = dims, sparse = sparse)` is a synonym of `fock(N, j; dims = dims, sparse = sparse)`.
35
39
"""
36
40
functionfock(N::Int, j::Int=0; dims::Union{Int,AbstractVector{Int},Tuple}= N, sparse::Union{Bool,Val}=Val(false))
It is also possible to specify the list of dimensions `dims` if different subsystems are present.
51
-
52
-
!!! warning "Beware of type-stability!"
53
-
If you want to keep type stability, it is recommended to use `basis(N, j, dims=dims)` with `dims` as a `Tuple` or `SVector` from [StaticArrays.jl](https://github.com/JuliaArrays/StaticArrays.jl) instead of `Vector`. See [this link](https://docs.julialang.org/en/v1/manual/performance-tips/#man-performance-value-type) and the [related Section](@ref doc:Type-Stability) about type stability for more details.
@@ -203,7 +196,7 @@ function spin_state(j::Real, m::Real)
203
196
throw(ArgumentError("Invalid eigenvalue m: (j - m) must be a non-negative integer."))
204
197
(m < (-j)) &&throw(ArgumentError("Invalid eigenvalue m, must satisfy: -j ≤ m ≤ j"))
205
198
206
-
returnbasis(Int(J), Int(Δ))
199
+
returnfock(Int(J), Int(Δ))
207
200
end
208
201
209
202
@docraw"""
@@ -318,6 +311,8 @@ Returns the `n`-qubit [W-state](https://en.wikipedia.org/wiki/W_state):
318
311
If you want to keep type stability, it is recommended to use `w_state(Val(n))` instead of `w_state(n)`. See [this link](https://docs.julialang.org/en/v1/manual/performance-tips/#man-performance-value-type) and the [related Section](@ref doc:Type-Stability) for more details.
319
312
"""
320
313
functionw_state(::Val{n}) where {n}
314
+
(n >=2) ||throw(ArgumentError("Invalid argument n, must satisfy: n ≥ 2"))
315
+
321
316
nzind =2.^ (0:(n-1)) .+1
322
317
nzval =fill(ComplexF64(1/sqrt(n)), n)
323
318
data =zeros(ComplexF64, 2^n)
@@ -341,6 +336,9 @@ Here, `d` specifies the dimension of each qudit. Default to `d=2` (qubit).
341
336
If you want to keep type stability, it is recommended to use `ghz_state(Val(n))` instead of `ghz_state(n)`. See [this link](https://docs.julialang.org/en/v1/manual/performance-tips/#man-performance-value-type) and the [related Section](@ref doc:Type-Stability) for more details.
342
337
"""
343
338
functionghz_state(::Val{n}; d::Int=2) where {n}
339
+
(n >=2) ||throw(ArgumentError("Invalid argument n, must satisfy: n ≥ 2"))
340
+
(d >=2) ||throw(ArgumentError("Invalid argument d, must satisfy: d ≥ 2"))
0 commit comments