@@ -4,16 +4,16 @@ This file defines the Dimensions structures, which can describe composite Hilber
44
55export AbstractDimensions, Dimensions, GeneralDimensions
66
7- abstract type AbstractDimensions{N} end
7+ abstract type AbstractDimensions{M, N} end
88
99@doc raw """
10- struct Dimensions{N,T<:Tuple} <: AbstractDimensions{N}
10+ struct Dimensions{N,T<:Tuple} <: AbstractDimensions{N, N }
1111 to::T
1212 end
1313
1414A structure that describes the Hilbert [`Space`](@ref) of each subsystems.
1515"""
16- struct Dimensions{N,T<: Tuple } <: AbstractDimensions{N}
16+ struct Dimensions{N,T<: Tuple } <: AbstractDimensions{N,N }
1717 to:: T
1818
1919 # make sure the elements in the tuple are all AbstractSpace
@@ -24,7 +24,7 @@ function Dimensions(dims::Union{AbstractVector{T},NTuple{N,T}}) where {T<:Intege
2424 L = length (dims)
2525 (L > 0 ) || throw (DomainError (dims, " The argument dims must be of non-zero length" ))
2626
27- return Dimensions (NTuple {L,Space} (Space .(dims)))
27+ return Dimensions (Tuple (Space .(dims)))
2828end
2929Dimensions (dims:: Int ) = Dimensions (Space (dims))
3030Dimensions (dims:: DimType ) where {DimType<: AbstractSpace } = Dimensions ((dims,))
@@ -42,14 +42,14 @@ Dimensions(dims::Any) = throw(
4242
4343A structure that describes the left-hand side (`to`) and right-hand side (`from`) Hilbert [`Space`](@ref) of an [`Operator`](@ref).
4444"""
45- struct GeneralDimensions{N,T1<: Tuple ,T2<: Tuple } <: AbstractDimensions{N}
45+ struct GeneralDimensions{M, N,T1<: Tuple ,T2<: Tuple } <: AbstractDimensions{M, N}
4646 # note that the number `N` should be the same for both `to` and `from`
4747 to:: T1 # space acting on the left
4848 from:: T2 # space acting on the right
4949
5050 # make sure the elements in the tuple are all AbstractSpace
51- GeneralDimensions (to:: NTuple{N ,T1} , from:: NTuple{N,T2} ) where {N,T1<: AbstractSpace ,T2<: AbstractSpace } =
52- new {N,typeof(to),typeof(from)} (to, from)
51+ GeneralDimensions (to:: NTuple{M ,T1} , from:: NTuple{N,T2} ) where {M, N,T1<: AbstractSpace ,T2<: AbstractSpace } =
52+ new {M, N,typeof(to),typeof(from)} (to, from)
5353end
5454function GeneralDimensions (dims:: Union{AbstractVector{T},NTuple{N,T}} ) where {T<: Union{AbstractVector,NTuple} ,N}
5555 (length (dims) != 2 ) && throw (ArgumentError (" Invalid dims = $dims " ))
@@ -59,14 +59,10 @@ function GeneralDimensions(dims::Union{AbstractVector{T},NTuple{N,T}}) where {T<
5959
6060 L1 = length (dims[1 ])
6161 L2 = length (dims[2 ])
62- ((L1 > 0 ) && (L1 == L2)) || throw (
63- DomainError (
64- (L1, L2),
65- " The length of the arguments `dims[1]` and `dims[2]` must be in the same length and have at least one element." ,
66- ),
67- )
68-
69- return GeneralDimensions (NTuple {L1,Space} (Space .(dims[1 ])), NTuple {L1,Space} (Space .(dims[2 ])))
62+ (L1 > 0 ) || throw (DomainError (L1, " The length of `dims[1]` must be larger or equal to 1." ))
63+ (L2 > 0 ) || throw (DomainError (L2, " The length of `dims[2]` must be larger or equal to 1." ))
64+
65+ return GeneralDimensions (Tuple (Space .(dims[1 ])), Tuple (Space .(dims[2 ])))
7066end
7167
7268_gen_dimensions (dims:: AbstractDimensions ) = dims
0 commit comments