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
abstract type AbstractSpace end# this show function is for printing AbstractDimensions
Base.show(io::IO, svec::SVector{N,AbstractSpace}) where {N} =print(io, "[", join(svec, ", "), "]")
The normal Hilbert space will be a structure called Space with a single field size:
struct Space <:AbstractSpace
size::IntfunctionSpace(size::Int)
(size <1) &&throw(DomainError(size, "The size of Space must be positive integer (≥ 1)."))
returnnew(size)
endend
Base.show(io::IO, s::Space) =print(io, s.size)
The AbstractSpace opens a door for us to implement energy-restricted space in the future (just a brief pseudo-code here):
The original dims can be implemented as a structure called Dimensions:
struct Dimensions{N} <:AbstractDimensions{N}
to::SVector{N,AbstractSpace}end
Base.show(io::IO, D::Dimensions) =print(io, D.to)
functionDimensions(dims::Union{AbstractVector{T},NTuple{N,T}}) where {T<:Integer,N}
QuantumToolbox._non_static_array_warning("dims", dims)
L =length(dims)
(L >0) ||throw(DomainError(dims, "The argument dims must be of non-zero length"))
returnDimensions(SVector{L,AbstractSpace}(Space.(dims)))
endDimensions(dims::Any) =throw(
ArgumentError(
"The argument dims must be a Tuple or a StaticVector of non-zero length and contain only positive integers.",
),
)
The AbstractDimensions opens a door for us to implement CompoundDimensions:
struct CompoundDimensions{N} <:AbstractDimensions{N}# note that the number `N` should be the same for both `to` and `from`
to::SVector{N,AbstractSpace}# space acting on the left
from::SVector{N,AbstractSpace}# space acting on the rightend
Base.show(io::IO, D::CompoundDimensions) =print(io, "[", D.to, ", ", D.from, "]")
By overloading some existing functions, I think we can implement it in our current code. For example,
Base.:(*)(i::Int, s::Space) = i * s.size
Base.:(*)(s1::Space, s2::Space) = s1.size * s2.size
Base.prod(dims::Dimensions) =prod(dims.to)
# not sure we should implement it like this or not for CompoundDimensions
Base.prod(dims::CompoundDimensions) =maximum(prod(dims.to), prod(dims.from))
Space
Define a new
AbstractSpace
The normal Hilbert space will be a structure called
Space
with a single fieldsize
:The
AbstractSpace
opens a door for us to implement energy-restricted space in the future (just a brief pseudo-code here):Dimensions
Define a new
AbstractDimensions
The original
dims
can be implemented as a structure calledDimensions
:For example,
The
AbstractDimensions
opens a door for us to implementCompoundDimensions
:By overloading some existing functions, I think we can implement it in our current code. For example,
Change definition of
Qobj
andQobjEvo
The text was updated successfully, but these errors were encountered: